MySetViewController.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  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. #import "iPhone.h"
  18. #import "CloudPhoneAPI.h"
  19. #import "UserDetailInfoModel.h"
  20. #import "BuyVIPViewController.h"
  21. #import "PayRecoderListViewController.h"
  22. #import "ComontAlretViewController.h"
  23. @interface MySetViewController ()<HelpDownScrollViewDelegate,UITableViewDelegate,UITableViewDataSource,ComontAlretViewControllerDelegate>
  24. {
  25. UILabel *phoneLabel;
  26. UILabel *vipTypeTipsLabel;
  27. }
  28. @property (nonatomic, strong, nullable) UITableView *tableView;
  29. @end
  30. @implementation MySetViewController
  31. - (void)viewDidLoad {
  32. [super viewDidLoad];
  33. // Do any additional setup after loading the view.
  34. [self drawAnyView];
  35. NSString* bg_tableName = nil;
  36. NSDictionary *dictLogin = [[UseAccountManage shareInstance] getLoginInfo];
  37. if (dictLogin && [[dictLogin allKeys] containsObject:@"touristId"])
  38. {
  39. NSString* username = [dictLogin objectForKey:@"touristId"];
  40. bg_tableName = User_Info_tableName(username);
  41. NSArray* finfAlls = [UserDetailInfoModel bg_findAll:bg_tableName];
  42. if (finfAlls && finfAlls.count >0) {
  43. UserDetailInfoModel *model = finfAlls[0];
  44. /*更新用户名称*/
  45. [phoneLabel setText:model.userName];
  46. }
  47. }
  48. /*获取个人信息*/
  49. [[UseAccountManage shareInstance] CommonPostCallBackCode:PostUserDetailInfo
  50. Params:[NSDictionary new]
  51. success:^(id _Nonnull responseObject) {
  52. UserDetailInfoDataModel *model = [[UserDetailInfoDataModel alloc] initWithDictionary:responseObject error:nil];
  53. if (model.status.integerValue == 0){
  54. /*内容用数据库更新到本地*/
  55. if (bg_tableName){
  56. model.data.bg_tableName = bg_tableName;
  57. [model.data bg_cover];
  58. if (self.whetherPhoneStatus != 0){
  59. [self->vipTypeTipsLabel setText:[NSString stringWithFormat:@"%@%@",NSLocalizedString(@"my_set_no_time_top",nil),model.data.exceptTime]];
  60. }
  61. }
  62. }else{
  63. ;
  64. }
  65. }
  66. failure:^(NSError * _Nonnull error) {
  67. ;
  68. }];
  69. //http://testprivacy.phone.armclouding.com:11180/api/user/v1/user/getUserDetailInfo
  70. }
  71. - (void)drawAnyView{
  72. [self.view setBackgroundColor:HWF5F7FAColor];
  73. [self.toolBar setHidden:YES];
  74. [self.navigationBar setHidden:YES];
  75. [self.view addSubview:self.tableView];
  76. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  77. make.left.mas_equalTo(0);
  78. make.right.mas_equalTo(0);
  79. make.bottom.mas_equalTo(0);
  80. make.top.mas_equalTo(0);
  81. }];
  82. [self.tableView setTableHeaderView:[self headViewForTable]];
  83. }
  84. - (UIView *)headViewForTable{
  85. /*236顶部视图, 44中间试图下部分, 126下方视图*/
  86. UIView *headView = [[UIView alloc] initWithFrame:(CGRectMake(0, 0, SCREEN_W, 236.f + 44.f + 126))];
  87. [headView setBackgroundColor:[UIColor clearColor]];
  88. UIImage *bgImage = [UIImage imageNamed:@"set_up_bg"];
  89. // bgImage = [bgImage resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 40, 80)];
  90. UIImageView *bgImView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 236.f)];
  91. [bgImView setImage:bgImage];
  92. [headView addSubview:bgImView];
  93. /*头像*/
  94. UIImageView *photoImage = [[UIImageView alloc] init];
  95. [photoImage setImage:[UIImage imageNamed:@"photo_normal"]];
  96. [bgImView addSubview:photoImage];
  97. [photoImage mas_makeConstraints:^(MASConstraintMaker *make) {
  98. make.left.mas_equalTo(16.f);
  99. make.top.mas_equalTo(99.f);
  100. make.width.mas_equalTo(62.f);
  101. make.height.mas_equalTo(62.f);
  102. }];
  103. NSDictionary *loginInfo = [[UseAccountManage shareInstance] getLoginInfo];
  104. /*用户名*/
  105. phoneLabel = [[UILabel alloc] init];
  106. [phoneLabel setFont:[UIFont boldSystemFontOfSize:18.f]];
  107. [phoneLabel setTextColor:[UIColor whiteColor]];
  108. if (loginInfo && [[loginInfo allKeys] containsObject:@"phone"]){
  109. [phoneLabel setText:[loginInfo objectForKey:@"phone"]];
  110. }
  111. [bgImView addSubview:phoneLabel];
  112. [phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  113. make.left.equalTo(photoImage.mas_right).offset(9);
  114. make.centerY.equalTo(photoImage.mas_centerY);
  115. make.right.mas_equalTo(-22.f);
  116. make.height.mas_equalTo(25.f);
  117. }];
  118. /*下方会员视图*/
  119. // vip_bg
  120. UIImageView *downBgView = [[UIImageView alloc] init];
  121. [downBgView setImage:[UIImage imageNamed:@"vip_bg"]];
  122. [headView addSubview:downBgView];
  123. [downBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  124. make.left.mas_equalTo(15.f);
  125. make.right.mas_equalTo(-15.f);
  126. make.bottom.mas_equalTo(-126.f);
  127. make.height.mas_equalTo(96.f);
  128. }];
  129. [downBgView setUserInteractionEnabled:YES];
  130. /*VIP类型*/
  131. UILabel *vipType = [[UILabel alloc] init];
  132. [vipType setText:@"VIP"];
  133. [vipType setTextColor:[UIColor whiteColor]];
  134. [vipType setFont:[UIFont boldSystemFontOfSize:24.f]];
  135. [downBgView addSubview:vipType];
  136. [vipType mas_makeConstraints:^(MASConstraintMaker *make) {
  137. make.left.mas_equalTo(20.f);
  138. make.right.mas_equalTo(-100.f);
  139. make.top.mas_equalTo(18.f);
  140. make.height.mas_equalTo(33.f);
  141. }];
  142. /*VIP类型提示*/
  143. vipTypeTipsLabel = [[UILabel alloc] init];
  144. if (self.whetherPhoneStatus != 0){
  145. [vipTypeTipsLabel setText:@""];
  146. }else{
  147. [vipTypeTipsLabel setText:NSLocalizedString(@"my_set_no_vip_tips",nil)];
  148. }
  149. [vipTypeTipsLabel setTextColor:[UIColor whiteColor]];
  150. [vipTypeTipsLabel setFont:[UIFont systemFontOfSize:12.f]];
  151. [downBgView addSubview:vipTypeTipsLabel];
  152. [vipTypeTipsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  153. make.left.mas_equalTo(20.f);
  154. make.right.mas_equalTo(-100.f);
  155. make.top.mas_equalTo(53.f);
  156. make.height.mas_equalTo(17.f);
  157. }];
  158. /*免费会员按钮*/
  159. UIButton *vipBtn = [[UIButton alloc] init];
  160. [vipBtn setBackgroundColor:[UIColor whiteColor]];
  161. if (self.whetherPhoneStatus != 0){
  162. [vipBtn setTitle:NSLocalizedString(@"no_enough_time_exchange",nil) forState:(UIControlStateNormal)];
  163. }else{
  164. [vipBtn setTitle:NSLocalizedString(@"my_set_no_vip_open_vip",nil) forState:(UIControlStateNormal)];
  165. }
  166. [vipBtn setTitleColor:HW0A132BColor forState:(UIControlStateNormal)];
  167. [vipBtn.titleLabel setFont:[UIFont systemFontOfSize:13.f]];
  168. [vipBtn addTarget:self
  169. action:@selector(vipBtnPressed)
  170. forControlEvents:(UIControlEventTouchUpInside)];
  171. [vipBtn.layer setCornerRadius:31.f/2.f];
  172. [downBgView addSubview:vipBtn];
  173. [vipBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  174. make.width.mas_equalTo(86.f);
  175. make.right.mas_equalTo(-20.f);
  176. make.centerY.equalTo(downBgView.mas_centerY);
  177. make.height.mas_equalTo(31.f);
  178. }];
  179. /*下方视图*/
  180. HelpDownScrollView *helpDownScrollView = [[HelpDownScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W - 30, 96.f) withImageAry:@[@"icon-tubiao",@"icon-jincheng"] tilteAry:@[NSLocalizedString(@"my_set_no_change_logo",nil),NSLocalizedString(@"my_set_no_hidden_app",nil)] numberOfLine:3];
  181. helpDownScrollView.presedDelegate = self;
  182. [headView addSubview:helpDownScrollView];
  183. [helpDownScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  184. make.left.mas_equalTo(15.f);
  185. make.right.mas_equalTo(-15.f);
  186. make.bottom.mas_equalTo(-15.f);
  187. make.height.mas_equalTo(96.f);
  188. }];
  189. [helpDownScrollView setBackgroundColor:[UIColor whiteColor]];
  190. [helpDownScrollView.layer setCornerRadius:8.f];
  191. return headView;
  192. }
  193. /*
  194. #pragma mark - Navigation
  195. // In a storyboard-based application, you will often want to do a little preparation before navigation
  196. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  197. // Get the new view controller using [segue destinationViewController].
  198. // Pass the selected object to the new view controller.
  199. }
  200. */
  201. - (void)helpDownScrollViewBePressed:(nonnull id)sender withIndex:(NSInteger)index {
  202. HLog(@"\n----点击了第个%ld按钮----",index);
  203. if (index == 0){
  204. ChangeLogoViewController *nextVC = [[ChangeLogoViewController alloc] init];
  205. [self.navigationController pushViewController:nextVC animated:YES];
  206. }else if (index == 1){/**/
  207. HidenMaskSetViewController *nextVC = [[HidenMaskSetViewController alloc] init];
  208. [self.navigationController pushViewController:nextVC animated:YES];
  209. }
  210. }
  211. #pragma mark - 懒加载
  212. - (UITableView *)tableView{
  213. if (!_tableView) {
  214. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStyleGrouped];
  215. _tableView.delegate = self;
  216. _tableView.dataSource = self;
  217. _tableView.showsVerticalScrollIndicator = NO;
  218. _tableView.showsHorizontalScrollIndicator = NO;
  219. _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  220. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  221. [_tableView setSeparatorColor:[UIColor clearColor]];
  222. [_tableView setBackgroundColor:[UIColor clearColor]];
  223. [_tableView setTableFooterView:[UIView new]];
  224. [_tableView setBounces:YES];
  225. if (@available(iOS 15.0, *)) {
  226. _tableView.sectionHeaderTopPadding = 0;
  227. }
  228. }
  229. return _tableView;
  230. }
  231. #pragma mark - 列表委托
  232. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  233. return 1;
  234. }
  235. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  236. return 7;
  237. }
  238. - (MineViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  239. NSInteger row = indexPath.row;
  240. static NSString *identifier = @"MineViewCell";
  241. MineViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  242. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  243. if (!cell){
  244. cell = [[MineViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  245. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  246. [cell setBackgroundColor:[UIColor clearColor]];
  247. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  248. }
  249. [cell.bgViewLayer removeFromSuperlayer];
  250. [cell.titleLabel2 setHidden:YES];
  251. [cell.rightImage setHidden:NO];
  252. [cell.lineView setHidden:NO];
  253. [cell.maskSwitch setHidden:YES];
  254. if (row == 0){
  255. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_invite_friend",nil)];
  256. [cell.titleLabel2 setText:NSLocalizedString(@"my_set_no_invite_friend_get_vip",nil)];
  257. [cell.mImageView setImage:[UIImage imageNamed:@"icon-yaoqing"]];
  258. [cell.titleLabel2 setHidden:NO];
  259. /*上圆角*/
  260. //设置部分圆角 贝塞尔曲线
  261. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  262. byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
  263. cornerRadii:CGSizeMake(8, 8)];
  264. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  265. maskLayer.frame = cell.cellBgView.bounds;
  266. maskLayer.path = maskPath.CGPath;
  267. cell.bgViewLayer = maskLayer;
  268. cell.cellBgView.layer.mask = cell.bgViewLayer;
  269. }else if (row == 1){
  270. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_fanzhuan_exit",nil)];
  271. [cell.mImageView setImage:[UIImage imageNamed:@"fanzhuan"]];
  272. [cell.rightImage setHidden:YES];
  273. [cell.maskSwitch setHidden:NO];
  274. }else if (row == 2){
  275. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_check_update",nil)];
  276. [cell.mImageView setImage:[UIImage imageNamed:@"app_update"]];
  277. }else if (row == 3){
  278. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_connect_kefu",nil)];
  279. [cell.mImageView setImage:[UIImage imageNamed:@"icon-kefu"]];
  280. }else if (row == 4){
  281. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_buy_recoder",nil)];
  282. [cell.mImageView setImage:[UIImage imageNamed:@"buy_recoder_icon"]];
  283. }else if (row == 5){/*重启空间*/
  284. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_restart_phone",nil)];
  285. [cell.mImageView setImage:[UIImage imageNamed:@"icon-gengxin"]];
  286. }else if (row == 6){
  287. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_logout",nil)];
  288. [cell.mImageView setImage:[UIImage imageNamed:@"icon-tuichu"]];
  289. [cell.rightImage setHidden:YES];
  290. /*下圆角*/
  291. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  292. byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
  293. cornerRadii:CGSizeMake(8, 8)];
  294. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  295. maskLayer.frame = cell.cellBgView.bounds;
  296. maskLayer.path = maskPath.CGPath;
  297. cell.bgViewLayer = maskLayer;
  298. cell.cellBgView.layer.mask = cell.bgViewLayer;
  299. [cell.lineView setHidden:YES];
  300. }
  301. return cell;
  302. }
  303. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  304. return 60;
  305. }
  306. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  307. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  308. NSInteger row = indexPath.row;
  309. if (0 == row){
  310. CustomerWebViewController *vc = [[CustomerWebViewController alloc] init];
  311. vc.needHidenNav = YES;
  312. NSDictionary *dictLogin = [[UseAccountManage shareInstance] getLoginInfo];
  313. if (dictLogin && [[dictLogin allKeys] containsObject:@"token"])
  314. {
  315. NSString *tokenStr = [dictLogin objectForKey:@"token"];
  316. NSString *url = [NSString stringWithFormat:@"http://192.168.11.32:11180/cloud/privacy/#/pages/invitation/index?token=%@&iosVersionNumber=%@", tokenStr,[iPhone appVersion]];
  317. vc.webUrl = url;
  318. [self.navigationController pushViewController:vc animated:YES];
  319. }
  320. }else if (1 == row){
  321. /*翻转退出*/
  322. }else if (2 == row){
  323. AboutViewController *vc = [[AboutViewController alloc] init];
  324. [self.navigationController pushViewController:vc animated:YES];
  325. }else if (3 == row){
  326. CustomerWebViewController *vc = [[CustomerWebViewController alloc] init];
  327. vc.titleStr = NSLocalizedString(@"my_set_no_app_kefu",nil);
  328. NSDictionary *dictLogin = [[UseAccountManage shareInstance] getLoginInfo];
  329. if (dictLogin && [[dictLogin allKeys] containsObject:@"token"])
  330. {
  331. NSString *tokenStr = [dictLogin objectForKey:@"token"];
  332. NSString *url = [NSString stringWithFormat:@"http://192.168.11.32:11180/cloud/privacy/#/pages/setup/online-customer-service?autoopen=true&token=%@", tokenStr];
  333. // if ([CloudService containsString:@"14.18.190.141:11180"]) { // 测试环境
  334. // url = [NSString stringWithFormat:@"http://testprivacy.phone.armclouding.com:11180/h5/customer-service?autoopen=true&token=%@", tokenStr];
  335. // }
  336. vc.webUrl = url;
  337. [self.navigationController pushViewController:vc animated:YES];
  338. }
  339. }
  340. else if (4 == row){/*购买记录*/
  341. /*跳入订单界面*/
  342. PayRecoderListViewController *nextVC = [[PayRecoderListViewController alloc] init];
  343. [self.navigationController pushViewController:nextVC animated:YES];
  344. }else if (5 == row){/*重启空间*/
  345. NSArray *phoneList = [UseAccountManage shareInstance].cloudPhoneListModel.diskInfo;
  346. if (!phoneList || phoneList.count == 0){
  347. [[iToast makeText:NSLocalizedString(@"my_set_no_restart_phone_tips_no_vip",nil)] show];
  348. return;
  349. }
  350. /*弹窗提示重启*/
  351. ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_restart_phone_tips",nil)
  352. msg:nil
  353. cancelTitle:NSLocalizedString(@"other_cancel",nil)
  354. okTitle:NSLocalizedString(@"my_set_no_restart_phone_btn_ok",nil)];
  355. nextVC.modalPresentationStyle = UIModalPresentationCustom;
  356. nextVC.delegate = self;
  357. [self presentViewController:nextVC animated:YES completion:^{
  358. nextVC.view.superview.backgroundColor = [UIColor clearColor];
  359. }];
  360. }else if (6 == row){/*退出登录*/
  361. [self.navigationController popToRootViewControllerAnimated:NO];
  362. [[UseAccountManage shareInstance] logout];
  363. }
  364. }
  365. - (void)okBtnClickPressed{
  366. /*重启云手机*/
  367. [self showNewIndicatorWithCanBack:YES canTouch:NO];
  368. CloudPhoneModel *model = [UseAccountManage shareInstance].cloudPhoneListModel.diskInfo.firstObject;
  369. [[UseAccountManage shareInstance] CommonGetWithCallBackCode:GetPhonereboot
  370. Parameters:@{@"userCardId":[NSNumber numberWithInteger:model.userCardId]}
  371. success:^(id _Nonnull responseObject) {
  372. HLog(@"%@", responseObject);
  373. [self removeNewIndicator];
  374. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  375. if (model.status && model.status.integerValue == 0) {
  376. if (model.msg.length > 0){
  377. [[iToast makeText:model.msg] show];
  378. }else{
  379. [[iToast makeText:NSLocalizedString(@"my_set_no_restart_phone_ok_tips",nil)] show];
  380. }
  381. }
  382. else
  383. {
  384. [[iToast makeText:model.msg] show];
  385. }
  386. } failure:^(NSError * _Nonnull error) {
  387. HLog(@"%@", error);
  388. [[iToast makeText:@"网络异常,请稍后重试!"] show];
  389. [self removeNewIndicator];
  390. }];
  391. }
  392. - (void)vipBtnPressed{
  393. /*跳转购买界面*/
  394. BuyVIPViewController *nextVC = [[BuyVIPViewController alloc] init];
  395. [self.navigationController pushViewController:nextVC animated:YES];
  396. }
  397. @end