OrderCell.m 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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 "ShowCommentVC.h"
  11. #import "OrbitVC.h"
  12. @implementation OrderCell
  13. - (void)awakeFromNib {
  14. [super awakeFromNib];
  15. }
  16. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  17. [super setSelected:selected animated:animated];
  18. }
  19. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  20. {
  21. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  22. if (self) {
  23. self.backgroundColor = [UIColor whiteColor];
  24. NSMutableArray *labelArray = [NSMutableArray arrayWithCapacity:7];
  25. for (int i = 0; i < 7; i ++) {
  26. UILabel *label = [UILabel new];
  27. [label setTextAlignment:NSTextAlignmentLeft];
  28. label.font = [UIFont scaleSize:Font16];
  29. label.textColor = contentTextColor;
  30. [self.contentView addSubview:label];
  31. [labelArray addObject:label];
  32. }
  33. orderNumLabel = labelArray[0];
  34. lineLabel = labelArray[1];
  35. nameLabel = labelArray[2];
  36. beginTimeLabel = labelArray[3];
  37. endTimeLabel = labelArray[4];
  38. priceLabel = labelArray[5];
  39. staticLabel = labelArray[6];
  40. orderNumLabel.textAlignment = NSTextAlignmentRight;
  41. priceLabel.textAlignment = NSTextAlignmentRight;
  42. staticLabel.textAlignment = NSTextAlignmentRight;
  43. staticLabel.textColor = [UIColor orangeColor];
  44. lineLabel.backgroundColor = lineColor;
  45. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  46. //轨迹
  47. [btn setTitle:@"" textColor:defGreen font:Font16 fotState:UIControlStateNormal];
  48. [btn target:self Tag:2];
  49. [self.contentView addSubview:btn];
  50. orbitBtn = btn;
  51. //投诉/评价/支付
  52. btn = [UIButton buttonWithType:UIButtonTypeCustom];
  53. [btn setTitle:@"" textColor:defGreen font:Font16 fotState:UIControlStateNormal];
  54. [btn target:self Tag:1];
  55. [self.contentView addSubview:btn];
  56. lookBtn = btn;
  57. }
  58. return self;
  59. }
  60. +(OrderCell *)cellForTabelView:(UITableView*)tableView
  61. {
  62. OrderCell* cell = [tableView dequeueReusableCellWithIdentifier:@"OrderCell"];
  63. if (!cell) {
  64. cell = [[OrderCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"OrderCell"];
  65. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  66. }
  67. return cell;
  68. }
  69. -(void)layoutSubviews
  70. {
  71. [super layoutSubviews];
  72. CGFloat wid = self.width;
  73. CGFloat x,y,w,h,bd;
  74. x = y = 0;
  75. bd = 5;
  76. w = wid - 20;
  77. h = 30;
  78. orderNumLabel.frame = setDIYFrame;
  79. x = 0;
  80. y += h;
  81. w = wid;
  82. h = 1.0;
  83. lineLabel.frame = setDIYFrame;
  84. x = 20;
  85. y += h + bd;
  86. w = wid - 40;
  87. h = 20;
  88. beginTimeLabel.frame = setDIYFrame;
  89. priceLabel.frame = setDIYFrame;
  90. y += h + bd;
  91. endTimeLabel.frame = setDIYFrame;
  92. staticLabel.frame = setDIYFrame;
  93. y += h + bd;
  94. nameLabel.frame = setDIYFrame;
  95. y -= 2;
  96. h = 25;
  97. w = 70;
  98. [lookBtn borderColor:defGreen width:1 cornorRadios:5];//评论投诉
  99. [orbitBtn borderColor:defGreen width:1 cornorRadios:5];//轨迹
  100. [orbitBtn setTitle:@"查看轨迹" forState:UIControlStateNormal];
  101. switch ([self.type integerValue]) {
  102. case 0:
  103. //轨迹
  104. x = wid - w - 20;//最右
  105. orbitBtn.frame = setDIYFrame;
  106. w = 0;
  107. lookBtn.frame = setDIYFrame;
  108. break;
  109. case 1:
  110. //轨迹
  111. x = wid - 2*w - 30;
  112. orbitBtn.frame = setDIYFrame;
  113. //收钱
  114. x = wid - w - 20;//最右
  115. lookBtn.frame = setDIYFrame;
  116. break;
  117. case 2:
  118. //轨迹
  119. x = wid - w - 20;//最右
  120. orbitBtn.frame = setDIYFrame;
  121. w = 0;
  122. lookBtn.frame = setDIYFrame;
  123. break;
  124. case 3:
  125. //轨迹
  126. x = wid - 2*w - 30;
  127. orbitBtn.frame = setDIYFrame;
  128. //查看评价
  129. x = wid - w - 20;//最右
  130. lookBtn.frame = setDIYFrame;
  131. break;
  132. case 4:
  133. //轨迹
  134. x = wid - 2*w - 30;
  135. orbitBtn.frame = setDIYFrame;
  136. //查看投诉
  137. x = wid - w - 20;//最右
  138. lookBtn.frame = setDIYFrame;
  139. break;
  140. default:
  141. break;
  142. }
  143. }
  144. -(void)setDataDic:(NSDictionary *)dataDic
  145. {
  146. switch ([self.type integerValue]) {
  147. case 0:
  148. break;
  149. case 1:
  150. [lookBtn setTitle:@"收款" forState:UIControlStateNormal];
  151. break;
  152. case 2:
  153. break;
  154. case 3:
  155. [lookBtn setTitle:@"查看评价" forState:UIControlStateNormal];
  156. break;
  157. case 4:
  158. [lookBtn setTitle:@"查看投诉" forState:UIControlStateNormal];
  159. break;
  160. default:
  161. break;
  162. }
  163. _dataDic = dataDic;
  164. NSString *stateString = @"未评价,未支付";
  165. if ([dataDic[@"RO_IS_PAY"] integerValue] == 1) {
  166. stateString = @"已支付,未评价";
  167. if ([dataDic[@"RO_IS_EVALUATE"] integerValue] == 1){
  168. stateString = @"已支付,已评价";
  169. }
  170. }
  171. orderNumLabel.text = [NSString stringWithFormat:@"订单号:%@",dataDic[@"RO_ORDER_NO"]];
  172. nameLabel.text = [NSString stringWithFormat:@"学员:%@",dataDic[@"RO_USER_NAME"]];
  173. beginTimeLabel.text = [NSString stringWithFormat:@"开始时间:%@",dataDic[@"RO_START_TIME"]];
  174. endTimeLabel.text = [NSString stringWithFormat:@"结束时间:%@",dataDic[@"RO_END_TIME"]];
  175. priceLabel.text = [NSString stringWithFormat:@"价格:%@元",dataDic[@"RO_MONEY"]];
  176. staticLabel.text = stateString;
  177. if ([dataDic[@"RO_END_TIME"] length] < 1) {
  178. endTimeLabel.text = @"结束时间:暂无";
  179. }
  180. if ([dataDic[@"RO_MONEY"] length] < 1) {
  181. endTimeLabel.text = @"价格:0元";
  182. }
  183. }
  184. -(void)btnClick:(UIButton *)btn
  185. {
  186. //1,评价/支付/投诉。2,轨迹
  187. if (btn.tag == 1) {
  188. switch ([self.type integerValue]) {
  189. case 0:
  190. break;
  191. case 1:
  192. //@"收款"
  193. payBlock(_dataDic);
  194. break;
  195. case 2:
  196. break;
  197. case 3:
  198. {
  199. //评价
  200. EvaluationAndPayVC *vc = [[EvaluationAndPayVC alloc] init];
  201. vc.dataDic = _dataDic;
  202. [_skipVC.navigationController pushViewController:vc animated:YES];
  203. }
  204. break;
  205. case 4:
  206. {
  207. //投诉
  208. ShowCommentVC *show = [[ShowCommentVC alloc] init];
  209. show.classID = _dataDic[@"RO_CLASS_ID"];
  210. show.stuId = _dataDic[@"RO_USER_ID"];
  211. [_skipVC.navigationController pushViewController:show animated:YES];
  212. }
  213. break;
  214. default:
  215. break;
  216. }
  217. }else if (btn.tag == 2) {
  218. //轨迹
  219. OrbitVC *orbit = [[OrbitVC alloc] init];
  220. orbit.classId = _dataDic[@"RO_CLASS_ID"];
  221. orbit.stuOutId = _dataDic[@"OUTID"];
  222. [_skipVC.navigationController pushViewController:orbit animated:YES];
  223. }
  224. }
  225. - (void)payClickToBlock:(MyBlockType)block
  226. {
  227. payBlock = block;
  228. }
  229. @end