12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232 |
- //
- // HSQMineMainViewController.m
- // YouHuiProject
- //
- // Created by xiaoxi on 2018/1/16.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "HSQMineMainViewController.h"
- #import "HFStretchableTableHeaderView.h"
- #import "HSQLoginViewController.h"
- #import "HSQCollectionViewController.h"
- #import "HSQSettingViewController.h"
- #import "HSQMyTicketViewController.h"
- #import "HSQMyOrderViewController.h"
- #import <AlibcTradeSDK/AlibcTradeSDK.h>
- #import "HSQBrowserHistoryController.h"
- #import "HSQAdWebViewController.h"
- #import "HSQFeedbackController.h"
- #import <StoreKit/StoreKit.h>
- #import "HSQFindBookWebViewController.h"
- #import "UITableViewCell+Cc_CornRadio.h"
- #import "HSQShopCarViewController.h"
- #import "CCActionSheet.h"
- #import "HSQMineBlanceView.h"
- #import "HSQMineOrderView.h"
- #import "HSQMoreMenuView.h"
- #import "HSQCommissionMainViewController.h"
- #import "HSQMyFansViewController.h"
- #import "HSQMyCollectionViewController.h"
- #import "HSQInviteFansViewController.h"
- #import "HSQMessageListController.h"
- #import "HSQUserInfo.h"
- #import "HSQUserInfoView.h"
- #import "HSQCollectionMainViewController.h"
- #import "HSQLinkFansController.h"
- #import "HSQPrivilegeReferralViewController.h"
- #import "HSQUserInfo.h"
- #import "HSQUserInfoManager.h"
- #import "HSQMonthMainViewController.h"
- #import "HSQMineAdView.h"
- #import "HSQChildAccountViewController.h"
- #import "AdPopModel.h"
- #import "AdJumpManager.h"
- #import "UIView+BABadgeView.h"
- #import "HSQBuyLimitMainController.h"
- #import "HSQAchievementView.h"
- #import "HSQAchievementViewController.h"
- #import "HSQIncomeViewController.h"
- #import "HSQMyWechatViewController.h"
- #import "HSQWebDetailController.h"
- #import "HSQClassifyListController.h"
- #import "PhoneLoginManager.h"
- #import "HSQLinkFansController.h"
- #import "HSQMinePersonInforVC.h"
- #import "HSQPushToWeixViewController.h"
- #import "HSQMineUserHintView.h"
- #import "HSQLinkFansController.h"
- #import "FSBaseViewController.h"
- #import "HSQMyWechatViewController.h"
- #import "HSQChildAccountViewController.h"
- #import "HSQPushToWeixViewController.h"
- #import <AssetsLibrary/AssetsLibrary.h>
- #import <Photos/Photos.h>
- #import <AlibcTradeSDK/AlibcTradeSDK.h>
- #import <AlibabaAuthSDK/ALBBSession.h>
- #import <AlibabaAuthSDK/ALBBSDK.h>
- @interface HSQMineMainViewController ()
- <
- UITableViewDelegate,
- UITableViewDataSource,
- CCActionSheetDelegate,
- YHMoreMenuViewDelegate
- >
- {
- UIButton *_newFansBtn;
- }
- @property (nonatomic, strong) UITableView *tableView;
- @property (nonatomic, strong) UIView *header;
- @property (nonatomic, strong) UIImageView *headerImg;
- @property (nonatomic, strong) HSQUserInfoView *userInfoView;
- @property (nonatomic, strong) HSQMineBlanceView *blanceView;
- //@property (nonatomic, strong) HSQMineOrderView *mineOrderView;
- @property (nonatomic, strong) HSQMoreMenuView *topMenuView;
- @property (nonatomic, strong) HSQMoreMenuView *bottomMenuView;
- @property (nonatomic, strong) HSQMineAdView *adView;
- @property (nonatomic, strong) HSQAchievementView *achievementView ;
- @property (nonatomic, strong) UIButton *messageBtn;
- @property (nonatomic, strong) HSQUserInfo *userInfo;
- @property (nonatomic, strong) UIView *userLocalNoticeView;//是否开启了通知
- @property (nonatomic, strong) HSQMineUserHintView *userHintView;
- /*dataSource**/
- @property (nonatomic, strong) NSArray *cellData;
- @property (nonatomic, strong) NSArray *sexArr;
- @end
- @implementation HSQMineMainViewController
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
- }
- - (void)viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
-
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
- [SVProgressHUD dismiss];
- [self loadUserInfo];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self configNavightion];
- [self configTableView];
- [self loadAdData];
- }
- - (void)configNavightion {
- self.navigationBar.backgroundColor = [UIColor clearColor];
- self.navigationBar.hidden = YES;
-
- }
- - (void)configTableView {
- [self.view addSubview:self.tableView];
- __weak typeof(self) weakSelf = self;
- //头部背景图
- self.headerImg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 170)];
- self.headerImg.userInteractionEnabled = YES;
- self.headerImg.image = [UIImage imageNamed:@"mine_bg"];
- self.headerImg.contentMode = UIViewContentModeScaleAspectFill;
- self.headerImg.layer.masksToBounds = YES;
-
- //头视图
- self.header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 170)];
- [self.header addSubview:self.headerImg];
-
- //广告view
- // self.adView = [[HSQMineAdView alloc] initWithFrame:CGRectMake(10, self.topMenuView.bottom+5, SCREEN_WIDTH-20, 0)];
- // self.adView.tapAdBlock = ^(AdPopModel *model) {
- // [AdJumpManager jumpToPageWithModel:model ParentViewControll:weakSelf];
- // };
- // [self.header addSubview:self.adView];
- // [self.adView mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.left.mas_equalTo(10);
- // make.right.mas_equalTo(-10);
- // make.top.mas_equalTo(self.topMenuView.mas_bottom).mas_offset(5);
- // make.height.mas_equalTo(0);
- // }];
- self.tableView.tableHeaderView = self.header;
- //用户信息
- self.userInfoView = [[HSQUserInfoView alloc] initWithFrame:CGRectMake(0, KStatusBarHeight +(self.header.height-KStatusBarHeight-60)/2, SCREEN_WIDTH, 60)];
- self.userInfoView.loginClick = ^{
- [weakSelf goToLoginPage];
- };
- self.userInfoView.settingClick = ^{
- if ([AccountTool isLogin]) {
- [weakSelf settingAction];
- }else {
- [weakSelf goToLoginPage];
- }
-
- };
- [self.tableView addSubview:self.userInfoView];
-
- //消息按钮
- // UIButton *setButton = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-9-30, NavBarHeight-30-8, 30, 30)];
- // [setButton setImage:[UIImage imageNamed:@"message_icon"] forState:UIControlStateNormal];
- // [setButton addTarget:self action:@selector(gotoMyMessagesPage) forControlEvents:UIControlEventTouchUpInside];
- // self.messageBtn = setButton;
- // [self.messageBtn ba_setBadgeLabelAttributes:^(BABadgeLabel *badgeLabel) {
- // UILabel *label = (UILabel *)badgeLabel;
- // label.textColor = [UIColor homeRedColor];
- // label.backgroundColor = [UIColor whiteColor];
- // label.height = label.width;
- // label.font = [UIFont systemFontOfSize:8];
- // }];
- // [self.messageBtn ba_moveBadgeWithX:-5 Y:6];
- // [self.messageBtn ba_hiddenBadge];
- // [self.tableView addSubview:setButton];
-
- //设置按钮setting
- UIButton *setting = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-9-30,NavBarHeight-30-8, 30, 30)];
- [setting setImage:[UIImage imageNamed:@"setting"] forState:UIControlStateNormal];
- [setting addTarget:self action:@selector(settingAction) forControlEvents:UIControlEventTouchUpInside];
- [self.tableView addSubview:setting];
-
-
- if (@available(iOS 11.0, *)) {
- self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;//UIScrollView也适用
- }else {
- self.automaticallyAdjustsScrollViewInsets = NO;
- }
- }
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView
- {
- CGFloat yOffset = scrollView.contentOffset.y;
- if(yOffset < 0)
- {
- self.headerImg.y = yOffset;
- self.headerImg.height = 170+ABS(yOffset);
- }
- }
- /**
- 加载用户信息
- */
- - (void)loadUserInfo {
-
- if (![AccountTool isLogin]) {
- [self noLoginView];
- [self.tableView.mj_header endRefreshing];
- return;
- }
-
- [HSQCacheHttp post:UserInfo params:nil success:^(id json, BOOL isCache) {
- //讲将数据保存到本地单例
- [HSQUserInfoManager shareManager].userInfoDic =json;
-
- self.userInfo = [HSQUserInfo yy_modelWithJSON:json];
-
- // [self.blanceView setBlancePrice:self.userInfo.all_settlement_income];//设置余额,我的收益
- // self.blanceView.todayMoney = self.userInfo.this_day_forecast_income;//我的收益
- [self.userInfoView setUserInfo:self.userInfo];//设置用户信息
- // [self setNewFansButtonCount]; //设置新增好友数
- // [self setUserHintView];
- // [self.tableView.mj_header endRefreshing];
- } failure:^(NSError *error) {
- if (![AccountTool isLogin]) {
- [self noLoginView];
- }
- }];
-
- }
- //是否显示通知栏
- - (void)setUserHintView {
-
- if ([AccountTool isLogin] && [self.userInfo.user_level isEqualToString:@"1"]) {
- //通知栏
- [self.userHintView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(41);
- }];
- [self.userHintView showUpdate];
- }
- if ([AccountTool isLogin] && [self.userInfo.user_level isEqualToString:@"3"] && ![self.userInfo.ishasWechat boolValue]) {
- [self.userHintView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(41);
- }];
- [self.userHintView showWechat];
- }
- }
- /**
- 去我的余额界面
- */
- - (void)gotoMyBlancePage {
- HSQChildAccountViewController *accountDetail = [[HSQChildAccountViewController alloc] init];//提现
- [self.navigationController pushViewController:accountDetail animated:YES];
- }
- - (void)setNewFansButtonCount {
- NSString *newFans;
- if ([self.userInfo.register_friends integerValue] > 99) {
- newFans = @"99+";
- }else {
- newFans = self.userInfo.register_friends;
- }
- [_newFansBtn ba_addBadgeWithText:newFans];
-
-
- CGFloat offX = 30;
- CGFloat offY = 20;
- [_newFansBtn ba_moveBadgeWithX:-offX Y:offY];
- if ([self.userInfo.register_friends integerValue] > 99) {
- [_newFansBtn ba_showBadge];
- }else {
- [_newFansBtn ba_hiddenBadge];
- }
- }
- - (void)noLoginView {
- [self.userInfoView setNologInView];
- [self.blanceView setBlancePrice:@"-.--"];
- self.blanceView.todayMoney = @"";
- [self.messageBtn ba_hiddenBadge];
- }
- /**
- 加载广告位数据
- */
- - (void)loadAdData {
-
- NSString *url = [NSString stringWithFormat:@"%@/api/v2/adv/advByType",BaseURL];
- NSDictionary *para = @{@"adv_type":@"4"};
- [HSQHttp get:url params:para success:^(id json) {
-
- NSArray *list = [NSArray yy_modelArrayWithClass:[AdPopModel class] json:json[@"data"]];
- if (list.count > 0) {
- [self showAdViewWithAdModel:list.firstObject];
- }
- } failure:^(NSError *error) {
-
- }];
-
- }
- - (void)showAdViewWithAdModel:(AdPopModel *)model {
- [self showAdView];
- self.adView.model = model;
- }
- - (void)showAdView {
- [UIView animateWithDuration:0.3 animations:^{
- [self.adView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo((SCREEN_WIDTH-20)*74/355);
- }];
- [self.view layoutIfNeeded];
- }];
-
-
- self.header.height = CGRectGetMaxY(self.bottomMenuView.frame)+50;
- self.tableView.tableHeaderView = self.header;
- }
- - (void)hiddenAdView {
- [UIView animateWithDuration:0.5 animations:^{
- self.adView.height = 0;
- self.bottomMenuView.y = self.adView.bottom;
- self.header.height = CGRectGetMaxY(self.bottomMenuView.frame)+5;
- self.tableView.tableHeaderView = self.header;
- }];
- }
- /**
- 特权信息
- */
- - (void)showUserType {
- [MobClick event:MineVipClick];
- if (![AccountTool isLogin]) {
- [self goToLoginPage];
- return;
- }
- HSQPrivilegeReferralViewController *Privilege = [[HSQPrivilegeReferralViewController alloc] init];
- [self.navigationController pushViewController:Privilege animated:YES];
- }
- #pragma mark ------------
- - (void)settingAction {
-
- HSQSettingViewController *setting = [[HSQSettingViewController alloc] init];
- setting.alipayFlag = self.userInfo.flag;
- setting.inviteCode = self.userInfo.invite_code;
- [self.navigationController pushViewController:setting animated:YES];
- }
- #pragma mark-个人信息
- -(void)Personinformation
- {
- HSQMinePersonInforVC *setting = [[HSQMinePersonInforVC alloc] init];
- setting.userModel = self.userInfo;
- // setting.alipayFlag = self.userInfo.flag;
- // setting.inviteCode = self.userInfo.invite_code;
- [self.navigationController pushViewController:setting animated:YES];
- }
- - (void)fansPageShowIndex:(NSInteger)showIndex {
- if (![AccountTool isLogin]) {
- [self goToLoginPage];
- return;
- }
- HSQMyFansViewController *myFasn = [[HSQMyFansViewController alloc] init];
- myFasn.showIndex = showIndex;
- [self.navigationController pushViewController:myFasn animated:YES];
- }
- #pragma mark ---- YHMoreMenuViewDelegate
- - (void)morenMenu:(HSQMoreMenuView *)menuView Button:(UIButton *)button clickIndex:(NSInteger)index {
-
- if (menuView == self.topMenuView) {
- switch (index) {
- case 0:
- [self gotoMyIncomePage]; //我的收益
-
- break;
- case 1:
- [self goToMyOrderPage]; //我的订单
- break;
- case 2:
- [self goToMyFansPage]; //我的好友
- break;
- case 3:
- [self goToInviteFansPage]; //邀请好友
- break;
- default:
- break;
- }
- }else if (menuView == self.bottomMenuView){
-
- if ([[PhoneLoginManager shareManager].showPhoneBtn boolValue]) {
-
- //过shen专用
- [self tapMenuWithIndex:index];
-
- }else {
- switch (index) {
- case 0:
- [self goToMyCollectionPage]; //收藏、浏览
- break;
- case 1:
-
- [self goTogetTicketGuide]; //赚钱秘籍
- break;
- case 2:
- [self connectToUs]; //联系我们 改成 专属客服
- break;
- case 3:
- [self showUserType]; //特权介绍
- break;
- case 4:
- [self becomeAgency]; //成为代理
- break;
- case 5:
- [self goToFeedbackPage]; //用户反馈
- break;
- case 6:
- [self gotoProblemPage];//常见问题
- break;
- case 7:
- [self settingAction]; //设置
- break;
- default:
- break;
- }
- }
-
-
- }
-
-
- }
- /**
- 过审点击
- */
- - (void)tapMenuWithIndex:(NSInteger)index {
- switch (index) {
- case 0:
- [self goToMyCollectionPage]; //收藏、浏览
- break;
- case 1:
-
- [self goTogetTicketGuide]; //赚钱秘籍
- break;
- case 2:
- [self connectToUs]; //联系我们 改成 专属客服
- break;
- case 3:
- [self goToFeedbackPage]; //用户反馈
- break;
- case 4:
- [self gotoProblemPage];//常见问题
- break;
- case 5:
- [self settingAction]; //设置
- break;
- default:
- break;
- }
- }
- #pragma mark ---------------- private ---------
- /**
- 常见问题
- */
- - (void)gotoProblemPage {
-
- HSQWebDetailController *findbook = [[HSQWebDetailController alloc] init];
- findbook.pageType = 2;
- [self.navigationController pushViewController:findbook animated:YES];
- }
- /**
- 用户登录
- */
- - (void)goToLoginPage {
- HSQLoginViewController *login = [[HSQLoginViewController alloc] init];
- [self presentViewController:login animated:YES completion:nil];
- }
- /**
- 我的粉丝
- */
- - (void)goToMyFansPage {
- if (![AccountTool isLogin]) {
- [self goToLoginPage];
- return;
- }
- HSQMyFansViewController *myFans = [[HSQMyFansViewController alloc] init];
- [self.navigationController pushViewController:myFans animated:YES];
- }
- /**
- 我的订单
- */
- - (void)goToMyOrderPage {
-
- [self openMyOrderWebView];
- }
- - (void)openMyOrderWebView {
-
- if ([[ALBBSession sharedInstance] isLogin]){
- HSQWebPageViewController *order = [[HSQWebPageViewController alloc] init];
- order.openPage = AlibcOpenPageMyOrder;
- [self.navigationController pushViewController:order animated:YES];
- }else {
- //淘宝授权
- ALBBSDK *albbSDK = [ALBBSDK sharedInstance];
- [albbSDK setAppkey:ALBC_APP_KEY];
- [albbSDK setAuthOption:NormalAuth];
-
- [albbSDK auth:self successCallback:^(ALBBSession *session){
- HSQWebPageViewController *order = [[HSQWebPageViewController alloc] init];
- order.openPage = AlibcOpenPageMyOrder;
- [self.navigationController pushViewController:order animated:YES];
-
- } failureCallback:^(ALBBSession *session,NSError *error){
- }];
- }
-
-
- }
- /**
- 我的收益
- */
- - (void)gotoMyIncomePage {
- if (![AccountTool isLogin]) {
- [self goToLoginPage];
- return;
- }
- HSQAchievementViewController *detail = [[HSQAchievementViewController alloc] init];
- [self.navigationController pushViewController:detail animated:YES];
- }
- /**
- 购物车
- */
- - (void)goToMyshopCarPage {
- HSQShopCarViewController *shopCar = [[HSQShopCarViewController alloc] init];
- [self.navigationController pushViewController:shopCar animated:YES];
- }
- /**
- 我的收藏/浏览
- */
- - (void)goToMyCollectionPage {
- if (![AccountTool isLogin]) {
- [self goToLoginPage];
- return;
- }
- HSQCollectionMainViewController *collection = [[HSQCollectionMainViewController alloc] init];
- [self.navigationController pushViewController:collection animated:YES];
- }
- /**
- 我的消息
- */
- - (void)gotoMyMessagesPage {
- if (![AccountTool isLogin]) {
- [self goToLoginPage];
- return;
- }
-
- HSQMessageListController *messages = [[HSQMessageListController alloc] init];
- [self.navigationController pushViewController:messages animated:YES];
- }
- /**
- 绑定邀请码
- */
- - (void)blindInviteCode {
-
-
- if (![AccountTool isLogin]) {
- [self goToLoginPage];
- return;
- }
-
- if ([self.userInfo.is_have_parent boolValue]) {
-
- NSString *msg = [NSString stringWithFormat:@"您已绑定过邀请码%@",self.userInfo.parent_code];
- [MBProgressHUD showMessage:msg];
- return;
- }
-
- HSQLinkFansController *linkFans = [[HSQLinkFansController alloc] init];
- [self.navigationController pushViewController:linkFans animated:YES];
- }
- /**
- 已领优惠券
- */
- - (void)goToMyTicketPage {
- if (![AccountTool isLogin]) {
- [self goToLoginPage];
- return;
- }
- HSQMyTicketViewController *ticket = [[HSQMyTicketViewController alloc] init];
- [self.navigationController pushViewController:ticket animated:YES];
- }
- /**
- 浏览历史
- */
- - (void)goToMyBrowserHistory {
- HSQBrowserHistoryController *history = [[HSQBrowserHistoryController alloc] init];
- [self.navigationController pushViewController:history animated:YES];
- }
- /**
- 邀请好友
- */
- - (void)goToInviteFansPage {
- if (![AccountTool isLogin]) {
- [self goToLoginPage];
- return;
- }
- HSQInviteFansViewController *invite = [[HSQInviteFansViewController alloc] init];
- [self.navigationController pushViewController:invite animated:YES];
- }
- /**
- 新手指南
- */
- - (void)goTogetTicketGuide {
- HSQWebDetailController *findbook = [[HSQWebDetailController alloc] init];
- findbook.pageType = 0;
- [self.navigationController pushViewController:findbook animated:YES];
- }
- /**
- 成为代理
- */
- - (void)becomeAgency {
- if (![AccountTool isLogin]) {
- [self goToLoginPage];
- return;
- }
- NSDictionary *dict = [HSQUserInfoManager shareManager].userInfoDic;
- HSQUserInfo *userInfo = [HSQUserInfo yy_modelWithJSON:dict];
- if (![userInfo.user_level isEqualToString:@"3"]) {
- [MBProgressHUD showMessage:@"您还不是运营商"];
- return;
- }
-
- NSString *url = self.userInfo.operator_system;
- HSQAdWebViewController *web = [[HSQAdWebViewController alloc] init];
- web.url = url;
- [self.navigationController pushViewController:web animated:YES];
- }
- /**
- 意见反馈
- */
- - (void)goToFeedbackPage {
- HSQFeedbackController *feedback = [[HSQFeedbackController alloc] init];
- feedback.userInfo = self.userInfo;
- [self.navigationController pushViewController:feedback animated:YES];
- }
- /**
- 赚钱秘籍
- */
- - (void)goToGetMoneyPage {
- HSQFindBookWebViewController *findbook = [[HSQFindBookWebViewController alloc] init];
- findbook.pageType = 1;
- [self.navigationController pushViewController:findbook animated:YES];
- [MobClick event:MineGetMoneyUrl];
- }
- /**
- //联系我们 改成 专属客服
- */
- - (void)connectToUs {
- // if (![AccountTool isLogin]) {
- // [self goToLoginPage];
- // return;
- // }
-
- HSQPushToWeixViewController *weixin = [[HSQPushToWeixViewController alloc] init];
- weixin.userInfo = self.userInfo;
- [self.navigationController pushViewController:weixin animated:YES];
-
- // HSQWebDetailController *web = [[HSQWebDetailController alloc] init];
- // web.url = self.userInfo.contact_us;
- // [self.navigationController pushViewController:web animated:YES];
- }
- /**
- 五星好评
- */
- - (void)commentAndStart {
-
- NSString * nsStringToOpen = [NSString stringWithFormat: @"itms-apps://itunes.apple.com/app/id%@?action=write-review",APP_ID];//替换为对应的APPID
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:nsStringToOpen]];
- }
- #pragma mark -------------------- YHMineFourButtonViewDelegate ---------
- - (void)YHMineFourButtonViewDidClickButtonIndex:(NSInteger)index {
- switch (index) {
- case 0:
- [self goToMyOrderPage];
- break;
- case 1:
- [self goToMyTicketPage];
- break;
- case 2:
- [self goToMyshopCarPage];
- break;
- case 3:
- [self goToMyBrowserHistory];
- break;
-
- default:
- break;
- }
- }
- #pragma mark ------------------------
- - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
- {
- //圆角cell
- // [cell radioCellWithTableView:tableView atIndexPath:indexPath];
- if ([cell respondsToSelector:@selector(separatorInset)]) {
- cell.separatorInset = UIEdgeInsetsMake(0, 20, 0, 20);
- }
-
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- NSArray *arr = self.cellData[section];
- return arr.count;
- }
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return self.cellData.count;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
- return 10;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellID"];
- cell.textLabel.textColor = [UIColor YHColorWithHex:0x646464];
- cell.textLabel.font = [UIFont systemFontOfSize:14];
- cell.textLabel.text = self.cellData[indexPath.section][indexPath.row][@"title"];
- NSString *imgStr = self.cellData[indexPath.section][indexPath.row][@"image"];
- cell.imageView.image = [UIImage imageNamed:imgStr];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
- //
- // UIButton *sexBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-15-50, 12, 50, 30)];
- //
- // [sexBtn setImage:[UIImage imageNamed:@"me_girl"] forState:UIControlStateNormal];
- // [sexBtn setImage:[UIImage imageNamed:@"me_man"] forState:UIControlStateSelected];
- // [cell addSubview:sexBtn];
- // NSString *sex = [[NSUserDefaults standardUserDefaults] objectForKey:UserSexKey];
- // sexBtn.selected = [sex boolValue];
- // [sexBtn addTarget:self action:@selector(changeSexButtonClick:) forControlEvents:UIControlEventTouchUpInside];
- //
- //
- // [cell.contentView mas_updateConstraints:^(MASConstraintMaker *make) {
- // make.edges.mas_equalTo(UIEdgeInsetsMake(0, 10, 0, 0));
- // }];
-
- return cell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- return 55;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- switch (indexPath.section) {
- case 0:
- {
- switch (indexPath.row) {
- case 0:
- [self goToMyOrderPage];
- break;
- case 1:
- [self goToMyCollectionPage];
- break;
- case 2:
- [self goTogetTicketGuide];
- break;
- default:
- break;
- }
- }
-
- break;
- case 1:
- {
- switch (indexPath.row) {
- case 0:
- [self goToFeedbackPage];
- break;
- case 1:
- [self settingAction];
- break;
- case 2:
- [self settingAction];
- break;
-
- default:
- break;
- }
- }
-
- break;
- default:
- break;
- }
-
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
- UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10)];
- view.backgroundColor = [UIColor YHColorWithHex:0xF4F4F4];
- return view;
- }
- /**
- 改变性别
- */
- - (void)changeSexButtonClick:(UIButton *)sender {
- NSString *newSex = sender.selected?@"0":@"1";
- NSDictionary *para = @{@"sex":newSex};
- if ([AccountTool isLogin]) {
-
- [SVProgressHUD show];
- sender.enabled = NO;
- [HSQHttp post:MySetting params:para success:^(id json) {
- [SVProgressHUD dismiss];
- [self saveSexWithNewSex:newSex];
- sender.enabled = YES;
- [[NSNotificationCenter defaultCenter] postNotificationName:ChangeSex object:nil];
- } failure:^(NSError *error) {
- [SVProgressHUD dismiss];
- sender.enabled = YES;
- }];
-
- }else {
- [self saveSexWithNewSex:newSex];
- [[NSNotificationCenter defaultCenter] postNotificationName:ChangeSex object:nil];
- }
- }
- - (void)saveSexWithNewSex:(NSString *)newSex {
-
- [[NSUserDefaults standardUserDefaults] setObject:newSex forKey:UserSexKey];
- [[NSUserDefaults standardUserDefaults] synchronize];
- [self.tableView reloadData];
- }
- - (void)switchAction {
-
- NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
- if([[UIApplication sharedApplication]canOpenURL:url] ) {
- if (@available(iOS 10.0, *)) {
- [[UIApplication sharedApplication] openURL:url options:@{}completionHandler:^(BOOL success) {
- }];
- } else {
- [[UIApplication sharedApplication]openURL:url];
- }
- }
-
- }
- /**
- 我的微信号
- */
- - (void)gotoWechat {
- HSQMyWechatViewController *wechat = [[HSQMyWechatViewController alloc] init];
- [self.navigationController pushViewController:wechat animated:YES];
- }
- #pragma mark ===================== layezer ==============
- - (UITableView *)tableView {
- if (!_tableView) {
- _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-TabbarHeight) style:UITableViewStylePlain];
- _tableView.estimatedSectionHeaderHeight = 0;
- _tableView.estimatedSectionFooterHeight = 0;
- _tableView.sectionFooterHeight = 0;
- _tableView.sectionHeaderHeight = 0;
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
- _tableView.backgroundColor = [UIColor YHColorWithHex:0xf4f4f4];
- _tableView.bounces = YES;
- _tableView.showsVerticalScrollIndicator = NO;
- // _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _tableView.separatorColor = [UIColor YHColorWithHex:0xEEEEEE];
- // MJRefreshGifHeader *header = [MJRefreshGifHeader headerWithRefreshingBlock:^{
- // [self loadUserInfo];
- // if ([AccountTool isLogin]) {
- // [self checkForNewMessage];
- // }
- // }];
- // header.lastUpdatedTimeLabel.hidden = YES;
- // header.stateLabel.hidden = YES;
- //
- // //正在刷新的图片
- // NSArray *imgArr = @[[UIImage imageNamed:@"ant1"],[UIImage imageNamed:@"ant2"]];
- // [header setImages:imgArr duration:0.3 forState:MJRefreshStateRefreshing];
- // [header setImages:@[[UIImage imageNamed:@"ant1"]] duration:1 forState:MJRefreshStateWillRefresh];
- // [header setImages:@[[UIImage imageNamed:@"ant1"]] duration:1 forState:MJRefreshStatePulling];
- // _tableView.mj_header = header;
- }
- return _tableView;
- }
- - (NSArray *)cellData {
- if (!_cellData) {//@"order",@"quan",@"history"
- _cellData = @[@[@{@"title":@"我的订单",@"image":@"dan"},
- @{@"title":@"收藏浏览",@"image":@"xing"},
- @{@"title":@"新手指南",@"image":@"nan"}],
- @[@{@"title":@"用户反馈",@"image":@"fan"},
- @{@"title":@"设置",@"image":@"she"},]];
-
- }
- return _cellData;
- }
- - (NSArray *)sexArr {
- if (!_sexArr) {
- _sexArr = @[@"女",@"男"];
- }
- return _sexArr;
- }
- - (HSQMineUserHintView *)userHintView {
- if (!_userHintView) {
- __weak typeof(self) weakSelf = self;
- _userHintView = [[HSQMineUserHintView alloc] initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH, 0)];
- _userHintView.clickBlock = ^(NSInteger index) {
- if (index == 0) {
- [weakSelf connectToUs];
- }else if (index == 1){
- [weakSelf switchAction];
- }else if(index == 2){
- [weakSelf gotoWechat];
- }
- };
- }
- return _userHintView;
- }
- -(UIView *)userLocalNoticeView {
-
- if (!_userLocalNoticeView) {
-
- _userLocalNoticeView = [[UIView alloc] init];
- _userLocalNoticeView.layer.masksToBounds = YES;
- _userLocalNoticeView.backgroundColor = [UIColor whiteColor];
- _userLocalNoticeView.layer.cornerRadius = 6;
- UIImageView *leftNoticeImgView = [[UIImageView alloc] init];
- [_userLocalNoticeView addSubview:leftNoticeImgView];
- [leftNoticeImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(_userLocalNoticeView).mas_offset(FITSIZE(10));
- make.centerY.mas_equalTo(_userLocalNoticeView);
- make.width.mas_equalTo(FITSIZE(17));
- make.height.mas_equalTo(FITSIZE(14));
- }];
- leftNoticeImgView.image = [UIImage imageNamed:@"我的_通知"];
-
- UILabel *titleLabel = [[UILabel alloc] init];
- [_userLocalNoticeView addSubview:titleLabel];
- [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(leftNoticeImgView.mas_right).mas_offset(FITSIZE(6));
- make.centerY.mas_equalTo(_userLocalNoticeView);
- make.width.mas_greaterThanOrEqualTo(FITSIZE(240));
- make.height.mas_equalTo(FITSIZE(17));
- }];
- titleLabel.text = @"开启消息通知,收益新增、好友新增马上知道";
- titleLabel.textColor = [UIColor YHColorWithHex:0xFB452F];
- titleLabel.font = [UIFont systemFontOfSize:FITSIZE(12)];
-
- UIButton *startButton = [[UIButton alloc] init];
- [_userLocalNoticeView addSubview:startButton];
- [startButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(_userLocalNoticeView).mas_offset(FITSIZE(-5));
- make.centerY.mas_equalTo(_userLocalNoticeView);
- make.width.mas_equalTo(FITSIZE(40));
- make.height.mas_equalTo(FITSIZE(17));
- }];
- [startButton setImage:[UIImage imageNamed:@"开启"] forState:UIControlStateNormal];
- startButton.layer.cornerRadius = FITSIZE(10);
- [startButton.layer masksToBounds];
-
- //点击一整行,都跳转到系统设置
- UIButton *maskButton = [[UIButton alloc] init];
- [_userLocalNoticeView addSubview:maskButton];
- [maskButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.mas_equalTo(_userLocalNoticeView);
- }];
- [maskButton addTarget:self action:@selector(goToAppSystemSetting) forControlEvents:UIControlEventTouchUpInside];
-
- }
- return _userLocalNoticeView;
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (BOOL)isUserNotificationEnable { // 判断用户是否允许接收通知
- BOOL isEnable = NO;
- if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0f) { // iOS版本 >=8.0 处理逻辑
- UIUserNotificationSettings *setting = [[UIApplication sharedApplication] currentUserNotificationSettings];
- isEnable = (UIUserNotificationTypeNone == setting.types) ? NO : YES;
- } else { // iOS版本 <8.0 处理逻辑
- UIRemoteNotificationType type = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
- isEnable = (UIRemoteNotificationTypeNone == type) ? NO : YES;
- }
- return isEnable;
- }
- // 如果用户关闭了接收通知功能,该方法可以跳转到APP设置页面进行修改 iOS版本 >=8.0 处理逻辑
- - (void)goToAppSystemSetting {
- UIApplication *application = [UIApplication sharedApplication];
- NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
- if ([application canOpenURL:url]) {
- if ([application respondsToSelector:@selector(openURL:options:completionHandler:)]) {
- [application openURL:url options:@{} completionHandler:nil];
- } else {
- [application openURL:url];
- }
- }
- }
- -(NSString *)getCurrentTime {//获取当前时间
-
- NSDate *currentDate = [NSDate date];
- NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
- [dateFormatter setDateFormat:@"yyyy-MM-dd"];
- NSString *currentDateStr = [dateFormatter stringFromDate:currentDate];
-
- return currentDateStr;
- }
- -(NSString *)getNextWeekTime {//获取下周时间
-
- NSDate * date = [NSDate date];
- NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init];
- [dateFormatter setDateFormat:@"yyyy-MM-dd"];
- //一周的秒数
- NSTimeInterval time = 7 * 24 * 60 * 60;
- //下周就把"-"去掉
- NSDate *lastWeek = [date dateByAddingTimeInterval:time];
- NSString *startDate = [dateFormatter stringFromDate:lastWeek];
-
- return startDate;
- }
- //一周显示一次,是否显示本地通知提醒
- -(BOOL)isShowLocationNotification {
-
- NSString *localNotificationDateString = [[NSUserDefaults standardUserDefaults]objectForKey:@"userNotification"];
-
- if (localNotificationDateString.length <= 0) {//第一次显示本地通知
- return YES;
- }else {//之前有保存的本地通知显示时间
- BOOL isOut = [self compareDate:localNotificationDateString withDate:[self getCurrentTime]];//当前时间和应该显示的时间比较
- if (isOut) {
- return YES;
- }else {
- return NO;
- }
- }
-
- return NO;
- }
- //比较两个日期大小,后者大于等于前者为YES,小于为NO
- -(BOOL)compareDate:(NSString*)startDate withDate:(NSString*)endDate{
-
- BOOL comparisonResult;
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- [formatter setDateFormat:@"yyyy-MM-dd"];
- NSDate *date1 = [[NSDate alloc] init];
- NSDate *date2 = [[NSDate alloc] init];
- date1 = [formatter dateFromString:startDate];
- date2 = [formatter dateFromString:endDate];
- NSComparisonResult result = [date1 compare:date2];
- switch (result)
- {
- //date02比date01大
- case NSOrderedAscending:
- comparisonResult = YES;
- break;
- //date02比date01小
- case NSOrderedDescending:
- comparisonResult = NO;
- break;
- //date02=date01
- case NSOrderedSame:
- comparisonResult = YES;
- break;
- default:
- NSLog(@"erorr dates %@, %@", date1, date2);
- break;
- }
- return comparisonResult;
- }
- -(void)getNetWorkerWithMessageNew {
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
-
- [HSQHttp post:messageNew params:dict success:^(id json) {
-
- NSDictionary *rstDict = (NSDictionary*)json[@"data"];
-
-
- NSString *newMsg = [NSString stringWithFormat:@"%@",rstDict[@"newMsg"]];//新消息个数
-
-
-
- NSInteger newNumber = [newMsg integerValue];
-
- if (newNumber > 9) {
- if ([AccountTool isLogin]) {
- [self.messageBtn ba_addBadgeWithText:@"9+"];
- [self.messageBtn ba_showBadge];
- }
-
- }else {
- [self.messageBtn ba_addBadgeWithNumber:newNumber];
- }
-
- } failure:^(NSError *error) {
-
-
- }];
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|