NewMineViewController.m 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. //
  2. // NewMineViewController.m
  3. // jitao
  4. //
  5. // Created by 罗云飞 on 2018/8/10.
  6. // Copyright © 2018年 罗云飞. All rights reserved.
  7. //
  8. #import "NewMineViewController.h"
  9. #import "BlankCell.h"
  10. #import "CategoryCell.h"
  11. #import "NewLoginViewController.h"
  12. #import "NewOrderManagementViewController.h"
  13. #import "SetupViewController.h"
  14. #import "NewMyfollowViewController.h"
  15. #import "NewMyneedsViewController.h"
  16. #import "NewAchievementsViewController.h"
  17. #import "NewMycollectionViewController.h"
  18. //#import "NewclassificationViewController.h"
  19. //#import "NewmoneyViewController.h"
  20. #import "NewFenLeiViewController.h"
  21. #import "NewKeFuViewController.h"
  22. #import "NewMessageViewController.h"
  23. #import "NewRegisterViewController.h"
  24. @interface NewMineViewController ()<UITableViewDelegate,UITableViewDataSource>{
  25. UITableView *newtableView;
  26. NSMutableArray *dataArray;
  27. NSArray *dingdanArray;
  28. }
  29. @end
  30. @implementation NewMineViewController
  31. - (void)viewWillAppear:(BOOL)animated
  32. {
  33. [super viewWillAppear:animated];
  34. [self.navgationBar setHidden:YES];
  35. [newtableView reloadData];
  36. }
  37. - (void)viewDidDisappear:(BOOL)animated
  38. {
  39. [super viewDidDisappear:animated];
  40. [self.navgationBar setHidden:NO];
  41. }
  42. - (void)viewDidLoad {
  43. [super viewDidLoad];
  44. self.view.userInteractionEnabled = YES;
  45. [self dataInitialization];
  46. [self loadsView];
  47. // Do any additional setup after loading the view.
  48. }
  49. #pragma mark - 数据初始化
  50. - (void)dataInitialization{
  51. dataArray = NewMutableArrayInit;
  52. for (int i = 0; i<8; i++) {
  53. NSDictionary *dataDic = [NSDictionary dictionary];
  54. switch (i) {
  55. case 0:
  56. dataDic = @{@"nameKey":@"我的关注",@"imageKey":@"wdgz",@"classKey":@""};
  57. [dataArray addObject:dataDic];
  58. break;
  59. case 1:
  60. dataDic = @{@"nameKey":@"我的收藏",@"imageKey":@"wdsc",@"classKey":@""};
  61. [dataArray addObject:dataDic];
  62. break;
  63. case 2:
  64. dataDic = @{@"nameKey":@"我的成果",@"imageKey":@"wdcg",@"classKey":@""};
  65. [dataArray addObject:dataDic];
  66. break;
  67. case 3:
  68. dataDic = @{@"nameKey":@"我的需求",@"imageKey":@"wdxq",@"classKey":@""};
  69. [dataArray addObject:dataDic];
  70. break;
  71. case 4:
  72. dataDic = @{@"nameKey":@"",@"imageKey":@"",@"classKey":@""};
  73. [dataArray addObject:dataDic];
  74. break;
  75. case 5:
  76. dataDic = @{@"nameKey":@"我的消息",@"imageKey":@"wdxx",@"classKey":@""};
  77. [dataArray addObject:dataDic];
  78. break;
  79. case 6:
  80. dataDic = @{@"nameKey":@"我的设置",@"imageKey":@"wdsz",@"classKey":@""};
  81. [dataArray addObject:dataDic];
  82. break;
  83. case 7:
  84. dataDic = @{@"nameKey":@"技淘客服",@"imageKey":@"kdkf",@"classKey":@""};
  85. [dataArray addObject:dataDic];
  86. break;
  87. default:
  88. break;
  89. }
  90. }
  91. dingdanArray = @[@"全部订单",@"赚钱订单",@"成果订单",@"需求订单",@"顾问订单",@"专家订单"];
  92. }
  93. #pragma mark ----加载界面
  94. - (void)loadsView{
  95. [self.view addSubview:newtableView = [NewControlPackage tableViewInitWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-TABBAR_HEIGHT) backgroundColor:NewNavigationColor style:UITableViewStyleGrouped delegate:self dataSource:self showsHorizontalScrollIndicator:NO showsVerticalScrollIndicator:NO hidden:NO tag:100 userInteractionEnabled:YES]];
  96. newtableView.separatorStyle = NO;
  97. }
  98. #pragma mark-------------------------UITableView------------------------------------
  99. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  100. {
  101. return 1;
  102. }
  103. //返回每段行数
  104. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  105. {
  106. return dataArray.count;
  107. }
  108. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  109. {
  110. static NSString *Cell2 = @"Cell";
  111. static NSString *Cell1 = @"Cell1";
  112. if (indexPath.row == 4){
  113. BlankCell * cell = [tableView dequeueReusableCellWithIdentifier:Cell1];
  114. if (cell == nil) {
  115. cell = [[BlankCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell1];
  116. }
  117. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//(这种是没有点击后的阴影效果)
  118. cell.accessoryType = UITableViewCellAccessoryNone;
  119. return cell;
  120. }else{
  121. CategoryCell * cell = [tableView dequeueReusableCellWithIdentifier:Cell2];
  122. if (cell == nil) {
  123. cell = [[CategoryCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell2];
  124. }
  125. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//(这种是没有点击后的阴影效果)
  126. cell.accessoryType = UITableViewCellAccessoryNone;
  127. [cell assignment:dataArray[indexPath.row]];
  128. if (indexPath.row == 3||indexPath.row == 7) {
  129. cell.line.hidden = YES;
  130. }
  131. // if (indexPath.row == 8) {
  132. cell.seedetails.hidden = YES;
  133. // cell.backimage.hidden = YES;
  134. // }
  135. return cell;
  136. }
  137. return [[UITableViewCell alloc] init];
  138. }
  139. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  140. {
  141. if (indexPath.row == 4) {
  142. return 10;
  143. }
  144. return fitScreenHeight(44);
  145. }
  146. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  147. if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"我的订单"]) {
  148. NewOrderManagementViewController *vc = [NewOrderManagementViewController new];
  149. NewPushViewController(vc);
  150. }else if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"我的设置"]){
  151. SetupViewController *vc = [SetupViewController new];
  152. [vc setTuichudenglu:^(NSString *string) {
  153. if ([string isEqualToString:@"退出登录"]) {
  154. [newtableView reloadData];
  155. }
  156. }];
  157. NewPushViewController(vc);
  158. }else if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"我的关注"]){
  159. if ([UserHelper isLogin]) {
  160. NSLog(@"%@",@"已登录");
  161. NewMyfollowViewController *vc = [NewMyfollowViewController new];
  162. NewPushViewController(vc);
  163. }else{
  164. NSLog(@"%@",@"未登录");
  165. NewLoginViewController *vc = [[NewLoginViewController alloc] init];
  166. [vc setLoginSuccess:^(NSString *string) {
  167. NewDismissNavigationController;
  168. }];
  169. NewPresentNavigationController(vc);
  170. }
  171. }else if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"我的需求"]){
  172. if ([UserHelper isLogin]) {
  173. NSLog(@"%@",@"已登录");
  174. NewMyneedsViewController *vc = [NewMyneedsViewController new];
  175. NewPushViewController(vc);
  176. }else{
  177. NSLog(@"%@",@"未登录");
  178. NewLoginViewController *vc = [[NewLoginViewController alloc] init];
  179. [vc setLoginSuccess:^(NSString *string) {
  180. NewDismissNavigationController;
  181. }];
  182. NewPresentNavigationController(vc);
  183. }
  184. }else if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"我的成果"]){
  185. if ([UserHelper isLogin]) {
  186. NSLog(@"%@",@"已登录");
  187. NewAchievementsViewController *vc = [NewAchievementsViewController new];
  188. NewPushViewController(vc);
  189. }else{
  190. NSLog(@"%@",@"未登录");
  191. NewLoginViewController *vc = [[NewLoginViewController alloc] init];
  192. [vc setLoginSuccess:^(NSString *string) {
  193. NewDismissNavigationController;
  194. }];
  195. NewPresentNavigationController(vc);
  196. }
  197. }else if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"我的收藏"]){
  198. if ([UserHelper isLogin]) {
  199. NSLog(@"%@",@"已登录");
  200. NewMycollectionViewController *vc = [NewMycollectionViewController new];
  201. NewPushViewController(vc);
  202. }else{
  203. NSLog(@"%@",@"未登录");
  204. NewLoginViewController *vc = [[NewLoginViewController alloc] init];
  205. [vc setLoginSuccess:^(NSString *string) {
  206. NewDismissNavigationController;
  207. }];
  208. NewPresentNavigationController(vc);
  209. }
  210. }else if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"技淘客服"]){
  211. NewKeFuViewController *vc = [NewKeFuViewController new];
  212. NewPushViewController(vc);
  213. }else if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"我的消息"]){
  214. if ([UserHelper isLogin]) {
  215. NSLog(@"%@",@"已登录");
  216. NewMessageViewController *vc = [NewMessageViewController new];
  217. NewPushViewController(vc);
  218. }else{
  219. NSLog(@"%@",@"未登录");
  220. NewLoginViewController *vc = [[NewLoginViewController alloc] init];
  221. [vc setLoginSuccess:^(NSString *string) {
  222. NewDismissNavigationController;
  223. }];
  224. NewPresentNavigationController(vc);
  225. }
  226. }
  227. }
  228. // tableView 如果是Gruop类型的话,section之间的间距变宽,执行返回高度的同时还需要执行return UIView的代理
  229. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  230. return 300;
  231. }
  232. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  233. return CGFLOAT_MIN;
  234. }
  235. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  236. UIView *headview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 300)];
  237. headview.userInteractionEnabled = YES;
  238. headview.backgroundColor = NewNavigationColor;
  239. UIImageView *backview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 196)];
  240. [backview setImage:NewImageNamed(@"bj3")];
  241. backview.userInteractionEnabled = YES;
  242. [headview addSubview:backview];
  243. // UIButton *UserimageBT = [UIButton new];
  244. UIImageView *headimage = [UIImageView new];
  245. [headimage sd_setImageWithURL:NewURL([[UserEntity sharedInstance].headPortraitUrl mosaicUrlPrefix]) placeholderImage:NewImageNamed(@"txty")];
  246. // [UserimageBT setBackgroundImage:headimage.image forState:UIControlStateNormal];
  247. ViewRadius(headimage, fitScreenWidth(73/2));
  248. // UserimageBT.tag = 100;
  249. [backview addSubview:headimage];
  250. headimage.sd_layout
  251. .leftSpaceToView(backview, 15)
  252. .heightIs(fitScreenWidth(73))
  253. .widthIs(fitScreenWidth(73))
  254. .topSpaceToView(backview, 62);
  255. if ([UserHelper isLogin]) {
  256. UILabel *name = [UILabel new];
  257. name.text = [NSString stringWithFormat:@"%@,欢迎您",[UserEntity sharedInstance].name];
  258. name.font = NewFont(fitScreenWidth(17));
  259. [name setSingleLineAutoResizeWithMaxWidth:0];
  260. name.textColor = NewWhiteColor;
  261. [backview addSubview:name];
  262. name.sd_layout
  263. .heightIs(15)
  264. .topSpaceToView(backview, 80)
  265. .leftSpaceToView(headimage, 15);
  266. UILabel *userlvl = [UILabel new];
  267. CGFloat width = [NewUtils heightforString:[UserEntity sharedInstance].type andHeight:23 fontSize:fitScreenWidth(14)];
  268. userlvl.text = [UserEntity sharedInstance].type;
  269. userlvl.textColor = NewWhiteColor;
  270. userlvl.backgroundColor = [UIColor colorWithString:@"#0D79C5"];
  271. userlvl.font = NewFont(fitScreenWidth(14));
  272. ViewRadius(userlvl, 23/2);
  273. [userlvl setTextAlignment:NSTextAlignmentCenter];
  274. [backview addSubview:userlvl];
  275. userlvl.sd_layout
  276. .leftEqualToView(name)
  277. .heightIs(23)
  278. .topSpaceToView(name, 6)
  279. .widthIs(width+10);
  280. }else{
  281. UIButton *usernameBT = [UIButton new];
  282. [usernameBT setTitle:@"登 录" forState:UIControlStateNormal];
  283. [usernameBT setTitleColor:NewWhiteColor forState:UIControlStateNormal];
  284. usernameBT.titleLabel.font = NewFont(17);
  285. NewTouchUpInside(usernameBT, usernameBTclick:);
  286. [usernameBT setupAutoSizeWithHorizontalPadding:0 buttonHeight:34];
  287. usernameBT.tag = 100;
  288. [backview addSubview:usernameBT];
  289. usernameBT.sd_layout
  290. .leftSpaceToView(headimage, 15)
  291. .heightIs(34)
  292. .centerYEqualToView(headimage);
  293. // NewTouchUpInside(headimage, usernameBTclick:);
  294. UIButton *usernameBT1 = [UIButton new];
  295. [usernameBT1 setTitle:@"/注 册" forState:UIControlStateNormal];
  296. [usernameBT1 setTitleColor:NewWhiteColor forState:UIControlStateNormal];
  297. usernameBT1.titleLabel.font = NewFont(17);
  298. NewTouchUpInside(usernameBT1, usernameBTclick:);
  299. [usernameBT1 setupAutoSizeWithHorizontalPadding:0 buttonHeight:34];
  300. usernameBT1.tag = 101;
  301. [backview addSubview:usernameBT1];
  302. usernameBT1.sd_layout
  303. .leftSpaceToView(usernameBT, 0)
  304. .heightIs(34)
  305. .centerYEqualToView(headimage);
  306. // NewTouchUpInside(UserimageBT, usernameBTclick:);
  307. }
  308. UIView *dingdanView = [[UIView alloc] initWithFrame:CGRectMake(15, 179, SCREEN_WIDTH-30, 109)];
  309. ViewRadius(dingdanView, 5);
  310. dingdanView.backgroundColor = NewWhiteColor;
  311. dingdanView.userInteractionEnabled = YES;
  312. [backview addSubview:dingdanView];
  313. UILabel *myOrder = [UILabel new];
  314. myOrder.text = @"我的订单";
  315. myOrder.font = NewFont(15);
  316. myOrder.textColor = NewBlackColor;
  317. [myOrder setSingleLineAutoResizeWithMaxWidth:0];
  318. [dingdanView addSubview:myOrder];
  319. myOrder.sd_layout
  320. .leftSpaceToView(dingdanView, 10)
  321. .heightIs(15)
  322. .topSpaceToView(dingdanView, 10);
  323. UILabel *line = [UILabel new];
  324. line.backgroundColor = NewLineGrayColor;
  325. [dingdanView addSubview:line];
  326. line.sd_layout
  327. .leftEqualToView(dingdanView)
  328. .heightIs(0.8)
  329. .rightEqualToView(dingdanView)
  330. .topSpaceToView(dingdanView, 35);
  331. NSArray *arr = @[@"qbdd",@"zqdd",@"cgdd",@"xqdd",@"gwdd",@"zjdd"];
  332. for (int i = 0; i<6; i++) {
  333. UIButton *button111 = [UIButton buttonWithType:UIButtonTypeCustom];
  334. NewTouchUpInside(button111, afasaafsafasfsaf:);
  335. [button111 setBackgroundColor:NewClearColor];
  336. float btwidth = (SCREEN_WIDTH-30)/6;
  337. button111.frame = CGRectMake(15+i*btwidth, 179+37, btwidth, 74);
  338. button111.tag = 100+i;
  339. [headview addSubview:button111];
  340. UIImageView *image = [UIImageView new];
  341. [image setImage:[UIImage imageNamed:arr[i]]];
  342. float X = (btwidth-18)/2;
  343. image.frame = CGRectMake(X, 15, 18, 18);
  344. [button111 addSubview:image];
  345. UILabel *titlelabel = [UILabel new];
  346. titlelabel.text = dingdanArray[i];
  347. titlelabel.font = NewFont(13);
  348. titlelabel.textAlignment = NSTextAlignmentCenter;
  349. titlelabel.frame = CGRectMake(0, 25+18, btwidth, 15);
  350. [button111 addSubview:titlelabel];
  351. }
  352. return headview;
  353. }
  354. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
  355. return [[UIView alloc] init];
  356. }
  357. - (void)usernameBTclick:(UIButton *)sender {
  358. if (sender.tag == 100) {
  359. NewLoginViewController *vc = [[NewLoginViewController alloc] init];
  360. [vc setLoginSuccess:^(NSString *string) {
  361. // [self Networkrequest];
  362. [newtableView reloadData];
  363. NewDismissNavigationController;
  364. }];
  365. NewPresentNavigationController(vc);
  366. }else{
  367. NewRegisterViewController *vc = [[NewRegisterViewController alloc] init];
  368. NewPresentNavigationController(vc);
  369. }
  370. }
  371. - (void)afasaafsafasfsaf:(UIButton *)sender{
  372. if ([UserHelper isLogin]) {
  373. NSLog(@"%@",@"已登录");
  374. NewOrderManagementViewController *vc = [NewOrderManagementViewController new];
  375. vc.dingdantype = dingdanArray[sender.tag-100];
  376. NewPushViewController(vc);
  377. }else{
  378. NSLog(@"%@",@"未登录");
  379. NewLoginViewController *vc = [[NewLoginViewController alloc] init];
  380. [vc setLoginSuccess:^(NSString *string) {
  381. NewDismissNavigationController;
  382. }];
  383. NewPresentNavigationController(vc);
  384. }
  385. }
  386. - (void)didReceiveMemoryWarning {
  387. [super didReceiveMemoryWarning];
  388. // Dispose of any resources that can be recreated.
  389. }
  390. /*
  391. #pragma mark - Navigation
  392. // In a storyboard-based application, you will often want to do a little preparation before navigation
  393. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  394. // Get the new view controller using [segue destinationViewController].
  395. // Pass the selected object to the new view controller.
  396. }
  397. */
  398. @end