You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
231 lines
8.9 KiB
231 lines
8.9 KiB
1 year ago
|
//
|
||
|
// MoreViewController.m
|
||
|
// watch
|
||
|
//
|
||
|
// Created by xTT on 2017/7/3.
|
||
|
// Copyright © 2017年 xTT. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "MyViewController.h"
|
||
|
#import "WatchHomeViewController.h"
|
||
|
#import "AppDelegate.h"
|
||
|
#import "messageHearderCell.h"
|
||
|
#import "WebViewController.h"
|
||
|
#import "MessageViewController.h"
|
||
|
#import "DPClearCacheTool.h"
|
||
|
#import "MyTableViewCollectionCell.h"
|
||
|
#import "MessageTitle.h"
|
||
|
#import "BRManager.h"
|
||
|
#import "EditMeViewController.h"
|
||
|
|
||
|
#import "CommonTableView.h"
|
||
|
#import "AboutViewController.h"
|
||
|
#import "CommProViewController.h"
|
||
|
#import <UIButton+WebCache.h>
|
||
|
#import "CommonPopView.h"
|
||
|
|
||
|
@interface MyViewController()
|
||
|
|
||
|
@property (strong, nonatomic)NSArray * iconImageArr;
|
||
|
@property (strong, nonatomic)NSArray * iconTitleArr;
|
||
|
|
||
|
@property (nonatomic ,strong) CommonTableView *myTableView;
|
||
|
|
||
|
@property (nonatomic ,strong) UIView *headerView;
|
||
|
|
||
|
@property (nonatomic ,weak) UIButton *iconImg;
|
||
|
|
||
|
@property (nonatomic ,weak) UILabel *nameLabel;
|
||
|
|
||
|
@property (nonatomic ,weak) UILabel *idLabel;
|
||
|
|
||
|
/// 在线客服URL
|
||
|
@property (nonatomic ,strong) NSString *ServiceUrl;
|
||
|
|
||
|
@end
|
||
|
|
||
|
@implementation MyViewController
|
||
|
|
||
|
- (void)viewDidLoad {
|
||
|
[super viewDidLoad];
|
||
|
// Do any additional setup after loading the view.
|
||
|
self.zx_navBarBackgroundColor = KKClearColor;
|
||
|
UIImageView *topImg = [[UIImageView alloc] init];
|
||
|
topImg.image = ImageName_(@"comm_bg_img_");
|
||
|
[self.view addSubview:topImg];
|
||
|
[topImg mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.top.equalTo(self.view);
|
||
|
make.left.right.equalTo(self.view);
|
||
|
make.height.mas_equalTo(Adapted(topImg.image.size.height));
|
||
|
}];
|
||
|
|
||
|
[self.view addSubview:self.myTableView];
|
||
|
[self.myTableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.top.equalTo(self.view);
|
||
|
make.left.right.equalTo(self.view).inset(16);
|
||
|
make.bottom.equalTo(self.view.mas_bottom);
|
||
|
}];
|
||
|
[self GetServiceUrl];
|
||
|
|
||
|
}
|
||
|
|
||
|
-(void)viewWillAppear:(BOOL)animated
|
||
|
{
|
||
|
self.iconTitleArr = @[@"清除缓存",@"常见问题",@"在线客服",@"关于我们"];
|
||
|
self.iconImageArr = @[@"icon_clear_the_cache",@"icon_common_problems",@"my_customer_icon",@"icon_about_us"];
|
||
|
self.myTableView.cellRow = self.iconImageArr.count;
|
||
|
[self updatamessage];
|
||
|
[self.myTableView reloadData];
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
- (CommonTableView *)myTableView
|
||
|
{
|
||
|
if (!_myTableView)
|
||
|
{
|
||
|
WEAKSELF
|
||
|
_myTableView = [[CommonTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain cellHeight:55 cellRow:self.iconImageArr.count isAdaptive:NO isLine:YES commonCell:MyTableViewCollectionCell.class createCell:^(ZZTableViewCell * _Nonnull cells, NSIndexPath * _Nonnull indexPath) {
|
||
|
|
||
|
MyTableViewCollectionCell *cell = (MyTableViewCollectionCell *)cells;
|
||
|
[UICommon tableView:self->_myTableView willDisplayCell:cell forRowAtIndexPath:indexPath cellCoutn:self.iconImageArr.count sizeH:0];
|
||
|
if (indexPath.row == self.iconImageArr.count-1)
|
||
|
[UICommon setExtraCellLineHidden:cell];
|
||
|
cell.imageStr = self.iconImageArr[indexPath.row];
|
||
|
cell.titleStr = self.iconTitleArr[indexPath.row];
|
||
|
|
||
|
|
||
|
} selectedCell:^(UITableView * _Nonnull tableView, NSIndexPath * _Nonnull indexPath) {
|
||
|
|
||
|
MyTableViewCollectionCell * cell = (MyTableViewCollectionCell *)[tableView cellForRowAtIndexPath:indexPath];//即为要得到的cell
|
||
|
NSLog(@"%@",cell.titleLabel.text);
|
||
|
NSString *title = cell.titleLabel.text;
|
||
|
if ([title isEqualToString:@"清除缓存"])
|
||
|
{
|
||
|
CommonPopView *popView = [CommonPopView new];
|
||
|
[popView subPopView:popViewType_binding PopTitle:@"清除缓存" PopText:@"您确定清空缓存吗?" okTouchBlock:^{
|
||
|
[DPClearCacheTool clearCaches];
|
||
|
[weakSelf.myTableView reloadData];
|
||
|
}];
|
||
|
}
|
||
|
else if ([title isEqualToString:@"常见问题"])
|
||
|
{
|
||
|
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
|
||
|
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"CommProViewController"];
|
||
|
[weakSelf.navigationController pushViewController:vc animated:YES];
|
||
|
}
|
||
|
else if ([title isEqualToString:@"在线客服"])
|
||
|
{
|
||
|
WebViewController *webVC = [WebViewController new];
|
||
|
webVC.title = @"在线客服";
|
||
|
webVC.url = self.ServiceUrl;
|
||
|
[self.navigationController pushViewController:webVC animated:YES];
|
||
|
}
|
||
|
else if ([title isEqualToString:@"关于我们"])
|
||
|
{
|
||
|
// AboutViewController *vc = [[AboutViewController alloc] init];
|
||
|
// [weakSelf.navigationController pushViewController:vc animated:YES];
|
||
|
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
|
||
|
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"AboutViewController"];
|
||
|
[weakSelf.navigationController pushViewController:vc animated:YES];
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
} DidscrollView:^(UIScrollView * _Nonnull scrollView) {
|
||
|
|
||
|
}];
|
||
|
_myTableView.tableHeaderView = self.headerView;
|
||
|
_myTableView.tableHeaderView.height = iPhoneX_NavHeight + 160;
|
||
|
_myTableView.backgroundColor = KKClearColor;
|
||
|
[UICommon setTavleViewlink:_myTableView distance:15];
|
||
|
|
||
|
}
|
||
|
return _myTableView;
|
||
|
}
|
||
|
|
||
|
|
||
|
- (UIView *)headerView
|
||
|
{
|
||
|
if (!_headerView)
|
||
|
{
|
||
|
_headerView = [UIView new];
|
||
|
_headerView.frame = CGRectMake(0, 0, ScreenWidth, iPhoneX_NavHeight + 160);
|
||
|
_headerView.backgroundColor = KKClearColor;
|
||
|
|
||
|
|
||
|
UIButton *iconImg = [UICommon ui_buttonSimple:CGRectZero font:Font_(0) normalColor:KKWhiteColorColor normalText:@"" click:^(id x) {
|
||
|
EditMeViewController *vc = (EditMeViewController *)[UICommon PusXibViewController:[EditMeViewController new] :@"EditMeViewController"];
|
||
|
|
||
|
}];
|
||
|
iconImg.layer.borderWidth = 1.5;
|
||
|
iconImg.layer.borderColor = KKWhiteColorColor.CGColor;
|
||
|
iconImg.layer.cornerRadius = 40;
|
||
|
iconImg.layer.masksToBounds = YES;
|
||
|
[iconImg sd_setImageWithURL:[NSURL URLWithString:cUser.avator] forState:0
|
||
|
placeholderImage:[myHelper getImageWithName:@"默认用户头像"]];
|
||
|
self.iconImg = iconImg;
|
||
|
[_headerView addSubview:iconImg];
|
||
|
[iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.top.equalTo(_headerView).offset(iPhoneX_NavHeight);
|
||
|
make.centerX.equalTo(_headerView);
|
||
|
make.size.mas_equalTo(CGSizeMake(80, 80));
|
||
|
}];
|
||
|
|
||
|
/// 昵称
|
||
|
UILabel *nameLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:FontBold_(18) textColor:KKTextBlackColor text:cUser.name Radius:0];
|
||
|
if (cUser.name.length == 0)
|
||
|
nameLabel.text = @"未设置昵称";
|
||
|
self.nameLabel = nameLabel;
|
||
|
[_headerView addSubview:nameLabel];
|
||
|
[nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.centerX.equalTo(_headerView);
|
||
|
make.top.equalTo(iconImg.mas_bottom).offset(15);
|
||
|
}];
|
||
|
|
||
|
UILabel *idLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentLeft font:Font_(16) textColor:KKGrey102 text:@"" Radius:0];
|
||
|
idLabel.text = [NSString stringWithFormat:@"ID:%@",cUser.id];
|
||
|
self.idLabel = idLabel;
|
||
|
[_headerView addSubview:idLabel];
|
||
|
[idLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.centerX.equalTo(_headerView);
|
||
|
make.top.equalTo(nameLabel.mas_bottom).offset(5);
|
||
|
}];
|
||
|
|
||
|
UIButton *editImg = [UICommon ui_buttonSimple:CGRectZero font:0 normalColor:KKWhiteColorColor normalText:@"" click:^(id x) {
|
||
|
[UICommon PusXibViewController:[EditMeViewController new] :@"EditMeViewController"];
|
||
|
}];
|
||
|
[editImg setImage:ImageName_(@"my_edit_icon") forState:0];
|
||
|
[_headerView addSubview:editImg];
|
||
|
[editImg mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.left.equalTo(nameLabel.mas_right).offset(5);
|
||
|
make.centerY.equalTo(nameLabel);
|
||
|
make.size.mas_equalTo(editImg.currentImage.size);
|
||
|
}];
|
||
|
|
||
|
}
|
||
|
return _headerView;
|
||
|
}
|
||
|
|
||
|
#pragma mark 获取在线客服
|
||
|
- (void)GetServiceUrl
|
||
|
{
|
||
|
[cUser.cDevice getZuoYeBangServiceSuccess:^(id responseObject) {
|
||
|
self.ServiceUrl = responseObject[@"url"];
|
||
|
|
||
|
} failure:^(id faiObject) {
|
||
|
|
||
|
}];
|
||
|
}
|
||
|
|
||
|
|
||
|
- (void)updatamessage
|
||
|
{
|
||
|
[self.iconImg sd_setImageWithURL:[NSURL URLWithString:cUser.avator] forState:0
|
||
|
placeholderImage:[myHelper getImageWithName:@"默认用户头像"]];
|
||
|
self.idLabel.text = [NSString stringWithFormat:@"ID:%@",cUser.id];
|
||
|
self.nameLabel.text = cUser.name;
|
||
|
}
|
||
|
|
||
|
@end
|