OrderCell.m 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. //
  2. // OrderCell.m
  3. // jiaPei
  4. //
  5. // Created by apple on 16/6/7.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "OrderCell.h"
  9. //#import "EvaluationAndPayVC.h"
  10. #import "ComplainVC.h"
  11. #import "ShowCommentVC.h"
  12. #import "APViewController.h"
  13. #import "OrbitVC.h"
  14. #import "Evaluation.h"
  15. #import "orderCommentVC.h"
  16. @implementation OrderCell
  17. - (void)awakeFromNib {
  18. [super awakeFromNib];
  19. }
  20. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  21. [super setSelected:selected animated:animated];
  22. }
  23. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  24. {
  25. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  26. if (self) {
  27. self.backgroundColor = [UIColor whiteColor];
  28. NSMutableArray *labelArray = [NSMutableArray arrayWithCapacity:7];
  29. for (int i = 0; i < 8; i ++) {
  30. UILabel *label = [UILabel new];
  31. [label setTextAlignment:NSTextAlignmentLeft];
  32. label.font = [UIFont scaleSize:NormalFont];
  33. label.textColor = contentTextColor;
  34. [self.contentView addSubview:label];
  35. [labelArray addObject:label];
  36. }
  37. orderNumLabel = labelArray[0];
  38. lineLabel = labelArray[1];
  39. nameLabel = labelArray[2];
  40. beginTimeLabel = labelArray[3];
  41. endTimeLabel = labelArray[4];
  42. priceLabel = labelArray[5];
  43. staticLabel = labelArray[6];
  44. contentLab = labelArray[7];
  45. orderNumLabel.textAlignment = NSTextAlignmentRight;
  46. priceLabel.textAlignment = NSTextAlignmentRight;
  47. staticLabel.textAlignment = NSTextAlignmentRight;
  48. staticLabel.textColor = [UIColor orangeColor];
  49. contentLab.numberOfLines = 0;
  50. lineLabel.backgroundColor = KlineColor;
  51. NSArray *titleName = @[@"投诉",@"评价",@"刷新",@"支付",@"查看轨迹"];
  52. NSArray *titleNameH = @[@"查看投诉",@"查看评价",@"刷新",@"支付",@"查看轨迹"];
  53. NSMutableArray *btns = [NSMutableArray arrayWithCapacity:3];
  54. for (int i = 0; i < titleName.count; i++) {
  55. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  56. [btn setTitle:titleName[i] forState:UIControlStateNormal];
  57. [btn setTitle:titleNameH[i] forState:UIControlStateSelected];
  58. [btn.titleLabel setFont:[UIFont systemFontOfSize:13]];
  59. [btn setTitleColor:defGreen forState:UIControlStateNormal];
  60. [btn borderColor:defGreen width:1 cornorRadios:5];
  61. [btn setTitleColor:[UIColor colorWithRed:134/255.0 green:240/255.0 blue:90/255.0 alpha:1] forState:UIControlStateHighlighted];
  62. [btn target:self tag:i + 1];
  63. [self.contentView addSubview:btn];
  64. [btns addObject:btn];
  65. }
  66. complainBtn = btns[0];
  67. commentBtn = btns[1];
  68. refershBtn = btns[2];
  69. payBtn = btns[3];
  70. orbitButton = btns[4];
  71. }
  72. return self;
  73. }
  74. +(OrderCell *)cellForTabelView:(UITableView*)tableView
  75. {
  76. OrderCell* cell = [tableView dequeueReusableCellWithIdentifier:@"OrderCell"];
  77. if (!cell) {
  78. cell = [[OrderCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"OrderCell"];
  79. }
  80. return cell;
  81. }
  82. -(void)layoutSubviews
  83. {
  84. [super layoutSubviews];
  85. CGFloat wid = self.width;
  86. CGFloat x,y,w,h,bd;
  87. x = y = 0;
  88. bd = 5;
  89. w = wid - 20;
  90. h = 30;
  91. orderNumLabel.frame = setDIYFrame;
  92. x = 0;
  93. y += h;
  94. w = wid;
  95. h = 1.0;
  96. lineLabel.frame = setDIYFrame;
  97. x = 20;
  98. y += h + bd;
  99. w = wid - 40;
  100. h = 20;
  101. beginTimeLabel.frame = setDIYFrame;
  102. priceLabel.frame = setDIYFrame;
  103. y += h + bd;
  104. endTimeLabel.frame = setDIYFrame;
  105. staticLabel.frame = setDIYFrame;
  106. y += h + bd;
  107. h = 44;
  108. contentLab.frame = setDIYFrame;
  109. y += h + bd;
  110. h=20;
  111. nameLabel.frame = setDIYFrame;
  112. y -= bd;
  113. h = 35;
  114. w = 80;
  115. x = wid - w - 20;
  116. //STATUS--订单状态 0 训练中 1 训练结束待支付 2 已支付未评价 3 已评价 4 投诉中 5 投诉
  117. complainBtn.selected = NO;
  118. commentBtn.selected = NO;
  119. orbitButton.hidden = YES;
  120. payBtn.hidden = YES;
  121. switch ([_type integerValue]) {
  122. case 0:
  123. {
  124. complainBtn.hidden = YES;
  125. commentBtn.hidden = YES;
  126. payBtn.hidden = YES;
  127. refershBtn.hidden = YES;
  128. }
  129. break;
  130. case 1:
  131. {
  132. complainBtn.hidden = NO;
  133. commentBtn.hidden = YES;
  134. payBtn.hidden = YES;
  135. refershBtn.hidden = YES;
  136. //投诉(daizhifu)
  137. complainBtn.frame = setDIYFrame;
  138. }
  139. break;
  140. case 2:
  141. {
  142. complainBtn.hidden = YES;
  143. commentBtn.hidden = NO;
  144. payBtn.hidden = YES;
  145. refershBtn.hidden = YES;
  146. //投诉+评论
  147. // x -= w+5;
  148. // orbitButton.frame = setDIYFrame;
  149. commentBtn.frame = setDIYFrame;
  150. }
  151. break;
  152. case 3:
  153. {
  154. complainBtn.hidden = YES;
  155. commentBtn.hidden = NO;
  156. payBtn.hidden = YES;
  157. refershBtn.hidden = YES;
  158. //查看评论
  159. // x += 65;
  160. // orbitButton.frame = setDIYFrame;
  161. // x += 65;
  162. commentBtn.frame = setDIYFrame;
  163. commentBtn.selected = YES;
  164. }
  165. break;
  166. case 4:
  167. {
  168. complainBtn.hidden = NO;
  169. commentBtn.hidden = YES;
  170. payBtn.hidden = YES;
  171. refershBtn.hidden = YES;
  172. // //查看投诉
  173. // x += 65;
  174. // orbitButton.frame = setDIYFrame;
  175. // x += 65;
  176. complainBtn.frame = setDIYFrame;
  177. complainBtn.selected = YES;
  178. }
  179. break;
  180. default:
  181. break;
  182. }
  183. }
  184. -(void)setDataDic:(NSDictionary *)dataDic
  185. {
  186. _dataDic = dataDic;
  187. NSString *stateString = @"";
  188. NSInteger status = [dataDic[@"STATUS"] integerValue];
  189. //STATUS--订单状态 0 训练中 1 训练结束待支付 2 已支付未评价 3 已评价 4 投诉中 5 投诉
  190. switch (status) {
  191. case 0:
  192. case 1:
  193. stateString = @"未支付,未评价";
  194. break;
  195. case 2:
  196. stateString = @"已支付,未评价";
  197. break;
  198. case 3:
  199. stateString = @"已支付,已评价";
  200. break;
  201. }
  202. orderNumLabel.text = [NSString stringWithFormat:@"订单号:%@",dataDic[@"ORDER_NO"]];
  203. nameLabel.text = [NSString stringWithFormat:@"教练:%@",dataDic[@"COACHNAME"]];
  204. beginTimeLabel.text = [NSString stringWithFormat:@"开始时间:%@",dataDic[@"STARTTIME"]];
  205. endTimeLabel.text = [NSString stringWithFormat:@"结束时间:%@",dataDic[@"ENDTIME"]];
  206. priceLabel.text = [NSString stringWithFormat:@"价格:%@元",dataDic[@"PRICE"]];
  207. staticLabel.text = stateString;
  208. NSString *totalString = [NSString stringWithFormat:@"本次培训总时长为%@分钟,有效时长为%@分钟,培训总价格为%@元",dataDic[@"TOTALTIME"],dataDic[@"VAILDTIME"],dataDic[@"TOTAL_FEE"]];
  209. contentLab.text = totalString;
  210. if ([dataDic[@"ENDTIME"] length] < 1) {
  211. endTimeLabel.text = @"结束时间:暂无";
  212. }
  213. if ([dataDic[@"STARTTIME"] length] < 1) {
  214. endTimeLabel.text = @"价格:0元";
  215. }
  216. }
  217. -(void)btnClick:(UIButton *)btn
  218. {
  219. if (btn.tag == 1) {
  220. if (btn.selected == YES) {
  221. //已投诉 查看页面
  222. ShowCommentVC *show = [[ShowCommentVC alloc] init];
  223. show.classID = _dataDic[@"CLASSID"];
  224. [_skipVC navPushHideTabbarToVC:show];
  225. return;
  226. }
  227. ComplainVC *vc = [[ComplainVC alloc] init];
  228. vc.dataDic = _dataDic;
  229. [_skipVC navPushHideTabbarToVC:vc];
  230. }
  231. if (btn.tag == 2) {
  232. // EvaluationAndPayVC *vc = [[EvaluationAndPayVC alloc] init];
  233. // if (btn.selected == YES) {
  234. // //已评价
  235. // vc.isFinishEva = YES;
  236. // }else{
  237. // vc.isFinishEva = NO;
  238. // }
  239. // vc.dataDic = _dataDic;
  240. // [_skipVC navPushHideTabbarToVC:vc];
  241. //
  242. if (btn.selected == YES) {
  243. //查看我对订单的评价
  244. orderCommentVC * vc = [[orderCommentVC alloc]init];
  245. vc.type = 1;
  246. vc.dic = _dataDic;
  247. [_skipVC navPushHideTabbarToVC:vc];
  248. }else{
  249. //进行评价
  250. NSDictionary *dic = [[NSDictionary alloc]initWithObjectsAndKeys:_dataDic[@"COACHID"],@"coachId",_dataDic[@"CLASSID"],@"classId",_dataDic[@"COACHNAME"],@"coachName", nil];
  251. Evaluation * vc = [[Evaluation alloc]init];
  252. vc.orderDic = dic;
  253. [_skipVC navPushHideTabbarToVC:vc];
  254. }
  255. }
  256. if (btn.tag == 3) {
  257. ShowMsg(@"建设中,暂未开放");
  258. return;
  259. // [self getReserveOrderTimeAndMoney];
  260. }
  261. if (btn.tag == 4) {
  262. ShowMsg(@"建设中,暂未开放");
  263. return;
  264. // if (_dataDic) {
  265. // APViewController *ap = [[APViewController alloc] init];
  266. // ap.orderDic = _dataDic;
  267. // [_skipVC navPushHideTabbarToVC:ap];
  268. // }else{
  269. // ShowMsg(@"订单信息错误,请重试");
  270. // }
  271. }
  272. if (btn.tag == 5) {
  273. OrbitVC *orbit = [[OrbitVC alloc] init];
  274. orbit.orderId = _dataDic[@"CLASSID"];
  275. orbit.type = @"1";
  276. [_skipVC navPushHideTabbarToVC:orbit];
  277. }
  278. }
  279. - (void)getReserveOrderTimeAndMoney
  280. {
  281. if (![Util connectedToNetWork]) {
  282. showMsgUnconnect();
  283. return;
  284. }
  285. NSMutableArray *arr=[NSMutableArray array];
  286. //订单ID
  287. [arr addPro:@"orderId" Value:_dataDic[@"ID"]];
  288. NSString* method = @"getReserveOrderTimeAndMoney";
  289. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  290. if (!root) {
  291. return ;
  292. }
  293. if ([root[@"code"] isEqualToString:@"1"]) {
  294. ShowMsg(root[@"body"]);
  295. return;
  296. }
  297. //看能不能用这个来做刷新操作
  298. //self.dataDic =
  299. }];
  300. }
  301. @end