YOUPAILCBaseDynamicVC.m 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. //
  2. // YOUPAILCBaseDynamicVC.m
  3. // LiveChat
  4. //
  5. // Created by 张灿 on 2018/9/7.
  6. // Copyright © 2018年 caicai. All rights reserved.
  7. //
  8. #import "YOUPAILCBaseDynamicVC.h"
  9. #import "YOUPAILCDynamicCell.h"
  10. #import "YOUPAILCReportVC.h"
  11. #import "YOUPAILZUserShowVC.h"
  12. #import "YOUPAILCGiftSendView.h"
  13. #import "YOUPAILCIMSessionVC.h"
  14. #import "YOUPAILCTabBarVC.h"
  15. #import "YOUPAILCDynamicSendVideoByLinkVC.h"
  16. #import "YOUPAILZCommonGiftView.h"
  17. #import "UIViewController+TFPresent.h"
  18. #import "YBIBVideoData.h"
  19. #import "YOUPAIXRWalletVC.h"
  20. #import "LZAlertWindow.h"
  21. #import "YOUPAIHRRechargePayWindow.h"
  22. @interface YOUPAILCBaseDynamicVC ()<UITableViewDelegate,UITableViewDataSource,LCDynamicCellDelegate>
  23. @property(nonatomic,assign)NSInteger youpaipcurrentPage;
  24. @property(nonatomic,assign)NSInteger youpaipcurrentSize;
  25. @property(nonatomic,assign)NSInteger youpaiptotalPage;
  26. @property(nonatomic,strong)NSMutableArray* youpaipdynamicArray;
  27. @property(nonatomic,strong)NSMutableArray* youpaipdynamicIdArray;
  28. @property (nonatomic,strong) NSMutableDictionary *youpaipheightDict;
  29. @end
  30. @implementation YOUPAILCBaseDynamicVC
  31. -(void)dealloc
  32. {
  33. [[NSNotificationCenter defaultCenter] removeObserver:self];
  34. }
  35. - (NSMutableDictionary *)youpaipheightDict{
  36. if (_youpaipheightDict == nil) {
  37. _youpaipheightDict = [NSMutableDictionary dictionary];
  38. }
  39. return _youpaipheightDict;
  40. }
  41. -(void)youpaifsetDynamicType:(NSInteger)type andGender:(NSInteger)gender
  42. {
  43. self.youpaiptype = type;
  44. self.youpaipgender = gender;
  45. [self.tableView.mj_header beginRefreshing];
  46. }
  47. - (void)youpaifsetupTableView{
  48. self.tableView.frame = CGRectZero;
  49. self.tableView.showsVerticalScrollIndicator = NO;
  50. self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  51. self.tableView.estimatedRowHeight = 100;
  52. self.tableView.estimatedSectionFooterHeight = 0.0f;
  53. self.tableView.estimatedSectionHeaderHeight = 0.0f;
  54. self.tableView.delegate = self;
  55. self.tableView.dataSource= self;
  56. self.tableView.backgroundColor = LZFAFAFCColor;
  57. self.isAllowScroll = YES;
  58. [self.view addSubview:self.tableView];
  59. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  60. make.left.top.bottom.right.offset(0.0f);
  61. }];
  62. self.tableView.mj_header = self.refreshHeader;
  63. self.tableView.mj_footer = self.noLoadMoreFooter;
  64. // self.tableView.mj_header = [LCRefreshDotGiftHeader headerWithRefreshingTarget:self refreshingAction:@selector(youpaifloadNewData)];
  65. // MJRefreshAutoNormalFooter* normalFooter = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(youpaifloadMoreData)];
  66. // [normalFooter setTitle:@"正在加载..." forState:(MJRefreshStateRefreshing)];
  67. // [normalFooter setTitle:@"" forState:(MJRefreshStateNoMoreData)];
  68. // self.tableView.mj_footer = normalFooter;
  69. // self.tableView.mj_footer.automaticallyHidden = YES;
  70. }
  71. /// 下拉刷新回调方法,具体实现代码需要子类实现
  72. - (void)headerRefreshing{
  73. self.youpaipcurrentPage = 1;
  74. [self getDynamicListData];
  75. }
  76. /// 上拉加载回调方法,具体实现代码需要子类实现
  77. - (void)footerRefreshing{
  78. self.youpaipcurrentPage++;
  79. [self getDynamicListData];
  80. }
  81. - (void)getDynamicListData{
  82. [LCHttpHelper requestWithURLString:DynamicList parameters:@{
  83. @"page":@(self.youpaipcurrentPage),
  84. @"type":@(self.youpaiptype),
  85. @"gender":@(self.youpaipgender)
  86. } needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  87. NSDictionary* dict = (NSDictionary*)responseObject;
  88. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  89. if (code == 0) {
  90. NSDictionary *data = [dict dictionaryValueForKey:@"data" defaultValue:@{}];
  91. NSArray *result = [data arrayValueForKey:@"list" defaultValue:@[]];
  92. if (self.youpaipcurrentPage == 1) {
  93. [self.youpaipheightDict removeAllObjects];
  94. [self.youpaipdynamicArray removeAllObjects];
  95. [self.youpaipdynamicIdArray removeAllObjects];
  96. }
  97. //
  98. // NSArray* array = [[dict objectForKey:@"data"]objectForKey:@"list"];
  99. NSMutableArray* modelArray = [YOUPAILCDynamicModel mj_objectArrayWithKeyValuesArray:result];
  100. NSMutableArray* tempArray = [NSMutableArray arrayWithArray:(NSArray*)modelArray];
  101. for (YOUPAILCDynamicModel* model in modelArray) {
  102. if ([self.youpaipdynamicIdArray containsObject:model.youpaipdynamicId]) {
  103. [tempArray removeObject:model];
  104. }else{
  105. [self.youpaipdynamicIdArray addObject:model.youpaipdynamicId];
  106. }
  107. }
  108. [self.youpaipdynamicArray addObjectsFromArray:tempArray];
  109. // self.youpaiptotalPage = [[[dict objectForKey:@"data"]objectForKey:@"total_page"]integerValue];
  110. // self.youpaipcurrentPage = [[[dict objectForKey:@"data"]objectForKey:@"page"]integerValue];
  111. [self.tableView reloadData];
  112. self.tableView.mj_footer = result.count < self.youpaipcurrentSize ? self.noLoadMoreFooter : self.loadMoreFooter;
  113. // if (self.youpaipcurrentPage>=self.youpaiptotalPage) {
  114. // [self.tableView.mj_footer endRefreshingWithNoMoreData];
  115. // self.tableView.mj_footer.hidden = YES;
  116. // }
  117. if (self.youpaipdynamicArray.count != 0) {
  118. [self.tableView lz_hideEmptyView];
  119. }else{
  120. [self.tableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_dynamic_data"] content:@"暂无发布动态"];
  121. }
  122. [self.tableView.mj_header endRefreshing];
  123. [self.tableView.mj_footer endRefreshing];
  124. }else{
  125. [self.tableView.mj_header endRefreshing];
  126. [self.tableView.mj_footer endRefreshing];
  127. }
  128. } failure:^(NSError *error) {
  129. if(self.youpaipcurrentPage != 1){
  130. self.youpaipcurrentPage--;
  131. }
  132. [self.tableView.mj_header endRefreshing];
  133. [self.tableView.mj_footer endRefreshing];
  134. }];
  135. }
  136. - (void)youpaifloadNewData{
  137. self.tableView.mj_footer.hidden = YES;
  138. [self.tableView.mj_footer endRefreshing];//先结束上拉,假如有的话
  139. self.youpaipcurrentPage = 1;
  140. [LCHttpHelper requestWithURLString:DynamicList parameters:@{@"page":@(self.youpaipcurrentPage),@"type":@(self.youpaiptype),@"gender":@(self.youpaipgender)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  141. NSDictionary* dict = (NSDictionary*)responseObject;
  142. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  143. if (code==0) {//成功
  144. [self.youpaipheightDict removeAllObjects];
  145. [self.youpaipdynamicArray removeAllObjects];
  146. [self.youpaipdynamicIdArray removeAllObjects];
  147. NSArray* array = [[dict objectForKey:@"data"]objectForKey:@"list"];
  148. NSMutableArray* modelArray = [YOUPAILCDynamicModel mj_objectArrayWithKeyValuesArray:array];
  149. NSMutableArray* tempArray = [NSMutableArray arrayWithArray:(NSArray*)modelArray];
  150. for (YOUPAILCDynamicModel* model in modelArray) {
  151. if ([self.youpaipdynamicIdArray containsObject:model.youpaipdynamicId]) {
  152. [tempArray removeObject:model];
  153. }else{
  154. [self.youpaipdynamicIdArray addObject:model.youpaipdynamicId];
  155. }
  156. }
  157. [self.youpaipdynamicArray addObjectsFromArray:tempArray];
  158. self.youpaiptotalPage = [[[dict objectForKey:@"data"]objectForKey:@"total_page"]integerValue];
  159. self.youpaipcurrentPage = [[[dict objectForKey:@"data"]objectForKey:@"page"]integerValue];
  160. [self.tableView reloadData];
  161. if (self.youpaipcurrentPage>=self.youpaiptotalPage) {
  162. [self.tableView.mj_footer endRefreshingWithNoMoreData];
  163. self.tableView.mj_footer.hidden = YES;
  164. }
  165. if (self.youpaipdynamicArray.count != 0) {
  166. [self.tableView lz_hideEmptyView];
  167. }else{
  168. [self.tableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_dynamic_data"] content:@"暂无发布动态"];
  169. }
  170. [self.tableView.mj_header endRefreshing];
  171. }else{
  172. [self.tableView.mj_header endRefreshing];
  173. }
  174. } failure:^(NSError *error) {
  175. [self.tableView.mj_header endRefreshing];
  176. }];
  177. }
  178. - (void)youpaifloadMoreData{
  179. //先结束下拉 假如有的话
  180. [self.tableView.mj_header endRefreshing];
  181. self.tableView.mj_footer.hidden = YES;
  182. [self.tableView.mj_footer endRefreshing];
  183. self.youpaipcurrentPage+=1;
  184. // AppDelegate* app =(AppDelegate*)[UIApplication sharedApplication].delegate;
  185. // YOUPAILCTabBarVC* tabbar = [[YOUPAILCTabBarVC alloc]init];
  186. // app.window.rootViewController = tabbar;
  187. [LCHttpHelper requestWithURLString:DynamicList parameters:@{@"page":@(self.youpaipcurrentPage),@"type":@(self.youpaiptype),@"gender":@(self.youpaipgender)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  188. NSDictionary* dict = (NSDictionary*)responseObject;
  189. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  190. if (code==0) {//成功
  191. NSArray* array = [[dict objectForKey:@"data"]objectForKey:@"list"];
  192. NSMutableArray* modelArray = [YOUPAILCDynamicModel mj_objectArrayWithKeyValuesArray:array];
  193. NSMutableArray* tempArray = [NSMutableArray arrayWithArray:(NSArray*)modelArray];
  194. for (YOUPAILCDynamicModel* model in modelArray) {
  195. if ([self.youpaipdynamicIdArray containsObject:model.youpaipdynamicId]) {
  196. [tempArray removeObject:model];
  197. }else{
  198. [self.youpaipdynamicIdArray addObject:model.youpaipdynamicId];
  199. }
  200. }
  201. [self.youpaipdynamicArray addObjectsFromArray:tempArray];
  202. self.youpaiptotalPage = [[[dict objectForKey:@"data"]objectForKey:@"total_page"]integerValue];
  203. self.youpaipcurrentPage = [[[dict objectForKey:@"data"]objectForKey:@"page"] integerValue];
  204. [self.tableView reloadData];
  205. if (self.youpaipcurrentPage>=self.youpaiptotalPage) {
  206. [self.tableView.mj_footer endRefreshingWithNoMoreData];
  207. self.tableView.mj_footer.hidden = YES;
  208. }
  209. [self.tableView.mj_header endRefreshing];
  210. }else{
  211. [self.tableView.mj_header endRefreshing];
  212. }
  213. } failure:^(NSError *error) {
  214. [self.tableView.mj_header endRefreshing];
  215. }];
  216. }
  217. - (void)viewDidLoad {
  218. [super viewDidLoad];
  219. self.view.backgroundColor = LZFAFAFCColor;
  220. self.youpaipdynamicArray = [NSMutableArray array];
  221. self.youpaipdynamicIdArray = [NSMutableArray array];
  222. [self youpaifsetupTableView];
  223. [self.tableView.mj_header beginRefreshing];
  224. self.youpaipcurrentPage = 1;
  225. self.youpaipcurrentSize = 10;
  226. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youpaiftoTopAction) name:@"dynamicToTop" object:nil];//置顶
  227. }
  228. -(void)youpaiftoTopAction
  229. {
  230. if (self.youpaipdynamicArray.count != 0) {
  231. NSIndexPath* indexPat = [NSIndexPath indexPathForRow:0 inSection:0];
  232. [self.tableView scrollToRowAtIndexPath:indexPat atScrollPosition:UITableViewScrollPositionBottom animated:YES];
  233. }
  234. }
  235. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  236. CGFloat height = 9.0f;
  237. if (self.youpaipdynamicArray.count != 0) {
  238. YOUPAILCDynamicModel* model = self.youpaipdynamicArray[section];
  239. if (model.youpaipstatus == 0) {
  240. height += 27.0f;
  241. }
  242. }
  243. return height;
  244. }
  245. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  246. return CGFLOAT_MIN;
  247. }
  248. -(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
  249. UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 27.0f + 9.0f)];
  250. UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 9.0f, KScreenWidth, 27)];
  251. headerView.backgroundColor = [UIColor whiteColor];
  252. [v addSubview:headerView];
  253. //bg
  254. UIView *bgView = [UIView new];
  255. [headerView addSubview:bgView];
  256. [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
  257. make.edges.mas_equalTo(0);
  258. }];
  259. bgView.backgroundColor = [UIColor whiteColor];
  260. //icon
  261. UIImageView *iconImage = [UIImageView new];
  262. [bgView addSubview:iconImage];
  263. [iconImage mas_makeConstraints:^(MASConstraintMaker *make) {
  264. make.left.mas_equalTo(16);
  265. make.centerY.mas_equalTo(0);
  266. make.size.mas_equalTo(CGSizeMake(15, 15));
  267. }];
  268. iconImage.image = [UIImage imageNamed:@"vqu_images_D_dynamic_hint"];
  269. iconImage.contentMode = UIViewContentModeScaleAspectFill;
  270. iconImage.clipsToBounds = YES;
  271. //title
  272. UILabel *titleLabel = [UILabel new];
  273. [bgView addSubview:titleLabel];
  274. [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  275. make.left.mas_equalTo(iconImage.mas_right).offset(6);
  276. make.centerY.mas_equalTo(0);
  277. }];
  278. titleLabel.text = @"动态将在审核后发布";
  279. titleLabel.textColor = HexColorFromRGB(0xFFA68B);
  280. titleLabel.font = [UIFont systemFontOfSize:12];
  281. YOUPAILCDynamicModel* model = self.youpaipdynamicArray[section];
  282. if (model.youpaipstatus == 0) {
  283. //1676
  284. return v;
  285. }else{
  286. return [UIView new];
  287. }
  288. }
  289. - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
  290. return 150;
  291. }
  292. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  293. CGFloat height;
  294. YOUPAILCDynamicModel* model =self.youpaipdynamicArray[indexPath.section];
  295. NSNumber* number =[self.youpaipheightDict objectForKey:model.youpaipdynamicId];
  296. if (number && [number floatValue]>0) {
  297. height = [number floatValue];
  298. }else{
  299. height = [YOUPAILCDynamicCell youpaifcellHeightWithModel:self.youpaipdynamicArray[indexPath.section]];
  300. [self.youpaipheightDict setObject:[NSNumber numberWithFloat:(float)height] forKey:model.youpaipdynamicId];
  301. }
  302. return height;
  303. }
  304. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  305. return self.youpaipdynamicArray.count;
  306. }
  307. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  308. // NSLog(@"数组数量 == %ld",self.youpaipdynamicArray.count);
  309. return 1;
  310. }
  311. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  312. YOUPAILCDynamicCell* cell = [[YOUPAILCDynamicCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"YOUPAILCDynamicCell"];
  313. YOUPAILCDynamicModel* model = self.youpaipdynamicArray[indexPath.section];
  314. cell.youpaipdelegate = self;
  315. cell.youpaipcurrentIndex = indexPath.section;
  316. cell.youpaipdynamicModel = model;
  317. cell.backgroundColor = [UIColor whiteColor];
  318. return cell;
  319. }
  320. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  321. //动态无响应事件
  322. }
  323. - (void)youpaifclickReward:(YOUPAILCDynamicModel*)model{
  324. if ([[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id isEqualToString:model.youpaipuser_id]) {
  325. [ZCHUDHelper showTitle:@"不能赠送自己"];
  326. }else{
  327. YOUPAILCGiftSendView* sendView = [[YOUPAILCGiftSendView alloc]initWithModel:nil type:1];
  328. //modify by leo fix bug 20191009
  329. sendView.youpaipalertWindow.hidden = NO;
  330. // sendView.alertWindow.rootViewController = self;
  331. sendView.youpaipsendMultiGift = ^(NSString *giftId, NSInteger count) {
  332. [LCHttpHelper requestWithURLString:DynamicSendGift parameters:@{@"num":@(count),@"dynamic_id":model.youpaipdynamicId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  333. NSDictionary* dict = (NSDictionary*)responseObject;
  334. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  335. if (code==0) {//成功
  336. [ZCHUDHelper showTitle:@"赠送成功"];
  337. }
  338. } failure:^(NSError *error) {
  339. }];
  340. };
  341. [sendView youpaifshow];
  342. }
  343. }
  344. -(void)youpaifclickImVideo:(YOUPAILCDynamicModel *)model
  345. {
  346. if ([YOUPAILZChatRoomManager shareManager].chatroomWindow != nil && [YOUPAILZChatRoomManager shareManager].chatroomWindow.hidden == NO) {
  347. [ZCHUDHelper showTitle:@"你正在房间中,暂不可拨打视频"];
  348. return;
  349. }
  350. [UCAuthorityManager cameraAuthority:^{
  351. [LCHttpHelper requestWithURLString:CallChatType parameters:@{@"to_uid":model.youpaipuser_id,@"skill_id":@"",@"type":@"0"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  352. NSDictionary* dict = (NSDictionary*)responseObject;
  353. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  354. if (code==0) {//成功
  355. YOUPAILCVideoChatModel* videoModel = [YOUPAILCVideoChatModel mj_objectWithKeyValues:[dict objectForKey:@"data"]];
  356. [[YOUPAILZChatRoomManager shareManager] youpaifcloseChatRoom];
  357. [[NSNotificationCenter defaultCenter] postNotificationName:@"MeCallVideo" object:nil userInfo:nil];
  358. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  359. YOUPAILCVideoRequestVC* chatRequest = [[YOUPAILCVideoRequestVC alloc]init];
  360. chatRequest.youpaipvideoModel = videoModel;
  361. //modify by leo fix bug ios13
  362. ZCBaseNavigationVC *nav = [[ZCBaseNavigationVC alloc]initWithRootViewController:chatRequest];
  363. chatRequest.view.backgroundColor = HexColorFromRGBA(0x000000, 0.55);
  364. chatRequest.definesPresentationContext = YES;
  365. nav.modalPresentationStyle = UIModalPresentationOverCurrentContext;
  366. [self.navigationController presentViewController:nav animated:YES completion:^{
  367. // chatRequest.view.backgroundColor = HexColorFromRGBA(0x000000, 0.55);
  368. }];
  369. });
  370. }
  371. } failure:^(NSError *error) {
  372. }];
  373. } denied:^{
  374. dispatch_async(dispatch_get_main_queue(), ^{
  375. UIAlertController *systemAlert = [UIAlertController alertControllerWithTitle:@"请在iphone的“设置-隐私-相机”选项中,允许APP访问您的相机。" message:nil preferredStyle:UIAlertControllerStyleAlert];
  376. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"现在去设置" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action){
  377. if ([[UIDevice currentDevice].systemVersion floatValue] < 10.0)
  378. {
  379. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
  380. }
  381. else
  382. {
  383. // 去系统设置页面
  384. if (@available(iOS 10.0, *)) {
  385. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
  386. } else {
  387. // Fallback on earlier versions
  388. }
  389. }
  390. }];
  391. UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil];
  392. [systemAlert addAction:cancelAction];
  393. [systemAlert addAction:action];
  394. [self presentViewController: systemAlert animated: YES completion: nil];
  395. });
  396. }];
  397. }
  398. -(void)youpaifclickImChat:(YOUPAILCDynamicModel *)model{
  399. [self goChatPageWithUserId:model.youpaipuser_id];
  400. }
  401. - (void)goChatPageWithUserId:(NSString *)userId{
  402. @weakify(self);
  403. if (![LCTools isGirlsRealNameAuthentication]) {
  404. return;
  405. };
  406. NIMSession *session = [NIMSession session:userId type:NIMSessionTypeP2P];
  407. if (session) {
  408. [ZCHUDHelper show];
  409. [[[NIMSDK sharedSDK] userManager] fetchUserInfos:@[session.sessionId] completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
  410. @strongify(self);
  411. [ZCHUDHelper dismiss];
  412. YOUPAILCIMSessionVC *vc = [[YOUPAILCIMSessionVC alloc] initWithSession:session];
  413. vc.type = @"2";
  414. [self.navigationController pushViewController:vc animated:YES];
  415. }];
  416. }
  417. // [UMengRecordTool umengEventCountWithId:PrivateChatDynamic];
  418. // [LCHttpHelper requestWithURLString:IsChat parameters:@{@"user_id":userId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  419. // NSDictionary* dict = (NSDictionary*)responseObject;
  420. // NSInteger code = [[dict objectForKey:@"code"] integerValue];
  421. // if (code==0) {//成功
  422. // NSInteger is_chat = [[[dict objectForKey:@"data"] objectForKey:@"is_chat"] integerValue];
  423. // NSString *msg = [[dict objectForKey:@"data"] objectForKey:@"msg"];
  424. // @strongify(self);
  425. // if (is_chat == 0) { /// 0不可以 1可以私信
  426. // LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"再想想" handler:^(LZAlertAction *action) {
  427. //
  428. // }];
  429. // cancelAction.cornerRadius = 5.0f;
  430. // cancelAction.color = LZ273145Color;
  431. // cancelAction.bgColor = LZF5F4F7Color;
  432. // LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"去充值" handler:^(LZAlertAction *action) {
  433. // @strongify(self);
  434. // YOUPAIHRRechargePayWindow *payWindow = [YOUPAIHRRechargePayWindow new];
  435. // payWindow.isTouchDismiss = NO;
  436. // [self.navigationController TFPresentVC:payWindow completion:^{
  437. //
  438. // }];
  439. // }];
  440. // confimAction.cornerRadius = 5.0f;
  441. // confimAction.color = [UIColor whiteColor];
  442. // confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:GradientLeftToRight]];
  443. // LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"提示" content:msg action:@[cancelAction,confimAction]];
  444. // alert.contentTextAlignment = NSTextAlignmentCenter;
  445. // [self TFPresentVC:alert completion:^{}];
  446. // }else{
  447. // [UMengRecordTool umengEventCountWithId:InitiatePrivateChat];
  448. // NIMSession *session = [NIMSession session:userId type:NIMSessionTypeP2P];
  449. // if (session) {
  450. // [ZCHUDHelper show];
  451. // [[[NIMSDK sharedSDK] userManager] fetchUserInfos:@[session.sessionId] completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
  452. // @strongify(self);
  453. // [ZCHUDHelper dismiss];
  454. // YOUPAILCIMSessionVC *vc = [[YOUPAILCIMSessionVC alloc] initWithSession:session];
  455. // vc.type = @"2";
  456. // [self.navigationController pushViewController:vc animated:YES];
  457. // }];
  458. // }
  459. // }
  460. // }
  461. // } failure:^(NSError *error) {
  462. // }];
  463. }
  464. - (void)youpaifclickAvatar:(YOUPAILCDynamicModel*)model{
  465. // LCUserShowVC* userShow = [[LCUserShowVC alloc]init];
  466. // YOUPAILZUserShowVC *userShow = [[YOUPAILZUserShowVC alloc] init];
  467. // userShow.youpaipuserId = model.youpaipuser_id;
  468. // [self.navigationController pushViewController:userShow animated:YES];
  469. YMPersonalPageViewModel *personalPageVM = [[YMPersonalPageViewModel alloc]initWithParams:@{
  470. ParamsId:@([model.youpaipuser_id intValue])
  471. }];
  472. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_PERSONAL_PAGE) withUserInfo:@{
  473. RouterViewModel:personalPageVM
  474. } completion:nil];
  475. }
  476. -(void)youpaifclickAttention:(YOUPAILCDynamicModel *)model
  477. {
  478. if (model.youpaipis_follow == 0) {//+关注
  479. [LCCommonHttp followUserId:model.youpaipuser_id];
  480. model.youpaipis_follow = 1;
  481. [self.tableView reloadData];
  482. }else{
  483. [LCCommonHttp followUserId:model.youpaipuser_id];
  484. model.youpaipis_follow = 0;
  485. [self.tableView reloadData];
  486. }
  487. }
  488. - (void)youpaifclickMoreBtn:(YOUPAILCDynamicModel*)model index:(NSInteger)index{
  489. NSMutableArray* actionArray = [NSMutableArray array];
  490. if ([model.youpaipuser_id isEqualToString:[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id]) {
  491. ZCAlertAction* action = [ZCAlertAction actionWithTitle:@"删除" andblock:^{//删除动态
  492. [LCHttpHelper requestWithURLString:DynamicDelete parameters:@{@"dynamic_id":model.youpaipdynamicId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  493. NSDictionary* dict = (NSDictionary*)responseObject;
  494. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  495. if (code==0) {//成功
  496. [self.youpaipdynamicArray removeObject:model];
  497. [self.youpaipdynamicIdArray removeObject:model.youpaipdynamicId];
  498. [self.youpaipheightDict removeObjectForKey:model.youpaipdynamicId];
  499. [self.tableView reloadData];
  500. }
  501. } failure:^(NSError *error) {
  502. }];
  503. }];
  504. [actionArray addObject:action];
  505. }else{
  506. if ([[LCSaveData getServiceIdArr] containsObject:[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id]) {
  507. ZCAlertAction* action1 = [ZCAlertAction actionWithTitle:@"删除整条" andblock:^{//删除动态
  508. [LCHttpHelper requestWithURLString:DynamicDelete parameters:@{@"dynamic_id":model.youpaipdynamicId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  509. NSDictionary* dict = (NSDictionary*)responseObject;
  510. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  511. if (code==0) {//成功
  512. [self.youpaipdynamicArray removeObject:model];
  513. [self.youpaipdynamicIdArray removeObject:model.youpaipdynamicId];
  514. [self.youpaipheightDict removeObjectForKey:model.youpaipdynamicId];
  515. NSIndexPath *reloadIndexPath = [NSIndexPath indexPathForRow:index inSection:0];
  516. [self.tableView deleteRowsAtIndexPaths:@[reloadIndexPath] withRowAnimation:(UITableViewRowAnimationNone)];
  517. }
  518. } failure:^(NSError *error) {
  519. }];
  520. }];
  521. [actionArray addObject:action1];
  522. ZCAlertAction* action2 = [ZCAlertAction actionWithTitle:@"删除文字" andblock:^{//删除动态
  523. [LCHttpHelper requestWithURLString:DynamicDeleteLower parameters:@{@"type":@"1",@"info_id":model.youpaipdynamicId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  524. NSDictionary* dict = (NSDictionary*)responseObject;
  525. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  526. if (code==0) {//成功
  527. model.youpaipcontent = @"";
  528. NSIndexPath *reloadIndexPath=[NSIndexPath indexPathForRow:index inSection:0];
  529. [self.tableView reloadRowsAtIndexPaths:@[reloadIndexPath] withRowAnimation:UITableViewRowAnimationNone];
  530. }
  531. } failure:^(NSError *error) {
  532. }];
  533. }];
  534. [actionArray addObject:action2];
  535. }
  536. ZCAlertAction* reportAction = [ZCAlertAction actionWithTitle:@"举报该条动态" andblock:^{//举报
  537. YOUPAILCReportVC* report = [[YOUPAILCReportVC alloc]init];
  538. report.youpaipreport_uid = model.youpaipuser_id;
  539. report.youpaiptype = 3;
  540. [self.navigationController pushViewController:report animated:YES];
  541. }];
  542. [actionArray addObject:reportAction];
  543. }
  544. ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:actionArray];
  545. //modify by leo --fix bug ios13 20191009
  546. //alertSheet.alertWindow.rootViewController = self;
  547. alertSheet.alertWindow.hidden = NO;
  548. [alertSheet show];
  549. }
  550. #pragma mark-点击播放短视频
  551. -(void)youpaiffootViewdidSendGift:(YOUPAILCDynamicModel *)model{
  552. YOUPAILZCommonGiftView *view = [YOUPAILZCommonGiftView new];
  553. view.isTouchDismiss = YES;
  554. view.youpaipisAnchor = NO;
  555. [view setJumToWalletBlock1:^{
  556. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  557. [[NSNotificationCenter defaultCenter] postNotificationName:@"InsufficientBalanceNotice" object:nil userInfo:nil];
  558. YOUPAIXRWalletVC *coinRecharge = [[YOUPAIXRWalletVC alloc]init];
  559. [self.navigationController pushViewController:coinRecharge animated:YES];
  560. });
  561. }];
  562. [view setYoupaiplzgiftblock:^(YOUPAILCGiftModel * _Nonnull giftModel, NSInteger count,NSString*categoryID) {
  563. // 1 个人详情页 2.IM页面 3视频页 4.直播间
  564. [LCHttpHelper requestWithURLString:SendGift_New parameters:@{@"type":@(3),@"to_uid":model.youpaipuser_id,@"gift_id":giftModel.youpaipid,@"num":@(count),@"gift_type_id":categoryID} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  565. NSDictionary* dict = (NSDictionary*)responseObject;
  566. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  567. if (code==0) {//成功
  568. [ZCHUDHelper showTitle:@"礼物赠送成功"];
  569. }
  570. } failure:^(NSError *error) {
  571. }];
  572. }];
  573. [self TFPresentVC:view completion:^{
  574. }];
  575. }
  576. -(void)youpaifCelldidPlayVideo:(YOUPAILCDynamicModel *)model{
  577. if (model.youpaipfile_url.length>0) {//废弃
  578. // YBIBVideoData *model1 = [YBIBVideoData new];
  579. // model1.videoURL = [NSURL URLWithString:model.file_url];
  580. //// model1.projectiveView = self.imgViewArray[i];
  581. //
  582. // YBImageBrowser *browser = [YBImageBrowser new];
  583. // browser.dataSourceArray = @[model1];
  584. // browser.currentPage = 0;
  585. // [browser show];
  586. // YOUPAILCDynamicSendVideoByLinkVC *vc = [YOUPAILCDynamicSendVideoByLinkVC new];
  587. // vc.videoLikesModel = model;
  588. // [self.navigationController pushViewController:vc animated:YES];
  589. }
  590. }
  591. -(void)youpaifdeleteImage:(YOUPAILCDynamicModel *)model index:(NSInteger)index
  592. {
  593. CGFloat height = [YOUPAILCDynamicCell youpaifcellHeightWithModel:self.youpaipdynamicArray[index]];
  594. [self.youpaipheightDict setObject:[NSNumber numberWithFloat:(float)height] forKey:model.youpaipdynamicId];
  595. NSIndexPath *reloadIndexPath=[NSIndexPath indexPathForRow:index inSection:0];
  596. [self.tableView reloadRowsAtIndexPaths:@[reloadIndexPath] withRowAnimation:UITableViewRowAnimationNone];
  597. }
  598. - (void)youpaifneedUpdateCellHeight:(NSInteger)index cell:(YOUPAILCDynamicCell *)cell{
  599. NSIndexPath *reloadIndexPath = [NSIndexPath indexPathForRow:index inSection:0];
  600. [self.youpaipheightDict setObject:[NSNumber numberWithFloat:cell.youpaipcellHeight] forKey:cell.youpaipdynamicModel.youpaipdynamicId];
  601. [self.tableView beginUpdates];
  602. [self.tableView reloadRowsAtIndexPaths:@[reloadIndexPath] withRowAnimation:(UITableViewRowAnimationNone)];
  603. [self.tableView endUpdates];
  604. }
  605. #pragma mark - JXCategoryListContentViewDelegate
  606. - (UIView *)listView{
  607. return self.view;
  608. }
  609. @end