JXTransferNoticeCell.m 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. //
  2. // JXTransferNoticeCell.m
  3. // shiku_im
  4. //
  5. // Created by 1 on 2019/3/8.
  6. // Copyright © 2019年 Reese. All rights reserved.
  7. //
  8. #import "JXTransferNoticeCell.h"
  9. #import "JXTransferNoticeModel.h"
  10. #import "JXTransferModel.h"
  11. #import "JXTransferOpenPayModel.h"
  12. @interface JXTransferNoticeCell ()
  13. @property (nonatomic, strong) UIView *baseView;
  14. @property (nonatomic, strong) UILabel *title;
  15. @property (nonatomic, strong) UILabel *moneyTit;
  16. @property (nonatomic, strong) UILabel *moneyLab;
  17. @property (nonatomic, strong) UILabel *payTit;
  18. @property (nonatomic, strong) UILabel *nameLab;
  19. @property (nonatomic, strong) UILabel *noteTit;
  20. @property (nonatomic, strong) UILabel *noteLab;
  21. @property (nonatomic, strong) UILabel *backLab;
  22. @property (nonatomic, strong) UILabel *backTime;
  23. @property (nonatomic, strong) UILabel *sendLab;
  24. @property (nonatomic, strong) UILabel *sendTime;
  25. @end
  26. @implementation JXTransferNoticeCell
  27. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  28. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  29. self.backgroundColor = [UIColor clearColor];
  30. _baseView = [[UIView alloc] initWithFrame:CGRectMake(15, 15, JX_SCREEN_WIDTH-30, 200)];
  31. _baseView.backgroundColor = [UIColor whiteColor];
  32. _baseView.layer.masksToBounds = YES;
  33. _baseView.layer.cornerRadius = 7.f;
  34. [self.contentView addSubview:_baseView];
  35. _title = [[UILabel alloc] initWithFrame:CGRectMake(15, 10, 200, 18)];
  36. _title.font = SYSFONT(16);
  37. [_baseView addSubview:_title];
  38. //收款金额
  39. _moneyTit = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_title.frame)+10, _baseView.frame.size.width, 18)];
  40. _moneyTit.text = Localized(@"JX_GetMoney");
  41. _moneyTit.textAlignment = NSTextAlignmentCenter;
  42. _moneyTit.textColor = HEXCOLOR(0x999999);
  43. [_baseView addSubview:_moneyTit];
  44. _moneyLab = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_moneyTit.frame)+10, _baseView.frame.size.width, 43)];
  45. _moneyLab.textAlignment = NSTextAlignmentCenter;
  46. _moneyLab.font = [UIFont boldSystemFontOfSize:40];
  47. [_baseView addSubview:_moneyLab];
  48. //第一行
  49. _payTit = [[UILabel alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(_moneyLab.frame)+20, 80, 18)];
  50. _payTit.textColor = HEXCOLOR(0x999999);
  51. _payTit.font = SYSFONT(16);
  52. [_baseView addSubview:_payTit];
  53. _nameLab = [[UILabel alloc] initWithFrame:CGRectMake(95, _payTit.frame.origin.y, _baseView.frame.size.width-70, 18)];
  54. _nameLab.textColor = HEXCOLOR(0x999999);
  55. _nameLab.font = SYSFONT(16);
  56. [_baseView addSubview:_nameLab];
  57. //第二行
  58. _noteTit = [[UILabel alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(_payTit.frame)+10, 80, 18)];
  59. _noteTit.textColor = HEXCOLOR(0x999999);
  60. _noteTit.font = SYSFONT(16);
  61. [_baseView addSubview:_noteTit];
  62. _noteLab = [[UILabel alloc] initWithFrame:CGRectMake(95, _noteTit.frame.origin.y, _baseView.frame.size.width-70, 18)];
  63. _noteLab.textColor = HEXCOLOR(0x999999);
  64. _noteLab.font = SYSFONT(16);
  65. [_baseView addSubview:_noteLab];
  66. //第三行
  67. _backLab = [[UILabel alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(_noteTit.frame)+10, 80, 18)];
  68. _backLab.text = Localized(@"JX_ReturnTheTime");
  69. _backLab.textColor = HEXCOLOR(0x999999);
  70. _backLab.font = SYSFONT(16);
  71. [_baseView addSubview:_backLab];
  72. _backTime = [[UILabel alloc] initWithFrame:CGRectMake(95, _backLab.frame.origin.y, _baseView.frame.size.width-70, 18)];
  73. _backTime.textColor = HEXCOLOR(0x999999);
  74. _backTime.font = SYSFONT(16);
  75. [_baseView addSubview:_backTime];
  76. //第四行
  77. _sendLab = [[UILabel alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(_backLab.frame)+10, 80, 18)];
  78. _sendLab.text = Localized(@"JX_TransferTime");
  79. _sendLab.textColor = HEXCOLOR(0x999999);
  80. _sendLab.font = SYSFONT(16);
  81. [_baseView addSubview:_sendLab];
  82. _sendTime = [[UILabel alloc] initWithFrame:CGRectMake(95, _sendLab.frame.origin.y, _baseView.frame.size.width-70, 18)];
  83. _sendTime.textColor = HEXCOLOR(0x999999);
  84. _sendTime.font = SYSFONT(16);
  85. [_baseView addSubview:_sendTime];
  86. }
  87. return self;
  88. }
  89. - (void)setDataWithMsg:(JXMessageObject *)msg model:(id)tModel {
  90. if ([msg.type intValue] == kWCMessageTypeTransferBack) {
  91. JXTransferModel *model = (JXTransferModel *)tModel;
  92. _moneyTit.text = Localized(@"JX_Refunds");
  93. _payTit.text = Localized(@"JX_TheRefundWay");
  94. _nameLab.text = Localized(@"JX_ReturnedToTheChange");
  95. _noteTit.text = Localized(@"JX_ReturnReason");
  96. [self hideTime:NO];
  97. _moneyLab.text = [NSString stringWithFormat:@"¥%.2f",model.money];
  98. _backTime.text = model.outTime;
  99. _sendTime.text = model.createTime;
  100. _baseView.frame = CGRectMake(10, 10, JX_SCREEN_WIDTH-20, 200+56);
  101. }
  102. else if ([msg.type intValue] == kWCMessageTypeOpenPaySuccess) {
  103. JXTransferOpenPayModel *model = (JXTransferOpenPayModel *)tModel;
  104. _noteTit.text = Localized(@"JX_Note");
  105. _payTit.text = Localized(@"JX_Payee");
  106. _nameLab.text = model.name;;
  107. [self hideTime:YES];
  108. _moneyLab.text = [NSString stringWithFormat:@"¥%.2f",model.money];
  109. _baseView.frame = CGRectMake(10, 10, JX_SCREEN_WIDTH-20, 200);
  110. }
  111. else {
  112. JXTransferNoticeModel *model = (JXTransferNoticeModel *)tModel;
  113. _noteTit.text = Localized(@"JX_Note");
  114. if (model.type == 1 && [model.userId intValue] == [MY_USER_ID intValue]) {
  115. _payTit.text = Localized(@"JX_Payee");
  116. _nameLab.text = model.toUserName;
  117. }
  118. else if (model.type == 1 && [model.userId intValue] != [MY_USER_ID intValue]) {
  119. _payTit.text = Localized(@"JX_Drawee");
  120. _nameLab.text = model.userName;
  121. }
  122. else if (model.type == 2 && [model.userId intValue] == [MY_USER_ID intValue]) {
  123. _payTit.text = Localized(@"JX_Drawee");
  124. _nameLab.text = model.toUserName;
  125. }
  126. else if (model.type == 2 && [model.userId intValue] != [MY_USER_ID intValue]){
  127. _payTit.text = Localized(@"JX_Payee");
  128. _nameLab.text = model.userName;
  129. }
  130. [self hideTime:YES];
  131. _moneyLab.text = [NSString stringWithFormat:@"¥%.2f",model.money];
  132. _baseView.frame = CGRectMake(10, 10, JX_SCREEN_WIDTH-20, 200);
  133. }
  134. _title.text = [self getTitle:[msg.type intValue]];
  135. _noteLab.text = [self getNote:msg];
  136. }
  137. - (void)hideTime:(BOOL)isHide {
  138. _backLab.hidden = isHide;
  139. _backTime.hidden = isHide;
  140. _sendLab.hidden = isHide;
  141. _sendTime.hidden = isHide;
  142. }
  143. - (NSString *)getTitle:(int)type {
  144. NSString *string;
  145. // 过期退还
  146. if (type == kWCMessageTypeTransferBack) {
  147. string = Localized(@"JX_RefundNoticeOfOverdueTransfer");
  148. }
  149. // 支付通知
  150. else if (type == kWCMessageTypePaymentOut || type == kWCMessageTypeReceiptOut) {
  151. string = Localized(@"JX_PaymentNo.");
  152. }
  153. // 收款通知
  154. else if (type == kWCMessageTypePaymentGet || type == kWCMessageTypeReceiptGet) {
  155. string = Localized(@"JX_ReceiptNotice");
  156. }
  157. // 第三方调用IM支付
  158. if (type == kWCMessageTypeOpenPaySuccess) {
  159. string = Localized(@"JX_PaymentVoucher");
  160. }
  161. return string;
  162. }
  163. - (NSString *)getNote:(JXMessageObject *)msg {
  164. NSString *string;
  165. // 过期退还
  166. if ([msg.type intValue] == kWCMessageTypeTransferBack) {
  167. string = Localized(@"JX_TransferIsOverdueAndTheChange");
  168. }
  169. // 支付通知
  170. else if ([msg.type intValue] == kWCMessageTypePaymentOut || [msg.type intValue] == kWCMessageTypeReceiptOut) {
  171. string = Localized(@"JX_PaymentToFriend");
  172. }
  173. // 收款通知
  174. else if ([msg.type intValue] == kWCMessageTypePaymentGet || [msg.type intValue] == kWCMessageTypeReceiptGet) {
  175. string = Localized(@"JX_PaymentReceived");
  176. }
  177. // 转账退款通知
  178. else if ([msg.type intValue] == kWCMessageTypeTransferBack) {
  179. string = [NSString stringWithFormat:@"%@%@",msg.toUserName,Localized(@"JX_NotReceive24Hours")];
  180. }
  181. // 第三方调用IM支付通知
  182. if ([msg.type intValue] == kWCMessageTypeOpenPaySuccess) {
  183. string = Localized(@"JX_PaymentToFriend");
  184. }
  185. return string;
  186. }
  187. + (float)getChatCellHeight:(JXMessageObject *)msg {
  188. if ([msg.type intValue] == kWCMessageTypeTransferBack) {
  189. return 220+56;
  190. }else {
  191. return 220;
  192. }
  193. return 0;
  194. }
  195. @end