CNLiveMineViewController.swift
22.1 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
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
//
// CNLiveMineViewController.swift
// metaCode
//
// Created by open on 2023/6/6.
//
import Foundation
import CNLiveShareToolKit
class CNLiveMineViewController : CNLiveBaseViewController, UITableViewDelegate, UITableViewDataSource{
let kCNLiveMinePlayHistoryCellIdentifier = "kCNLiveMinePlayHistoryCellIdentifier"
let kCNLiveMineMineOrderCellIdentifier = "kCNLiveMineMineOrderCellIdentifier"
let kCNLiveMineGiftCellIdentifier = "kCNLiveMineGiftCellIdentifier"
let kCNLiveMineOneViewCellIdentifier = "kCNLiveMineOneViewCellIdentifier"
let kCNLiveMineTwoViewCellIdentifier = "kCNLiveMineTwoViewCellIdentifier"
let kMineBodyThreeViewCellIdentifier = "kMineBodyThreeViewCellIdentifier"
lazy var tableView : UITableView = {
let tableView = UITableView(frame: .zero, style: .grouped)
tableView.dataSource = self
tableView.delegate = self
tableView.backgroundColor = .clear
tableView.tableFooterView = UIView.init()
tableView.separatorStyle = .none
tableView.register(MineBodyOneListViewCell.self, forCellReuseIdentifier: kCNLiveMineOneViewCellIdentifier)
tableView.register(MineBodyTwoListViewCell.self, forCellReuseIdentifier: kCNLiveMineTwoViewCellIdentifier)
tableView.register(MineBodyThreeViewCell.self, forCellReuseIdentifier: kMineBodyThreeViewCellIdentifier)
tableView.register(CNLiveMinePlayHistoryCell.self, forCellReuseIdentifier: kCNLiveMinePlayHistoryCellIdentifier)
tableView.register(CNLiveMineMineOrderCell.self, forCellReuseIdentifier: kCNLiveMineMineOrderCellIdentifier)
tableView.register(CNLiveMineGiftCell.self, forCellReuseIdentifier: kCNLiveMineGiftCellIdentifier)
return tableView
}()
lazy var mainView: UIImageView = {
let mainView = UIImageView.init()
mainView.backgroundColor = .clear
mainView.image = UIImage(named: "mine_header_icon_back")
mainView.contentMode = .scaleAspectFill
return mainView
}()
lazy var dataArray: NSMutableArray = {
let dataArray = NSMutableArray()
// dataArray.add([""])
let array1 : [Dictionary] = [["name":"播放记录","icon":"mine_list_icon_help_feedback"]]
dataArray.add(array1)
if metaAppDelegate.isGift{
let array0 : [Dictionary] = [["name":"送礼","icon":""]]
dataArray.add(array0)
}
let array01 : [Dictionary] = [["name":"已购内容","icon":"mine_list_icon_help_feedback"]]
dataArray.add(array01)
let array2 : [Dictionary] = [["name":"我的订单","icon":"mine_list_icon_help_feedback"]]
dataArray.add(array2)
// let array01 : [Dictionary] = [["name":"我的身份","icon":"mine_header_icon_identity"]]
// dataArray.add(array01)
// let array02 : [Dictionary] = [["name":"我的数字简历","icon":"mine_jianli"]]
// dataArray.add(array02)
// let array03 : [Dictionary] = [["name":"官方认证","icon":"mine_renzheng"]]
// dataArray.add(array03)
let array04 : [Dictionary] = [["name":"帮助与反馈","icon":"mine_list_icon_help_feedback"],
["name":"更多设置","icon":"mine_list_icon_set_more"]]
dataArray.add(array04)
let array05 : [Dictionary] = [["name":"订单列表","icon":"mine_list_icon_help_feedback"],
["name":"交易记录","icon":"mine_list_icon_help_feedback"],
["name":"新增优惠券","icon":"mine_list_icon_help_feedback"],
["name":"优惠券管理","icon":"mine_list_icon_help_feedback"],
["name":"抖音短视频","icon":"mine_list_icon_help_feedback"]]
// dataArray.add(array05)
return dataArray
}()
lazy var headerView: MineHeaderView = {
let headerView = MineHeaderView.init(frame: CGRect(x: 0, y: 0, width: KSreenWidth, height: 80))
return headerView
}()
var checkModel: MinePointCheckInModel!
var followModels:[CNLiveHomeFollowModel]?//播放记录
var giftModel:CNLiveHomePageHuBiLieGiftModel?//送礼分享model
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = HexColor("#f9f9f9")
setNeedsStatusBarAppearanceUpdate()
view.addSubview(mainView)
mainView.snp.makeConstraints { make in
make.left.top.right.equalToSuperview()
make.height.equalTo(KSreenHeight * 0.4)
}
view.addSubview(tableView)
tableView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
self.getHomePageFollowApi(sid: UserInfoManager.shared.userInfo.uid)//UserInfoManager.shared.userInfo.uid)
// NotificationCenter.default.addObserver(self, selector: #selector(StandAuthNotificationSuccessAction), name: Notification.Name.StandAuth.StandAuthNotificationSuccess, object: nil)
// NotificationCenter.default.addObserver(self, selector: #selector(StandAuthNotificationSuccessAction), name: Notification.Name.StandAuth.StandAuthSortNotificationResult, object: nil)
// NotificationCenter.default.addObserver(self, selector: #selector(loadDataWithPoint), name: Notification.Name.NetworkStatus.CNLiveNetworkStatusNotificationReachableViaWiFi, object: nil)
// NotificationCenter.default.addObserver(self, selector: #selector(loadDataWithPoint), name: Notification.Name.NetworkStatus.CNLiveNetworkStatusNotificationReachableViaWWAN, object: nil)
// StandAuthNotificationSuccessAction()
//登录成功通知
NotificationCenter.default.addObserver(self, selector: #selector(CNLiveLoginSuccessNotificationAction), name: Notification.Name.LoginManage.CNLiveLoginSuccessNotification, object: nil)
}
@objc func CNLiveLoginSuccessNotificationAction() {
//登录成功
self.headerView.loginBtn.isHidden = true
}
func loadGift(){
showLoading(message: "")
CNLiveHomePageViewModel.requestGetHomePageTopBannerGift{[weak self] result, status in
guard let self = self else { return }
hiddenLoading()
if status == .success{
let giftModel = result as! CNLiveHomePageHuBiLieGiftModel
self.giftModel = giftModel
self.tableView.reloadData()
}
}
}
func getHomePageFollowApi(sid:String){
CNLiveHomePageViewModel.requestGetMinePlayHistory(sid: sid, page: 1){[weak self] result, status in
guard let self = self else { return }
hiddenLoading()
if status == .success{
let followBaseMdl = result as! CNLiveHomeFollowListBaseModel
self.followModels = followBaseMdl.list
self.loadGift()
}else{
//没有
}
}
}
@objc public func loadDataWithPoint() {
CNLiveMineViewModel.requestWithCheckIn { [weak self] result, respStatue in
if respStatue == .success {
self?.checkModel = result as? MinePointCheckInModel
self?.tableView.reloadData()
} else {
self?.checkModel = MinePointCheckInModel.init()
self?.tableView.reloadData()
}
}
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
headerView.updateHeaderView()
tableView.reloadData()
// loadDataWithPoint()
delegate.window?.subviews.forEach({ view in
if view.tag >= 20000{
view.isHidden = false
}
})
}
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
let delegate = UIApplication.shared.delegate as! AppDelegate
/// 未认证-inputType17时弹窗背景图
lazy var alertBgImgView:UIImageView = {
let alertBgImgView:UIImageView = UIImageView()
alertBgImgView.tag = 20001
alertBgImgView.isUserInteractionEnabled = true
alertBgImgView.contentMode = .scaleAspectFit
alertBgImgView.backgroundColor = .white
return alertBgImgView
}()
lazy var agreeBtn: UIButton = {
let nextBtn = UIButton(type: .custom)
nextBtn.width = 285
nextBtn.height = 44
nextBtn.setTitle("同意协议 领取一下", for: .normal)
nextBtn.setTitleColor(.white, for: .normal)
nextBtn.layer.cornerRadius = 22
nextBtn.clipsToBounds = true
nextBtn.addTarget(self, action: #selector(agreeBtnAction), for: .touchUpInside)
nextBtn.backgroundColor = HexColor("#8E8BFB")
// fillCode
let bgLayer1 = CAGradientLayer()
bgLayer1.colors = [UIColor(red: 0.1, green: 0.38, blue: 1, alpha: 1).cgColor, UIColor(red: 0.56, green: 0.55, blue: 0.98, alpha: 1).cgColor]
bgLayer1.locations = [0, 1]
bgLayer1.frame = nextBtn.bounds
bgLayer1.startPoint = CGPoint(x: 0.5, y: 1)
bgLayer1.endPoint = CGPoint(x: 0, y: 0)
nextBtn.layer.addSublayer(bgLayer1)
return nextBtn
}()
lazy var xieyiLabel: UILabel = {
let label = UILabel()
let attrString = NSMutableAttributedString(string: "查看《元码数字简历服务协议》")
label.frame = CGRect(x: 0, y: 0, width: KSreenWidth, height: 20)
let attr1: [NSAttributedString.Key : Any] = [.font: Font_14,.foregroundColor: HexColor("#20252A")!]
attrString.addAttributes(attr1, range: NSRange(location: 0, length: 2))
let attr: [NSAttributedString.Key : Any] = [.font: Font_14,.foregroundColor: HexColor("#1961FE")!]
attrString.addAttributes(attr, range: NSRange(location: 2, length: attrString.length-2))
label.attributedText = attrString
label.textAlignment = .center
label.isUserInteractionEnabled = true
label.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(xieyiAction)))
return label
}()
// MARK: - 弹出数字简历协议alert
func showXieyiAlert(){
delegate.window?.addSubview(self.alertBgImgView)
alertBgImgView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.centerY.equalToSuperview()
make.width.equalToSuperview()
make.height.equalToSuperview()
}
self.alertBgImgView.image = UIImage(named: "mine_jianli_xieyiBg")
alertBgImgView.addSubview(self.agreeBtn)
self.agreeBtn.snp.makeConstraints { make in
make.bottom.equalToSuperview().offset(-50)
make.width.equalTo(285)
make.centerX.equalToSuperview()
make.height.equalTo(44)
}
alertBgImgView.addSubview(self.xieyiLabel)
self.xieyiLabel.snp.makeConstraints { make in
make.bottom.equalTo(self.agreeBtn.snp.top).offset(-10)
make.left.right.equalToSuperview()
make.height.equalTo(20)
}
}
@objc func xieyiAction(){
//查看数字简历协议
let webVC = CNWebViewController()
webVC.url = URL(string: "https://wjj.ys1.cnliveimg.com/term/ymRlsbyhxxcjxy.html")
self.navigationController?.pushViewController(webVC, animated: true)
delegate.window?.subviews.forEach({ view in
if view.tag >= 20000{
view.isHidden = true
}
})
}
@objc func agreeBtnAction(){
//同意协议按钮
delegate.window?.subviews.forEach({ view in
if view.tag >= 20000{
view.removeFromSuperview()
}
})
//本地存储已同意
UserDefaults.standard.set(true,forKey: "is_agree_shuzijianlixieyi")
//跳转数字简历页面
let vc = CNLiveDigitalResumeController()
self.navigationController?.pushViewController(vc, animated: true)
}
@objc func StandAuthNotificationSuccessAction() {
CNLiveMineViewModel.requestsGETAuthInfoList(page: 1) { [self] result, respStatue in
if respStatue == .success {
tableView.reloadData()
}
}
}
deinit {
NotificationCenter.default.removeObserver(self)
// NotificationCenter.default.removeObserver(self, name: Notification.Name.StandAuth.StandAuthNotificationSuccess, object: nil)
// NotificationCenter.default.removeObserver(self, name: Notification.Name.StandAuth.StandAuthSortNotificationResult, object: nil)
}
}
extension CNLiveMineViewController {
func numberOfSections(in tableView: UITableView) -> Int {
return dataArray.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return (dataArray[section] as AnyObject).count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// if indexPath.section == 0 {//我的身份
// let cell = tableView.dequeueReusableCell(withIdentifier: kMineBodyThreeViewCellIdentifier) as! MineBodyThreeViewCell
// cell.checkModel = self.checkModel
// return cell
// }
// if indexPath.section == 1 {
// let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveMineOneViewCellIdentifier) as! MineBodyOneListViewCell
// cell.reloadWithData()
// return cell
// }
let array = dataArray[indexPath.section]
let sub_dict = (array as! Array<Any>)[indexPath.row] as! Dictionary<String, Any>
let name = sub_dict["name"] as! String
if name == "播放记录"{
let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveMinePlayHistoryCellIdentifier) as! CNLiveMinePlayHistoryCell
if let models = self.followModels{
cell.followModels = models
}
return cell
}else if name == "送礼"{
let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveMineGiftCellIdentifier) as! CNLiveMineGiftCell
cell.giftModel = self.giftModel
return cell
}else if name == "已购内容"{
let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveMineTwoViewCellIdentifier) as! MineBodyTwoListViewCell
let array = dataArray[indexPath.section]
let sub_dict = (array as! Array<Any>)[indexPath.row] as! Dictionary<String, Any>
cell.setupWithDataSource(show_type: .feedback,dict: sub_dict)
return cell
}else if name == "我的订单"{
let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveMineMineOrderCellIdentifier) as! CNLiveMineMineOrderCell
return cell
}else if name == "帮助与反馈"{
let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveMineTwoViewCellIdentifier) as! MineBodyTwoListViewCell
let array = dataArray[indexPath.section]
let sub_dict = (array as! Array<Any>)[indexPath.row] as! Dictionary<String, Any>
cell.setupWithDataSource(show_type: .feedback,dict: sub_dict)
return cell
}else if name == "更多设置"{
let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveMineTwoViewCellIdentifier) as! MineBodyTwoListViewCell
let array = dataArray[indexPath.section]
let sub_dict = (array as! Array<Any>)[indexPath.row] as! Dictionary<String, Any>
cell.setupWithDataSource(show_type: .feedback,dict: sub_dict)
return cell
}else{
}
return UITableViewCell()
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let array = dataArray[indexPath.section]
let sub_dict = (array as! Array<Any>)[indexPath.row] as! Dictionary<String, Any>
let name = sub_dict["name"] as! String
if name == "播放记录"{
if let models = self.followModels{
if models.count > 0{
return 260
}else{
return 100
}
}
}else if name == "送礼"{
return CGFloat(Float(CNLiveHomeADH))
}else if name == "已购内容"{
return 60
}else if name == "我的订单"{
return 218+5
}else if name == "帮助与反馈"{
return 60
}else if name == "更多设置"{
return 60
}else{
}
// if indexPath.section == 0 {
// return 100
// }
// if indexPath.section == 1 {
// return 120
// }
return 60
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let array = dataArray[indexPath.section]
let sub_dict = (array as! Array<Any>)[indexPath.row] as! Dictionary<String, Any>
let name = sub_dict["name"] as! String
if name == "播放记录"{
}else if name == "送礼"{
}else if name == "已购内容"{
//已购内容
if metaAppDelegate.isLogin{
let webVC = CNWebViewController()
webVC.url = URL(string: "http://wjjh5.cnlive.com/cnYjzg.html?id=6&channelName=yjzg&isShowTitle=true")
self.navigationController?.pushViewController(webVC, animated: true)
}else{
metaAppDelegate.pushLoginVC()
}
}else if name == "我的订单"{
}else if name == "帮助与反馈"{
self.navigationController?.pushViewController(CNLiveHelpFeedBackViewController.init(), animated: true)
}else if name == "更多设置"{
self.navigationController?.pushViewController(CNLiveTypeFeedBackViewController.init(show_type: .setting), animated: true)
}else{
}
// if indexPath.section == 0 {
// self.navigationController?.pushViewController(CNLiveMineQuestViewController.init(checkModel: checkModel), animated: true)
// }
// if indexPath.section == 1 {
// //我的身份跳转 我的数字资产
// navigationViewController().pushViewController(CNLiveDigitalAssetsController(), animated: true)
// }
// if indexPath.section == 2 {
// //我的数字简历
//
// if UserInfoManager.shared.userInfo.userMsgUsers?.verifyUsers.count ?? 0 > 0{
// //实名认证过
// let is_agree = UserDefaults.standard.bool(forKey: "is_agree_shuzijianlixieyi")
// if is_agree{
// //跳转数字简历页面
// let vc = CNLiveDigitalResumeController()
// self.navigationController?.pushViewController(vc, animated: true)
// }else{
// self.showXieyiAlert()
// }
//
// }else{
// //未实名认证->实名认证
// let vc = CNLiveRealNameAuthController()
// vc.isResume = true
// self.navigationController?.pushViewController(vc, animated: true)
// }
//
//
// }
// if indexPath.section == 3 {
// //官方认证--身份大库
// let vc = CNLiveIdentityRepositoryController()
// vc.channelId = ""
// vc.type = "1"
// navigationViewController().pushViewController(vc, animated: true)
// }
// if indexPath.section == 0 {
// //已购内容
// let webVC = CNWebViewController()
// webVC.url = URL(string: "http://wjjh5.cnlive.com/cnYjzg.html?id=6&channelName=yjzg&isShowTitle=true")
// self.navigationController?.pushViewController(webVC, animated: true)
// }
// if indexPath.section == 1 && indexPath.row == 0 {
//
// self.navigationController?.pushViewController(CNLiveHelpFeedBackViewController.init(), animated: true)
// }
// if indexPath.section == 1 && indexPath.row == 1 {
// self.navigationController?.pushViewController(CNLiveTypeFeedBackViewController.init(show_type: .setting), animated: true)
// }
// if indexPath.section == 2 {
// if indexPath.row == 0 {
//// self.navigationController?.pushViewController(CNLiveShopOrderViewController.init(), animated: true)
//// StandSortManager.removeStandSort()
//// CNLiveShareImageManager.pushWeChatMiniProgrem(withMiniAppId: "gh_234d4ed615a3", path: "page/login_hint/login_hint", extMsg: "", extDic: [:])
// }
// if indexPath.row == 1 {
// self.navigationController?.pushViewController(CNLiveShopTransViewController.init(), animated: true)
// }
// if indexPath.row == 2 {
// self.navigationController?.pushViewController(CNLiveShopCouponViewController.init(), animated: true)
// }
// if indexPath.row == 3 {
// self.navigationController?.pushViewController(CNLiveShopCouponManagerViewController.init(), animated: true)
// }
// if indexPath.row == 4 {
// self.navigationController?.pushViewController(CNLiveShortVideoViewController.init(aid: "cms_ugc_10504077_1704334474587"), animated: true)
// }
// }
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if section == 0 {
return 150
}
return 0.001
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if section == 0 {
return headerView
}
return UIView.init()
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let offsetY = scrollView.contentOffset.y
mainView.snp.updateConstraints { make in
make.left.top.right.equalToSuperview()
make.height.equalTo(offsetY < 0 ? (KSreenHeight * 0.4) + abs(offsetY) : KSreenHeight * 0.4)
}
}
}