MySetViewController.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. //
  2. // MySetViewController.m
  3. // 双子星云手机
  4. //
  5. // Created by APPLE on 2023/8/17.
  6. //
  7. #import "MySetViewController.h"
  8. #import <SDWebImage.h>
  9. #import <Masonry.h>
  10. #import "UseAccountManage.h"
  11. #import "HelpDownScrollView.h"
  12. #import "MineViewCell.h"
  13. #import "ChangeLogoViewController.h"
  14. #import "HidenMaskSetViewController.h"
  15. #import "CustomerWebViewController.h"
  16. #import "AboutViewController.h"
  17. @interface MySetViewController ()<HelpDownScrollViewDelegate,UITableViewDelegate,UITableViewDataSource>
  18. @property (nonatomic, strong, nullable) UITableView *tableView;
  19. @end
  20. @implementation MySetViewController
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. // Do any additional setup after loading the view.
  24. [self drawAnyView];
  25. }
  26. - (void)drawAnyView{
  27. [self.view setBackgroundColor:HWF5F7FAColor];
  28. [self.toolBar setHidden:YES];
  29. [self.navigationBar setHidden:YES];
  30. [self.view addSubview:self.tableView];
  31. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  32. make.left.mas_equalTo(0);
  33. make.right.mas_equalTo(0);
  34. make.bottom.mas_equalTo(0);
  35. make.top.mas_equalTo(0);
  36. }];
  37. [self.tableView setTableHeaderView:[self headViewForTable]];
  38. }
  39. - (UIView *)headViewForTable{
  40. /*236顶部视图, 44中间试图下部分, 126下方视图*/
  41. UIView *headView = [[UIView alloc] initWithFrame:(CGRectMake(0, 0, SCREEN_W, 236.f + 44.f + 126))];
  42. [headView setBackgroundColor:[UIColor clearColor]];
  43. UIImage *bgImage = [UIImage imageNamed:@"set_up_bg"];
  44. // bgImage = [bgImage resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 40, 80)];
  45. UIImageView *bgImView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 236.f)];
  46. [bgImView setImage:bgImage];
  47. [headView addSubview:bgImView];
  48. /*头像*/
  49. UIImageView *photoImage = [[UIImageView alloc] init];
  50. [photoImage setImage:[UIImage imageNamed:@"photo_normal"]];
  51. [bgImView addSubview:photoImage];
  52. [photoImage mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.left.mas_equalTo(16.f);
  54. make.top.mas_equalTo(99.f);
  55. make.width.mas_equalTo(62.f);
  56. make.height.mas_equalTo(62.f);
  57. }];
  58. NSDictionary *loginInfo = [[UseAccountManage shareInstance] getLoginInfo];
  59. /*用户名*/
  60. UILabel *phoneLabel = [[UILabel alloc] init];
  61. [phoneLabel setFont:[UIFont boldSystemFontOfSize:18.f]];
  62. [phoneLabel setTextColor:[UIColor whiteColor]];
  63. if (loginInfo && [[loginInfo allKeys] containsObject:@"phone"]){
  64. [phoneLabel setText:[loginInfo objectForKey:@"phone"]];
  65. }
  66. [bgImView addSubview:phoneLabel];
  67. [phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.left.equalTo(photoImage.mas_right).offset(9);
  69. make.centerY.equalTo(photoImage.mas_centerY);
  70. make.right.mas_equalTo(-22.f);
  71. make.height.mas_equalTo(25.f);
  72. }];
  73. /*下方会员视图*/
  74. // vip_bg
  75. UIImageView *downBgView = [[UIImageView alloc] init];
  76. [downBgView setImage:[UIImage imageNamed:@"vip_bg"]];
  77. [headView addSubview:downBgView];
  78. [downBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  79. make.left.mas_equalTo(15.f);
  80. make.right.mas_equalTo(-15.f);
  81. make.bottom.mas_equalTo(-126.f);
  82. make.height.mas_equalTo(96.f);
  83. }];
  84. /*VIP类型*/
  85. UILabel *vipType = [[UILabel alloc] init];
  86. [vipType setText:@"VIP"];
  87. [vipType setTextColor:[UIColor whiteColor]];
  88. [vipType setFont:[UIFont boldSystemFontOfSize:24.f]];
  89. [downBgView addSubview:vipType];
  90. [vipType mas_makeConstraints:^(MASConstraintMaker *make) {
  91. make.left.mas_equalTo(20.f);
  92. make.right.mas_equalTo(-100.f);
  93. make.top.mas_equalTo(18.f);
  94. make.height.mas_equalTo(33.f);
  95. }];
  96. /*VIP类型提示*/
  97. UILabel *vipTypeTipsLabel = [[UILabel alloc] init];
  98. [vipTypeTipsLabel setText:@"你当前为非会员,无法享受专属私密手机"];
  99. [vipTypeTipsLabel setTextColor:[UIColor whiteColor]];
  100. [vipTypeTipsLabel setFont:[UIFont systemFontOfSize:12.f]];
  101. [downBgView addSubview:vipTypeTipsLabel];
  102. [vipTypeTipsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  103. make.left.mas_equalTo(20.f);
  104. make.right.mas_equalTo(-100.f);
  105. make.top.mas_equalTo(53.f);
  106. make.height.mas_equalTo(17.f);
  107. }];
  108. /*免费会员按钮*/
  109. UIButton *vipBtn = [[UIButton alloc] init];
  110. [vipBtn setBackgroundColor:[UIColor whiteColor]];
  111. [vipBtn setTitle:@"免费领会员" forState:(UIControlStateNormal)];
  112. [vipBtn setTitleColor:HW0A132BColor forState:(UIControlStateNormal)];
  113. [vipBtn.titleLabel setFont:[UIFont systemFontOfSize:13.f]];
  114. [vipBtn.layer setCornerRadius:31.f/2.f];
  115. [downBgView addSubview:vipBtn];
  116. [vipBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  117. make.width.mas_equalTo(86.f);
  118. make.right.mas_equalTo(-20.f);
  119. make.centerY.equalTo(downBgView.mas_centerY);
  120. make.height.mas_equalTo(31.f);
  121. }];
  122. /*下方视图*/
  123. HelpDownScrollView *helpDownScrollView = [[HelpDownScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W - 30, 96.f) withImageAry:@[@"icon-tubiao",@"icon-jincheng"] tilteAry:@[@"更换图标",@"进程隐藏"] numberOfLine:3];
  124. helpDownScrollView.presedDelegate = self;
  125. [headView addSubview:helpDownScrollView];
  126. [helpDownScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  127. make.left.mas_equalTo(15.f);
  128. make.right.mas_equalTo(-15.f);
  129. make.bottom.mas_equalTo(-15.f);
  130. make.height.mas_equalTo(96.f);
  131. }];
  132. [helpDownScrollView setBackgroundColor:[UIColor whiteColor]];
  133. [helpDownScrollView.layer setCornerRadius:8.f];
  134. return headView;
  135. }
  136. /*
  137. #pragma mark - Navigation
  138. // In a storyboard-based application, you will often want to do a little preparation before navigation
  139. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  140. // Get the new view controller using [segue destinationViewController].
  141. // Pass the selected object to the new view controller.
  142. }
  143. */
  144. - (void)helpDownScrollViewBePressed:(nonnull id)sender withIndex:(NSInteger)index {
  145. HLog(@"\n----点击了第个%ld按钮----",index);
  146. if (index == 0){
  147. ChangeLogoViewController *nextVC = [[ChangeLogoViewController alloc] init];
  148. [self.navigationController pushViewController:nextVC animated:YES];
  149. }else if (index == 1){/**/
  150. HidenMaskSetViewController *nextVC = [[HidenMaskSetViewController alloc] init];
  151. [self.navigationController pushViewController:nextVC animated:YES];
  152. }
  153. }
  154. #pragma mark - 懒加载
  155. - (UITableView *)tableView{
  156. if (!_tableView) {
  157. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStyleGrouped];
  158. _tableView.delegate = self;
  159. _tableView.dataSource = self;
  160. _tableView.showsVerticalScrollIndicator = NO;
  161. _tableView.showsHorizontalScrollIndicator = NO;
  162. _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  163. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  164. [_tableView setSeparatorColor:[UIColor clearColor]];
  165. [_tableView setBackgroundColor:[UIColor clearColor]];
  166. [_tableView setTableFooterView:[UIView new]];
  167. [_tableView setBounces:YES];
  168. if (@available(iOS 15.0, *)) {
  169. _tableView.sectionHeaderTopPadding = 0;
  170. }
  171. }
  172. return _tableView;
  173. }
  174. #pragma mark - 列表委托
  175. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  176. return 1;
  177. }
  178. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  179. return 5;
  180. }
  181. - (MineViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  182. NSInteger row = indexPath.row;
  183. static NSString *identifier = @"MineViewCell";
  184. MineViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  185. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  186. if (!cell){
  187. cell = [[MineViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  188. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  189. [cell setBackgroundColor:[UIColor clearColor]];
  190. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  191. }
  192. [cell.bgViewLayer removeFromSuperlayer];
  193. [cell.titleLabel2 setHidden:YES];
  194. [cell.rightImage setHidden:NO];
  195. [cell.lineView setHidden:NO];
  196. if (row == 0){
  197. [cell.titleLabel setText:@"邀请好友"];
  198. [cell.titleLabel2 setText:@"邀请好友送会员"];
  199. [cell.mImageView setImage:[UIImage imageNamed:@"icon-yaoqing"]];
  200. [cell.titleLabel2 setHidden:NO];
  201. /*上圆角*/
  202. //设置部分圆角 贝塞尔曲线
  203. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  204. byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
  205. cornerRadii:CGSizeMake(8, 8)];
  206. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  207. maskLayer.frame = cell.cellBgView.bounds;
  208. maskLayer.path = maskPath.CGPath;
  209. cell.bgViewLayer = maskLayer;
  210. cell.cellBgView.layer.mask = cell.bgViewLayer;
  211. }else if (row == 1){
  212. [cell.titleLabel setText:@"清除缓存"];
  213. [cell.titleLabel2 setText:@"0M"];
  214. [cell.titleLabel2 setHidden:NO];
  215. /*计算缓存大小*/
  216. [cell.mImageView setImage:[UIImage imageNamed:@"icon-qingchu"]];
  217. }else if (row == 2){
  218. [cell.titleLabel setText:@"检测更新"];
  219. [cell.mImageView setImage:[UIImage imageNamed:@"icon-gengxin"]];
  220. }else if (row == 3){
  221. [cell.titleLabel setText:@"联系客服"];
  222. [cell.mImageView setImage:[UIImage imageNamed:@"icon-kefu"]];
  223. }else if (row == 4){
  224. [cell.titleLabel setText:@"退出账号"];
  225. [cell.mImageView setImage:[UIImage imageNamed:@"icon-tuichu"]];
  226. [cell.rightImage setHidden:YES];
  227. /*下圆角*/
  228. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  229. byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
  230. cornerRadii:CGSizeMake(8, 8)];
  231. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  232. maskLayer.frame = cell.cellBgView.bounds;
  233. maskLayer.path = maskPath.CGPath;
  234. cell.bgViewLayer = maskLayer;
  235. cell.cellBgView.layer.mask = cell.bgViewLayer;
  236. [cell.lineView setHidden:YES];
  237. }
  238. return cell;
  239. }
  240. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  241. return 60;
  242. }
  243. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  244. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  245. NSInteger row = indexPath.row;
  246. if (3 == row){
  247. CustomerWebViewController *vc = [[CustomerWebViewController alloc] init];
  248. NSDictionary *dictLogin = [[UseAccountManage shareInstance] getLoginInfo];
  249. if (dictLogin && [[dictLogin allKeys] containsObject:@"token"])
  250. {
  251. NSString *tokenStr = [dictLogin objectForKey:@"token"];
  252. NSString *url = [NSString stringWithFormat:@"%@/h5/customer-service?autoopen=true&token=%@", CloudService, tokenStr];
  253. if ([CloudService containsString:@"14.18.190.141:11180"]) { // 测试环境
  254. url = [NSString stringWithFormat:@"http://testprivacy.phone.armclouding.com:11180/h5/customer-service?autoopen=true&token=%@", tokenStr];
  255. }
  256. vc.webUrl = url;
  257. [self.navigationController pushViewController:vc animated:YES];
  258. }
  259. }else if (2 == row){
  260. AboutViewController *vc = [[AboutViewController alloc] init];
  261. [self.navigationController pushViewController:vc animated:YES];
  262. }
  263. }
  264. @end