JXredPacketDetailVC.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. //
  2. // JXredPacketDetailVC.m
  3. // shiku_im
  4. //
  5. // Created by Apple on 16/8/30.
  6. // Copyright © 2016年 Reese. All rights reserved.
  7. //
  8. #import "JXredPacketDetailVC.h"
  9. #import "JXRPacketListCell.h"
  10. #import "JXRedPacketListVC.h"
  11. @interface JXredPacketDetailVC () <UITextViewDelegate>
  12. @property (nonatomic, strong) UILabel *replyLab;
  13. @property (nonatomic, strong) UIView *bigView;
  14. @property (nonatomic, strong) UIView *baseView;
  15. @property (nonatomic, strong) UIView *topView;
  16. @property (nonatomic, strong) UILabel *replayTitle;
  17. @property (nonatomic, strong) UITextView *replayTextView;
  18. @property (nonatomic, assign) int replayNum;
  19. @property (nonatomic, strong) NSString *replyContent;
  20. @property (nonatomic, strong) NSString *money;
  21. @property (nonatomic, strong) UIColor *watermarkColor;
  22. @property (nonatomic, strong) UILabel *tintLab;
  23. @end
  24. @implementation JXredPacketDetailVC
  25. - (instancetype)init
  26. {
  27. self = [super init];
  28. if (self) {
  29. self.heightHeader = 0;
  30. self.heightFooter = 0;
  31. self.isGotoBack = YES;
  32. }
  33. return self;
  34. }
  35. - (void)viewDidLoad {
  36. [super viewDidLoad];
  37. self.view.backgroundColor = HEXCOLOR(0xF2F2F2);
  38. [self createHeadAndFoot];
  39. self.watermarkColor = [UIColor lightGrayColor];
  40. //获取数据
  41. _packetObj = [JXPacketObject getPacketObject:_dataDict];
  42. _OpenMember = [self arraySortDESC:[JXGetPacketList getPackList:_dataDict]];
  43. NSNumber * typeNum = _dataDict[@"packet"][@"type"];
  44. switch ([typeNum intValue]) {
  45. case 1:
  46. self.title = Localized(@"JX_UsualGift");
  47. break;
  48. case 2:
  49. self.title = Localized(@"JX_LuckGift");
  50. break;
  51. case 3:
  52. self.title = Localized(@"JX_MesGift");
  53. break;
  54. default:
  55. break;
  56. }
  57. self.replyContent = [NSString string];
  58. for (JXGetPacketList * memberObj in _OpenMember) {
  59. if ([memberObj.userId intValue] == [MY_USER_ID intValue]) {
  60. self.replyContent = memberObj.reply;
  61. self.money = [NSString stringWithFormat:@"%.2f %@",memberObj.money,Localized(@"JX_ChinaMoney")];
  62. }
  63. }
  64. _table.backgroundColor = [UIColor whiteColor];
  65. _table.allowsSelection = NO;
  66. self.isShowFooterPull = NO;
  67. self.view.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT);
  68. [self createCustomView];
  69. _table.frame = CGRectMake(0, CGRectGetMaxY(_contentView.frame), JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT - CGRectGetMaxY(_headImgV.frame));
  70. // _getPacketListTBV.delegate = self;
  71. // _getPacketListTBV.dataSource = self;
  72. // _getPacketListTBV.separatorStyle = UITableViewCellSeparatorStyleNone;
  73. // //设置tableview不可被点击
  74. // _getPacketListTBV.allowsSelection = NO;
  75. // _wait = [ATMHud sharedInstance];
  76. [self setViewSize];
  77. [self setViewData];
  78. }
  79. -(void)createCustomView{
  80. _headImgV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, 150)];
  81. _headImgV.image = [UIImage imageNamed:@"redPacket"];
  82. _headImgV.userInteractionEnabled = YES;
  83. [self.view addSubview:_headImgV];
  84. UIButton *closeBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, JX_SCREEN_TOP - 46, 46, 46)];
  85. [closeBtn setBackgroundImage:[[UIImage imageNamed:@"title_back_black_big"] imageWithTintColor:[UIColor whiteColor]] forState:UIControlStateNormal];
  86. [closeBtn addTarget:self action:@selector(closeBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  87. [_headImgV addSubview:closeBtn];
  88. UIButton *listBtn = [[UIButton alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH - 62-15, JX_SCREEN_TOP - 32, 62, 20)];
  89. [listBtn setTitle:Localized(@"JX_RedPacketRecord") forState:UIControlStateNormal];
  90. listBtn.titleLabel.font = [UIFont systemFontOfSize:15.0];
  91. [listBtn addTarget:self action:@selector(listBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  92. [_headImgV addSubview:listBtn];
  93. UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(0, JX_SCREEN_TOP - 32, JX_SCREEN_WIDTH, 20)];
  94. title.textAlignment = NSTextAlignmentCenter;
  95. title.text = Localized(@"JX_ShikuRedPacket");
  96. title.textColor = [UIColor whiteColor];
  97. title.font = [UIFont systemFontOfSize:18.0];
  98. [_headImgV addSubview:title];
  99. _contentView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_headImgV.frame), JX_SCREEN_WIDTH, self.money.length > 0 ? 210 : 150)];
  100. _contentView.backgroundColor = HEXCOLOR(0xF2F2F2);
  101. [self.view addSubview:_contentView];
  102. _headerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, -34, 68, 68)];
  103. _headerImageView.center = CGPointMake(_headImgV.frame.size.width / 2, _headerImageView.center.y);
  104. _headerImageView.image = [UIImage imageNamed:@"avatar_normal"];
  105. _headerImageView.userInteractionEnabled = YES;
  106. [_contentView addSubview:_headerImageView];
  107. // _totalMoneyLabel = [UIFactory createLabelWith:CGRectMake(CGRectGetMaxX(_headerImageView.frame) +8, CGRectGetMinY(_headerImageView.frame), 130, 27) text:@"共100.01元"];
  108. // _totalMoneyLabel.textColor = [UIColor yellowColor];
  109. // _totalMoneyLabel.font = g_factory.font20;
  110. // [_headImgV addSubview:_totalMoneyLabel];
  111. _fromUserLabel = [UIFactory createLabelWith:CGRectMake(0, CGRectGetMaxY(_headerImageView.frame) + 10, _contentView.frame.size.width, 22) text:Localized(@"JX_IsRedEnvelopes")];
  112. _fromUserLabel.textColor = HEXCOLOR(0x323232);
  113. _fromUserLabel.textAlignment = NSTextAlignmentCenter;
  114. _fromUserLabel.font = g_factory.font15;
  115. [_contentView addSubview:_fromUserLabel];
  116. _greetLabel = [UIFactory createLabelWith:CGRectMake(0, CGRectGetMaxY(_fromUserLabel.frame) + 5, _contentView.frame.size.width, 22) text:Localized(@"JX_KungHeiFatChoi")];
  117. _greetLabel.textColor = HEXCOLOR(0x323232);
  118. _greetLabel.textAlignment = NSTextAlignmentCenter;
  119. _greetLabel.font = g_factory.font15;
  120. [_contentView addSubview:_greetLabel];
  121. if (self.money.length > 0) {
  122. NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:self.money];
  123. [attStr addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:50]} range:NSMakeRange(0, self.money.length-1)];
  124. UILabel *moneyLab = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_greetLabel.frame) + 10, JX_SCREEN_WIDTH, 60)];
  125. moneyLab.attributedText = attStr;
  126. moneyLab.textAlignment = NSTextAlignmentCenter;
  127. [_contentView addSubview:moneyLab];
  128. _replyLab = [UIFactory createLabelWith:CGRectMake((JX_SCREEN_WIDTH-200)/2, CGRectGetMaxY(moneyLab.frame) + 10, 200, 20) text:self.replyContent.length > 0 ? self.replyContent : Localized(@"JX_ThankForReply!")];
  129. _replyLab.textColor = HEXCOLOR(0xE9996B);
  130. _replyLab.textAlignment = NSTextAlignmentCenter;
  131. _replyLab.userInteractionEnabled = YES;
  132. _replyLab.font = g_factory.font16;
  133. [_contentView addSubview:_replyLab];
  134. }
  135. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(replyToTheRedPacket)];
  136. [_replyLab addGestureRecognizer:tap];
  137. UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, 30)];
  138. _showNumLabel = [UIFactory createLabelWith:CGRectMake(15, 0, JX_SCREEN_WIDTH - 10, 30) text:Localized(@"JX_ ReceiveRed")];
  139. _showNumLabel.textColor = [UIColor grayColor];
  140. _showNumLabel.font = g_factory.font14;
  141. [headView addSubview:_showNumLabel];
  142. UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 30 - LINE_WH, JX_SCREEN_WIDTH, LINE_WH)];
  143. lineView.backgroundColor = THE_LINE_COLOR;
  144. [headView addSubview:lineView];
  145. self.tableView.tableHeaderView = headView;
  146. [self setupReplayView];
  147. }
  148. - (void)setupReplayView {
  149. int height = 44;
  150. self.bigView = [[UIView alloc] initWithFrame:self.view.bounds];
  151. self.bigView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.7];
  152. self.bigView.hidden = YES;
  153. [g_App.window addSubview:self.bigView];
  154. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyBoard)];
  155. [self.bigView addGestureRecognizer:tap];
  156. self.baseView = [[UIView alloc] initWithFrame:CGRectMake(40, JX_SCREEN_HEIGHT/4-.5, JX_SCREEN_WIDTH-80, 162.5)];
  157. self.baseView.backgroundColor = [UIColor whiteColor];
  158. self.baseView.layer.masksToBounds = YES;
  159. self. baseView.layer.cornerRadius = 4.0f;
  160. [self.bigView addSubview:self.baseView];
  161. int n = 20;
  162. _replayTitle = [[UILabel alloc] initWithFrame:CGRectMake(INSETS, n, self.baseView.frame.size.width - INSETS*2, 20)];
  163. _replayTitle.lineBreakMode = NSLineBreakByTruncatingTail;
  164. _replayTitle.textColor = HEXCOLOR(0x333333);
  165. _replayTitle.font = SYSFONT(16);
  166. [self.baseView addSubview:_replayTitle];
  167. n = n + height;
  168. self.replayTextView = [self createTextField:self.baseView default:nil hint:nil];
  169. self.replayTextView.backgroundColor = [UIColor colorWithRed:0.97 green:0.97 blue:0.97 alpha:1];
  170. self.replayTextView.frame = CGRectMake(10, n, self.baseView.frame.size.width - INSETS*2, 35.5);
  171. self.replayTextView.delegate = self;
  172. self.replayTextView.textColor = HEXCOLOR(0x595959);
  173. n = n + INSETS + height;
  174. self.topView = [[UIView alloc] initWithFrame:CGRectMake(0, n, self.baseView.frame.size.width, 44)];
  175. [self.baseView addSubview:self.topView];
  176. //水印
  177. self.tintLab = [[UILabel alloc] initWithFrame:CGRectMake(5, 35.5/2-10, self.replayTextView.frame.size.width-10, 20)];
  178. self.tintLab.textColor = self.watermarkColor;
  179. [self.replayTextView addSubview:self.tintLab];
  180. // 两条线
  181. UIView *topLine = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.baseView.frame.size.width, LINE_WH)];
  182. topLine.backgroundColor = THE_LINE_COLOR;
  183. [self.topView addSubview:topLine];
  184. UIView *botLine = [[UIView alloc] initWithFrame:CGRectMake(self.baseView.frame.size.width/2, 0, LINE_WH, self.topView.frame.size.height)];
  185. botLine.backgroundColor = THE_LINE_COLOR;
  186. [self.topView addSubview:botLine];
  187. // 取消
  188. UIButton *cancelBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(topLine.frame), self.baseView.frame.size.width/2, botLine.frame.size.height)];
  189. [cancelBtn setTitle:Localized(@"JX_Cencal") forState:UIControlStateNormal];
  190. [cancelBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  191. [cancelBtn.titleLabel setFont:SYSFONT(15)];
  192. [cancelBtn addTarget:self action:@selector(hideBigView) forControlEvents:UIControlEventTouchUpInside];
  193. [self.topView addSubview:cancelBtn];
  194. // 发送
  195. UIButton *sureBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.baseView.frame.size.width/2, CGRectGetMaxY(topLine.frame), self.baseView.frame.size.width/2, botLine.frame.size.height)];
  196. [sureBtn setTitle:Localized(@"JX_Send") forState:UIControlStateNormal];
  197. [sureBtn setTitleColor:HEXCOLOR(0x55BEB8) forState:UIControlStateNormal];
  198. [sureBtn.titleLabel setFont:SYSFONT(15)];
  199. [sureBtn addTarget:self action:@selector(onRelease) forControlEvents:UIControlEventTouchUpInside];
  200. [self.topView addSubview:sureBtn];
  201. }
  202. - (void)hideBigView {
  203. [self resignKeyBoard];
  204. }
  205. - (void)onRelease {
  206. if (self.replayTextView.text.length > 0) {
  207. [g_server redPacketReply:self.packetObj.packetId content:self.replayTextView.text toView:self];
  208. [self hideBigView];
  209. }
  210. }
  211. - (void)replyToTheRedPacket {
  212. if (self.replayTextView.text.length > 0) {
  213. self.replayTextView.text = nil;
  214. }
  215. self.bigView.hidden = NO;
  216. [self.replayTextView becomeFirstResponder];
  217. self.replayTextView.textColor = self.watermarkColor;
  218. self.tintLab.hidden = NO;
  219. self.tintLab.text = self.replyContent.length > 0 ? self.replyContent : Localized(@"JX_ThankForReply!");
  220. }
  221. - (void)textViewDidChange:(UITextView *)textView {
  222. self.tintLab.hidden = textView.text.length > 0;
  223. if (textView.text.length > 10) {
  224. textView.text = [textView.text substringToIndex:10];
  225. }
  226. static CGFloat maxHeight =66.0f;
  227. CGRect frame = textView.frame;
  228. CGSize constraintSize = CGSizeMake(JX_SCREEN_WIDTH-80-INSETS*2, MAXFLOAT);
  229. CGSize size = [textView sizeThatFits:constraintSize];
  230. if (size.height >= maxHeight)
  231. {
  232. size.height = maxHeight;
  233. textView.scrollEnabled = YES; // 允许滚动
  234. }
  235. else
  236. {
  237. textView.scrollEnabled = NO; // 不允许滚动
  238. }
  239. textView.frame = CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, size.height);
  240. NSLog(@"--------%@",NSStringFromCGRect(self.baseView.frame));
  241. self.baseView.frame = CGRectMake(40, JX_SCREEN_HEIGHT/4+35-size.height, JX_SCREEN_WIDTH-80, 162-35+size.height);
  242. self.topView.frame = CGRectMake(0, 118-35+size.height, self.baseView.frame.size.width, 40);
  243. }
  244. - (void)closeBtnAction:(UIButton *)btn {
  245. [self actionQuit];
  246. }
  247. - (void)listBtnAction:(UIButton *)btn {
  248. JXRedPacketListVC *vc = [[JXRedPacketListVC alloc] init];
  249. [g_navigation pushViewController:vc animated:YES];
  250. }
  251. - (void)viewWillAppear:(BOOL)animated{
  252. [super viewWillAppear:animated];
  253. // [UIView animateWithDuration:0.3 animations:^{
  254. // self.view.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT);
  255. // }];
  256. }
  257. -(void)quitOutAnimate{
  258. [self actionQuit];
  259. // [UIView animateWithDuration:0.3 animations:^{
  260. // self.view.frame = CGRectMake(JX_SCREEN_WIDTH, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT);
  261. // } completion:^(BOOL finished) {
  262. // [self.view removeFromSuperview];
  263. // }];
  264. }
  265. - (void)setViewSize{
  266. _headerImageView.layer.cornerRadius = 34;
  267. _headerImageView.clipsToBounds = YES;
  268. }
  269. - (void)creatTBHeaderView{
  270. //红包过时,提示
  271. UIView * headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, 30)];
  272. _table.tableHeaderView = headerView;
  273. _returnMoneyLabel = [[UILabel alloc]initWithFrame:headerView.frame];
  274. _returnMoneyLabel.font = g_UIFactory.font12;
  275. _returnMoneyLabel.text = [NSString stringWithFormat:@"%@(%.2f%@)%@",Localized(@"JXredPacketDetailVC_ReturnMoney1"),_packetObj.over,Localized(@"JX_ChinaMoney"),Localized(@"JXredPacketDetailVC_ReturnMoney2")];
  276. _returnMoneyLabel.textAlignment = NSTextAlignmentCenter;
  277. _returnMoneyLabel.center = headerView.center;
  278. [headerView addSubview:_returnMoneyLabel];
  279. }
  280. //填写界面上的数据
  281. - (void)setViewData{
  282. [g_server getHeadImageSmall:_packetObj.userId userName:_packetObj.userName imageView:_headerImageView];
  283. _totalMoneyLabel.text = [NSString stringWithFormat:@"%@%.2f%@",Localized(@"JXredPacketDetailVC_All"),_packetObj.money,Localized(@"JX_ChinaMoney")];
  284. _fromUserLabel.text = [NSString stringWithFormat:@"%@%@", _packetObj.userName,Localized(@"JX_WhoIsRedEnvelopes")];
  285. _greetLabel.text = _packetObj.greetings;
  286. NSString * isCanOpen = nil;
  287. NSString *over = [NSString stringWithFormat:@"%.2f",_packetObj.over];
  288. if(self.code == 100102 || [over doubleValue] < 0.01){
  289. isCanOpen = Localized(@"JXredPacketDetailVC_DrawOver");
  290. }else if(self.code == 100101){ // _dataDict[@"resultMsg"]
  291. isCanOpen = Localized(@"JXredPacketDetailVC_Overdue");
  292. [self creatTBHeaderView];
  293. }else if ([_OpenMember count] < _packetObj.count) {
  294. isCanOpen = Localized(@"JXredPacketDetailVC_DrawOK");
  295. }
  296. if ([over doubleValue] < 0.01) {
  297. _showNumLabel.text = [NSString stringWithFormat:@"%@%ld/%ld,%@",Localized(@"JXredPacketDetailVC_Drawed"),[_OpenMember count],_packetObj.count,isCanOpen];
  298. }else{
  299. _showNumLabel.text = [NSString stringWithFormat:@"%@%ld/%ld, %@%.2f%@,%@",Localized(@"JXredPacketDetailVC_Drawed"),[_OpenMember count],_packetObj.count,Localized(@"JXredPacketDetailVC_Rest"),_packetObj.over,Localized(@"JX_ChinaMoney"),isCanOpen];
  300. }
  301. }
  302. - (void)didReceiveMemoryWarning {
  303. [super didReceiveMemoryWarning];
  304. // Dispose of any resources that can be recreated.
  305. }
  306. - (void)back:(id)sender {
  307. [self quitOutAnimate];
  308. }
  309. #pragma mark --------------------TableView-------------------------
  310. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  311. return 1;
  312. }
  313. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  314. return [_OpenMember count];
  315. }
  316. -(JXRPacketListCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  317. //领取过红包的用户,使用JXRPacketListCell展示
  318. NSString * cellName = @"RPacketListCell";
  319. JXRPacketListCell * cell = [tableView dequeueReusableCellWithIdentifier:cellName];
  320. if(cell==nil){
  321. cell = [[NSBundle mainBundle] loadNibNamed:@"JXRPacketListCell" owner:self options:nil][0];
  322. cell.line = [[UIView alloc] init];
  323. cell.line.frame = CGRectMake(15, 68-LINE_WH, JX_SCREEN_WIDTH-15, LINE_WH);
  324. cell.line.backgroundColor = THE_LINE_COLOR;
  325. [cell.contentView addSubview:cell.line];
  326. }
  327. JXGetPacketList * memberObj = _OpenMember[indexPath.row];
  328. [g_server getHeadImageSmall:memberObj.userId userName:memberObj.userName imageView:cell.headerImage];
  329. //用户名
  330. cell.nameLabel.text = memberObj.userName;
  331. //回复内容
  332. cell.contentLab.text = memberObj.reply;
  333. //日期
  334. NSTimeInterval getTime = memberObj.time;
  335. NSDate * date = [NSDate dateWithTimeIntervalSince1970:getTime];
  336. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  337. [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm"];
  338. [dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:8*60*60]];//中国专用
  339. cell.timeLabel.text = [dateFormatter stringFromDate:date];
  340. //金额
  341. cell.moneyLabel.text = [NSString stringWithFormat:@"%.2f %@",memberObj.money,Localized(@"JX_ChinaMoney")];
  342. NSString *over = [NSString stringWithFormat:@"%.2f",_packetObj.over];
  343. if (_packetObj.status == 2 && [over doubleValue] < 0.01 && indexPath.row == [self getMaxMoney] && self.isGroup) {
  344. cell.kingImgV.hidden = NO;
  345. cell.bestLab.hidden = NO;
  346. }else {
  347. cell.kingImgV.hidden = YES;
  348. cell.bestLab.hidden = YES;
  349. }
  350. return cell;
  351. }
  352. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  353. return 68;
  354. }
  355. //-(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  356. //
  357. // if ([aDownload.action isEqualToString:act_getRedPacket]) {
  358. // self.dataDict = [[NSDictionary alloc]initWithDictionary:dict];
  359. // }
  360. //
  361. //
  362. //}
  363. //
  364. //-(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  365. //
  366. // //自己查看红包
  367. // if ([aDownload.action isEqualToString:act_getRedPacket]) {
  368. // self.dataDict = [[NSDictionary alloc]initWithDictionary:dict];
  369. // }
  370. // return hide_error;
  371. //}
  372. - (void)resignKeyBoard {
  373. self.bigView.hidden = YES;
  374. [self hideKeyBoard];
  375. [self resetBigView];
  376. }
  377. - (void)resetBigView {
  378. self.replayTextView.frame = CGRectMake(10, 64, self.baseView.frame.size.width - INSETS*2, 35.5);
  379. self.baseView.frame = CGRectMake(40, JX_SCREEN_HEIGHT/4-.5, JX_SCREEN_WIDTH-80, 162.5);
  380. self.topView.frame = CGRectMake(0, 118, self.baseView.frame.size.width, 40);
  381. }
  382. - (void)hideKeyBoard {
  383. if (self.replayTextView.isFirstResponder) {
  384. [self.replayTextView resignFirstResponder];
  385. }
  386. }
  387. -(UITextView*)createTextField:(UIView*)parent default:(NSString*)s hint:(NSString*)hint{
  388. UITextView* p = [[UITextView alloc] initWithFrame:CGRectMake(0,INSETS,JX_SCREEN_WIDTH,54)];
  389. p.delegate = self;
  390. p.autocorrectionType = UITextAutocorrectionTypeNo;
  391. p.autocapitalizationType = UITextAutocapitalizationTypeNone;
  392. p.enablesReturnKeyAutomatically = YES;
  393. p.scrollEnabled = NO;
  394. p.showsVerticalScrollIndicator = NO;
  395. p.showsHorizontalScrollIndicator = NO;
  396. p.textAlignment = NSTextAlignmentLeft;
  397. p.userInteractionEnabled = YES;
  398. p.backgroundColor = [UIColor whiteColor];
  399. p.text = s;
  400. p.font = g_factory.font16;
  401. [parent addSubview:p];
  402. return p;
  403. }
  404. - (void)dealloc {
  405. // [_headerImageView release];
  406. // [_totalMoneyLabel release];
  407. // [_fromUserLabel release];
  408. // [_greetLabel release];
  409. // [_showNumLabel release];
  410. // [_getPacketListTBV release];
  411. // [super dealloc];
  412. }
  413. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  414. [_wait hide];
  415. if([aDownload.action isEqualToString:act_redPacketReply]){
  416. for (JXGetPacketList * memberObj in _OpenMember) {
  417. if ([memberObj.userId intValue] == [MY_USER_ID intValue]) {
  418. memberObj.reply = self.replayTextView.text;
  419. }
  420. }
  421. self.replyContent = self.replayTextView.text;
  422. self.replyLab.text = self.replayTextView.text;
  423. [_table reloadData];
  424. }
  425. }
  426. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  427. [_wait hide];
  428. if([aDownload.action isEqualToString:act_redPacketReply]){
  429. [g_server showMsg:Localized(@"JX_FailureReply")];
  430. }
  431. return hide_error;
  432. }
  433. -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{//error为空时,代表超时
  434. [_wait hide];
  435. if([aDownload.action isEqualToString:act_redPacketReply]){
  436. [g_server showMsg:Localized(@"JX_FailureReply")];
  437. }
  438. return hide_error;
  439. }
  440. -(void) didServerConnectStart:(JXConnection*)aDownload{
  441. [_wait start];
  442. }
  443. - (NSArray *)arraySortDESC:(NSArray *)dataDict {
  444. //对数组按领取时间time 进行降序排序
  445. // 排序key, 某个对象的属性名称,是否升序, YES-升序, NO-降序
  446. NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"time" ascending:NO];
  447. // 排序结果
  448. return [dataDict sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];
  449. }
  450. - (NSUInteger)getMaxMoney {
  451. // 获取手气最佳用户的index
  452. NSArray *tempArr = [NSArray array];
  453. NSMutableArray *list = [NSMutableArray array];
  454. NSSortDescriptor *sortDescriptor1 = [NSSortDescriptor sortDescriptorWithKey:@"money" ascending:NO];
  455. // 排序结果
  456. tempArr = [_OpenMember sortedArrayUsingDescriptors:[NSArray arrayWithObjects:sortDescriptor1, nil]];
  457. JXGetPacketList *tempPacket = (JXGetPacketList *)tempArr.firstObject;
  458. NSString *tempMoney = [NSString stringWithFormat:@"%.2f",tempPacket.money];
  459. for (JXGetPacketList *packet in _OpenMember) {
  460. NSString *money = [NSString stringWithFormat:@"%.2f",packet.money];
  461. if ([money doubleValue] == [tempMoney doubleValue]) {
  462. [list addObject:packet];
  463. }
  464. }
  465. if (list.count > 1) {
  466. NSArray *sortArr = list.copy;
  467. NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"time" ascending:YES];
  468. sortArr = [sortArr sortedArrayUsingDescriptors:[NSArray arrayWithObjects:sort, nil]];
  469. JXGetPacketList *sortPacket = (JXGetPacketList *)sortArr.firstObject;
  470. for (JXGetPacketList *packet in _OpenMember) {
  471. if ([packet.userId intValue] == [sortPacket.userId intValue]) {
  472. return [_OpenMember indexOfObject:packet];
  473. }
  474. }
  475. }else {
  476. return [_OpenMember indexOfObject:[list firstObject]];
  477. }
  478. return 0;
  479. }
  480. @end