酷店

KDPDrawerVC.m 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. //
  2. // KDPDrawerVC.m
  3. // KuDianProject
  4. //
  5. // Created by 学丽 on 2019/7/4.
  6. // Copyright © 2019 KDP. All rights reserved.
  7. //
  8. #import "KDPDrawerVC.h"
  9. #import "KDPDrawerListCell.h"
  10. #import "KDPIDViewController.h"
  11. #import "KDPSetViewController.h"
  12. #import "KDPCollectHistoryVC.h"
  13. #import "KDPWebInteractionVC.h"
  14. #import "KDPWebVC.h"
  15. #import "KDPWebInteractionVC.h"
  16. #import "KDPCollectHistoryPageVC.h"
  17. @interface KDPDrawerVC ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetDelegate,DZNEmptyDataSetSource>
  18. {
  19. UIImageView *headImgV;
  20. UILabel *headLabel;
  21. NSArray *infoArray;
  22. }
  23. @property(nonatomic,strong)UITableView *listTabView;
  24. @end
  25. @implementation KDPDrawerVC
  26. - (void)viewDidLoad {
  27. [super viewDidLoad];
  28. self.navBar.hidden=YES;
  29. if (![KDPublicMethod JumpOpenURL:KWai]) {//没有安装快手,
  30. infoArray=@[@{@"img":@"shoucangliulan",@"title":@"收藏浏览"},@{@"img":@"kefuxiaomi",@"title":@"客服小蜜"},@{@"img":@"zhoashang",@"title":@"招商合作"},@{@"img":@"shezhi",@"title":@"设置"}];
  31. }else{
  32. infoArray=@[@{@"img":@"shoucangliulan",@"title":@"收藏浏览"},@{@"img":@"kefuxiaomi",@"title":@"客服小蜜"},@{@"img":@"zhoashang",@"title":@"招商合作"},@{@"img":@"kuaishouxiaodian",@"title":@"快手小店Pid"},@{@"img":@"shezhi",@"title":@"设置"}];
  33. }
  34. [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(changeEixts ) name:@"exitLogin" object:nil];
  35. [self.view addSubview:self.listTabView];
  36. }
  37. -(void)changeEixts
  38. {
  39. // 注意:动画要设置为YES
  40. [self dismissViewControllerAnimated:YES completion:nil];
  41. }
  42. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  43. {
  44. KDPDrawerListCell *listC=[tableView dequeueReusableCellWithIdentifier:@"draw"];
  45. if (!listC) {
  46. listC=[[KDPDrawerListCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"draw"];
  47. listC.selectionStyle=UITableViewCellSelectionStyleNone;
  48. }
  49. NSDictionary *dic=infoArray[indexPath.row];
  50. listC.iconImg.image=[UIImage imageNamed:dic[@"img"]];
  51. listC.titleLabel.text=dic[@"title"];
  52. return listC;
  53. }
  54. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  55. {
  56. return infoArray.count;
  57. }
  58. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  59. {
  60. if (![KDPublicMethod JumpOpenURL:KWai]) {//没有安装快手,
  61. switch (indexPath.row) {
  62. case 0://收藏浏览
  63. [self collectVC];
  64. break;
  65. case 1://客服小蜜
  66. [self messageWithweb];
  67. break;
  68. case 2://招商合作
  69. [self webLoad];
  70. break;
  71. case 3://设置
  72. [self SetVC];
  73. break;
  74. default:
  75. break;
  76. }
  77. return;
  78. }
  79. switch (indexPath.row) {
  80. case 0://收藏浏览
  81. [self collectVC];
  82. break;
  83. case 1://客服小蜜
  84. [self messageWithweb];
  85. break;
  86. case 2://招商合作
  87. [self webLoad];
  88. break;
  89. case 3://快手小店
  90. [self pidVC];
  91. break;
  92. case 4://设置
  93. [self SetVC];
  94. break;
  95. default:
  96. break;
  97. }
  98. }
  99. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  100. {
  101. return 50;
  102. }
  103. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  104. {
  105. return 1;
  106. }
  107. -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  108. {
  109. UIView *headV=[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH/3*2, 20)];
  110. headV.backgroundColor=[UIColor whiteColor];
  111. return headV;
  112. }
  113. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  114. {
  115. return 20;
  116. }
  117. - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView{
  118. return [UIImage imageNamed:@"no_order"];
  119. }
  120. - (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView{
  121. return YES;
  122. }
  123. - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView{
  124. return [[NSAttributedString alloc] initWithString:@"还没有记录" attributes:@{NSForegroundColorAttributeName:[UIColor colorWithHex:0x333333],NSFontAttributeName:FONT_SYS(12)}];
  125. }
  126. - (CGFloat )spaceHeightForEmptyDataSet:(UIScrollView *)scrollView{
  127. return 30;
  128. }
  129. -(UITableView *)listTabView
  130. {
  131. if (!_listTabView) {
  132. _listTabView=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH/3*2, self.view.height)];
  133. _listTabView.backgroundColor=[UIColor clearColor];
  134. _listTabView.emptyDataSetDelegate = self;
  135. _listTabView.emptyDataSetSource = self; _listTabView.separatorStyle=UITableViewCellSeparatorStyleNone;
  136. _listTabView.scrollEnabled=NO;
  137. if (@available(iOS 11.0, *)) {
  138. _listTabView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  139. } else {
  140. self.automaticallyAdjustsScrollViewInsets = NO;
  141. }
  142. _listTabView.delegate=self;
  143. _listTabView.dataSource=self;
  144. [self addheadView];
  145. }
  146. return _listTabView;
  147. }
  148. -(void)addheadView
  149. {
  150. UIView *backV=[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH/3*2, 111+KDNavBarHeight)];
  151. backV.backgroundColor=[UIColor colorWithHexString:@"#2E2E2E"];
  152. backV.userInteractionEnabled=YES;
  153. UITapGestureRecognizer *tapget=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(userinfoClickButton)];
  154. [backV addGestureRecognizer:tapget];
  155. self.listTabView.tableHeaderView=backV;
  156. headImgV=[[UIImageView alloc]initWithFrame:CGRectMake(0, KDNavBarHeight, 62, 62)];
  157. headImgV.backgroundColor=[UIColor whiteColor];
  158. headImgV.layer.cornerRadius=31;
  159. headImgV.layer.masksToBounds=YES;
  160. [backV addSubview:headImgV];
  161. KDPAccountModel *model =[KDPAccountTool account];
  162. [headImgV sd_setImageWithURL:[NSURL URLWithString:model.img]placeholderImage:[UIImage imageNamed:placholderImg]];
  163. headImgV.centerX=backV.centerX;
  164. headLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, headImgV.bottom+10, SCREEN_WIDTH/3*2, 21)];
  165. headLabel.text=model.name;
  166. headLabel.textColor=[UIColor whiteColor];
  167. headLabel.font=[UIFont systemFontOfSize:15];
  168. headLabel.textAlignment=NSTextAlignmentCenter;
  169. [backV addSubview:headLabel];
  170. }
  171. #pragma mark---跳转
  172. -(void)userinfoClickButton
  173. {
  174. KDPUserInfoVC *infoV=[[KDPUserInfoVC alloc]init];
  175. [self cw_pushViewController:infoV];
  176. }
  177. #pragma mark---快手小店
  178. -(void)pidVC
  179. {
  180. KDPIDViewController *pidV=[[KDPIDViewController alloc]init];
  181. [self cw_pushViewController:pidV];
  182. }
  183. #pragma mark---设置
  184. -(void)SetVC
  185. {
  186. KDPSetViewController *pidV=[[KDPSetViewController alloc]init];
  187. [self cw_pushViewController:pidV];
  188. }
  189. #pragma mark---收藏
  190. -(void)collectVC
  191. {
  192. KDPCollectHistoryPageVC *pidV=[[KDPCollectHistoryPageVC alloc]init];
  193. [self cw_pushViewController:pidV];
  194. }
  195. #pragma mark---web
  196. -(void)webLoad
  197. {
  198. KDPWebVC *pidV=[[KDPWebVC alloc]init];
  199. pidV.webUrl=ZSHZURl;
  200. [self cw_pushViewController:pidV];
  201. }
  202. #pragma mark---客服小蜜
  203. -(void)messageWithweb
  204. {
  205. KDPWebInteractionVC *pidV=[[KDPWebInteractionVC alloc]init];
  206. pidV.url=custSerURL;
  207. [self cw_pushViewController:pidV];
  208. }
  209. @end