线上所有马甲包模板,与《猎豆》同UI。域名zhuadd

HSQMineMainViewController.m 38KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232
  1. //
  2. // HSQMineMainViewController.m
  3. // YouHuiProject
  4. //
  5. // Created by xiaoxi on 2018/1/16.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "HSQMineMainViewController.h"
  9. #import "HFStretchableTableHeaderView.h"
  10. #import "HSQLoginViewController.h"
  11. #import "HSQCollectionViewController.h"
  12. #import "HSQSettingViewController.h"
  13. #import "HSQMyTicketViewController.h"
  14. #import "HSQMyOrderViewController.h"
  15. #import <AlibcTradeSDK/AlibcTradeSDK.h>
  16. #import "HSQBrowserHistoryController.h"
  17. #import "HSQAdWebViewController.h"
  18. #import "HSQFeedbackController.h"
  19. #import <StoreKit/StoreKit.h>
  20. #import "HSQFindBookWebViewController.h"
  21. #import "UITableViewCell+Cc_CornRadio.h"
  22. #import "HSQShopCarViewController.h"
  23. #import "CCActionSheet.h"
  24. #import "HSQMineBlanceView.h"
  25. #import "HSQMineOrderView.h"
  26. #import "HSQMoreMenuView.h"
  27. #import "HSQCommissionMainViewController.h"
  28. #import "HSQMyFansViewController.h"
  29. #import "HSQMyCollectionViewController.h"
  30. #import "HSQInviteFansViewController.h"
  31. #import "HSQMessageListController.h"
  32. #import "HSQUserInfo.h"
  33. #import "HSQUserInfoView.h"
  34. #import "HSQCollectionMainViewController.h"
  35. #import "HSQLinkFansController.h"
  36. #import "HSQPrivilegeReferralViewController.h"
  37. #import "HSQUserInfo.h"
  38. #import "HSQUserInfoManager.h"
  39. #import "HSQMonthMainViewController.h"
  40. #import "HSQMineAdView.h"
  41. #import "HSQChildAccountViewController.h"
  42. #import "AdPopModel.h"
  43. #import "AdJumpManager.h"
  44. #import "UIView+BABadgeView.h"
  45. #import "HSQBuyLimitMainController.h"
  46. #import "HSQAchievementView.h"
  47. #import "HSQAchievementViewController.h"
  48. #import "HSQIncomeViewController.h"
  49. #import "HSQMyWechatViewController.h"
  50. #import "HSQWebDetailController.h"
  51. #import "HSQClassifyListController.h"
  52. #import "PhoneLoginManager.h"
  53. #import "HSQLinkFansController.h"
  54. #import "HSQMinePersonInforVC.h"
  55. #import "HSQPushToWeixViewController.h"
  56. #import "HSQMineUserHintView.h"
  57. #import "HSQLinkFansController.h"
  58. #import "FSBaseViewController.h"
  59. #import "HSQMyWechatViewController.h"
  60. #import "HSQChildAccountViewController.h"
  61. #import "HSQPushToWeixViewController.h"
  62. #import <AssetsLibrary/AssetsLibrary.h>
  63. #import <Photos/Photos.h>
  64. #import <AlibcTradeSDK/AlibcTradeSDK.h>
  65. #import <AlibabaAuthSDK/ALBBSession.h>
  66. #import <AlibabaAuthSDK/ALBBSDK.h>
  67. @interface HSQMineMainViewController ()
  68. <
  69. UITableViewDelegate,
  70. UITableViewDataSource,
  71. CCActionSheetDelegate,
  72. YHMoreMenuViewDelegate
  73. >
  74. {
  75. UIButton *_newFansBtn;
  76. }
  77. @property (nonatomic, strong) UITableView *tableView;
  78. @property (nonatomic, strong) UIView *header;
  79. @property (nonatomic, strong) UIImageView *headerImg;
  80. @property (nonatomic, strong) HSQUserInfoView *userInfoView;
  81. @property (nonatomic, strong) HSQMineBlanceView *blanceView;
  82. //@property (nonatomic, strong) HSQMineOrderView *mineOrderView;
  83. @property (nonatomic, strong) HSQMoreMenuView *topMenuView;
  84. @property (nonatomic, strong) HSQMoreMenuView *bottomMenuView;
  85. @property (nonatomic, strong) HSQMineAdView *adView;
  86. @property (nonatomic, strong) HSQAchievementView *achievementView ;
  87. @property (nonatomic, strong) UIButton *messageBtn;
  88. @property (nonatomic, strong) HSQUserInfo *userInfo;
  89. @property (nonatomic, strong) UIView *userLocalNoticeView;//是否开启了通知
  90. @property (nonatomic, strong) HSQMineUserHintView *userHintView;
  91. /*dataSource**/
  92. @property (nonatomic, strong) NSArray *cellData;
  93. @property (nonatomic, strong) NSArray *sexArr;
  94. @end
  95. @implementation HSQMineMainViewController
  96. - (void)viewWillDisappear:(BOOL)animated {
  97. [super viewWillDisappear:animated];
  98. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
  99. }
  100. - (void)viewDidAppear:(BOOL)animated {
  101. [super viewDidAppear:animated];
  102. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  103. }
  104. - (void)viewWillAppear:(BOOL)animated {
  105. [super viewWillAppear:animated];
  106. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  107. [SVProgressHUD dismiss];
  108. [self loadUserInfo];
  109. }
  110. - (void)viewDidLoad {
  111. [super viewDidLoad];
  112. [self configNavightion];
  113. [self configTableView];
  114. [self loadAdData];
  115. }
  116. - (void)configNavightion {
  117. self.navigationBar.backgroundColor = [UIColor clearColor];
  118. self.navigationBar.hidden = YES;
  119. }
  120. - (void)configTableView {
  121. [self.view addSubview:self.tableView];
  122. __weak typeof(self) weakSelf = self;
  123. //头部背景图
  124. self.headerImg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 170)];
  125. self.headerImg.userInteractionEnabled = YES;
  126. self.headerImg.image = [UIImage imageNamed:@"mine_bg"];
  127. self.headerImg.contentMode = UIViewContentModeScaleAspectFill;
  128. self.headerImg.layer.masksToBounds = YES;
  129. //头视图
  130. self.header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 170)];
  131. [self.header addSubview:self.headerImg];
  132. //广告view
  133. // self.adView = [[HSQMineAdView alloc] initWithFrame:CGRectMake(10, self.topMenuView.bottom+5, SCREEN_WIDTH-20, 0)];
  134. // self.adView.tapAdBlock = ^(AdPopModel *model) {
  135. // [AdJumpManager jumpToPageWithModel:model ParentViewControll:weakSelf];
  136. // };
  137. // [self.header addSubview:self.adView];
  138. // [self.adView mas_makeConstraints:^(MASConstraintMaker *make) {
  139. // make.left.mas_equalTo(10);
  140. // make.right.mas_equalTo(-10);
  141. // make.top.mas_equalTo(self.topMenuView.mas_bottom).mas_offset(5);
  142. // make.height.mas_equalTo(0);
  143. // }];
  144. self.tableView.tableHeaderView = self.header;
  145. //用户信息
  146. self.userInfoView = [[HSQUserInfoView alloc] initWithFrame:CGRectMake(0, KStatusBarHeight +(self.header.height-KStatusBarHeight-60)/2, SCREEN_WIDTH, 60)];
  147. self.userInfoView.loginClick = ^{
  148. [weakSelf goToLoginPage];
  149. };
  150. self.userInfoView.settingClick = ^{
  151. if ([AccountTool isLogin]) {
  152. [weakSelf settingAction];
  153. }else {
  154. [weakSelf goToLoginPage];
  155. }
  156. };
  157. [self.tableView addSubview:self.userInfoView];
  158. //消息按钮
  159. // UIButton *setButton = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-9-30, NavBarHeight-30-8, 30, 30)];
  160. // [setButton setImage:[UIImage imageNamed:@"message_icon"] forState:UIControlStateNormal];
  161. // [setButton addTarget:self action:@selector(gotoMyMessagesPage) forControlEvents:UIControlEventTouchUpInside];
  162. // self.messageBtn = setButton;
  163. // [self.messageBtn ba_setBadgeLabelAttributes:^(BABadgeLabel *badgeLabel) {
  164. // UILabel *label = (UILabel *)badgeLabel;
  165. // label.textColor = [UIColor homeRedColor];
  166. // label.backgroundColor = [UIColor whiteColor];
  167. // label.height = label.width;
  168. // label.font = [UIFont systemFontOfSize:8];
  169. // }];
  170. // [self.messageBtn ba_moveBadgeWithX:-5 Y:6];
  171. // [self.messageBtn ba_hiddenBadge];
  172. // [self.tableView addSubview:setButton];
  173. //设置按钮setting
  174. UIButton *setting = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-9-30,NavBarHeight-30-8, 30, 30)];
  175. [setting setImage:[UIImage imageNamed:@"setting"] forState:UIControlStateNormal];
  176. [setting addTarget:self action:@selector(settingAction) forControlEvents:UIControlEventTouchUpInside];
  177. [self.tableView addSubview:setting];
  178. if (@available(iOS 11.0, *)) {
  179. self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;//UIScrollView也适用
  180. }else {
  181. self.automaticallyAdjustsScrollViewInsets = NO;
  182. }
  183. }
  184. - (void)scrollViewDidScroll:(UIScrollView *)scrollView
  185. {
  186. CGFloat yOffset = scrollView.contentOffset.y;
  187. if(yOffset < 0)
  188. {
  189. self.headerImg.y = yOffset;
  190. self.headerImg.height = 170+ABS(yOffset);
  191. }
  192. }
  193. /**
  194. 加载用户信息
  195. */
  196. - (void)loadUserInfo {
  197. if (![AccountTool isLogin]) {
  198. [self noLoginView];
  199. [self.tableView.mj_header endRefreshing];
  200. return;
  201. }
  202. [HSQCacheHttp post:UserInfo params:nil success:^(id json, BOOL isCache) {
  203. //讲将数据保存到本地单例
  204. [HSQUserInfoManager shareManager].userInfoDic =json;
  205. self.userInfo = [HSQUserInfo yy_modelWithJSON:json];
  206. // [self.blanceView setBlancePrice:self.userInfo.all_settlement_income];//设置余额,我的收益
  207. // self.blanceView.todayMoney = self.userInfo.this_day_forecast_income;//我的收益
  208. [self.userInfoView setUserInfo:self.userInfo];//设置用户信息
  209. // [self setNewFansButtonCount]; //设置新增好友数
  210. // [self setUserHintView];
  211. // [self.tableView.mj_header endRefreshing];
  212. } failure:^(NSError *error) {
  213. if (![AccountTool isLogin]) {
  214. [self noLoginView];
  215. }
  216. }];
  217. }
  218. //是否显示通知栏
  219. - (void)setUserHintView {
  220. if ([AccountTool isLogin] && [self.userInfo.user_level isEqualToString:@"1"]) {
  221. //通知栏
  222. [self.userHintView mas_updateConstraints:^(MASConstraintMaker *make) {
  223. make.height.mas_equalTo(41);
  224. }];
  225. [self.userHintView showUpdate];
  226. }
  227. if ([AccountTool isLogin] && [self.userInfo.user_level isEqualToString:@"3"] && ![self.userInfo.ishasWechat boolValue]) {
  228. [self.userHintView mas_updateConstraints:^(MASConstraintMaker *make) {
  229. make.height.mas_equalTo(41);
  230. }];
  231. [self.userHintView showWechat];
  232. }
  233. }
  234. /**
  235. 去我的余额界面
  236. */
  237. - (void)gotoMyBlancePage {
  238. HSQChildAccountViewController *accountDetail = [[HSQChildAccountViewController alloc] init];//提现
  239. [self.navigationController pushViewController:accountDetail animated:YES];
  240. }
  241. - (void)setNewFansButtonCount {
  242. NSString *newFans;
  243. if ([self.userInfo.register_friends integerValue] > 99) {
  244. newFans = @"99+";
  245. }else {
  246. newFans = self.userInfo.register_friends;
  247. }
  248. [_newFansBtn ba_addBadgeWithText:newFans];
  249. CGFloat offX = 30;
  250. CGFloat offY = 20;
  251. [_newFansBtn ba_moveBadgeWithX:-offX Y:offY];
  252. if ([self.userInfo.register_friends integerValue] > 99) {
  253. [_newFansBtn ba_showBadge];
  254. }else {
  255. [_newFansBtn ba_hiddenBadge];
  256. }
  257. }
  258. - (void)noLoginView {
  259. [self.userInfoView setNologInView];
  260. [self.blanceView setBlancePrice:@"-.--"];
  261. self.blanceView.todayMoney = @"";
  262. [self.messageBtn ba_hiddenBadge];
  263. }
  264. /**
  265. 加载广告位数据
  266. */
  267. - (void)loadAdData {
  268. NSString *url = [NSString stringWithFormat:@"%@/api/v2/adv/advByType",BaseURL];
  269. NSDictionary *para = @{@"adv_type":@"4"};
  270. [HSQHttp get:url params:para success:^(id json) {
  271. NSArray *list = [NSArray yy_modelArrayWithClass:[AdPopModel class] json:json[@"data"]];
  272. if (list.count > 0) {
  273. [self showAdViewWithAdModel:list.firstObject];
  274. }
  275. } failure:^(NSError *error) {
  276. }];
  277. }
  278. - (void)showAdViewWithAdModel:(AdPopModel *)model {
  279. [self showAdView];
  280. self.adView.model = model;
  281. }
  282. - (void)showAdView {
  283. [UIView animateWithDuration:0.3 animations:^{
  284. [self.adView mas_updateConstraints:^(MASConstraintMaker *make) {
  285. make.height.mas_equalTo((SCREEN_WIDTH-20)*74/355);
  286. }];
  287. [self.view layoutIfNeeded];
  288. }];
  289. self.header.height = CGRectGetMaxY(self.bottomMenuView.frame)+50;
  290. self.tableView.tableHeaderView = self.header;
  291. }
  292. - (void)hiddenAdView {
  293. [UIView animateWithDuration:0.5 animations:^{
  294. self.adView.height = 0;
  295. self.bottomMenuView.y = self.adView.bottom;
  296. self.header.height = CGRectGetMaxY(self.bottomMenuView.frame)+5;
  297. self.tableView.tableHeaderView = self.header;
  298. }];
  299. }
  300. /**
  301. 特权信息
  302. */
  303. - (void)showUserType {
  304. [MobClick event:MineVipClick];
  305. if (![AccountTool isLogin]) {
  306. [self goToLoginPage];
  307. return;
  308. }
  309. HSQPrivilegeReferralViewController *Privilege = [[HSQPrivilegeReferralViewController alloc] init];
  310. [self.navigationController pushViewController:Privilege animated:YES];
  311. }
  312. #pragma mark ------------
  313. - (void)settingAction {
  314. HSQSettingViewController *setting = [[HSQSettingViewController alloc] init];
  315. setting.alipayFlag = self.userInfo.flag;
  316. setting.inviteCode = self.userInfo.invite_code;
  317. [self.navigationController pushViewController:setting animated:YES];
  318. }
  319. #pragma mark-个人信息
  320. -(void)Personinformation
  321. {
  322. HSQMinePersonInforVC *setting = [[HSQMinePersonInforVC alloc] init];
  323. setting.userModel = self.userInfo;
  324. // setting.alipayFlag = self.userInfo.flag;
  325. // setting.inviteCode = self.userInfo.invite_code;
  326. [self.navigationController pushViewController:setting animated:YES];
  327. }
  328. - (void)fansPageShowIndex:(NSInteger)showIndex {
  329. if (![AccountTool isLogin]) {
  330. [self goToLoginPage];
  331. return;
  332. }
  333. HSQMyFansViewController *myFasn = [[HSQMyFansViewController alloc] init];
  334. myFasn.showIndex = showIndex;
  335. [self.navigationController pushViewController:myFasn animated:YES];
  336. }
  337. #pragma mark ---- YHMoreMenuViewDelegate
  338. - (void)morenMenu:(HSQMoreMenuView *)menuView Button:(UIButton *)button clickIndex:(NSInteger)index {
  339. if (menuView == self.topMenuView) {
  340. switch (index) {
  341. case 0:
  342. [self gotoMyIncomePage]; //我的收益
  343. break;
  344. case 1:
  345. [self goToMyOrderPage]; //我的订单
  346. break;
  347. case 2:
  348. [self goToMyFansPage]; //我的好友
  349. break;
  350. case 3:
  351. [self goToInviteFansPage]; //邀请好友
  352. break;
  353. default:
  354. break;
  355. }
  356. }else if (menuView == self.bottomMenuView){
  357. if ([[PhoneLoginManager shareManager].showPhoneBtn boolValue]) {
  358. //过shen专用
  359. [self tapMenuWithIndex:index];
  360. }else {
  361. switch (index) {
  362. case 0:
  363. [self goToMyCollectionPage]; //收藏、浏览
  364. break;
  365. case 1:
  366. [self goTogetTicketGuide]; //赚钱秘籍
  367. break;
  368. case 2:
  369. [self connectToUs]; //联系我们 改成 专属客服
  370. break;
  371. case 3:
  372. [self showUserType]; //特权介绍
  373. break;
  374. case 4:
  375. [self becomeAgency]; //成为代理
  376. break;
  377. case 5:
  378. [self goToFeedbackPage]; //用户反馈
  379. break;
  380. case 6:
  381. [self gotoProblemPage];//常见问题
  382. break;
  383. case 7:
  384. [self settingAction]; //设置
  385. break;
  386. default:
  387. break;
  388. }
  389. }
  390. }
  391. }
  392. /**
  393. 过审点击
  394. */
  395. - (void)tapMenuWithIndex:(NSInteger)index {
  396. switch (index) {
  397. case 0:
  398. [self goToMyCollectionPage]; //收藏、浏览
  399. break;
  400. case 1:
  401. [self goTogetTicketGuide]; //赚钱秘籍
  402. break;
  403. case 2:
  404. [self connectToUs]; //联系我们 改成 专属客服
  405. break;
  406. case 3:
  407. [self goToFeedbackPage]; //用户反馈
  408. break;
  409. case 4:
  410. [self gotoProblemPage];//常见问题
  411. break;
  412. case 5:
  413. [self settingAction]; //设置
  414. break;
  415. default:
  416. break;
  417. }
  418. }
  419. #pragma mark ---------------- private ---------
  420. /**
  421. 常见问题
  422. */
  423. - (void)gotoProblemPage {
  424. HSQWebDetailController *findbook = [[HSQWebDetailController alloc] init];
  425. findbook.pageType = 2;
  426. [self.navigationController pushViewController:findbook animated:YES];
  427. }
  428. /**
  429. 用户登录
  430. */
  431. - (void)goToLoginPage {
  432. HSQLoginViewController *login = [[HSQLoginViewController alloc] init];
  433. [self presentViewController:login animated:YES completion:nil];
  434. }
  435. /**
  436. 我的粉丝
  437. */
  438. - (void)goToMyFansPage {
  439. if (![AccountTool isLogin]) {
  440. [self goToLoginPage];
  441. return;
  442. }
  443. HSQMyFansViewController *myFans = [[HSQMyFansViewController alloc] init];
  444. [self.navigationController pushViewController:myFans animated:YES];
  445. }
  446. /**
  447. 我的订单
  448. */
  449. - (void)goToMyOrderPage {
  450. [self openMyOrderWebView];
  451. }
  452. - (void)openMyOrderWebView {
  453. if ([[ALBBSession sharedInstance] isLogin]){
  454. HSQWebPageViewController *order = [[HSQWebPageViewController alloc] init];
  455. order.openPage = AlibcOpenPageMyOrder;
  456. [self.navigationController pushViewController:order animated:YES];
  457. }else {
  458. //淘宝授权
  459. ALBBSDK *albbSDK = [ALBBSDK sharedInstance];
  460. [albbSDK setAppkey:ALBC_APP_KEY];
  461. [albbSDK setAuthOption:NormalAuth];
  462. [albbSDK auth:self successCallback:^(ALBBSession *session){
  463. HSQWebPageViewController *order = [[HSQWebPageViewController alloc] init];
  464. order.openPage = AlibcOpenPageMyOrder;
  465. [self.navigationController pushViewController:order animated:YES];
  466. } failureCallback:^(ALBBSession *session,NSError *error){
  467. }];
  468. }
  469. }
  470. /**
  471. 我的收益
  472. */
  473. - (void)gotoMyIncomePage {
  474. if (![AccountTool isLogin]) {
  475. [self goToLoginPage];
  476. return;
  477. }
  478. HSQAchievementViewController *detail = [[HSQAchievementViewController alloc] init];
  479. [self.navigationController pushViewController:detail animated:YES];
  480. }
  481. /**
  482. 购物车
  483. */
  484. - (void)goToMyshopCarPage {
  485. HSQShopCarViewController *shopCar = [[HSQShopCarViewController alloc] init];
  486. [self.navigationController pushViewController:shopCar animated:YES];
  487. }
  488. /**
  489. 我的收藏/浏览
  490. */
  491. - (void)goToMyCollectionPage {
  492. if (![AccountTool isLogin]) {
  493. [self goToLoginPage];
  494. return;
  495. }
  496. HSQCollectionMainViewController *collection = [[HSQCollectionMainViewController alloc] init];
  497. [self.navigationController pushViewController:collection animated:YES];
  498. }
  499. /**
  500. 我的消息
  501. */
  502. - (void)gotoMyMessagesPage {
  503. if (![AccountTool isLogin]) {
  504. [self goToLoginPage];
  505. return;
  506. }
  507. HSQMessageListController *messages = [[HSQMessageListController alloc] init];
  508. [self.navigationController pushViewController:messages animated:YES];
  509. }
  510. /**
  511. 绑定邀请码
  512. */
  513. - (void)blindInviteCode {
  514. if (![AccountTool isLogin]) {
  515. [self goToLoginPage];
  516. return;
  517. }
  518. if ([self.userInfo.is_have_parent boolValue]) {
  519. NSString *msg = [NSString stringWithFormat:@"您已绑定过邀请码%@",self.userInfo.parent_code];
  520. [MBProgressHUD showMessage:msg];
  521. return;
  522. }
  523. HSQLinkFansController *linkFans = [[HSQLinkFansController alloc] init];
  524. [self.navigationController pushViewController:linkFans animated:YES];
  525. }
  526. /**
  527. 已领优惠券
  528. */
  529. - (void)goToMyTicketPage {
  530. if (![AccountTool isLogin]) {
  531. [self goToLoginPage];
  532. return;
  533. }
  534. HSQMyTicketViewController *ticket = [[HSQMyTicketViewController alloc] init];
  535. [self.navigationController pushViewController:ticket animated:YES];
  536. }
  537. /**
  538. 浏览历史
  539. */
  540. - (void)goToMyBrowserHistory {
  541. HSQBrowserHistoryController *history = [[HSQBrowserHistoryController alloc] init];
  542. [self.navigationController pushViewController:history animated:YES];
  543. }
  544. /**
  545. 邀请好友
  546. */
  547. - (void)goToInviteFansPage {
  548. if (![AccountTool isLogin]) {
  549. [self goToLoginPage];
  550. return;
  551. }
  552. HSQInviteFansViewController *invite = [[HSQInviteFansViewController alloc] init];
  553. [self.navigationController pushViewController:invite animated:YES];
  554. }
  555. /**
  556. 新手指南
  557. */
  558. - (void)goTogetTicketGuide {
  559. HSQWebDetailController *findbook = [[HSQWebDetailController alloc] init];
  560. findbook.pageType = 0;
  561. [self.navigationController pushViewController:findbook animated:YES];
  562. }
  563. /**
  564. 成为代理
  565. */
  566. - (void)becomeAgency {
  567. if (![AccountTool isLogin]) {
  568. [self goToLoginPage];
  569. return;
  570. }
  571. NSDictionary *dict = [HSQUserInfoManager shareManager].userInfoDic;
  572. HSQUserInfo *userInfo = [HSQUserInfo yy_modelWithJSON:dict];
  573. if (![userInfo.user_level isEqualToString:@"3"]) {
  574. [MBProgressHUD showMessage:@"您还不是运营商"];
  575. return;
  576. }
  577. NSString *url = self.userInfo.operator_system;
  578. HSQAdWebViewController *web = [[HSQAdWebViewController alloc] init];
  579. web.url = url;
  580. [self.navigationController pushViewController:web animated:YES];
  581. }
  582. /**
  583. 意见反馈
  584. */
  585. - (void)goToFeedbackPage {
  586. HSQFeedbackController *feedback = [[HSQFeedbackController alloc] init];
  587. feedback.userInfo = self.userInfo;
  588. [self.navigationController pushViewController:feedback animated:YES];
  589. }
  590. /**
  591. 赚钱秘籍
  592. */
  593. - (void)goToGetMoneyPage {
  594. HSQFindBookWebViewController *findbook = [[HSQFindBookWebViewController alloc] init];
  595. findbook.pageType = 1;
  596. [self.navigationController pushViewController:findbook animated:YES];
  597. [MobClick event:MineGetMoneyUrl];
  598. }
  599. /**
  600. //联系我们 改成 专属客服
  601. */
  602. - (void)connectToUs {
  603. // if (![AccountTool isLogin]) {
  604. // [self goToLoginPage];
  605. // return;
  606. // }
  607. HSQPushToWeixViewController *weixin = [[HSQPushToWeixViewController alloc] init];
  608. weixin.userInfo = self.userInfo;
  609. [self.navigationController pushViewController:weixin animated:YES];
  610. // HSQWebDetailController *web = [[HSQWebDetailController alloc] init];
  611. // web.url = self.userInfo.contact_us;
  612. // [self.navigationController pushViewController:web animated:YES];
  613. }
  614. /**
  615. 五星好评
  616. */
  617. - (void)commentAndStart {
  618. NSString * nsStringToOpen = [NSString stringWithFormat: @"itms-apps://itunes.apple.com/app/id%@?action=write-review",APP_ID];//替换为对应的APPID
  619. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:nsStringToOpen]];
  620. }
  621. #pragma mark -------------------- YHMineFourButtonViewDelegate ---------
  622. - (void)YHMineFourButtonViewDidClickButtonIndex:(NSInteger)index {
  623. switch (index) {
  624. case 0:
  625. [self goToMyOrderPage];
  626. break;
  627. case 1:
  628. [self goToMyTicketPage];
  629. break;
  630. case 2:
  631. [self goToMyshopCarPage];
  632. break;
  633. case 3:
  634. [self goToMyBrowserHistory];
  635. break;
  636. default:
  637. break;
  638. }
  639. }
  640. #pragma mark ------------------------
  641. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
  642. {
  643. //圆角cell
  644. // [cell radioCellWithTableView:tableView atIndexPath:indexPath];
  645. if ([cell respondsToSelector:@selector(separatorInset)]) {
  646. cell.separatorInset = UIEdgeInsetsMake(0, 20, 0, 20);
  647. }
  648. }
  649. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  650. NSArray *arr = self.cellData[section];
  651. return arr.count;
  652. }
  653. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  654. return self.cellData.count;
  655. }
  656. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  657. return 10;
  658. }
  659. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  660. UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellID"];
  661. cell.textLabel.textColor = [UIColor YHColorWithHex:0x646464];
  662. cell.textLabel.font = [UIFont systemFontOfSize:14];
  663. cell.textLabel.text = self.cellData[indexPath.section][indexPath.row][@"title"];
  664. NSString *imgStr = self.cellData[indexPath.section][indexPath.row][@"image"];
  665. cell.imageView.image = [UIImage imageNamed:imgStr];
  666. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  667. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  668. //
  669. // UIButton *sexBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-15-50, 12, 50, 30)];
  670. //
  671. // [sexBtn setImage:[UIImage imageNamed:@"me_girl"] forState:UIControlStateNormal];
  672. // [sexBtn setImage:[UIImage imageNamed:@"me_man"] forState:UIControlStateSelected];
  673. // [cell addSubview:sexBtn];
  674. // NSString *sex = [[NSUserDefaults standardUserDefaults] objectForKey:UserSexKey];
  675. // sexBtn.selected = [sex boolValue];
  676. // [sexBtn addTarget:self action:@selector(changeSexButtonClick:) forControlEvents:UIControlEventTouchUpInside];
  677. //
  678. //
  679. // [cell.contentView mas_updateConstraints:^(MASConstraintMaker *make) {
  680. // make.edges.mas_equalTo(UIEdgeInsetsMake(0, 10, 0, 0));
  681. // }];
  682. return cell;
  683. }
  684. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  685. return 55;
  686. }
  687. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  688. switch (indexPath.section) {
  689. case 0:
  690. {
  691. switch (indexPath.row) {
  692. case 0:
  693. [self goToMyOrderPage];
  694. break;
  695. case 1:
  696. [self goToMyCollectionPage];
  697. break;
  698. case 2:
  699. [self goTogetTicketGuide];
  700. break;
  701. default:
  702. break;
  703. }
  704. }
  705. break;
  706. case 1:
  707. {
  708. switch (indexPath.row) {
  709. case 0:
  710. [self goToFeedbackPage];
  711. break;
  712. case 1:
  713. [self settingAction];
  714. break;
  715. case 2:
  716. [self settingAction];
  717. break;
  718. default:
  719. break;
  720. }
  721. }
  722. break;
  723. default:
  724. break;
  725. }
  726. }
  727. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  728. UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10)];
  729. view.backgroundColor = [UIColor YHColorWithHex:0xF4F4F4];
  730. return view;
  731. }
  732. /**
  733. 改变性别
  734. */
  735. - (void)changeSexButtonClick:(UIButton *)sender {
  736. NSString *newSex = sender.selected?@"0":@"1";
  737. NSDictionary *para = @{@"sex":newSex};
  738. if ([AccountTool isLogin]) {
  739. [SVProgressHUD show];
  740. sender.enabled = NO;
  741. [HSQHttp post:MySetting params:para success:^(id json) {
  742. [SVProgressHUD dismiss];
  743. [self saveSexWithNewSex:newSex];
  744. sender.enabled = YES;
  745. [[NSNotificationCenter defaultCenter] postNotificationName:ChangeSex object:nil];
  746. } failure:^(NSError *error) {
  747. [SVProgressHUD dismiss];
  748. sender.enabled = YES;
  749. }];
  750. }else {
  751. [self saveSexWithNewSex:newSex];
  752. [[NSNotificationCenter defaultCenter] postNotificationName:ChangeSex object:nil];
  753. }
  754. }
  755. - (void)saveSexWithNewSex:(NSString *)newSex {
  756. [[NSUserDefaults standardUserDefaults] setObject:newSex forKey:UserSexKey];
  757. [[NSUserDefaults standardUserDefaults] synchronize];
  758. [self.tableView reloadData];
  759. }
  760. - (void)switchAction {
  761. NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
  762. if([[UIApplication sharedApplication]canOpenURL:url] ) {
  763. if (@available(iOS 10.0, *)) {
  764. [[UIApplication sharedApplication] openURL:url options:@{}completionHandler:^(BOOL success) {
  765. }];
  766. } else {
  767. [[UIApplication sharedApplication]openURL:url];
  768. }
  769. }
  770. }
  771. /**
  772. 我的微信号
  773. */
  774. - (void)gotoWechat {
  775. HSQMyWechatViewController *wechat = [[HSQMyWechatViewController alloc] init];
  776. [self.navigationController pushViewController:wechat animated:YES];
  777. }
  778. #pragma mark ===================== layezer ==============
  779. - (UITableView *)tableView {
  780. if (!_tableView) {
  781. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-TabbarHeight) style:UITableViewStylePlain];
  782. _tableView.estimatedSectionHeaderHeight = 0;
  783. _tableView.estimatedSectionFooterHeight = 0;
  784. _tableView.sectionFooterHeight = 0;
  785. _tableView.sectionHeaderHeight = 0;
  786. _tableView.delegate = self;
  787. _tableView.dataSource = self;
  788. _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  789. _tableView.backgroundColor = [UIColor YHColorWithHex:0xf4f4f4];
  790. _tableView.bounces = YES;
  791. _tableView.showsVerticalScrollIndicator = NO;
  792. // _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  793. _tableView.separatorColor = [UIColor YHColorWithHex:0xEEEEEE];
  794. // MJRefreshGifHeader *header = [MJRefreshGifHeader headerWithRefreshingBlock:^{
  795. // [self loadUserInfo];
  796. // if ([AccountTool isLogin]) {
  797. // [self checkForNewMessage];
  798. // }
  799. // }];
  800. // header.lastUpdatedTimeLabel.hidden = YES;
  801. // header.stateLabel.hidden = YES;
  802. //
  803. // //正在刷新的图片
  804. // NSArray *imgArr = @[[UIImage imageNamed:@"ant1"],[UIImage imageNamed:@"ant2"]];
  805. // [header setImages:imgArr duration:0.3 forState:MJRefreshStateRefreshing];
  806. // [header setImages:@[[UIImage imageNamed:@"ant1"]] duration:1 forState:MJRefreshStateWillRefresh];
  807. // [header setImages:@[[UIImage imageNamed:@"ant1"]] duration:1 forState:MJRefreshStatePulling];
  808. // _tableView.mj_header = header;
  809. }
  810. return _tableView;
  811. }
  812. - (NSArray *)cellData {
  813. if (!_cellData) {//@"order",@"quan",@"history"
  814. _cellData = @[@[@{@"title":@"我的订单",@"image":@"dan"},
  815. @{@"title":@"收藏浏览",@"image":@"xing"},
  816. @{@"title":@"新手指南",@"image":@"nan"}],
  817. @[@{@"title":@"用户反馈",@"image":@"fan"},
  818. @{@"title":@"设置",@"image":@"she"},]];
  819. }
  820. return _cellData;
  821. }
  822. - (NSArray *)sexArr {
  823. if (!_sexArr) {
  824. _sexArr = @[@"女",@"男"];
  825. }
  826. return _sexArr;
  827. }
  828. - (HSQMineUserHintView *)userHintView {
  829. if (!_userHintView) {
  830. __weak typeof(self) weakSelf = self;
  831. _userHintView = [[HSQMineUserHintView alloc] initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH, 0)];
  832. _userHintView.clickBlock = ^(NSInteger index) {
  833. if (index == 0) {
  834. [weakSelf connectToUs];
  835. }else if (index == 1){
  836. [weakSelf switchAction];
  837. }else if(index == 2){
  838. [weakSelf gotoWechat];
  839. }
  840. };
  841. }
  842. return _userHintView;
  843. }
  844. -(UIView *)userLocalNoticeView {
  845. if (!_userLocalNoticeView) {
  846. _userLocalNoticeView = [[UIView alloc] init];
  847. _userLocalNoticeView.layer.masksToBounds = YES;
  848. _userLocalNoticeView.backgroundColor = [UIColor whiteColor];
  849. _userLocalNoticeView.layer.cornerRadius = 6;
  850. UIImageView *leftNoticeImgView = [[UIImageView alloc] init];
  851. [_userLocalNoticeView addSubview:leftNoticeImgView];
  852. [leftNoticeImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  853. make.left.mas_equalTo(_userLocalNoticeView).mas_offset(FITSIZE(10));
  854. make.centerY.mas_equalTo(_userLocalNoticeView);
  855. make.width.mas_equalTo(FITSIZE(17));
  856. make.height.mas_equalTo(FITSIZE(14));
  857. }];
  858. leftNoticeImgView.image = [UIImage imageNamed:@"我的_通知"];
  859. UILabel *titleLabel = [[UILabel alloc] init];
  860. [_userLocalNoticeView addSubview:titleLabel];
  861. [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  862. make.left.mas_equalTo(leftNoticeImgView.mas_right).mas_offset(FITSIZE(6));
  863. make.centerY.mas_equalTo(_userLocalNoticeView);
  864. make.width.mas_greaterThanOrEqualTo(FITSIZE(240));
  865. make.height.mas_equalTo(FITSIZE(17));
  866. }];
  867. titleLabel.text = @"开启消息通知,收益新增、好友新增马上知道";
  868. titleLabel.textColor = [UIColor YHColorWithHex:0xFB452F];
  869. titleLabel.font = [UIFont systemFontOfSize:FITSIZE(12)];
  870. UIButton *startButton = [[UIButton alloc] init];
  871. [_userLocalNoticeView addSubview:startButton];
  872. [startButton mas_makeConstraints:^(MASConstraintMaker *make) {
  873. make.right.mas_equalTo(_userLocalNoticeView).mas_offset(FITSIZE(-5));
  874. make.centerY.mas_equalTo(_userLocalNoticeView);
  875. make.width.mas_equalTo(FITSIZE(40));
  876. make.height.mas_equalTo(FITSIZE(17));
  877. }];
  878. [startButton setImage:[UIImage imageNamed:@"开启"] forState:UIControlStateNormal];
  879. startButton.layer.cornerRadius = FITSIZE(10);
  880. [startButton.layer masksToBounds];
  881. //点击一整行,都跳转到系统设置
  882. UIButton *maskButton = [[UIButton alloc] init];
  883. [_userLocalNoticeView addSubview:maskButton];
  884. [maskButton mas_makeConstraints:^(MASConstraintMaker *make) {
  885. make.edges.mas_equalTo(_userLocalNoticeView);
  886. }];
  887. [maskButton addTarget:self action:@selector(goToAppSystemSetting) forControlEvents:UIControlEventTouchUpInside];
  888. }
  889. return _userLocalNoticeView;
  890. }
  891. - (void)didReceiveMemoryWarning {
  892. [super didReceiveMemoryWarning];
  893. // Dispose of any resources that can be recreated.
  894. }
  895. - (BOOL)isUserNotificationEnable { // 判断用户是否允许接收通知
  896. BOOL isEnable = NO;
  897. if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0f) { // iOS版本 >=8.0 处理逻辑
  898. UIUserNotificationSettings *setting = [[UIApplication sharedApplication] currentUserNotificationSettings];
  899. isEnable = (UIUserNotificationTypeNone == setting.types) ? NO : YES;
  900. } else { // iOS版本 <8.0 处理逻辑
  901. UIRemoteNotificationType type = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
  902. isEnable = (UIRemoteNotificationTypeNone == type) ? NO : YES;
  903. }
  904. return isEnable;
  905. }
  906. // 如果用户关闭了接收通知功能,该方法可以跳转到APP设置页面进行修改 iOS版本 >=8.0 处理逻辑
  907. - (void)goToAppSystemSetting {
  908. UIApplication *application = [UIApplication sharedApplication];
  909. NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
  910. if ([application canOpenURL:url]) {
  911. if ([application respondsToSelector:@selector(openURL:options:completionHandler:)]) {
  912. [application openURL:url options:@{} completionHandler:nil];
  913. } else {
  914. [application openURL:url];
  915. }
  916. }
  917. }
  918. -(NSString *)getCurrentTime {//获取当前时间
  919. NSDate *currentDate = [NSDate date];
  920. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  921. [dateFormatter setDateFormat:@"yyyy-MM-dd"];
  922. NSString *currentDateStr = [dateFormatter stringFromDate:currentDate];
  923. return currentDateStr;
  924. }
  925. -(NSString *)getNextWeekTime {//获取下周时间
  926. NSDate * date = [NSDate date];
  927. NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init];
  928. [dateFormatter setDateFormat:@"yyyy-MM-dd"];
  929. //一周的秒数
  930. NSTimeInterval time = 7 * 24 * 60 * 60;
  931. //下周就把"-"去掉
  932. NSDate *lastWeek = [date dateByAddingTimeInterval:time];
  933. NSString *startDate = [dateFormatter stringFromDate:lastWeek];
  934. return startDate;
  935. }
  936. //一周显示一次,是否显示本地通知提醒
  937. -(BOOL)isShowLocationNotification {
  938. NSString *localNotificationDateString = [[NSUserDefaults standardUserDefaults]objectForKey:@"userNotification"];
  939. if (localNotificationDateString.length <= 0) {//第一次显示本地通知
  940. return YES;
  941. }else {//之前有保存的本地通知显示时间
  942. BOOL isOut = [self compareDate:localNotificationDateString withDate:[self getCurrentTime]];//当前时间和应该显示的时间比较
  943. if (isOut) {
  944. return YES;
  945. }else {
  946. return NO;
  947. }
  948. }
  949. return NO;
  950. }
  951. //比较两个日期大小,后者大于等于前者为YES,小于为NO
  952. -(BOOL)compareDate:(NSString*)startDate withDate:(NSString*)endDate{
  953. BOOL comparisonResult;
  954. NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  955. [formatter setDateFormat:@"yyyy-MM-dd"];
  956. NSDate *date1 = [[NSDate alloc] init];
  957. NSDate *date2 = [[NSDate alloc] init];
  958. date1 = [formatter dateFromString:startDate];
  959. date2 = [formatter dateFromString:endDate];
  960. NSComparisonResult result = [date1 compare:date2];
  961. switch (result)
  962. {
  963. //date02比date01大
  964. case NSOrderedAscending:
  965. comparisonResult = YES;
  966. break;
  967. //date02比date01小
  968. case NSOrderedDescending:
  969. comparisonResult = NO;
  970. break;
  971. //date02=date01
  972. case NSOrderedSame:
  973. comparisonResult = YES;
  974. break;
  975. default:
  976. NSLog(@"erorr dates %@, %@", date1, date2);
  977. break;
  978. }
  979. return comparisonResult;
  980. }
  981. -(void)getNetWorkerWithMessageNew {
  982. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  983. [HSQHttp post:messageNew params:dict success:^(id json) {
  984. NSDictionary *rstDict = (NSDictionary*)json[@"data"];
  985. NSString *newMsg = [NSString stringWithFormat:@"%@",rstDict[@"newMsg"]];//新消息个数
  986. NSInteger newNumber = [newMsg integerValue];
  987. if (newNumber > 9) {
  988. if ([AccountTool isLogin]) {
  989. [self.messageBtn ba_addBadgeWithText:@"9+"];
  990. [self.messageBtn ba_showBadge];
  991. }
  992. }else {
  993. [self.messageBtn ba_addBadgeWithNumber:newNumber];
  994. }
  995. } failure:^(NSError *error) {
  996. }];
  997. }
  998. /*
  999. #pragma mark - Navigation
  1000. // In a storyboard-based application, you will often want to do a little preparation before navigation
  1001. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  1002. // Get the new view controller using [segue destinationViewController].
  1003. // Pass the selected object to the new view controller.
  1004. }
  1005. */
  1006. @end