CNLiveMineViewController.swift
15.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
//
// CNLiveMineViewController.swift
// metaCode
//
// Created by open on 2023/6/6.
//
import Foundation
import CNLiveShareToolKit
class CNLiveMineViewController : CNLiveBaseViewController, UITableViewDelegate, UITableViewDataSource{
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)
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 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!
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()
}
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()
}
@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, 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 cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveMineTwoViewCellIdentifier) as! MineBodyTwoListViewCell
let array = dataArray[indexPath.section]
let sub_dict = (array as! Array<Any>)[indexPath.row]
cell.setupWithDataSource(show_type: .feedback,dict: sub_dict as! Dictionary<String, Any>)
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.section == 0 {
return 100
}
if indexPath.section == 1 {
return 120
}
return 60
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
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 == 3 && indexPath.row == 0 {
self.navigationController?.pushViewController(CNLiveHelpFeedBackViewController.init(), animated: true)
}
if indexPath.section == 3 && indexPath.row == 1 {
self.navigationController?.pushViewController(CNLiveTypeFeedBackViewController.init(show_type: .setting), animated: true)
}
if indexPath.section == 4 {
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)
}
}
}