PurchaseintentionCell.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. //
  2. // PurchaseintentionCell.m
  3. // jitao
  4. //
  5. // Created by 罗云飞 on 2017/12/9.
  6. // Copyright © 2017年 罗云飞. All rights reserved.
  7. //
  8. #import "PurchaseintentionCell.h"
  9. @implementation PurchaseintentionCell{
  10. }
  11. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  12. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  13. if (self) {
  14. UILabel *headline = [UILabel new];
  15. headline.backgroundColor = NewGroupTableViewBackgroundColor;
  16. [self.contentView addSubview:headline];
  17. headline.sd_layout
  18. .widthIs(SCREEN_WIDTH)
  19. .topEqualToView(self.contentView)
  20. .heightIs(10);
  21. UIImageView *image = [UIImageView new];
  22. [image setImage:[UIImage imageNamed:@"dd1"]];
  23. [image setBackgroundColor:NewClearColor];
  24. [self.contentView addSubview:image];
  25. image.sd_layout
  26. .leftSpaceToView(self.contentView, 18)
  27. .topSpaceToView(headline, 13)
  28. .heightIs(19)
  29. .widthIs(14);
  30. _title = [UILabel new];
  31. _title.textColor = NewBlackColor;
  32. _title.font = NewFont(fitScreenWidth(14));
  33. _title.lineBreakMode = NSLineBreakByTruncatingTail;
  34. _title.numberOfLines = 1;
  35. // [self.contentView addSubview:_title];
  36. // _title.sd_layout
  37. // .leftSpaceToView(image, fitScreenWidth(7))
  38. // .topSpaceToView(headline, 15)
  39. // .heightIs(fitScreenWidth(14))
  40. // .rightSpaceToView(self.contentView, 35);
  41. UILabel *line = [UILabel new];
  42. line.backgroundColor = NewLineGrayColor;
  43. [self.contentView addSubview:line];
  44. line.sd_layout
  45. .leftEqualToView(self.contentView)
  46. .heightIs(0.8)
  47. .rightEqualToView(self.contentView)
  48. .topSpaceToView(headline, fitScreenHeight(44));
  49. _state = [UILabel new];
  50. _state.textColor = [UIColor colorWithString:@"#FF8523"];
  51. ViewBorderRadius(_state, 3, 1, [UIColor colorWithString:@"#FF8523"]);
  52. _state.font = NewFont(fitScreenWidth(11));
  53. _state.textAlignment = NSTextAlignmentCenter;
  54. [self.contentView addSubview:_state];
  55. _state.sd_layout
  56. .leftSpaceToView(self.contentView, 15)
  57. .widthIs(fitScreenWidth(75))
  58. .heightIs(fitScreenWidth(20))
  59. .bottomSpaceToView(self.contentView, 10+30+5);
  60. _jiage = [UILabel new];
  61. _jiage.textColor = [UIColor colorWithString:@"#FF8523"];
  62. _jiage.font = NewFont(fitScreenWidth(13));
  63. [_jiage setSingleLineAutoResizeWithMaxWidth:0];
  64. [self.contentView addSubview:_jiage];
  65. _jiage.sd_layout
  66. .centerYEqualToView(_state)
  67. .rightSpaceToView(self.contentView, 15)
  68. .heightIs(15);
  69. _ordernumber = [UILabel new];
  70. _ordernumber.textColor = [UIColor colorWithString:@"#FF8523"];
  71. _ordernumber.font = NewFont(fitScreenWidth(14));
  72. _ordernumber.lineBreakMode = NSLineBreakByTruncatingTail;
  73. _ordernumber.numberOfLines = 1;
  74. [self.contentView addSubview:_ordernumber];
  75. _ordernumber.sd_layout
  76. .leftSpaceToView(image, fitScreenWidth(7))
  77. .topSpaceToView(headline, 15)
  78. .heightIs(fitScreenWidth(14))
  79. .rightSpaceToView(self.contentView, 35);
  80. _time = [UILabel new];
  81. _time.font = NewFont(fitScreenWidth(11));
  82. [_time setSingleLineAutoResizeWithMaxWidth:0];
  83. _time.textColor = [UIColor colorWithString:@"#9A9A9A"];
  84. [self.contentView addSubview:_time];
  85. _time.sd_layout
  86. .leftSpaceToView(self.contentView, 15)
  87. .heightIs(10)
  88. .topSpaceToView(line, 10);
  89. _content = [UILabel new];
  90. _content.font = NewFont(fitScreenWidth(13));
  91. _content.textColor = [UIColor colorWithString:@"#9A9A9A"];
  92. _content.lineBreakMode = NSLineBreakByTruncatingTail;
  93. _content.numberOfLines = 1;
  94. [self.contentView addSubview:_content];
  95. _content.sd_layout
  96. .leftSpaceToView(self.contentView, 15)
  97. .topSpaceToView(_time, 10)
  98. .rightSpaceToView(self.contentView, 15)
  99. .heightIs(15);
  100. _content1 = [UILabel new];
  101. _content1.font = NewFont(fitScreenWidth(13));
  102. _content1.textColor = [UIColor colorWithString:@"#9A9A9A"];
  103. _content1.lineBreakMode = NSLineBreakByTruncatingTail;
  104. _content1.numberOfLines = 1;
  105. [self.contentView addSubview:_content1];
  106. _content1.sd_layout
  107. .leftSpaceToView(self.contentView, 15)
  108. .topSpaceToView(_content, 5)
  109. .rightSpaceToView(self.contentView, 15)
  110. .heightIs(15);
  111. _content2 = [UILabel new];
  112. _content2.font = NewFont(fitScreenWidth(13));
  113. _content2.textColor = [UIColor colorWithString:@"#9A9A9A"];
  114. _content2.lineBreakMode = NSLineBreakByTruncatingTail;
  115. _content2.numberOfLines = 1;
  116. [self.contentView addSubview:_content2];
  117. _content2.sd_layout
  118. .leftSpaceToView(self.contentView, 15)
  119. .topSpaceToView(_content1, 5)
  120. .rightSpaceToView(self.contentView, 15)
  121. .heightIs(15);
  122. _cancelintention = [UIButton new];
  123. [_cancelintention setTitleColor:NewWhiteColor forState:UIControlStateNormal];
  124. _cancelintention.titleLabel.font = NewFont(fitScreenWidth(12));
  125. [_cancelintention setBackgroundColor:NewButtonColor];
  126. NewTouchUpInside(_cancelintention, _cancelintentionclick:);
  127. ViewRadius(_cancelintention, 3);
  128. [_cancelintention setHidden:YES];
  129. [self.contentView addSubview:_cancelintention];
  130. _cancelintention.sd_layout
  131. .rightSpaceToView(self.contentView, 15)
  132. .bottomSpaceToView(self.contentView, 10)
  133. .heightIs(30)
  134. .widthIs(100);
  135. _cancelintention1111= [UIButton new];
  136. [_cancelintention1111 setTitleColor:NewWhiteColor forState:UIControlStateNormal];
  137. _cancelintention1111.titleLabel.font = NewFont(fitScreenWidth(12));
  138. [_cancelintention1111 setBackgroundColor:NewButtonColor];
  139. ViewRadius(_cancelintention1111, 3);
  140. NewTouchUpInside(_cancelintention1111, _cancelintentionclick:);
  141. [_cancelintention1111 setHidden:YES];
  142. [self.contentView addSubview:_cancelintention1111];
  143. _cancelintention1111.sd_layout
  144. .rightSpaceToView(_cancelintention, 20)
  145. .bottomSpaceToView(self.contentView, 10)
  146. .heightIs(30)
  147. .widthIs(100);
  148. }
  149. return self;
  150. }
  151. - (void)assignment:(PurchaseintentionModel *)model commoditysModel:(NSArray *)arr{
  152. _jiage.text = [NSString stringWithFormat:@"总额:%@",model.orderAmount];
  153. _title.text = model.commodityName;
  154. _state.text = model.orderStatus;
  155. _ordernumber.text = [NSString stringWithFormat:@"订单编号:%@",model.orderNo];
  156. [_time setText:model.createTime];
  157. if (arr.count>0) {
  158. if (arr.count == 1) {
  159. _content.text = [NSString stringWithFormat:@"%@",arr[0][@"commodityName"]];
  160. }else if (arr.count == 2){
  161. _content1.text = [NSString stringWithFormat:@"%@",arr[1][@"commodityName"]];
  162. }else if (arr.count == 3){
  163. _content2.text = [NSString stringWithFormat:@"%@",arr[2][@"commodityName"]];
  164. }
  165. }
  166. NSDictionary *dic = model.operatorActive;
  167. NSString *a = [NSString stringWithFormat:@"%@",dic[@"refuseIntention"]];
  168. NSString *a1 = [NSString stringWithFormat:@"%@",dic[@"applyForCancel"]];
  169. NSString *a2 = [NSString stringWithFormat:@"%@",dic[@"payForFirst"]];
  170. NSString *a3 = [NSString stringWithFormat:@"%@",dic[@"payForLast"]];
  171. NSString *a4 = [NSString stringWithFormat:@"%@",dic[@"applyForWithdraw"]];
  172. NSString *a5 = [NSString stringWithFormat:@"%@",dic[@"confirmPayForLast"]];
  173. NSString *a6 = [NSString stringWithFormat:@"%@",dic[@"confirmRefund"]];
  174. NSString *a7 = [NSString stringWithFormat:@"%@",dic[@"confirmWithdraw"]];
  175. NSString *a8 = [NSString stringWithFormat:@"%@",dic[@"confirmIntention"]];
  176. NSString *a9 = [NSString stringWithFormat:@"%@",dic[@"confirmPayForFirst"]];
  177. NSString *a10 = [NSString stringWithFormat:@"%@",dic[@"applyForRefund"]];
  178. NSString *a11 = [NSString stringWithFormat:@"%@",dic[@"agreeRefund"]];
  179. NSString *a12 = [NSString stringWithFormat:@"%@",dic[@"refuseRefund"]];
  180. NSArray *array = @[a.length>0?a:@"0",
  181. a1.length>0?a1:@"0",
  182. a2.length>0?a2:@"0",
  183. a3.length>0?a3:@"0",
  184. a4.length>0?a4:@"0",
  185. a5.length>0?a5:@"0",
  186. a6.length>0?a6:@"0",
  187. a7.length>0?a7:@"0",
  188. a8.length>0?a8:@"0",
  189. a9.length>0?a9:@"0",
  190. a10.length>0?a10:@"0",
  191. a11.length>0?a11:@"0",
  192. a12.length>0?a12:@"0"];
  193. NSMutableArray *dataArray = [NSMutableArray array];
  194. for (int i=0; i<array.count; i++) {
  195. NSString *state = array[i];
  196. if ([state isEqualToString:@"1"]) {
  197. switch (i) {
  198. case 0:
  199. [dataArray addObject:@{@"title":@"拒绝意向",@"state":@"1"}];
  200. break;
  201. case 1:
  202. [dataArray addObject:@{@"title":@"取消订单",@"state":@"1"}];
  203. break;
  204. case 2:
  205. [dataArray addObject:@{@"title":@"支付首付",@"state":@"1"}];
  206. break;
  207. case 3:
  208. [dataArray addObject:@{@"title":@"支付尾款",@"state":@"1"}];
  209. break;
  210. case 4:
  211. [dataArray addObject:@{@"title":@"提现",@"state":@"1"}];
  212. break;
  213. case 5:
  214. [dataArray addObject:@{@"title":@"确认支付尾款",@"state":@"1"}];
  215. break;
  216. case 6:
  217. [dataArray addObject:@{@"title":@"确认退款",@"state":@"1"}];
  218. break;
  219. case 7:
  220. [dataArray addObject:@{@"title":@"确认提现",@"state":@"1"}];
  221. break;
  222. case 8:
  223. [dataArray addObject:@{@"title":@"确认意向",@"state":@"1"}];
  224. break;
  225. case 9:
  226. [dataArray addObject:@{@"title":@"确认支付首付",@"state":@"1"}];
  227. break;
  228. case 10:
  229. [dataArray addObject:@{@"title":@"申请退款",@"state":@"1"}];
  230. break;
  231. case 11:
  232. [dataArray addObject:@{@"title":@"同意退款",@"state":@"1"}];
  233. break;
  234. case 12:
  235. [dataArray addObject:@{@"title":@"拒绝退款",@"state":@"1"}];
  236. break;
  237. default:
  238. break;
  239. }
  240. }
  241. }
  242. if (dataArray.count==0||dataArray.count>2) {
  243. _cancelintention.hidden = YES;
  244. _cancelintention1111.hidden = YES;
  245. }else if (dataArray.count==1) {
  246. [_cancelintention setTitle:dataArray[0][@"title"] forState:UIControlStateNormal];
  247. _cancelintention.hidden = NO;
  248. _cancelintention1111.hidden = YES;
  249. }else if (dataArray.count==2) {
  250. [_cancelintention setTitle:dataArray[0][@"title"] forState:UIControlStateNormal];
  251. [_cancelintention1111 setTitle:dataArray[1][@"title"] forState:UIControlStateNormal];
  252. _cancelintention.hidden = NO;
  253. _cancelintention1111.hidden = NO;
  254. }
  255. }
  256. - (void)_cancelintentionclick:(UIButton *)sender {
  257. if (self.delegate && [self.delegate respondsToSelector:@selector(transButIndex:)]) {
  258. [self.delegate transButIndex:sender];
  259. }
  260. }
  261. - (void)awakeFromNib {
  262. [super awakeFromNib];
  263. // Initialization code
  264. }
  265. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  266. [super setSelected:selected animated:animated];
  267. // Configure the view for the selected state
  268. }
  269. @end