省钱达人

DRMineMainViewController.m 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  1. //
  2. // DRMineMainViewController.m
  3. // YouHuiProject
  4. //
  5. // Created by xiaoxi on 2018/1/16.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "DRMineMainViewController.h"
  9. #import "HFStretchableTableHeaderView.h"
  10. #import "DRLoginViewController.h"
  11. #import "DRCollectionViewController.h"
  12. #import "DRSettingViewController.h"
  13. #import "DRMyTicketViewController.h"
  14. #import "DRMyOrderViewController.h"
  15. #import <AlibcTradeSDK/AlibcTradeSDK.h>
  16. #import "DRBrowserHistoryController.h"
  17. #import "DRAdWebViewController.h"
  18. #import "DRFeedbackController.h"
  19. #import <StoreKit/StoreKit.h>
  20. #import "DRFindBookWebViewController.h"
  21. #import "UITableViewCell+Cc_CornRadio.h"
  22. #import "DRFourButtonView.h"
  23. #import "DRShopCarViewController.h"
  24. #import "CCActionSheet.h"
  25. #import "DRMineBlanceView.h"
  26. #import "DRMineOrderView.h"
  27. #import "DRMoreMenuView.h"
  28. #import "DROrderMainViewController.h"
  29. #import "DROrderMainViewController.h"
  30. #import "DRCommissionMainViewController.h"
  31. #import "DRMyFansViewController.h"
  32. #import "DRMyCollectionViewController.h"
  33. #import "DRInviteFansViewController.h"
  34. #import "DRMessageListController.h"
  35. #import "DRUserInfo.h"
  36. #import "DRUserInfoView.h"
  37. #import "DRCollectionMainViewController.h"
  38. #import "DRLinkFansController.h"
  39. #import "DRPrivilegeReferralViewController.h"
  40. #import "DRUserInfo.h"
  41. #import "DRMonthMainViewController.h"
  42. #import "DRMineAdView.h"
  43. #import "DRAccountDetailController.h"
  44. #import "AdPopModel.h"
  45. #import "AdJumpManager.h"
  46. #import "UIView+BABadgeView.h"
  47. #import "DRBuyLimitMainController.h"
  48. #import "DRHistoryViewController.h"
  49. #import "DRUserView.h"
  50. @interface DRMineMainViewController ()
  51. <
  52. UITableViewDelegate,
  53. UITableViewDataSource,
  54. CCActionSheetDelegate,
  55. YHMineFourButtonViewDelegate,
  56. YHMoreMenuViewDelegate
  57. >
  58. @property (nonatomic, strong) UITableView *tableView;
  59. @property (nonatomic, strong) UIView *header;
  60. @property (nonatomic, strong) UIImageView *headerImg;
  61. //@property (nonatomic, strong) DRUserInfoView *userInfoView;
  62. //@property (nonatomic, strong) DRMineBlanceView *blanceView;
  63. //@property (nonatomic, strong) DRMineOrderView *mineOrderView;
  64. @property (nonatomic, strong) DRMoreMenuView *topMenuView;
  65. //@property (nonatomic, strong) DRMoreMenuView *bottomMenuView;
  66. @property (nonatomic, strong) DRMineAdView *adView;
  67. @property (nonatomic, strong) UIButton *messageBtn;
  68. @property (nonatomic, strong) DRUserInfo *userInfo;
  69. @property (nonatomic, strong) DRUserView *userView;
  70. /*dataSource**/
  71. @property (nonatomic, strong) NSArray *cellData;
  72. @property (nonatomic, strong) NSArray *sexArr;
  73. @end
  74. @implementation DRMineMainViewController
  75. - (void)viewWillDisappear:(BOOL)animated {
  76. [super viewWillDisappear:animated];
  77. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
  78. }
  79. - (void)viewDidAppear:(BOOL)animated {
  80. [super viewDidAppear:animated];
  81. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  82. }
  83. - (void)viewWillAppear:(BOOL)animated {
  84. [super viewWillAppear:animated];
  85. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  86. [self loadUserInfo];
  87. if ([AccountTool isLogin]) {
  88. [self checkForNewMessage];
  89. }
  90. }
  91. - (void)viewDidLoad {
  92. [super viewDidLoad];
  93. [self configNavightion];
  94. [self configTableView];
  95. [self loadAdData];
  96. }
  97. - (void)configNavightion {
  98. self.navigationBar.backgroundColor = [UIColor clearColor];
  99. self.navigationBar.hidden = YES;
  100. }
  101. - (void)configTableView {
  102. [self.view addSubview:self.tableView];
  103. __weak typeof(self) weakSelf = self;
  104. //头部背景图
  105. self.headerImg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 170)];
  106. self.headerImg.userInteractionEnabled = YES;
  107. self.header.backgroundColor = [UIColor homeRedColor];
  108. self.headerImg.contentMode = UIViewContentModeScaleAspectFill;
  109. //头视图
  110. self.header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 170)];
  111. self.headerImg.backgroundColor = [UIColor homeRedColor];
  112. [self.header addSubview:self.headerImg];
  113. //上边的多菜单
  114. NSArray *buttons = @[@{@"title":@"我的收藏",@"image":@"shoucang"},
  115. @{@"title":@"浏览记录",@"image":@"liulan"}];
  116. self.topMenuView = [[DRMoreMenuView alloc] initWithFrame:CGRectMake(0, self.header.bottom, SCREEN_WIDTH, (SCREEN_WIDTH)/4) buttonInfoArray:buttons];
  117. self.topMenuView.delelgate = self;
  118. [self.header addSubview:self.topMenuView];
  119. //广告view
  120. self.adView = [[DRMineAdView alloc] initWithFrame:CGRectMake(0, self.topMenuView.bottom, SCREEN_WIDTH, 0)];
  121. self.adView.tapAdBlock = ^(AdPopModel *model) {
  122. [AdJumpManager jumpToPageWithModel:model ParentViewControll:weakSelf];
  123. };
  124. self.adView.closeBlock = ^{
  125. [weakSelf hiddenAdView];
  126. };
  127. [self.header addSubview:self.adView];
  128. self.header.height = CGRectGetMaxY(self.adView.frame)+10;
  129. self.tableView.tableHeaderView = self.header;
  130. //用户信息
  131. self.userView = [[DRUserView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 95)];
  132. self.userView.centerY = KStatusBarHeight + (self.headerImg.height-KStatusBarHeight)/2;
  133. self.userView.tapActionBlock = ^{
  134. if ([AccountTool isLogin]) {
  135. [weakSelf settingAction];
  136. }else {
  137. [weakSelf goToLoginPage];
  138. }
  139. };
  140. [self.tableView addSubview:self.userView];
  141. //消息按钮
  142. // UIButton *setButton = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-20-40, KStatusBarHeight+10, 40, 40)];
  143. // [setButton setImage:[UIImage imageNamed:@"message_icon"] forState:UIControlStateNormal];
  144. // [setButton addTarget:self action:@selector(gotoMyMessagesPage) forControlEvents:UIControlEventTouchUpInside];
  145. // self.messageBtn = setButton;
  146. // [setButton ba_addDotWithColor:[UIColor redColor]];
  147. // [setButton ba_moveBadgeWithX:-12 Y:15];
  148. // [self.tableView addSubview:setButton];
  149. if (@available(iOS 11.0, *)) {
  150. self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;//UIScrollView也适用
  151. }else {
  152. self.automaticallyAdjustsScrollViewInsets = NO;
  153. }
  154. }
  155. - (void)scrollViewDidScroll:(UIScrollView *)scrollView
  156. {
  157. CGFloat yOffset = scrollView.contentOffset.y;
  158. if(yOffset < 0)
  159. {
  160. self.headerImg.y = yOffset;
  161. self.headerImg.height = 170+ABS(yOffset);
  162. }
  163. }
  164. /**
  165. 加载用户信息
  166. */
  167. - (void)loadUserInfo {
  168. if (![AccountTool isLogin]) {
  169. [self noLoginView];
  170. return;
  171. }
  172. [DRHttp post:UserInfo params:nil success:^(id json) {
  173. self.userInfo = [DRUserInfo yy_modelWithJSON:json];
  174. [self.userView setLoginView:self.userInfo];//设置用户信息
  175. } failure:^(NSError *error) {
  176. if (![AccountTool isLogin]) {
  177. [self noLoginView];
  178. }
  179. }];
  180. }
  181. - (void)noLoginView {
  182. [self.userView setUnLoginView];
  183. }
  184. /**
  185. 检查是否有新消息
  186. */
  187. - (void)checkForNewMessage {
  188. if ([AccountTool isLogin]) {
  189. NSString *url = [NSString stringWithFormat:@"%@/api/v2/message_push/messageNew",BaseURL];
  190. [DRHttp post:url params:nil success:^(id json) {
  191. NSNumber *new = json[@"data"][@"message_new"];
  192. if ([new boolValue]) {
  193. [self.messageBtn ba_showBadge];
  194. }else {
  195. [self.messageBtn ba_hiddenBadge];
  196. }
  197. [self.tableView.mj_header endRefreshing];
  198. } failure:^(NSError *error) {
  199. }];
  200. }
  201. }
  202. /**
  203. 加载广告位数据
  204. */
  205. - (void)loadAdData {
  206. NSString *url = [NSString stringWithFormat:@"%@/api/v2/adv/advPersonCenter",BaseURL];
  207. [DRHttp get:url params:nil success:^(id json) {
  208. NSArray *list = [NSArray yy_modelArrayWithClass:[AdPopModel class] json:json[@"data"]];
  209. if (list.count > 0) {
  210. [self showAdViewWithAdModel:list.firstObject];
  211. }else {
  212. [self hiddenAdView];
  213. }
  214. } failure:^(NSError *error) {
  215. }];
  216. }
  217. - (void)showAdViewWithAdModel:(AdPopModel *)model {
  218. [self showAdView];
  219. self.adView.model = model;
  220. }
  221. - (void)showAdView {
  222. [UIView animateWithDuration:0.5 animations:^{
  223. self.adView.height = 72;
  224. self.header.height = CGRectGetMaxY(self.adView.frame)+10;
  225. self.tableView.tableHeaderView = self.header;
  226. }];
  227. }
  228. - (void)hiddenAdView {
  229. [UIView animateWithDuration:0.5 animations:^{
  230. self.adView.height = 0;
  231. self.header.height = CGRectGetMaxY(self.adView.frame)+10;
  232. self.tableView.tableHeaderView = self.header;
  233. }];
  234. }
  235. /**
  236. 特权信息
  237. */
  238. - (void)showUserType {
  239. [MobClick event:MineVipClick];
  240. DRPrivilegeReferralViewController *Privilege = [[DRPrivilegeReferralViewController alloc] init];
  241. [self.navigationController pushViewController:Privilege animated:YES];
  242. }
  243. #pragma mark ------------
  244. - (void)settingAction {
  245. DRSettingViewController *setting = [[DRSettingViewController alloc] init];
  246. [self.navigationController pushViewController:setting animated:YES];
  247. }
  248. #pragma mark ---- YHMoreMenuViewDelegate
  249. - (void)morenMenu:(DRMoreMenuView *)menuView Button:(UIButton *)button clickIndex:(NSInteger)index {
  250. switch (index) {
  251. case 0:
  252. //我的收藏
  253. [self goToMyCollectionPage];
  254. break;
  255. case 1:
  256. //浏览记录
  257. [self goToMyBrowserHistory];
  258. break;
  259. case 2:
  260. //新手指南
  261. [self goTogetTicketGuide];
  262. break;
  263. case 3:{
  264. NSString *url = self.userInfo.becomeAgency;
  265. DRAdWebViewController *web = [[DRAdWebViewController alloc] init];
  266. web.url = url;
  267. [self.navigationController pushViewController:web animated:YES];
  268. }
  269. //成为代理
  270. break;
  271. default:
  272. break;
  273. }
  274. }
  275. #pragma mark ---------------- private ---------
  276. /**
  277. 用户登录
  278. */
  279. - (void)goToLoginPage {
  280. DRLoginViewController *login = [[DRLoginViewController alloc] init];
  281. [self presentViewController:login animated:YES completion:nil];
  282. }
  283. /**
  284. 我的粉丝
  285. */
  286. - (void)goToMyFansPage {
  287. if (![AccountTool isLogin]) {
  288. [self goToLoginPage];
  289. return;
  290. }
  291. DRMyFansViewController *myFans = [[DRMyFansViewController alloc] init];
  292. [self.navigationController pushViewController:myFans animated:YES];
  293. }
  294. /**
  295. 我的订单
  296. */
  297. - (void)goToMyOrderPage {
  298. [self openMyOrderWebView];
  299. }
  300. - (void)openMyOrderWebView {
  301. if (![AccountTool isLogin]) {
  302. [self goToLoginPage];
  303. return;
  304. }
  305. DRCommissionMainViewController *order = [[DRCommissionMainViewController alloc] init];
  306. [self.navigationController pushViewController:order animated:YES];
  307. }
  308. /**
  309. 购物车
  310. */
  311. - (void)goToMyshopCarPage {
  312. DRShopCarViewController *shopCar = [[DRShopCarViewController alloc] init];
  313. [self.navigationController pushViewController:shopCar animated:YES];
  314. }
  315. /**
  316. 我的收藏
  317. */
  318. - (void)goToMyCollectionPage {
  319. if (![AccountTool isLogin]) {
  320. [self goToLoginPage];
  321. return;
  322. }
  323. DRMyCollectionViewController *collection = [[DRMyCollectionViewController alloc] init];
  324. [self.navigationController pushViewController:collection animated:YES];
  325. }
  326. /**
  327. 我的消息
  328. */
  329. - (void)gotoMyMessagesPage {
  330. if (![AccountTool isLogin]) {
  331. [self goToLoginPage];
  332. return;
  333. }
  334. DRMessageListController *messages = [[DRMessageListController alloc] init];
  335. [self.navigationController pushViewController:messages animated:YES];
  336. }
  337. /**
  338. 绑定邀请码
  339. */
  340. - (void)blindInviteCode {
  341. if (![AccountTool isLogin]) {
  342. [self goToLoginPage];
  343. return;
  344. }
  345. if ([self.userInfo.is_have_parent boolValue]) {
  346. NSString *msg = [NSString stringWithFormat:@"您已绑定过邀请码%@",self.userInfo.parent_code];
  347. [MBProgressHUD showMessage:msg];
  348. return;
  349. }
  350. DRLinkFansController *linkFans = [[DRLinkFansController alloc] init];
  351. [self.navigationController pushViewController:linkFans animated:YES];
  352. }
  353. /**
  354. 已领优惠券
  355. */
  356. - (void)goToMyTicketPage {
  357. if (![AccountTool isLogin]) {
  358. [self goToLoginPage];
  359. return;
  360. }
  361. DRMyTicketViewController *ticket = [[DRMyTicketViewController alloc] init];
  362. [self.navigationController pushViewController:ticket animated:YES];
  363. }
  364. /**
  365. 浏览历史
  366. */
  367. - (void)goToMyBrowserHistory {
  368. if (![AccountTool isLogin]) {
  369. [self goToLoginPage];
  370. return;
  371. }
  372. DRHistoryViewController *history = [[DRHistoryViewController alloc] init];
  373. [self.navigationController pushViewController:history animated:YES];
  374. }
  375. /**
  376. 邀请好友
  377. */
  378. - (void)goToInviteFansPage {
  379. if (![AccountTool isLogin]) {
  380. [self goToLoginPage];
  381. return;
  382. }
  383. DRInviteFansViewController *invite = [[DRInviteFansViewController alloc] init];
  384. [self.navigationController pushViewController:invite animated:YES];
  385. }
  386. /**
  387. 新手指南
  388. */
  389. - (void)goTogetTicketGuide {
  390. DRFindBookWebViewController *findbook = [[DRFindBookWebViewController alloc] init];
  391. [self.navigationController pushViewController:findbook animated:YES];
  392. }
  393. /**
  394. 意见反馈
  395. */
  396. - (void)goToFeedbackPage {
  397. DRFeedbackController *feedback = [[DRFeedbackController alloc] init];
  398. [self.navigationController pushViewController:feedback animated:YES];
  399. }
  400. /**
  401. 赚钱秘籍
  402. */
  403. - (void)goToGetMoneyPage {
  404. DRFindBookWebViewController *findbook = [[DRFindBookWebViewController alloc] init];
  405. findbook.isGetMontyPage = YES;
  406. [self.navigationController pushViewController:findbook animated:YES];
  407. [MobClick event:MineGetMoneyUrl];
  408. }
  409. /**
  410. 五星好评
  411. */
  412. - (void)commentAndStart {
  413. NSString * nsStringToOpen = [NSString stringWithFormat: @"itms-apps://itunes.apple.com/app/id%@?action=write-review",APP_ID];//替换为对应的APPID
  414. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:nsStringToOpen]];
  415. // if (@available(iOS 10.3, *)) {
  416. // if([SKStoreReviewController respondsToSelector:@selector(requestReview)]){
  417. // [SKStoreReviewController requestReview];
  418. // }
  419. // } else {
  420. // NSString * nsStringToOpen = [NSString stringWithFormat: @"itms-apps://itunes.apple.com/app/id%@?action=write-review",APP_ID];//替换为对应的APPID
  421. // [[UIApplication sharedApplication] openURL:[NSURL URLWithString:nsStringToOpen]];
  422. // }
  423. // SKStoreProductViewController *storeProductViewContorller = [[SKStoreProductViewController alloc] init];
  424. // storeProductViewContorller.delegate = self;
  425. // //加载App Store视图展示
  426. // [storeProductViewContorller loadProductWithParameters:
  427. //
  428. // @{SKStoreProductParameterITunesItemIdentifier : @"APPID"} completionBlock:^(BOOL result, NSError *error) {
  429. //
  430. // if(error) {
  431. //
  432. // } else {
  433. //
  434. // //模态弹出appstore
  435. //
  436. // [self presentViewController:storeProductViewContorller animated:YES completion:^{
  437. //
  438. // }];
  439. //
  440. // }
  441. //
  442. // }];
  443. }
  444. #pragma mark -------------------- YHMineFourButtonViewDelegate ---------
  445. - (void)YHMineFourButtonViewDidClickButtonIndex:(NSInteger)index {
  446. switch (index) {
  447. case 0:
  448. [self goToMyOrderPage];
  449. break;
  450. case 1:
  451. [self goToMyTicketPage];
  452. break;
  453. case 2:
  454. [self goToMyshopCarPage];
  455. break;
  456. case 3:
  457. [self goToMyBrowserHistory];
  458. break;
  459. default:
  460. break;
  461. }
  462. }
  463. #pragma mark ------------------------
  464. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
  465. {
  466. //圆角cell
  467. // [cell radioCellWithTableView:tableView atIndexPath:indexPath];
  468. if ([cell respondsToSelector:@selector(separatorInset)]) {
  469. cell.separatorInset = UIEdgeInsetsMake(0, 20, 0, 20);
  470. }
  471. }
  472. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  473. NSArray *array = self.cellData[section];
  474. return array.count;
  475. }
  476. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  477. return self.cellData.count;
  478. }
  479. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  480. if (section == 0) {
  481. return 0.1;
  482. }else {
  483. return 10;
  484. }
  485. }
  486. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  487. UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellID"];
  488. cell.textLabel.textColor = [UIColor YHColorWithHex:0x646464];
  489. cell.textLabel.font = [UIFont systemFontOfSize:14];
  490. cell.textLabel.text = self.cellData[indexPath.section][indexPath.row][@"title"];
  491. NSString *imgStr = self.cellData[indexPath.section][indexPath.row][@"image"];
  492. cell.imageView.image = [UIImage imageNamed:imgStr];
  493. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  494. if (indexPath.section == 1) {
  495. UIButton *sexBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-15-50, 12, 50, 30)];
  496. [sexBtn setImage:[UIImage imageNamed:@"me_girl"] forState:UIControlStateNormal];
  497. [sexBtn setImage:[UIImage imageNamed:@"me_man"] forState:UIControlStateSelected];
  498. [cell addSubview:sexBtn];
  499. NSString *sex = [[NSUserDefaults standardUserDefaults] objectForKey:UserSexKey];
  500. sexBtn.selected = [sex boolValue];
  501. [sexBtn addTarget:self action:@selector(changeSexButtonClick:) forControlEvents:UIControlEventTouchUpInside];
  502. }else {
  503. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  504. }
  505. //
  506. // [cell.contentView mas_updateConstraints:^(MASConstraintMaker *make) {
  507. // make.edges.mas_equalTo(UIEdgeInsetsMake(0, 10, 0, 0));
  508. // }];
  509. return cell;
  510. }
  511. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  512. return 55;
  513. }
  514. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  515. if (indexPath.section == 0) {
  516. switch (indexPath.row) {
  517. case 0:
  518. //用户反馈
  519. [self goToFeedbackPage];
  520. break;
  521. case 1:
  522. //五星好评
  523. [self commentAndStart];
  524. break;
  525. case 2:
  526. //设置
  527. [self settingAction];
  528. break;
  529. default:
  530. break;
  531. }
  532. }
  533. }
  534. /**
  535. 改变性别
  536. */
  537. - (void)changeSexButtonClick:(UIButton *)sender {
  538. NSString *newSex = sender.selected?@"0":@"1";
  539. NSDictionary *para = @{@"sex":newSex};
  540. if ([AccountTool isLogin]) {
  541. [SVProgressHUD show];
  542. sender.enabled = NO;
  543. [DRHttp post:MySetting params:para success:^(id json) {
  544. [SVProgressHUD dismiss];
  545. [self saveSexWithNewSex:newSex];
  546. sender.enabled = YES;
  547. [[NSNotificationCenter defaultCenter] postNotificationName:ChangeSex object:nil];
  548. } failure:^(NSError *error) {
  549. [SVProgressHUD dismiss];
  550. sender.enabled = YES;
  551. }];
  552. }else {
  553. [self saveSexWithNewSex:newSex];
  554. [[NSNotificationCenter defaultCenter] postNotificationName:ChangeSex object:nil];
  555. }
  556. }
  557. - (void)saveSexWithNewSex:(NSString *)newSex {
  558. [[NSUserDefaults standardUserDefaults] setObject:newSex forKey:UserSexKey];
  559. [[NSUserDefaults standardUserDefaults] synchronize];
  560. [self.tableView reloadData];
  561. }
  562. #pragma mark ===================== layezer ==============
  563. - (UITableView *)tableView {
  564. if (!_tableView) {
  565. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-TabbarHeight) style:UITableViewStyleGrouped];
  566. _tableView.estimatedSectionHeaderHeight = 0;
  567. _tableView.estimatedSectionFooterHeight = 0;
  568. _tableView.sectionFooterHeight = 0;
  569. _tableView.sectionHeaderHeight = 0;
  570. _tableView.delegate = self;
  571. _tableView.dataSource = self;
  572. _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  573. _tableView.backgroundColor = [UIColor yhGrayColor];
  574. _tableView.bounces = YES;
  575. _tableView.showsVerticalScrollIndicator = NO;
  576. _tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
  577. _tableView.separatorColor = [UIColor YHColorWithHex:0xEEEEEE];
  578. // MJRefreshGifHeader *header = [MJRefreshGifHeader headerWithRefreshingBlock:^{
  579. // [self loadUserInfo];
  580. // if ([AccountTool isLogin]) {
  581. // [self checkForNewMessage];
  582. // }
  583. // }];
  584. // header.lastUpdatedTimeLabel.hidden = YES;
  585. // header.stateLabel.hidden = YES;
  586. //
  587. // //正在刷新的图片
  588. // NSArray *imgArr = @[[UIImage imageNamed:@"ant1"],[UIImage imageNamed:@"ant2"]];
  589. // [header setImages:imgArr duration:0.3 forState:MJRefreshStateRefreshing];
  590. // [header setImages:@[[UIImage imageNamed:@"ant1"]] duration:1 forState:MJRefreshStateWillRefresh];
  591. // [header setImages:@[[UIImage imageNamed:@"ant1"]] duration:1 forState:MJRefreshStatePulling];
  592. // _tableView.mj_header = header;
  593. }
  594. return _tableView;
  595. }
  596. - (NSArray *)cellData {
  597. if (!_cellData) {//@"order",@"quan",@"history"
  598. _cellData = @[@[@{@"title":@"用户反馈",@"image":@"fankui"},
  599. @{@"title":@"五星好评",@"image":@"haoping"},
  600. @{@"title":@"设置",@"image":@"设置"}]];
  601. }
  602. return _cellData;
  603. }
  604. - (NSArray *)sexArr {
  605. if (!_sexArr) {
  606. _sexArr = @[@"女",@"男"];
  607. }
  608. return _sexArr;
  609. }
  610. - (void)didReceiveMemoryWarning {
  611. [super didReceiveMemoryWarning];
  612. // Dispose of any resources that can be recreated.
  613. }
  614. /*
  615. #pragma mark - Navigation
  616. // In a storyboard-based application, you will often want to do a little preparation before navigation
  617. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  618. // Get the new view controller using [segue destinationViewController].
  619. // Pass the selected object to the new view controller.
  620. }
  621. */
  622. @end