NewSubscribleManageViewController.m 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. //
  2. // NewSubscribleManageViewController.m
  3. // shiku_im
  4. //
  5. // Created by on 16/10/10.
  6. // Copyright © 2016年 Reese. All rights reserved.
  7. #import "NewSubscribleManageViewController.h"
  8. #import "SegmentTapView.h"
  9. #import "JOTableViewCell.h"
  10. #import "AFNetworking.h"
  11. #import "SubscribleDetailViewController.h"
  12. #import "JODidSubscribleTableViewCell.h"
  13. #import "JXActionSheet.h"
  14. #import "MJRefresh.h"
  15. @interface NewSubscribleManageViewController ()<SegmentTapViewDelegate,UITableViewDelegate,UITableViewDataSource,UIScrollViewDelegate>
  16. @property(nonatomic,strong)SegmentTapView *segment;
  17. @property(nonatomic,strong)UITableView * LeftTableView;
  18. @property(nonatomic,strong)UITableView * RightTableView;
  19. @property(nonatomic,strong)UITableView * DidSubscribleTableView;
  20. @property(nonatomic,strong)NSMutableArray * arr2;
  21. @property(nonatomic,strong)NSMutableArray * image2Arr;
  22. @property (nonatomic, strong) NSMutableArray * messageFrames;
  23. @property(nonatomic,strong)NSMutableArray * tmp;
  24. @property(nonatomic,strong)NSMutableArray * dataSourceArray;
  25. @property(nonatomic,strong)NSMutableArray * backStatusArray;
  26. @property(nonatomic,strong)NSMutableArray * backIdArray;
  27. @property(nonatomic,strong)NSMutableArray * backImgArray;
  28. //未订阅
  29. @property(nonatomic,strong)NSMutableArray * backId;
  30. @property(nonatomic,strong)NSMutableArray * backStatus;
  31. @property(nonatomic,strong)NSMutableArray * backImg;
  32. //已订阅
  33. @property(nonatomic,strong)NSMutableArray * backNumId;
  34. //@property(nonatomic,strong)JOTableViewCell * cell;
  35. @property(nonatomic,strong)UIImageView * imageV;
  36. @property(nonatomic,strong)JXActionSheet * sheet;
  37. @property(nonatomic,strong)NSString * statusStr;
  38. @property(nonatomic,strong)NSString * isAppliedStr;
  39. @end
  40. static NSString * cellID1 = @"cellID1";
  41. static NSString * cellID2 = @"cellID2";
  42. @implementation NewSubscribleManageViewController
  43. {
  44. NSMutableArray * _bigTitle1;
  45. NSMutableArray * _smallTitle1Arr;
  46. NSMutableArray * _image1Arr;
  47. //判断订阅是否可以被取消
  48. NSMutableArray * _backDidImage;
  49. NSMutableArray * _isAppLIED;
  50. NSMutableArray * _bigTitle2;
  51. NSMutableArray * _smallTitle2Arr;
  52. NSMutableArray * _image2Arr;
  53. }
  54. - (void)viewDidLoad {
  55. [super viewDidLoad];
  56. self.title = Localized(@"UU_message_mySubscribe_manage");
  57. // self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"设置" style:UIBarButtonItemStyleDone target:self action:@selector(clickRightBtn)];
  58. UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeSystem];
  59. btn2.frame = CGRectMake(0, 5, 22, 22);
  60. CGFloat imageY = 0;
  61. if (iOS11) {
  62. imageY = 5;
  63. }
  64. UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(0, imageY, 22, 22)];
  65. image.image = [UIImage imageNamed:@"icon_back_nor3"];
  66. [btn2 addSubview:image];
  67. [btn2 addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
  68. UIBarButtonItem *bbi2 = [[UIBarButtonItem alloc]initWithCustomView:btn2];
  69. self.navigationItem.leftBarButtonItems = @[bbi2];
  70. //建立头部视图
  71. [self setSegmentController];
  72. [self initShuZu];
  73. [self getPersonalSubData];
  74. [self getAllSubData];
  75. //创建左边的TableView
  76. [self creatLeftTableView];
  77. [self creatRightTableView];
  78. [self buildDidSubscribleUI];
  79. [self setupDidSubscribleTableViewHeader];
  80. [self setupRightTableViewHeader];
  81. // self.view.backgroundColor = Color(230, 228, 228, 1);
  82. self.view.backgroundColor = [UIColor whiteColor];
  83. }
  84. -(void)backAction{
  85. [self.navigationController popViewControllerAnimated:YES];
  86. }
  87. //初始化数组
  88. -(void)initShuZu{
  89. _image1Arr = [[NSMutableArray alloc]init];
  90. _bigTitle1 = [[NSMutableArray alloc]init];
  91. _smallTitle1Arr = [[NSMutableArray alloc]init];
  92. _isAppLIED = [[NSMutableArray alloc]init];
  93. _backDidImage = [[NSMutableArray alloc]init];
  94. _bigTitle2= [[NSMutableArray alloc]init];
  95. _smallTitle2Arr = [[NSMutableArray alloc]init];
  96. _backStatus = [[NSMutableArray alloc]init];
  97. _backNumId = [[NSMutableArray alloc]init];
  98. _backId =[[NSMutableArray alloc]init];
  99. _backImg = [[NSMutableArray alloc]init];
  100. self.dataSourceArray = [[NSMutableArray alloc]init];
  101. self.backStatusArray = [[NSMutableArray alloc]init];
  102. self.backImgArray = [[NSMutableArray alloc]init];
  103. self.backIdArray = [[NSMutableArray alloc]init];
  104. _sheet = [[JXActionSheet alloc] initWithTitle:@"退订后将不再收到其订阅消息,是否退订?" cancelTitle:@"取消" otherTitles:@[@"退订"]];
  105. }
  106. -(void)creatLeftTableView
  107. {
  108. _LeftTableView = [[UITableView alloc]initWithFrame:CGRectMake(0,50,88, SCREEN_HEIGHT-50) style:UITableViewStylePlain];
  109. _LeftTableView.tag = 100;
  110. _LeftTableView.rowHeight = 40+cellScale;
  111. _LeftTableView.delegate = self;
  112. _LeftTableView.dataSource = self;
  113. _LeftTableView.separatorStyle = NO;
  114. _LeftTableView.backgroundColor = BGKJ_COLOR;
  115. [UIView setExtraCellLineHidden:_LeftTableView];
  116. // _LeftTableView.backgroundColor = [UIColor lightGrayColor];
  117. [self.view addSubview:_LeftTableView];
  118. }
  119. -(void)clickRightBtn{
  120. DLog(@"12342");
  121. }
  122. -(void)creatRightTableView
  123. {
  124. _RightTableView = [[UITableView alloc]initWithFrame:CGRectMake(89,50, SCREEN_WIDTH-89, SCREEN_HEIGHT-50-59) style:UITableViewStylePlain];
  125. _imageV =[[UIImageView alloc]initWithFrame:CGRectMake(88.5,50, 0.5, SCREEN_HEIGHT-50)];
  126. _imageV.backgroundColor = [[UIColor lightGrayColor]colorWithAlphaComponent:0.4];
  127. // _tableView1.estimatedRowHeight = 60;
  128. // _tableView1.rowHeight = UITableViewAutomaticDimension;
  129. _RightTableView.rowHeight = 50+cellScale;
  130. _RightTableView.tag = 101;
  131. _RightTableView.delegate = self;
  132. _RightTableView.dataSource = self;
  133. // _RightTableView.separatorStyle = NO;
  134. [_RightTableView registerClass:[JOTableViewCell class] forCellReuseIdentifier:cellID1];
  135. _RightTableView.backgroundColor = BGKJ_COLOR;
  136. [UIView setExtraCellLineHidden:_RightTableView];
  137. [self.view addSubview:_imageV];
  138. [self.view addSubview:_RightTableView];
  139. [self setupRightTableViewHeader];
  140. }
  141. - (void)setupRightTableViewHeader
  142. {
  143. _RightTableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  144. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  145. [self getAllSubData];
  146. [_RightTableView.mj_header endRefreshing];
  147. });
  148. }];
  149. }
  150. -(void)setupDidSubscribleTableViewHeader
  151. {
  152. __weak typeof(self) weakSelf = self;
  153. _DidSubscribleTableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  154. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  155. [weakSelf getPersonalSubData];
  156. [_DidSubscribleTableView.mj_header endRefreshing];
  157. });
  158. }];
  159. }
  160. -(void)buildDidSubscribleUI{
  161. _DidSubscribleTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 50, SCREEN_WIDTH, SCREEN_HEIGHT-50)];
  162. _DidSubscribleTableView.delegate = self;
  163. _DidSubscribleTableView.dataSource = self;
  164. _DidSubscribleTableView.rowHeight = 50+cellScale;
  165. _DidSubscribleTableView.hidden = YES;
  166. _DidSubscribleTableView.backgroundColor = BGKJ_COLOR;
  167. [_DidSubscribleTableView registerClass:[JODidSubscribleTableViewCell class] forCellReuseIdentifier:cellID2];
  168. [UIView setExtraCellLineHidden:_DidSubscribleTableView];
  169. [self.view addSubview:_DidSubscribleTableView];
  170. }
  171. //建立头部视图
  172. - (void)setSegmentController
  173. {
  174. self.segment = [[SegmentTapView alloc] initWithFrame:CGRectMake(0,0, self_width, 40) withDataArray:[NSArray arrayWithObjects:Localized(@"UU_message_mySubscribe_notSubscribe"),Localized(@"UU_message_mySubscribe_subscribed"),nil] withFont:15];
  175. self.segment.delegate = self;
  176. self.segment.lineColor = HexColor(@"#1084D1");;
  177. self.segment.textSelectedColor = HexColor(@"#1084D1");;
  178. // self.segment.textNomalColor = [UIColor blackColor];
  179. // self.segment.btnColor=[UIColor colorWithRed:230/255.0 green:228/255.0 blue:228/255.0 alpha:1.0];;
  180. UIImageView *line = [[UIImageView alloc]initWithFrame:CGRectMake(self_width/2, 10, 1, 20)];
  181. line.backgroundColor = [[UIColor lightGrayColor]colorWithAlphaComponent:0.4];
  182. UIImageView * imageV = [[UIImageView alloc]initWithFrame:CGRectMake(0, 39, SCREEN_WIDTH, 1)];
  183. imageV.backgroundColor =[[UIColor lightGrayColor]colorWithAlphaComponent:0.3];
  184. [self.segment addSubview:line];
  185. [self.segment addSubview:imageV];
  186. [self.view addSubview:self.segment];
  187. }
  188. #pragma mark -------- select Index
  189. -(void)selectedIndex:(NSInteger)index
  190. {
  191. switch (index) {
  192. case 0:
  193. {
  194. _LeftTableView.hidden = NO;
  195. _RightTableView.hidden = NO;
  196. _imageV.hidden = NO;
  197. _DidSubscribleTableView.hidden =YES;
  198. }
  199. break;
  200. case 1:
  201. {
  202. _LeftTableView.hidden = YES;
  203. _RightTableView.hidden = YES;
  204. _imageV.hidden = YES;
  205. _DidSubscribleTableView.hidden =NO;
  206. }
  207. break;
  208. default:
  209. break;
  210. }
  211. }
  212. // 已订阅请求数据
  213. -(void)getPersonalSubData{
  214. NSString * ipStr = [[NSUserDefaults standardUserDefaults] stringForKey:@"ipAndPort"];
  215. NSString *sessionId = [[NSUserDefaults standardUserDefaults] stringForKey:@"sessionId"];
  216. NSString *url = [NSString stringWithFormat:@"%@/common/charts/getPersonalSubs.action?master=%@&sessionUser=%@&em_code=%@&sessionId=%@",ipStr,g_master,g_sessionUser,[[NSUserDefaults standardUserDefaults] objectForKey:@"erpaccount"],sessionId];
  217. // DLog(@"保存订阅的url是:%@",url);
  218. url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  219. UASNetworkManager *mannage = [UASNetworkManager shareManager];
  220. //拼接sessionID
  221. NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
  222. //设置cookie
  223. [mannage.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
  224. [mannage.requestSerializer setValue:[NSString stringWithFormat:@"%@",g_sessionUser] forHTTPHeaderField:@"sessionUser"];
  225. //json序列化
  226. mannage.responseSerializer = [AFJSONResponseSerializer serializer];
  227. [mannage request:url method:POST parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
  228. DLog(@"返回的数据是%@",responseObject);
  229. [_bigTitle1 removeAllObjects];
  230. [_isAppLIED removeAllObjects];
  231. [_backNumId removeAllObjects];
  232. [_backDidImage removeAllObjects];
  233. for (id obj in responseObject[@"datas"]) {
  234. // DLog(@"ferftgfwvdgvfrv:%@",obj[@"TITLE_"]);
  235. // [_arr1 addObject:obj[@"TILTLE_"]];
  236. // DLog(@"得到的数组是%@",_arr1);
  237. [_bigTitle1 addObject:obj[@"TITLE_"]];
  238. [_isAppLIED addObject:obj[@"ISAPPLIED_"]];
  239. [_backNumId addObject:obj[@"NUM_ID"]];
  240. [_backDidImage addObject:obj[@"IMG_"]];
  241. }
  242. _backDidImage =[NSDictionary changeType:_backDidImage];
  243. // DLog(@"获取的订阅状态是:%@",_isAppLIED);
  244. [_DidSubscribleTableView reloadData];
  245. } failure:^(NSURLSessionDataTask *task, NSError *error) {
  246. DLog(@"返回失败:%@",error);
  247. }];
  248. }
  249. //未订阅请求数据
  250. -(void)getAllSubData{
  251. NSString * ipStr = [[NSUserDefaults standardUserDefaults] stringForKey:@"ipAndPort"];
  252. NSString *sessionId = [[NSUserDefaults standardUserDefaults] stringForKey:@"sessionId"];
  253. NSString *url = [NSString stringWithFormat:@"%@common/charts/getApplySubs.action?master=%@&sessionUser=%@&em_code=%@&sessionId=%@",ipStr,g_master,g_sessionUser,[[NSUserDefaults standardUserDefaults] objectForKey:@"erpaccount"],sessionId];
  254. url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  255. UASNetworkManager *mannage = [UASNetworkManager shareManager];
  256. //拼接sessionID
  257. NSString *paramSessionId=[@"" stringByAppendingFormat:@"JSESSIONID=%@",sessionId];
  258. //设置cookie
  259. [mannage.requestSerializer setValue:paramSessionId forHTTPHeaderField:@"Cookie"];
  260. mannage.responseSerializer = [AFJSONResponseSerializer serializer];
  261. [mannage request:url method:POST parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
  262. // DLog(@"全部订阅返回的数据是:%@",responseObject[@"datas"]);
  263. [_smallTitle2Arr removeAllObjects];
  264. [_backStatus removeAllObjects];
  265. [_backId removeAllObjects];
  266. [_backImg removeAllObjects];
  267. NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
  268. //dic=[NSDictionary changeType:dic];
  269. for (id obj in responseObject[@"datas"])
  270. {
  271. [dic addEntriesFromDictionary:obj];
  272. }
  273. //存储全部订阅所有的大标题
  274. // DLog(@"获取的大标题是:%@",_bigTitle2);
  275. _bigTitle2 = [[dic allKeys] mutableCopy];
  276. NSMutableArray *b = [[NSMutableArray alloc]init];
  277. NSMutableArray *c = [[NSMutableArray alloc]init];
  278. NSMutableArray * d =[[NSMutableArray alloc]init];
  279. NSMutableArray * e = [[NSMutableArray alloc]init];
  280. for (int i = 0; i < _bigTitle2.count; i++) {
  281. NSString *str = [NSString stringWithFormat:@"%@",_bigTitle2[i]];
  282. [b removeAllObjects];
  283. [c removeAllObjects];
  284. [d removeAllObjects];
  285. [e removeAllObjects];
  286. for (id obj in responseObject[@"datas"]) {
  287. for (id obk in obj[str])
  288. {
  289. NSString * str =[NSString stringWithFormat:@"%@",obk[@"status"]];
  290. if (![str isEqualToString:@"1"])
  291. {
  292. [b addObject:obk[@"title"]];
  293. [c addObject:obk[@"id"]];
  294. [d addObject:obk[@"status"]];
  295. [e addObject:obk[@"img"]];
  296. }
  297. }
  298. }
  299. NSArray *test1 = [b mutableCopy];
  300. NSArray *test2 = [c mutableCopy];
  301. NSArray *test3 = [d mutableCopy];
  302. NSArray *test4 = [e mutableCopy];
  303. [_smallTitle2Arr addObject:test1];
  304. [_backId addObject:test2];
  305. [_backStatus addObject:test3];
  306. [_backImg addObject:test4];
  307. }
  308. _backImg =[NSDictionary changeType:_backImg];
  309. if (_smallTitle2Arr.count != 0) {
  310. self.dataSourceArray = _smallTitle2Arr[0];
  311. self.backIdArray = _backId[0];
  312. self.backStatusArray = _backStatus[0];
  313. self.backImgArray = _backImg[0];
  314. [_RightTableView reloadData];
  315. [_LeftTableView reloadData];
  316. NSIndexPath *firstPath = [NSIndexPath indexPathForRow:0 inSection:0];
  317. [_LeftTableView selectRowAtIndexPath:firstPath animated:YES scrollPosition:UITableViewScrollPositionTop];
  318. }
  319. } failure:^(NSURLSessionDataTask *task, NSError *error) {
  320. DLog(@"返回失败:%@",error);
  321. }];
  322. }
  323. -(void)shengqingdingyueGetData:(ZXsubButton * )sender{
  324. NSString * ipStr = [[NSUserDefaults standardUserDefaults] stringForKey:@"ipAndPort"];
  325. NSString *sessionId = [[NSUserDefaults standardUserDefaults] stringForKey:@"sessionId"];
  326. NSString *url = [NSString stringWithFormat:@"%@common/charts/vastAddSubsApply.action?master=%@&sessionUser=%@&ids=%@&caller=VastAddSubsApplysessionId=%@",ipStr,g_master,g_sessionUser,sender.type,sessionId];
  327. // DLog(@"全部订阅的url是:%@",url);
  328. url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  329. [[UASNetworkManager shareManager] request:url method:POST parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
  330. DLog(@"chenggong");
  331. [sender setTitle:Localized(@"UU_message_mySubscribe_applied") forState:UIControlStateNormal];
  332. [sender setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  333. sender.userInteractionEnabled = NO;
  334. } failure:^(NSURLSessionDataTask *task, NSError *error) {
  335. DLog(@"返回失败:%@",error);
  336. }];
  337. }
  338. //取消订阅申请接口
  339. -(void)cancelledSub:(ZXsubButton * )sender{
  340. NSString * ipStr = [[NSUserDefaults standardUserDefaults] stringForKey:@"ipAndPort"];
  341. NSString *sessionId = [[NSUserDefaults standardUserDefaults] stringForKey:@"sessionId"];
  342. NSString *url = [NSString stringWithFormat:@"%@common/charts/removeSubsMans.action?master=%@&sessionUser=%@&emcode=%@&numIds=%@&sessionId=%@",ipStr,g_master,g_sessionUser,[[NSUserDefaults standardUserDefaults] objectForKey:@"erpaccount"],sender.numId,sessionId];
  343. // DLog(@"取消订阅的URl是:%@",url);
  344. url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  345. [[UASNetworkManager shareManager] request:url method:POST parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
  346. [_bigTitle1 removeObjectAtIndex:sender.tag];
  347. [_backNumId removeObjectAtIndex:sender.tag];
  348. [_isAppLIED removeObjectAtIndex:sender.tag];
  349. [_backDidImage removeObjectAtIndex:sender.tag];
  350. [_DidSubscribleTableView reloadData];
  351. // DLog(@"退订成功");
  352. // [_DidSubscribleTableView reloadData];
  353. // [self.navigationController popViewControllerAnimated:YES];
  354. } failure:^(NSURLSessionDataTask *task, NSError *error) {
  355. DLog(@"返回失败:%@",error);
  356. }];
  357. }
  358. #pragma mark - Table view data source
  359. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  360. return 1;
  361. }
  362. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  363. {
  364. if (tableView == _LeftTableView) {
  365. return _bigTitle2.count;
  366. }
  367. else if (tableView == _RightTableView){
  368. return self.dataSourceArray.count;
  369. }
  370. else
  371. {
  372. return _bigTitle1.count;
  373. }
  374. }
  375. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  376. {
  377. // DLog(@"ewretyju:%@",_backStatusArray);
  378. if (tableView==_LeftTableView)
  379. {
  380. // 1. 创建一个静态的NSString,防止一直被创建
  381. static NSString *cellID = @"cellID";
  382. // 2. 通过identifier去TabelView的重用队列中查找,有没有空闲出的TableViewCell
  383. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
  384. // 3. 如果有找到直接返回cell,没有找到就去创建
  385. if (cell == nil)
  386. {
  387. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
  388. cell.backgroundColor = BGKJ_COLOR;
  389. }
  390. if (_bigTitle2.count !=0) {
  391. cell.textLabel.text =[NSString stringWithFormat:@"%@",_bigTitle2[indexPath.row]];
  392. cell.textLabel.font = FONT_SIZE(12);
  393. cell.textLabel.textColor = [UIColor blackColor];
  394. cell.textLabel.numberOfLines = 0;
  395. cell.selectedTextColor = [UIColor redColor];
  396. }
  397. return cell;
  398. }
  399. else if (tableView == _RightTableView)
  400. {
  401. JOTableViewCell *cell1 = [tableView dequeueReusableCellWithIdentifier:cellID1 forIndexPath:indexPath];
  402. if (_backImgArray.count != 0) {
  403. cell1.lable1.text = [NSString stringWithFormat:@"%@",self.dataSourceArray[indexPath.row]];
  404. cell1.button1.type = [NSString stringWithFormat:@"%@",self.backIdArray[indexPath.row]];
  405. if ([_backImgArray[indexPath.row] isEqualToString:@""]) {
  406. cell1.image1.image = [UIImage imageNamed:@"a1"];
  407. }else{
  408. NSData * data = [NSData dataWithBase64EncodedString:_backImgArray[indexPath.row]];
  409. UIImage * image = [[UIImage alloc]initWithData:data];
  410. cell1.image1.image = image;
  411. }
  412. _statusStr = [NSString stringWithFormat:@"%@",self.backStatusArray[indexPath.row]];
  413. // DLog(@"点击的状态是:%@",_statusStr);
  414. if([_statusStr isEqualToString:@"2"])
  415. {
  416. [cell1.button1 setTitle:Localized(@"UU_message_mySubscribe_applied") forState:UIControlStateNormal];
  417. [cell1.button1 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  418. cell1.button1.userInteractionEnabled = NO;
  419. }
  420. else if([_statusStr isEqualToString:@"3"])
  421. {
  422. [cell1.button1 setTitle:Localized(@"UU_message_mySubscribe_subscribe") forState:UIControlStateNormal];
  423. [cell1.button1 addTarget:self action:@selector(clickdingyue:) forControlEvents:UIControlEventTouchUpInside];
  424. [cell1.button1 setTitleColor:[UIColor colorWithRed:60/255.0 green:151/255.0 blue:215/255.0 alpha:1.0] forState:UIControlStateNormal];
  425. }
  426. }
  427. return cell1;
  428. }else
  429. {
  430. JODidSubscribleTableViewCell * cell2 = [tableView dequeueReusableCellWithIdentifier:cellID2 forIndexPath:indexPath];
  431. // cell2.image2.image = [UIImage imageNamed:@"a1"];
  432. if (_backDidImage.count != 0) {
  433. cell2.lable2.text = [NSString stringWithFormat:@"%@",_bigTitle1[indexPath.row]];
  434. NSData * base64data = [NSData dataWithBase64EncodedString:_backDidImage[indexPath.row]];
  435. if ([_backDidImage[indexPath.row] isEqualToString:@""]) {
  436. cell2.image2.image = [UIImage imageNamed:@"a1"];
  437. }else{
  438. UIImage * image = [[UIImage alloc]initWithData:base64data];
  439. cell2.image2.image = image;
  440. }
  441. // DLog(@"已订阅获取的大标题是:%@",_bigTitle1);
  442. _isAppliedStr = [NSString stringWithFormat:@"%@",_isAppLIED[indexPath.row]];
  443. if ([_isAppliedStr isEqualToString:@"0"]) {
  444. [cell2.button2 setTitle:Localized(@"UU_message_mySubscribe_can'tSubscribe") forState:UIControlStateNormal];
  445. [cell2.button2 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal
  446. ];
  447. }else if([_isAppliedStr isEqualToString:@"-1"])
  448. {
  449. [cell2.button2 setTitle:Localized(@"UU_message_mySubscribe_unsubscribe") forState:UIControlStateNormal];
  450. // [self.button1 setTitleColor:[UIColor colorWithRed:60/255.0 green:151/255.0 blue:215/255.0 alpha:1.0] forState:UIControlStateNormal];
  451. if (_backNumId.count != 0) {
  452. cell2.button2.numId = [NSString stringWithFormat:@"%@",_backNumId[indexPath.row]];
  453. cell2.button2.tag = indexPath.row;
  454. [cell2.button2 addTarget:self action:@selector(clickTuiding:) forControlEvents:UIControlEventTouchUpInside];
  455. }
  456. }
  457. }
  458. else {
  459. DLog(@"wqertyrt");
  460. // return cell2;
  461. }
  462. return cell2;
  463. }
  464. }
  465. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  466. {
  467. if (tableView == _LeftTableView)
  468. {
  469. self.dataSourceArray = [[NSMutableArray alloc]initWithArray:_smallTitle2Arr[indexPath.row]];
  470. _backIdArray = [[NSMutableArray alloc]initWithArray:_backId[indexPath.row]];
  471. _backStatusArray = [[NSMutableArray alloc]initWithArray:_backStatus[indexPath.row]];
  472. _backImgArray = [[NSMutableArray alloc]initWithArray:_backImg[indexPath.row]];
  473. DLog(@"点击前面一行获取的信息:%@",_backStatusArray);
  474. [_RightTableView reloadData];
  475. }else if(tableView ==_RightTableView){
  476. [tableView deselectRowAtIndexPath:indexPath animated:NO];
  477. SubscribleDetailViewController * svc = [[SubscribleDetailViewController alloc]init];
  478. svc.index = indexPath.row;
  479. svc.success = ^(BOOL success, NSString *status, NSInteger index) {
  480. self.backStatusArray[index] = status;
  481. [_RightTableView reloadData];
  482. };
  483. svc.a = @"123";
  484. // svc.lableText = [NSString stringWithFormat:@"%@",self.dataSourceArray[indexPath.row]];
  485. svc.recieveId = [NSString stringWithFormat:@"%@",_backIdArray[indexPath.row]];
  486. // DLog(@"wefrgtrhy:%@",svc.heardLbl.text);
  487. svc.recieveStatus = [NSString stringWithFormat:@"%@",self.backStatusArray[indexPath.row]];
  488. [self.navigationController pushViewController:svc animated:YES];
  489. }
  490. else{
  491. SubscribleDetailViewController * svc = [[SubscribleDetailViewController alloc]init];
  492. svc.a = @"234";
  493. // svc.lableText = [NSString stringWithFormat:@"%@",_bigTitle1[indexPath.row]];
  494. svc.success = ^(BOOL success, NSString *status, NSInteger index) {
  495. [_bigTitle1 removeObjectAtIndex:indexPath.row];
  496. [_backNumId removeObjectAtIndex:indexPath.row];
  497. [_isAppLIED removeObjectAtIndex:indexPath.row];
  498. [_backDidImage removeObjectAtIndex:indexPath.row];
  499. [_DidSubscribleTableView reloadData];
  500. };
  501. svc.recieveId = [NSString stringWithFormat:@"%@",_backNumId[indexPath.row]];
  502. svc.recieveIsAppliedStr = [NSString stringWithFormat:@"%@",_isAppLIED[indexPath.row]];;
  503. [self.navigationController pushViewController:svc animated:YES];
  504. }
  505. }
  506. -(NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
  507. {
  508. if (tableView ==_RightTableView) {
  509. UITableViewRowAction *deleteRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:Localized(@"UU_custom_delete") handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  510. // DLog(@"indexfertyhr row%ld", _LeftTableView.indexPathForSelectedRow.row);
  511. // DLog(@"显示的位置是:%ld",(long)indexPath.row);
  512. DLog(@"显示的数组是1:%@",self.dataSourceArray);
  513. [_smallTitle2Arr[_LeftTableView.indexPathForSelectedRow.row] removeObjectAtIndex:indexPath.row];
  514. [_backId[_LeftTableView.indexPathForSelectedRow.row] removeObjectAtIndex:indexPath.row];
  515. [_backStatus[_LeftTableView.indexPathForSelectedRow.row] removeObjectAtIndex:indexPath.row];
  516. [_backImg[_LeftTableView.indexPathForSelectedRow.row] removeObjectAtIndex:indexPath.row];
  517. // DLog(@"");
  518. self.dataSourceArray=_smallTitle2Arr[_LeftTableView.indexPathForSelectedRow.row];
  519. self.backIdArray =_backId[_LeftTableView.indexPathForSelectedRow.row];
  520. self.backStatusArray=_backStatus[_LeftTableView.indexPathForSelectedRow.row];
  521. self.backImgArray = _backImg[_LeftTableView.indexPathForSelectedRow.row];
  522. DLog(@"显示的数组是2:%@",self.dataSourceArray);
  523. [_RightTableView reloadData];
  524. }];
  525. return @[deleteRowAction];
  526. }
  527. else if (tableView == _LeftTableView){
  528. UITableViewRowAction *deleteRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:Localized(@"UU_custom_delete") handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
  529. [_bigTitle2 removeObjectAtIndex:indexPath.row];
  530. [_smallTitle2Arr removeObjectAtIndex:indexPath.row];
  531. [_backId removeObjectAtIndex:indexPath.row];
  532. [_backStatus removeObjectAtIndex:indexPath.row];
  533. [_backImg removeObjectAtIndex:indexPath.row];
  534. //
  535. [_LeftTableView reloadData];
  536. if (_smallTitle2Arr.count != 0){
  537. NSIndexPath *firstPath = [NSIndexPath indexPathForRow:0 inSection:0];
  538. [_LeftTableView selectRowAtIndexPath:firstPath animated:YES scrollPosition:UITableViewScrollPositionTop];
  539. self.dataSourceArray = [[NSMutableArray alloc]initWithArray:_smallTitle2Arr[0]];
  540. _backIdArray = [[NSMutableArray alloc]initWithArray:_backId[0]];
  541. _backStatusArray = [[NSMutableArray alloc]initWithArray:_backStatus[0]];
  542. _backImgArray = [[NSMutableArray alloc]initWithArray:_backImg[0]];
  543. }else
  544. {
  545. [self.dataSourceArray removeAllObjects];
  546. [self.backStatusArray removeAllObjects];
  547. [self.backIdArray removeAllObjects];
  548. [self.backImgArray removeAllObjects];
  549. }
  550. [_RightTableView reloadData];
  551. }];
  552. return @[deleteRowAction];
  553. }
  554. else{
  555. return nil;
  556. }
  557. }
  558. -(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
  559. {
  560. if (_DidSubscribleTableView == tableView) {
  561. return NO;
  562. }
  563. else{
  564. return YES;
  565. }
  566. }
  567. -(void)clickdingyue:(ZXsubButton * )sender{
  568. [self shengqingdingyueGetData:sender];
  569. }
  570. -(void)clickTuiding:(id )sender{
  571. _sheet.destructiveButtonIndex = 0;
  572. [_sheet showView];
  573. [_sheet dismissForCompletionHandle:^(NSInteger clickedIndex, BOOL isCancel)
  574. {
  575. switch (clickedIndex){
  576. case 0:
  577. {
  578. [self cancelledSub:sender];
  579. }
  580. break;
  581. case 1:
  582. {
  583. }
  584. break;
  585. default:
  586. break;
  587. }
  588. }];
  589. }
  590. -(void)dealloc{
  591. }
  592. @end