CNMineAccountManageController.m
18.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
//
// CNMineAccountManageController.m
// CNLiveNetAdd
//
// Created by cnliveJunBo on 2018/3/27.
// Copyright © 2018年 cnlive. All rights reserved.
//
#import "CNMineAccountManageController.h"
#import "CNMineSettingCell.h"
#import "CNMySettingListModel.h"
#import "CNMineClearMemoryCell.h"
#import "CNMineChangePhoneNumController.h"
#import "CNAboutNetAddImgCell.h"
#import "CNMinePresent.h"
// AppStore中AppID用于跳转AppStore下载/评分
#define AppStoreAppId @"1337575478"
static NSString *accountCellId = @"accountCellId";
static NSString *clearMemoryCellId = @"clearMemoryCellId";
static NSString *aboutNetAddImgCellId = @"aboutNetAddImgCellId";
@interface CNMineAccountManageController ()<UITableViewDelegate, UITableViewDataSource>{
}
@property (nonatomic, assign) SettingListType type;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) UIView *footerView;
@property (nonatomic, strong) NSArray <CNMySettingListModel*>*dataArray;
@end
@implementation CNMineAccountManageController
- (instancetype)initWithType:(SettingListType)type
{
self = [super init];
if (self) {
_type = type;
}
return self;
}
- (void)loadData {
NSMutableArray *arrayM = [NSMutableArray array];
switch (_type) {
case SettingTypeAccount:
{
arrayM = [@[
@{
@"title":@"更换手机号",
@"image":@"grzx_shouji",
@"rowHeight":@55,
@"lineHeight":@10,
@"content":@"3700000000",
@"cellType":@32
}
] mutableCopy];
}
break;
case SettingTypeMessage:
{
arrayM = [@[
@{
@"title":@"有新消息时进行通知",
@"image":@"switch",
@"rowHeight":@55,
@"lineHeight":@10,
@"cellType":@33
},
@{
@"title":@"消息免打扰设置",
@"image":@"",
@"rowHeight":@55,
@"lineHeight":@10,
@"cellType":@33
}
] mutableCopy];
}
break;
case SettingTypeHelp:
{
arrayM = [@[
@{
@"title":[NSString stringWithFormat:@"%@使用手册",DisplayName],
@"image":@"",
@"rowHeight":@55,
@"lineHeight":@10,
@"cellType":@30
},
@{
@"title":@"达人经营指南",
@"image":@"",
@"rowHeight":@55,
@"lineHeight":@10,
@"cellType":@30
},
@{
@"title":@"产品建议",
@"image":@"",
@"rowHeight":@46,
@"lineHeight":@1,
@"cellType":@30
},
@{
@"title":@"故障反馈",
@"image":@"",
@"rowHeight":@55,
@"lineHeight":@10,
@"cellType":@30
}
] mutableCopy];
}
break;
// case SettingTypeClear:
// {
// arrayM = [@[
// @{
// @"title":@"0.0",
// @"rowHeight":@190,
// @"lineHeight":@10,
// @"leftAndRight":@10,
// @"content":@"7"
// }
// ] mutableCopy];
// }
// break;
case SettingTypeAbout:
{
arrayM = [@[
@{
@"title":@"",
@"rowHeight":@154,
@"lineHeight":@0,
@"cellType":@""
},
@{
@"title":@"给软件评分",
@"rowHeight":@45,
@"lineHeight":@0,
@"cellType":@30
},
@{
@"title":@"应用简介",
@"rowHeight":@55,
@"lineHeight":@10,
@"cellType":@30
},
@{
@"title":@"隐私政策协议",
@"rowHeight":@46,
@"lineHeight":@1,
@"cellType":@30
},
@{
@"title":@"软件许可及服务协议",
@"rowHeight":@46,
@"lineHeight":@1,
@"cellType":@30
},
@{
@"title":@"版权信息",
@"rowHeight":@46,
@"lineHeight":@1,
@"cellType":@30
},
@{
@"title":@"资质信息",
@"rowHeight":@46,
@"lineHeight":@1,
@"cellType":@30
},
@{
@"title":@"当前版本",
@"rowHeight":@46,
@"lineHeight":@1,
@"cellType":@39
},
@{
@"title":@"联系我们",
@"rowHeight":@45,
@"lineHeight":@1,
@"cellType":@30
},
@{
@"title":@"投诉",
@"rowHeight":@45,
@"lineHeight":@1,
@"cellType":@30
}
] mutableCopy];
}
break;
default:
break;
}
NSMutableArray *modelArray = [CNMySettingListModel mj_objectArrayWithKeyValuesArray:arrayM];
self.dataArray = modelArray.copy;
[self.tableView reloadData];
}
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.dataArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// if (_type == SettingTypeClear) {
// MJWeakSelf
// CNMineClearMemoryCell *cell = [tableView dequeueReusableCellWithIdentifier:clearMemoryCellId forIndexPath:indexPath];
// cell.model = self.dataArray[indexPath.row];
// cell.selectionStyle = UITableViewCellSelectionStyleNone;
//// weakself
// cell.clearBlock = ^(){
// //这里是清除已下载视频的清除方法
// [[CNFirendsVideoDownLoadManager manager] removeDownLoadSourceAllFile];
//
//// [[CNGroupListAvaterUtil cacheAvator] removeAllObjects];
// // 清除缓存
//// [[NSURLCache sharedURLCache] removeAllCachedResponses];
//
// //好友和达人头像也存在SD,暂时不能清除
// [[SDImageCache sharedImageCache] clearMemory];
// [[SDImageCache sharedImageCache] clearDiskOnCompletion:^{
// [weakSelf.tableView reloadData];
// }];
// };
// return cell;
//
// } else
if (_type == SettingTypeAbout && indexPath.row==0) { //关于网++ 图片
CNAboutNetAddImgCell *cell = [tableView dequeueReusableCellWithIdentifier:aboutNetAddImgCellId forIndexPath:indexPath];
cell.userInteractionEnabled = NO;
return cell;
}
else {
CNMineSettingCell *cell = [tableView dequeueReusableCellWithIdentifier:accountCellId forIndexPath:indexPath];
cell.model = self.dataArray[indexPath.row];
// 解决cell重用
cell.userInteractionEnabled = YES;
if (_type == SettingTypeAbout && indexPath.row==7) { //当前版本 不可点击
cell.userInteractionEnabled = NO;
}
if (_type==SettingTypeMessage && indexPath.row == 0) {
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
return cell;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return self.dataArray[indexPath.row].rowHeight*RATIO;
}
#pragma mark -
#pragma mark - UITableViewDelegate !
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self.tableView qmui_clearsSelection];
switch (_type) {
case SettingTypeAccount:
{
CNMineChangePhoneNumController *cpnVC = [[CNMineChangePhoneNumController alloc] init];
[[BaseAppDelegate sharedAppDelegate] pushViewController:cpnVC withBackTitle:@" "];
}
break;
case SettingTypeMessage:
{
}
break;
case SettingTypeHelp:
{
}
break;
case SettingTypeAbout:
{
if (indexPath.row == 1) { //评分
// 应用地址
NSString *appStr = [NSString stringWithFormat:@"https://itunes.apple.com/app/apple-store/id%@?ct=web&mt=8",AppStoreAppId];
if (@available(iOS 10.0, *)) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:appStr] options:@{} completionHandler:nil];
} else {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:appStr]];
}
return;
// 评分页面地址
// @"385242275" 互动电视 测试使用
NSString *scoreStr = [NSString stringWithFormat:@"https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=%@&pageNumber=0&sortOrdering=2&type=Purple+Software&mt=8",AppStoreAppId];
//目前苹果为iOS10开放了一个key:UIApplicationOpenURLOptionUniversalLinksOnly但亲测无效
//目前使用的是这个key:UIApplicationOpenURLOptionsSourceApplicationKey
if ( @available(iOS 10 , * )) {
NSDictionary *options = @{ UIApplicationOpenURLOptionsSourceApplicationKey:@(YES) };
// BOOL can = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:scoreStr]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:scoreStr] options:options completionHandler:^(BOOL success) {
NSLog(@"已经进入 App Store 页面了");
}];
} else {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:appStr]];
}
}
else if (indexPath.row == 2) { //应用简介
[CNLiveCMineService pushCMineIWebVCParam:@{@"path":@"yyjj",@"urlStr":@"/newCpjj.html"} CurrentVC:self];
}
else if (indexPath.row == 3) { //隐私政策协议
[CNLiveCMineService pushCMineIWebVCParam:@{@"path":@"yszc",@"urlStr":@"/term_xieyi5.html"} CurrentVC:self];
}
else if (indexPath.row == 4) { //软件许可
[CNLiveCMineService pushCMineIWebVCParam:@{@"path":@"rjxkxy",@"urlStr":@"/newRjxkfw_xieyi.html"} CurrentVC:self];
}
else if (indexPath.row == 5) { //版权信息
[CNLiveCMineService pushCMineIWebVCParam:@{@"path":@"bqxx",@"urlStr":@"/sdk.html"} CurrentVC:self];
}
else if (indexPath.row == 6) { //资质信息
[CNMinePresent getAgreementH5WithType:CNAgreementEnterpriseQualification success:^(NSString *h5, NSString *title) {
[[CNLiveCMineService shareMineProtocol] pushCMineContentForCMainPlatWithType:1 param:@{@"title":title,@"urlStr":h5} contentVC:self ];
} failure:^(NSError *error) {
[QMUITips showError:error.localizedDescription inView:self.view hideAfterDelay:1.5];
}];
}
else if (indexPath.row == 8) { //联系我们
NSString *phone = [[NSUserDefaults standardUserDefaults] objectForKey:@"wjjCommonPhone"];
if (!phone) {
phone = @"010-65832485";
}
NSString *messageStr = [NSString stringWithFormat:@"您确定要拨打%@吗?",phone];
UIAlertController *actionAlert = [UIAlertController alertControllerWithTitle:@"联系我们" message:messageStr preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}];
UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSMutableString *str = [[NSMutableString alloc] initWithFormat:@"telprompt://%@",phone];
if (@available(iOS 10.0, *)) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str] options:@{} completionHandler:nil];
} else {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}
}];
[actionAlert addAction:action1];
[actionAlert addAction:action2];
[self presentViewController:actionAlert animated:YES completion:nil];
}
else if (indexPath.row == 9) { //投诉
[[CNLiveCMineService shareMineProtocol] pushCMineContentForCMainPlatWithType:6 param:@{} contentVC:self ];
}
}
break;
default:
break;
}
}
#pragma mark - setupUI !
- (void)initSubviews
{
[super initSubviews];
[self loadData];
[self.view addSubview:self.tableView];
}
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.equalTo(self.view);
make.top.equalTo(self.view).offset(kNavigationBarHeight);
}];
}
#pragma mark - SubViews !
- (UITableView *)tableView {
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_tableView.backgroundColor = RGB(242, 242, 242);
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.rowHeight = 45;
_tableView.showsVerticalScrollIndicator = NO;
_tableView.showsHorizontalScrollIndicator = NO;
[_tableView registerClass:[CNMineSettingCell class] forCellReuseIdentifier:accountCellId];
[_tableView registerClass:[CNMineClearMemoryCell class] forCellReuseIdentifier:clearMemoryCellId];
[_tableView registerClass:[CNAboutNetAddImgCell class] forCellReuseIdentifier:aboutNetAddImgCellId];
if (_type == SettingTypeAbout) {
_tableView.tableFooterView = self.footerView;
}
}
return _tableView;
}
- (UIView *)footerView {
if (!_footerView) {
_footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 150)];
_footerView.backgroundColor = [UIColor clearColor];
UILabel *titleLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 50, KScreenWidth, 15)];
titleLab.textColor = KTextBlackColor;
titleLab.font = [UIFont systemFontOfSize:12.0f];
titleLab.text = @"版权信息";
titleLab.textAlignment = NSTextAlignmentCenter;
[_footerView addSubview:titleLab];
UILabel *subTitleLab = [[UILabel alloc] initWithFrame:CGRectMake(0, titleLab.bottom+18, KScreenWidth, 15)];
subTitleLab.textColor = KTextBlackColor;
subTitleLab.font = [UIFont systemFontOfSize:12.0f];
subTitleLab.text = @"北京中投视讯文化传媒股份有限公司版权所有";
subTitleLab.textAlignment = NSTextAlignmentCenter;
[_footerView addSubview:subTitleLab];
}
return _footerView;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
switch (_type) {
case SettingTypeAccount:
self.title = @"更换手机号";
break;
case SettingTypeMessage:
self.title = @"消息提醒";
break;
case SettingTypeHelp:
self.title = @"帮助与反馈";
break;
// case SettingTypeClear:
// self.title = @"存储空间";
// break;
case SettingTypeAbout:
{
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
NSString *appName = [infoDictionary objectForKey:@"CFBundleDisplayName"];
self.title = [NSString stringWithFormat:@"关于%@",appName];
}
break;
default:
break;
}
self.view.backgroundColor = [UIColor whiteColor];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end