123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489 |
- //
- // DataViewController.m
- // ZBProject
- //
- // Created by 学丽 on 2019/3/26.
- // Copyright © 2019 ZB. All rights reserved.
- //
- #import "DataViewController.h"
- #import "ZBEaingingTitleView.h"
- #import "ZBIncomeViewController.h"
- #import "ZBEarnHeadModel.h"
- #import "ZBEarnModel.h"
- @interface DataViewController ()<UITableViewDelegate,UITableViewDataSource>
- {
- BOOL changeAccount;//近期结算和近期预估的切换,yes为预估
- BOOL monthAccount;
- NSString *chartTyep;//0今天、1昨天、2本月
- NSString *btnType;//结算和预估的切换
- CGFloat _oldY;
- }
- @property(nonatomic,strong)UITableView *tableViews;
- @property(nonatomic,strong)NSMutableArray *listArray;
- @property(nonatomic,strong)UILabel *accountMoneyL;
- @property(nonatomic,strong)ZBEaingingTitleView *titleView;
- @property(nonatomic,strong)ZBEarnHeadModel *headModel;
- @property(nonatomic,strong)ZBTipeView *tipView;
- @end
- @implementation DataViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self initNav];
- //接收通知
- [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(leftSliderClickWithRow:) name:@"data" object:nil];
- //接收通知
- [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(changeHeadInfo) name:@"datahead" object:nil];
-
- [[UIApplication sharedApplication].keyWindow addSubview:self.tipView];
- [self.tipView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.bottom.right.mas_equalTo(0);
- }];
-
- }
- -(void)changeHeadInfo
- {
- ZBUserInfoViewController *setV =[[ZBUserInfoViewController alloc]init];
- [self.navigationController pushViewController:setV animated:YES];
- }
- #pragma mark -- 左边控制器页面push方法
- -(void)leftSliderClickWithRow:(NSNotification *)noti{
- NSIndexPath *indexPaht =[noti object];
- NSInteger row =indexPaht.row;
- if (row == 0 ) {//收藏夹
- ZBCollectionVC *collV =[[ZBCollectionVC alloc]init];
- [self.navigationController pushViewController:collV animated:YES];
- return;
- }else if (row == 1) {//客服小蜜
- ZBAdWebViewController *adWeb = [[ZBAdWebViewController alloc] init];
- adWeb.url =jiaochengUrl;
- [self.navigationController pushViewController:adWeb animated:YES];
- return;
- }
- //过审.没有快手
- if (![PublicFunction canOpenURL:kwaiUrl]) {
- ZBSetViewController *setv=[[ZBSetViewController alloc]init];
- [self.navigationController pushViewController:setv animated:YES];
-
- }else{
- if (row == 2){//招商合作
- ZBWebViewController *web = [[ZBWebViewController alloc] init];
-
- web.url = CooperationURl;
- [self.navigationController pushViewController:web animated:YES];
- }else if (row == 3) {//PId
- ZBPIdViewController *pidV =[[ZBPIdViewController alloc]init];
- [self.navigationController pushViewController:pidV animated:YES];
-
- }else if (row == 4){//设置
- ZBSetViewController *setv=[[ZBSetViewController alloc]init];
- [self.navigationController pushViewController:setv animated:YES];
- }
- }
-
-
- }
- #pragma mark -- 移除通知
- -(void)dealloc{
-
- [[NSNotificationCenter defaultCenter]removeObserver:self];
- }
- -(void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- [self getAccounthead];
- if (monthAccount) {
- [self getMonthWithtype:chartTyep AndCate:@"0"];
- }else{
- [self getMonthWithtype:chartTyep AndCate:@"1"];
- }
- if ([AccountTool isLogin]) {
- AccountModel *infomodels =[AccountTool account];
- NSLog(@"%@",infomodels.img);
- [self.headImgV sd_setImageWithURL:[NSURL URLWithString:infomodels.img]];
-
- }
- [PublicFunction saveAccountWithPush:@"data"];
- [PublicFunction saveAccountChangeInfoWithPush:@"datahead"];
- }
- #pragma mark----收益
- //头部信息
- -(void)getAccounthead
- {
- if (![AccountTool isLogin]) {
- return;
- }
- [LoadingView showInView:self.view];
- [ZBHTTP post:getMyEarnURL params:nil success:^(id _Nonnull json) {
- [LoadingView dismiss];
- NSLog(@"%@",json);
- self.headModel=[ZBEarnHeadModel yy_modelWithJSON:json];
- [self.titleView.orderNum setTitle:self.headModel.allIncomePredict forState:UIControlStateNormal];
- [self.titleView.orderMoney setTitle:self.headModel.allIncomeEnd forState:UIControlStateNormal];
-
-
- self.accountMoneyL.text=[NSString stringWithFormat:@"¥%@",self.headModel.account_balance];
- self.titleView.model=self.headModel;
- [self.tableViews reloadData];
- } failure:^(NSError * _Nonnull error) {
- [LoadingView dismiss];
- // [MBProgressHUD showMessage:@"网络错误"];
- }];
- }
- #pragma mark---预估折线图
- #pragma mark---每月预估
- -(void)getMonthWithtype:(NSString *)type AndCate:(NSString *)cate
- {//预估1,结算2
- if (![AccountTool isLogin]) {
- return;
- }
- NSDictionary *dic =@{@"type":type,@"cate":cate};
- [LoadingView showInView:self.view];
- [ZBHTTP post:[NSString stringWithFormat:@"%@api/order/myEarningOrderStatistics",BASEURL] params:dic success:^(id _Nonnull json) {
- [LoadingView dismiss];
- NSArray *array =(NSArray *)json;
-
- [self.listArray removeAllObjects];
- [self.listArray addObjectsFromArray:array];
- [self.tableViews reloadData];
- NSLog(@"%@",json);
- } failure:^(NSError * _Nonnull error) {
- [LoadingView dismiss];
- // [MBProgressHUD showMessage:@"网络错误"];
- }];
- }
- -(void)initNav
- {
- chartTyep = @"0";//默认是今天
- self.backView.hidden=NO;
- self.navBar.navTitleLabel.font=[UIFont systemFontOfSize:18];
- self.navBar.hidden=NO;
- changeAccount = YES;//近期预估
- monthAccount =YES;
- btnType =@"1";//预估
-
-
- UIButton *rightBtn =[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 20, 20)];
- [rightBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
- [rightBtn addTarget:self action:@selector(rightClickIncomeBtn) forControlEvents:UIControlEventTouchUpInside];
- [self.navBar setCustomRightButtons:@[rightBtn]];
-
- //收益
- self.titleView =[[ZBEaingingTitleView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-20, 124)];
- __weak typeof(self) weakself = self;
- self.titleView.Incomeblock = ^{
- [weakself getYUGU];
- };
-
-
- [self.view addSubview:self.tableViews];
- [self.tableViews mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(15+NavBarHeight);
- make.bottom.mas_equalTo(self.view.mas_bottom);
- make.left.mas_equalTo(10);
- make.right.mas_equalTo(-10);
- }];
- [self.view addSubview:self.titleView];
- ZBIncomeView *headV= [[ZBIncomeView alloc]initWithFrame:CGRectMake(0, 124, SCREEN_WIDTH-20, 64)];
- headV.IncomeClickVc = ^{
- [self clickMyWithMoney];
- };
- headV.myOrderListVc = ^{
- [self selectedTextHeader];
- };
-
- UIView *headView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-20, 188)];
- headView.backgroundColor=[UIColor clearColor];
- [headView addSubview:self.titleView];
- [headView addSubview:headV];
-
- self.tableViews.tableHeaderView=headView;
-
-
- }
- #pragma mark---TableViewDelegate&&DataSource
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (indexPath.section == 1) {
- ZBIncomeChartCell *chartC =[tableView dequeueReusableCellWithIdentifier:@"chartC"];
- if (!chartC) {
- chartC=[[ZBIncomeChartCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"chartC"];
- chartC.selectionStyle=UITableViewCellSelectionStyleNone;
-
- }
-
- chartC.changeType = ^(NSString * _Nonnull Type) {
- chartTyep = Type;
- };
- if (monthAccount) {
- chartC.cateType = @"0";//销量
- }else{
- chartC.cateType=@"1";//收益
- }
- chartC.array = self.listArray;
- return chartC;
- }
- ZBAccountListCell *listC =[tableView dequeueReusableCellWithIdentifier:@"list"];
- if (!listC) {
- listC=[[ZBAccountListCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"list"];
- listC.selectionStyle=UITableViewCellSelectionStyleNone;
- }
- listC.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
- if (indexPath.row == self.listArray.count-1) {
- listC.lineV.hidden = YES;
- }else{
- listC.lineV.hidden=NO;
- }
- if (indexPath.section == 1) {
-
- listC.yearLabel.hidden=NO;
- [listC.timeLabel mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(25);
- make.top.mas_equalTo(5);
- }];
- listC.model = self.listArray[indexPath.row];
- }else if (indexPath.section == 0 && self.headModel != nil)
- {
- if (indexPath.row == 0) {
- listC.timeLabel.text=@"今日";
- if (changeAccount) {//近期预估
- listC.numLabel.text=[NSString stringWithFormat:@"共%@单",self.headModel.thisDayOrderCount];
- listC.moneyLabel.text=[NSString stringWithFormat:@"¥%@",self.headModel.thisDayIncomePredict];
- }else{//结算
- listC.numLabel.text=[NSString stringWithFormat:@"共%@单",self.headModel.thisDayOrderCountEnd];
- listC.moneyLabel.text=[NSString stringWithFormat:@"¥%@",self.headModel.thisDayIncomeEnd];
- }
- }else if (indexPath.row == 1) {
- listC.timeLabel.text=@"昨日";
- if (changeAccount) {//近期预估
- listC.numLabel.text=[NSString stringWithFormat:@"共%@单",self.headModel.lastDayOrderCount];
- listC.moneyLabel.text=[NSString stringWithFormat:@"¥%@",self.headModel.lastDayIncomePredict];
- }else{//结算
- listC.numLabel.text=[NSString stringWithFormat:@"共%@单",self.headModel.lastDayOrderCountEnd];
- listC.moneyLabel.text=[NSString stringWithFormat:@"¥%@",self.headModel.lastDayIncomeEnd];
- }
- }else if (indexPath.row == 2) {
- listC.timeLabel.text=@"本月";
- if (changeAccount) {//近期预估
- listC.numLabel.text=[NSString stringWithFormat:@"共%@单",self.headModel.currentMonthOrderCount];
- listC.moneyLabel.text=[NSString stringWithFormat:@"¥%@",self.headModel.currentMonthIncomePredict];
- }else{//结算
- listC.numLabel.text=[NSString stringWithFormat:@"共%@单",self.headModel.currentMonthCountEnd];
- listC.moneyLabel.text=[NSString stringWithFormat:@"¥%@",self.headModel.currentMonthIncomeEnd];
- }
- }
-
- }
- return listC;
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- if (section==0) {
- return 3;
- }
- return 1;
- }
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return 2;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (indexPath.section == 1) {
- return 280;
- }
- return 52;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- {
-
- return 55;
- }
- -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- {
-
- ZBAccountHeadView *headV =[[ZBAccountHeadView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-20, 55)];
- if (section == 0) {
- headV.recently = changeAccount;
- }else{
- headV.recently = monthAccount;
- }
-
- if (section == 0) {
- [headV.frastBtn setTitle:@"近期预估" forState:UIControlStateNormal];
- [headV.accountBtn setTitle:@"近期结算" forState:UIControlStateNormal];
- headV.allBtn.hidden =NO;
- headV.allBlock = ^{
- [self getYUGU];
- };
- }else{
- headV.allBtn.hidden=YES;
- [headV.frastBtn setTitle:@"销量走势" forState:UIControlStateNormal];
- [headV.accountBtn setTitle:@"收益走势" forState:UIControlStateNormal];
- }
- headV.changeBtnBlock = ^(UIButton * _Nonnull button) {
- if (section == 0) {
- if (button.tag == 1234) {
- changeAccount = YES;
- }else{
- changeAccount = NO;
- }
- [self.tableViews reloadData];
- }else{
- if (button.tag == 1234) {
-
- monthAccount = YES;//销量
- [self getMonthWithtype:chartTyep AndCate:@"0"];//热销商品
- }else{
- monthAccount = NO;//收益
- [self getMonthWithtype:chartTyep AndCate:@"1"];//销量走势
- }
- }
- if (button.tag == 1234) {//近期预估
- btnType=@"1";
- }else{//结算
- btnType =@"2";
- }
-
- };
-
- return headV;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- ZBIncomeViewController *incomV =[[ZBIncomeViewController alloc]init];
- if (indexPath.section == 0) {//当天结算列表
- incomV.isDay =1;//按天
- if (indexPath.row == 0) {//今日
- incomV.yearMonthDay=[PublicFunction getCurrentDay];
- }else if(indexPath.row == 1){//昨日
- incomV.yearMonthDay=[PublicFunction getYestDay];
- }else{//本月
- incomV.isDay =0;
- incomV.yearMonthDay=[PublicFunction backToPassedTimeWithMonthNumber:0];
- }
- incomV.type=btnType;//1:预估收入 2:结算收入
- [self.navigationController pushViewController:incomV animated:YES];
- }
- }
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
-
- if ([scrollView isEqual: self.tableViews] && self.tableViews.contentSize.height > SCREEN_HEIGHT-95) {
-
- if (self.tableViews.contentOffset.y > NavBarHeight) {
- // 上滑
- [UIView animateWithDuration:0.5 animations:^{
- self.backView.frame=CGRectMake(0, NavBarHeight, SCREEN_WIDTH, 0);
- [self.tableViews mas_updateConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(NavBarHeight);
- }];
-
- }];
- }
- else{
- // 下滑
- [UIView animateWithDuration:0.5 animations:^{
- self.backView.frame=CGRectMake(0, NavBarHeight, SCREEN_WIDTH, 95);
- [self.tableViews mas_updateConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(NavBarHeight+15);
- }];
- }];
-
- }
- }
- }
- -(UITableView *)tableViews
- {
- if (!_tableViews) {
- _tableViews =[[UITableView alloc]initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStylePlain];
- _tableViews.delegate=self;
- _tableViews.dataSource=self;
- _tableViews.backgroundColor=[UIColor YHColorWithHex:0xF4F4F4];
- _tableViews.separatorStyle=UITableViewCellSeparatorStyleNone;
- _tableViews.sectionHeaderHeight=55;
- _tableViews.layer.cornerRadius=8;
- _tableViews.layer.masksToBounds=YES;
- _tableViews.showsHorizontalScrollIndicator=NO;
- _tableViews.showsVerticalScrollIndicator=NO;
-
- }
- return _tableViews;
- }
- -(NSMutableArray *)listArray
- {
- if (!_listArray) {
- _listArray=[NSMutableArray array];
- }
- return _listArray;
- }
- #pragma mark---我的账户
- -(void)clickMyWithMoney
- {
- ZBWithDrawalViewController *drawV =[[ZBWithDrawalViewController alloc]init];
- [self.navigationController pushViewController:drawV animated:YES];
- }
- #pragma mark---订单结算明细
- -(void)selectedTextHeader
- {
- ZBOrderListViewController *listV =[[ZBOrderListViewController alloc]init];
- [self.navigationController pushViewController:listV animated:YES];
- }
- -(UILabel *)accountMoneyL
- {
- if (!_accountMoneyL ) {
- _accountMoneyL =[[UILabel alloc]init];
- _accountMoneyL.textAlignment=NSTextAlignmentRight;
- _accountMoneyL.text=@"Y--.--";
- _accountMoneyL.textColor=[UIColor YHColorWithHex:0xFF7D00];
- _accountMoneyL.font=[UIFont boldSystemFontOfSize:18];
- }
- return _accountMoneyL;
- }
- #pragma mark----收益统计
- -(void)rightClickIncomeBtn
- {
- ZBIncomeStatisticsViewController *incomeV =[[ZBIncomeStatisticsViewController alloc]init];
- [self.navigationController pushViewController:incomeV animated:YES];
- }
- #pragma mark----提示视图
- -(ZBTipeView *)tipView
- {
- if (!_tipView) {
- _tipView =[[ZBTipeView alloc]init];
- _tipView.hidden=YES;
- _tipView.tag=1010;
- }
- return _tipView;
- }
- #pragma mark---预估明细
- -(void)getYUGU
- {
- ZBMonthOrderVC *orderV =[[ZBMonthOrderVC alloc]init];
- [self.navigationController pushViewController:orderV animated:YES];
- }
- @end
|