123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346 |
- //
- // ImitateOrderCell.m
- // jiaPei
- //
- // Created by EchoShacolee on 2017/5/15.
- // Copyright © 2017年 JCZ. All rights reserved.
- //
- #import "ImitateOrderCell.h"
- @implementation ImitateOrderCell
- {
- UIView *backView;
- UITextView *reasonTV;
- }
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
-
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
-
- self.backgroundColor = backGroundColor;
-
- NSMutableArray *labelArray = [NSMutableArray arrayWithCapacity:7];
- for (int i = 0; i < 8; i ++) {
-
- UILabel *label = [UILabel new];
- [label setTextAlignment:NSTextAlignmentLeft];
- label.font = [UIFont scaleSize:NormalFont];
- label.textColor = contentTextColor;
- [self.contentView addSubview:label];
- [labelArray addObject:label];
- }
- orderNumLab = labelArray[0];
- lineLab = labelArray[1];
- yuyueDateLab = labelArray[2];
- moniTimeLab = labelArray[3];
- trainLineLab = labelArray[4];
- deviceLableLab = labelArray[5];
- allPriceLab = labelArray[6];
-
- lineLab.backgroundColor = RQlineColor;
- orderNumLab.textAlignment = NSTextAlignmentRight;
- allPriceLab.textAlignment = NSTextAlignmentRight;
- moniTimeLab.textAlignment = NSTextAlignmentRight;
-
- NSArray *titleName = @[@"支付",@"取消订单"];
-
- NSMutableArray *btns = [NSMutableArray arrayWithCapacity:3];
- for (int i = 0; i < titleName.count; i++) {
-
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- [btn setTitle:titleName[i] forState:UIControlStateNormal];
- [btn.titleLabel setFont:[UIFont systemFontOfSize:13]];
- [btn setTitleColor:RQ_MAIN_COLOR forState:UIControlStateNormal];
- [btn borderColor:RQ_MAIN_COLOR width:1 cornorRadius:5];
- [btn target:self tag:i + 1];
- [self.contentView addSubview:btn];
- [btns addObject:btn];
- }
- payBtn = btns[0];
- cancleOrderBtn = btns[1];
- }
- return self;
- }
- +(ImitateOrderCell *)cellForTabelView:(UITableView*)tableView block:(MyBlockType)block
- {
- ImitateOrderCell* cell = [tableView dequeueReusableCellWithIdentifier:@"ImitateOrderCell"];
- if (!cell) {
- cell = [[ImitateOrderCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ImitateOrderCell"];
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
- cell.backgroundColor = backGroundColor;
- }
- cell.block = block;
- return cell;
- }
- -(void)layoutSubviews
- {
- [super layoutSubviews];
- CGFloat wid = self.width;
- CGFloat x,y,w,h,bd;
-
- x = y = 0;
- bd = 5;
- w = wid - 20;
- h = 29;
- orderNumLab.frame = setDIYFrame;
-
- x = 0;
- y += h;
- w = wid;
- h = 1.0;
- lineLab.frame = setDIYFrame;
-
- x = 20;
- y += h + bd;
- w = wid - 40;
- h = 20;
- yuyueDateLab.frame = setDIYFrame;
- moniTimeLab.frame = setDIYFrame;
-
- y += h + bd;
- trainLineLab.frame = setDIYFrame;//训练点
- allPriceLab.frame = setDIYFrame;//价格
-
- y += h + bd;
- deviceLableLab.frame = setDIYFrame;//设备号
-
-
-
-
- y += 5;
- h = 25;
- w = 60;
- x = wid - 190 - 20;
- //订单状态 1 待支付 2 有效单 3 已完成 4 已取消 5 退款单
- switch (self.type) {
- case 1:
- {
- payBtn.hidden = NO;
- cancleOrderBtn.hidden = NO;
- //刷新
- x += 65;
- payBtn.frame = setDIYFrame;
- x += 65;
- cancleOrderBtn.frame = setDIYFrame;
- }
- break;
- case 2:
- {
- payBtn.hidden = YES;
- cancleOrderBtn.hidden = NO;
- //刷新
- x += 65;
- payBtn.frame = setDIYFrame;
- x += 65;
- cancleOrderBtn.frame = setDIYFrame;
- }
- break;
- case 3:
- {
- payBtn.hidden = YES;
- cancleOrderBtn.hidden = YES;
- //刷新
- x += 65;
- payBtn.frame = setDIYFrame;
- x += 65;
- cancleOrderBtn.frame = setDIYFrame;
- }
- break;
- case 4:
- {
- payBtn.hidden = YES;
- cancleOrderBtn.hidden = YES;
- //刷新
- x += 65;
- payBtn.frame = setDIYFrame;
- x += 65;
- cancleOrderBtn.frame = setDIYFrame;
- }
- break;
- case 5:
- {
- payBtn.hidden = YES;
- cancleOrderBtn.hidden = YES;
- //刷新
- x += 65;
- payBtn.frame = setDIYFrame;
- x += 65;
- cancleOrderBtn.frame = setDIYFrame;
- }
- break;
- default:
- break;
- }
- }
- -(void)setDataDic:(NSDictionary *)dataDic
- {
- _dataDic = dataDic;
- /*
- UILabel * orderNumLab;
- UILabel * yuyueDateLab;
- UILabel * moniTimeLab;
- UILabel * trainLineLab;
- UILabel * deviceLableLab;
- UILabel * allPriceLab;
- UILabel * lineLab;
- */
- orderNumLab.text = [NSString stringWithFormat:@"订单号:%@",dataDic[@"ORDERNO"]];
- yuyueDateLab.text = [NSString stringWithFormat:@"预约日期:%@",dataDic[@"PXRQ"]];
- moniTimeLab.text = [NSString stringWithFormat:@"培训时间:%@",dataDic[@"PXTIME"]];
- trainLineLab.text = [NSString stringWithFormat:@"训练点: %@",dataDic[@"XLDMC"]];
- deviceLableLab.text = [NSString stringWithFormat:@"设备号: %@",dataDic[@"CODE"]];
- NSString * price = dataDic[@"MONEY"];
- if ([price length] < 1) {
- price = @"0";
- }
-
-
- NSMutableAttributedString *abs = [[NSMutableAttributedString alloc]initWithString:@"价格:免费"];
-
- if (price.floatValue > 0.0) {
- abs = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"价格:%@元",price]];
- }
-
- [abs beginEditing];
- //字体大小
- [abs addAttribute:NSFontAttributeName
- value:[UIFont scaleSize:17]
- range:NSMakeRange(3, abs.length-3)];
- [abs addAttribute:NSFontAttributeName
- value:[UIFont scaleSize:15]
- range:NSMakeRange(0, 3)];
- //字体颜色
- [abs addAttribute:NSForegroundColorAttributeName
- value:[UIColor redColor]
- range:NSMakeRange(3, abs.length-3)];
-
- [abs addAttribute:NSForegroundColorAttributeName
- value:contentTextColor
- range:NSMakeRange(0,3)];
-
- allPriceLab.attributedText = abs;
-
- }
- -(void)btnClick:(UIButton *)btn{
-
- switch (btn.tag) {
- case 1:
- {
- //支付
- }
- break;
- case 2:
- {
- backView = [[UIView alloc] initWithFrame:kFrame];
- backView.backgroundColor = windowBlockColor;
- [myDelegate.window addSubview:backView];
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeybored)];
- [backView addGestureRecognizer:tap];
-
-
- CGFloat w = kSize.width - 40;
- UIView *view = [[UIView alloc] initWithFrame:CGRectMake(20, kSize.height/2.0 - 100, w, 160)];
- view.backgroundColor = backGroundColor;
- [view borderColor:RQlineColor width:1 cornorRadius:5];
- [backView addSubview:view];
-
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, w, 30)];
- [label setText:@"请输入取消原因" Font:Font17 TextColor:kTitleColor Alignment:NSTextAlignmentCenter];
- [view addSubview:label];
- reasonTV = [[UITextView alloc] initWithFrame:CGRectMake(20, 30, w - 40, 80)];
- [reasonTV borderColor:RQlineColor width:1 cornorRadius:5];
- [view addSubview:reasonTV];
-
- UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(30, 120, 80, 30)];
- [btn setTitle:@"取消" textColor:RQ_MAIN_COLOR Font:Font17 fotState:UIControlStateNormal];
- [btn borderColor:RQ_MAIN_COLOR width:1 cornorRadius:5];
- [btn target:self tag:3];
- [view addSubview:btn];
-
- btn = [[UIButton alloc] initWithFrame:CGRectMake(w - 110, 120, 80, 30)];
- [btn setTitle:@"确认" textColor:RQ_MAIN_COLOR Font:Font17 fotState:UIControlStateNormal];
- [btn borderColor:RQ_MAIN_COLOR width:1 cornorRadius:5];
- [btn target:self tag:4];
- [view addSubview:btn];
- }
- break;
- case 3:
- {
- [backView removeFromSuperview];
- }
- break;
- case 4:
- {
- if (reasonTV.text.length < 1) {
- ShowMsg(@"请输入取消订单原因");
- return;
- }
-
- [backView removeFromSuperview];
- //取消订单
- [self deteleReserveMn];
- }
- break;
- default:
- break;
- }
- }
- -(void)deteleReserveMn{
-
- [LoadingView showHUD];
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"reserveId" Value:_dataDic[@"ID"]];
- [arr addPro:@"reason" Value:reasonTV.text];
-
- NSString* method = @"deteleReserveMn";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
-
- RemoveHUD();
-
- if (!root) {
- return;
- }
-
- if ([root[@"code"] intValue] == 1) {
- ShowMsg(root[@"body"]);
- return;
- }
-
- if (_block) {
- _block([NSString stringWithFormat:@"%@",_dataDic[@"ID"]]);
- }
- }];
- }
- - (void)closeKeybored {
- [reasonTV resignFirstResponder];
- }
- @end
|