YOUPAILZGameAccompanyListCell.m 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. //
  2. // YOUPAILZGameAccompanyListCell.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/4/27.
  6. // Copyright © 2021 leo. All rights reserved.
  7. //
  8. #import "YOUPAILZGameAccompanyListCell.h"
  9. #import "YOUPAILZGameAccompanyModel.h"
  10. @interface YOUPAILZGameAccompanyListCell ()
  11. @property (nonatomic, weak) UILabel *youpaipdayL; //日期
  12. @property (nonatomic, weak) UILabel *youpaiporderIDL; //订单号
  13. @property (nonatomic, weak) UILabel *youpaipstateL; //状态
  14. @property (nonatomic, weak) UIImageView *youpaipgameLogoImgV; //游戏logo
  15. @property (nonatomic, weak) UILabel *youpaipnicknameL; //昵称
  16. @property (nonatomic, weak) UILabel *youpaipgameNameL; //游戏名称
  17. @property (nonatomic, weak) UILabel *youpaiplevelL; //段位
  18. @property (nonatomic, weak) UILabel *youpaipregionL; //大区
  19. @property (nonatomic, weak) UILabel *youpaippriceL; //价格
  20. @property (nonatomic, weak) UIButton *youpaipbtn; // 按钮
  21. @property (nonatomic, strong)YOUPAILZGameAccompanyModel *youpaipmodel;
  22. @end
  23. @implementation YOUPAILZGameAccompanyListCell
  24. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  25. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  26. self.selectionStyle = UITableViewCellSelectionStyleNone;
  27. [self youpaifsetupUI];
  28. }
  29. return self;
  30. }
  31. - (void)youpaifsetupUI{
  32. UILabel *dayL = [[UILabel alloc] init];
  33. dayL.font = LCFont14;
  34. dayL.textColor = HexColorFromRGB(0x666666);
  35. [self.contentView addSubview:dayL];
  36. self.youpaipdayL = dayL;
  37. [dayL mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.left.offset(16.0f);
  39. make.top.offset(10.0f);
  40. make.height.offset(20.0f);
  41. }];
  42. UILabel *orderIDL = [[UILabel alloc] init];
  43. orderIDL.font = LCFont14;
  44. orderIDL.textColor = HexColorFromRGB(0x666666);
  45. [self.contentView addSubview:orderIDL];
  46. self.youpaiporderIDL = orderIDL;
  47. [orderIDL mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.left.offset(16.0f);
  49. make.top.equalTo(dayL.mas_bottom).offset(0.0f);
  50. make.height.offset(20.0f);
  51. }];
  52. UILabel *stateL = [[UILabel alloc] init];
  53. stateL.font = LCFont14;
  54. stateL.textColor = HexColorFromRGB(0x666666);
  55. [self.contentView addSubview:stateL];
  56. self.youpaipstateL = stateL;
  57. [stateL mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.right.offset(-16.0f);
  59. make.top.offset(10.0f);
  60. make.height.offset(20.0f);
  61. }];
  62. UIImageView *gameLogoImgV = [[UIImageView alloc] init];
  63. [self.contentView addSubview:gameLogoImgV];
  64. self.youpaipgameLogoImgV = gameLogoImgV;
  65. [gameLogoImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.top.equalTo(orderIDL.mas_bottom).offset(10.0f);
  67. make.left.offset(16.0f);
  68. make.size.mas_offset(CGSizeMake(80.0f, 80.0f));
  69. }];
  70. UILabel *nicknameL = [[UILabel alloc] init];
  71. nicknameL.font = LCBoldFont(15.0f);
  72. nicknameL.textColor = HexColorFromRGB(0x333333);
  73. [self.contentView addSubview:nicknameL];
  74. self.youpaipnicknameL = nicknameL;
  75. [nicknameL mas_makeConstraints:^(MASConstraintMaker *make) {
  76. make.left.equalTo(gameLogoImgV.mas_right).offset(9.0f);
  77. make.top.equalTo(orderIDL.mas_bottom).offset(10.0f);
  78. make.height.offset(21.0f);
  79. }];
  80. UILabel *gameNameL = [[UILabel alloc] init];
  81. gameNameL.font = LCFont12;
  82. gameNameL.textColor = HexColorFromRGB(0x999999);
  83. [self.contentView addSubview:gameNameL];
  84. self.youpaipgameNameL = gameNameL;
  85. [gameNameL mas_makeConstraints:^(MASConstraintMaker *make) {
  86. make.left.equalTo(gameLogoImgV.mas_right).offset(9.0f);
  87. make.top.equalTo(nicknameL.mas_bottom).offset(1.0f);
  88. make.height.offset(16.5f);
  89. }];
  90. UILabel *levelL = [[UILabel alloc] init];
  91. levelL.font = LCFont12;
  92. levelL.textColor = HexColorFromRGB(0x999999);
  93. [self.contentView addSubview:levelL];
  94. self.youpaiplevelL = levelL;
  95. [levelL mas_makeConstraints:^(MASConstraintMaker *make) {
  96. make.left.equalTo(gameLogoImgV.mas_right).offset(9.0f);
  97. make.top.equalTo(gameNameL.mas_bottom).offset(1.0f);
  98. make.height.offset(16.5f);
  99. }];
  100. UILabel *regionL = [[UILabel alloc] init];
  101. regionL.font = LCFont12;
  102. regionL.textColor = HexColorFromRGB(0x999999);
  103. [self.contentView addSubview:regionL];
  104. self.youpaipregionL = regionL;
  105. [regionL mas_makeConstraints:^(MASConstraintMaker *make) {
  106. make.left.equalTo(gameLogoImgV.mas_right).offset(9.0f);
  107. make.top.equalTo(levelL.mas_bottom).offset(1.0f);
  108. make.height.offset(16.5f);
  109. }];
  110. UILabel *priceL = [[UILabel alloc] init];
  111. priceL.font = LCFont13;
  112. priceL.textColor = HexColorFromRGB(0x999999);
  113. [self.contentView addSubview:priceL];
  114. self.youpaippriceL = priceL;
  115. [priceL mas_makeConstraints:^(MASConstraintMaker *make) {
  116. make.right.offset(-16.0f);
  117. make.bottom.offset(-16.5f);
  118. }];
  119. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  120. btn.titleLabel.font = LCFont14;
  121. [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  122. UIImage *bgImg = [LCTools ColorImage:CGSizeMake(86.0f, 25.0f) FromColors:@[LCGradientOneColor,LCGradientTwoColor] ByGradientType:GradientLeftToRight];
  123. [btn setBackgroundImage:bgImg forState:UIControlStateNormal];
  124. [btn setBackgroundImage:bgImg forState:UIControlStateHighlighted];
  125. btn.layer.cornerRadius = 5.0f;
  126. btn.clipsToBounds = YES;
  127. [btn addTarget:self action:@selector(youpaifbtnClick) forControlEvents:UIControlEventTouchUpInside];
  128. [self.contentView addSubview:btn];
  129. self.youpaipbtn = btn;
  130. [btn mas_makeConstraints:^(MASConstraintMaker *make) {
  131. make.right.offset(-16.0f);
  132. make.bottom.equalTo(priceL.mas_top).offset(-2.0f);
  133. make.size.mas_offset(CGSizeMake(86.0f, 25.0f));
  134. }];
  135. }
  136. - (void)youpaifbtnClick{
  137. //状态 0 待接单,1 已接单,2 买家申请退款中,3 拒绝退款,4 已退款,5 服务已完成,6 已结算
  138. NSInteger status = [self.youpaipmodel.youpaipstatus integerValue];
  139. NSInteger is_anchor = [LCSaveModel getUserModel].youpaipuserinfo.youpaipis_anchor;
  140. if (is_anchor == 1) {
  141. if (status == 0) {
  142. if ([self.delegate respondsToSelector:@selector(youpaifagreeTakeOrderWithCell:model:)]) {
  143. [self.delegate youpaifagreeTakeOrderWithCell:self model:self.youpaipmodel];
  144. }
  145. }else if (status == 1){
  146. if ([self.delegate respondsToSelector:@selector(youpaiffinishOrderWithCell:model:)]) {
  147. [self.delegate youpaiffinishOrderWithCell:self model:self.youpaipmodel];
  148. }
  149. }else if (status == 2){
  150. if ([self.delegate respondsToSelector:@selector(youpaifhandleRefundWithCell:model:)]) {
  151. [self.delegate youpaifhandleRefundWithCell:self model:self.youpaipmodel];
  152. }
  153. }
  154. }else{
  155. if (status == 1 || status == 5) {
  156. if ([self.delegate respondsToSelector:@selector(youpaifapplyRefundWithCell:model:)]) {
  157. [self.delegate youpaifapplyRefundWithCell:self model:self.youpaipmodel];
  158. }
  159. }else if (status == 3){
  160. if ([self.delegate respondsToSelector:@selector(youpaifcomplaintWithCell:model:)]) {
  161. [self.delegate youpaifcomplaintWithCell:self model:self.youpaipmodel];
  162. }
  163. }
  164. }
  165. }
  166. - (void)youpaifreloadWithModel:(YOUPAILZGameAccompanyModel *)model{
  167. self.youpaipmodel = model;
  168. self.youpaipdayL.text = model.youpaipcreate_time_text;
  169. self.youpaiporderIDL.text = [NSString stringWithFormat:@"订单号:%@",model.youpaiporder_no];
  170. self.youpaipnicknameL.text = model.youpaipnickname;
  171. self.youpaipgameNameL.text = model.youpaipgame_name;
  172. [self.youpaipgameLogoImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaipgame_icon]];
  173. self.youpaiplevelL.text = [NSString stringWithFormat:@"段位:%@",model.youpaipdan_text];
  174. self.youpaipregionL.text = [NSString stringWithFormat:@"大区:%@",model.youpaipregion_text];
  175. //状态 0 待接单,1 已接单,2 买家申请退款中,3 拒绝退款,4 已退款,5 服务已完成,6 已结算
  176. NSInteger status = [model.youpaipstatus integerValue];
  177. if (status == 0 || status == 1 || status == 2) {
  178. self.youpaipstateL.textColor = [UIColor redColor];
  179. }else{
  180. self.youpaipstateL.textColor = HexColorFromRGB(0x666666);
  181. }
  182. NSInteger is_anchor = [LCSaveModel getUserModel].youpaipuserinfo.youpaipis_anchor;
  183. if (status == 6) {
  184. self.youpaippriceL.hidden = NO;
  185. if (is_anchor == 1) {
  186. self.youpaippriceL.text = [NSString stringWithFormat:@"收入%@钻",model.youpaipearnings];
  187. }else{
  188. self.youpaippriceL.text = [NSString stringWithFormat:@"支出%@钻",model.youpaipamount];
  189. }
  190. }else{
  191. self.youpaippriceL.hidden = YES;
  192. }
  193. self.youpaipstateL.text = model.youpaipstatus_text;
  194. self.youpaipbtn.hidden = YES;
  195. if (is_anchor == 1) {
  196. if (status == 0) {
  197. self.youpaipbtn.hidden = NO;
  198. [self.youpaipbtn setTitle:@"同意接单" forState:UIControlStateNormal];
  199. }else if (status == 1){
  200. self.youpaipbtn.hidden = NO;
  201. [self.youpaipbtn setTitle:@"服务完成" forState:UIControlStateNormal];
  202. }else if (status == 2){
  203. self.youpaipbtn.hidden = NO;
  204. [self.youpaipbtn setTitle:@"处理退款" forState:UIControlStateNormal];
  205. }
  206. }else{
  207. if (status == 1 || status == 5) {
  208. self.youpaipbtn.hidden = NO;
  209. [self.youpaipbtn setTitle:@"申请退款" forState:UIControlStateNormal];
  210. }else if (status == 3){
  211. self.youpaipbtn.hidden = NO;
  212. [self.youpaipbtn setTitle:@"申诉" forState:UIControlStateNormal];
  213. }
  214. }
  215. }
  216. @end