Commit 8be0f8c1539b3b7d599d0fb53709240a787b4010
Merge branch 'master' of http://bj.gitlab.cnlive.com/ios-team/CNLiveMateCode
Showing
13 changed files
with
246 additions
and
21 deletions
metaCode/Classes/Main/MinePage/Controller/CNLiveMineAuthFormViewController.swift
| ... | ... | @@ -7,14 +7,17 @@ |
| 7 | 7 | |
| 8 | 8 | import Foundation |
| 9 | 9 | import UIKit |
| 10 | +import EmptyDataSet_Swift | |
| 10 | 11 | |
| 11 | -class CNLiveMineAuthFormViewController: CNLiveBaseViewController, UITableViewDelegate, UITableViewDataSource { | |
| 12 | +class CNLiveMineAuthFormViewController: CNLiveBaseViewController, UITableViewDelegate, UITableViewDataSource,EmptyDataSetSource, EmptyDataSetDelegate { | |
| 12 | 13 | |
| 13 | 14 | let kMIneBodyAuthFormViewCellIdentifier = "kMIneBodyAuthFormViewCellIdentifier" |
| 14 | 15 | lazy var tableView: UITableView = { |
| 15 | 16 | let tableView = UITableView.init(frame: .zero, style: .grouped) |
| 16 | 17 | tableView.delegate = self |
| 17 | 18 | tableView.dataSource = self |
| 19 | + tableView.emptyDataSetSource = self | |
| 20 | + tableView.emptyDataSetDelegate = self | |
| 18 | 21 | tableView.backgroundColor = .clear |
| 19 | 22 | tableView.separatorStyle = .none |
| 20 | 23 | tableView.showsVerticalScrollIndicator = false |
| ... | ... | @@ -23,6 +26,28 @@ class CNLiveMineAuthFormViewController: CNLiveBaseViewController, UITableViewDel |
| 23 | 26 | return tableView |
| 24 | 27 | }() |
| 25 | 28 | |
| 29 | + lazy var dataArray: NSMutableArray = { | |
| 30 | + let array = NSMutableArray.init() | |
| 31 | + if _listModel.userAuth { | |
| 32 | + array.add(["back":"mine_form_auth_btn_persion","icon":"mine_form_auth_btn_persion_icon","name":"个人认证","desc":"适合个人创作者、行业专家、自媒体领域"]) | |
| 33 | + } | |
| 34 | + if _listModel.enterpriseAuth && _listModel.agencyAuth { | |
| 35 | + let dict01 = ["back":"mine_form_auth_btn_formal_larg","icon":"mine_form_auth_btn_enterprise_icon","name":"企业认证","desc":"适合企业、个体工商户"] | |
| 36 | + let dict02 = ["back":"mine_form_auth_btn_formal_larg","icon":"mine_form_auth_btn_agency_icon","name":"机构认证","desc":"适合国家机构、社会组织、高校等"] | |
| 37 | + let temp_array = NSMutableArray() | |
| 38 | + temp_array.add(dict01) | |
| 39 | + temp_array.add(dict02) | |
| 40 | + array.add(temp_array as! [Dictionary<String,String>]) | |
| 41 | + } else { | |
| 42 | + if _listModel.enterpriseAuth { | |
| 43 | + array.add(["back":"mine_form_auth_btn_formal","icon":"mine_form_auth_btn_enterprise_icon","name":"企业认证","desc":"适合企业、个体工商户"]) | |
| 44 | + }else if _listModel.agencyAuth { | |
| 45 | + array.add(["back":"mine_form_auth_btn_formal","icon":"mine_form_auth_btn_agency_icon","name":"机构认证","desc":"适合国家机构、社会组织、高校等"]) | |
| 46 | + } | |
| 47 | + } | |
| 48 | + return array | |
| 49 | + }() | |
| 50 | + | |
| 26 | 51 | var _listModel: StandListModel! |
| 27 | 52 | |
| 28 | 53 | init(listModel:StandListModel) { |
| ... | ... | @@ -48,25 +73,61 @@ class CNLiveMineAuthFormViewController: CNLiveBaseViewController, UITableViewDel |
| 48 | 73 | } |
| 49 | 74 | |
| 50 | 75 | func numberOfSections(in tableView: UITableView) -> Int { |
| 51 | - return 2 | |
| 76 | + return dataArray.count | |
| 52 | 77 | } |
| 53 | 78 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
| 54 | - return section == 0 ? 1 : 2 | |
| 79 | + return 1 | |
| 55 | 80 | } |
| 56 | 81 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
| 57 | 82 | guard let cell = tableView.dequeueReusableCell(withIdentifier: kMIneBodyAuthFormViewCellIdentifier) as? MineAuthFormTableViewCell else { |
| 58 | 83 | return MineAuthFormTableViewCell() |
| 59 | 84 | } |
| 60 | - if indexPath.section == 0 && indexPath.row == 1 { | |
| 61 | - cell.mainView.image = UIImage(named: "mine_form_auth_btn_persion") | |
| 85 | + cell.indexPath = indexPath | |
| 86 | + cell.clickBlock = {[weak self] indexPath, view in | |
| 87 | + guard let self = self else { return } | |
| 88 | + let titleLabel = view.viewWithTag(1000) as! UILabel | |
| 89 | + if titleLabel.text == "个人认证" { | |
| 90 | + self.navigationController?.pushViewController(CNLiveMineInputViewController.init(listModel: _listModel, authType: .person), animated: true) | |
| 91 | + } | |
| 92 | + if titleLabel.text == "企业认证" { | |
| 93 | + self.navigationController?.pushViewController(CNLiveMineInputViewController.init(listModel: _listModel, authType: .enterprise), animated: true) | |
| 94 | + } | |
| 95 | + if titleLabel.text == "机构认证" { | |
| 96 | + self.navigationController?.pushViewController(CNLiveMineInputViewController.init(listModel: _listModel, authType: .agency), animated: true) | |
| 97 | + } | |
| 98 | + } | |
| 99 | + let obj = dataArray[indexPath.section] | |
| 100 | + if obj is Dictionary<String, String> { | |
| 101 | + let dict = obj as! Dictionary<String, String> | |
| 102 | + cell.mainView.image = UIImage(named: dict["back"]! as String) | |
| 103 | + cell.headerImageView.image = UIImage(named: dict["icon"]! as String) | |
| 104 | + cell.titleLabel.text = dict["name"]! as String | |
| 105 | + cell.descLabel.text = dict["desc"]! as String | |
| 106 | + cell.whiteView01.isHidden = true | |
| 62 | 107 | } |
| 63 | - if indexPath.section == 1 { | |
| 64 | - cell.mainView.image = UIImage(named: "mine_form_auth_btn") | |
| 108 | + if obj is [Dictionary<String,String>] { | |
| 109 | + cell.whiteView01.isHidden = false | |
| 110 | + let dict01 = (obj as! Array<Dictionary<String, String>>).first | |
| 111 | + cell.mainView.image = UIImage(named: dict01!["back"]! as String) | |
| 112 | + cell.headerImageView.image = UIImage(named: dict01!["icon"]! as String) | |
| 113 | + cell.titleLabel.text = dict01!["name"]! as String | |
| 114 | + cell.descLabel.text = dict01!["desc"]! as String | |
| 115 | + let dict02 = (obj as! Array<Dictionary<String, String>>).last | |
| 116 | + cell.headerImageView01.image = UIImage(named: dict02!["icon"]! as String) | |
| 117 | + cell.titleLabel01.text = dict02!["name"]! as String | |
| 118 | + cell.descLabel01.text = dict02!["desc"]! as String | |
| 65 | 119 | } |
| 66 | 120 | return cell |
| 67 | 121 | } |
| 68 | 122 | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { |
| 69 | - return adapt_length(length: 190) | |
| 123 | + let obj = dataArray[indexPath.section] | |
| 124 | + if obj is Dictionary<String, String> { | |
| 125 | + return adapt_length(length: 190) | |
| 126 | + } | |
| 127 | + if obj is [Dictionary<String,String>] { | |
| 128 | + return adapt_length(length: 280) | |
| 129 | + } | |
| 130 | + return adapt_length(length: 0.01) | |
| 70 | 131 | } |
| 71 | 132 | func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { |
| 72 | 133 | return adapt_length(length: 10) |
| ... | ... | @@ -74,19 +135,19 @@ class CNLiveMineAuthFormViewController: CNLiveBaseViewController, UITableViewDel |
| 74 | 135 | func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { |
| 75 | 136 | return adapt_length(length: 10) |
| 76 | 137 | } |
| 77 | - func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | |
| 78 | -// if indexPath.section == 0 { | |
| 79 | -// self.navigationController?.pushViewController(CNLiveMineInputViewController.init(listModel: _listModel, authType: .person), animated: true) | |
| 80 | -// } | |
| 81 | -// if indexPath.section == 1 { | |
| 82 | -// self.navigationController?.pushViewController(CNLiveMineInputViewController.init(listModel: _listModel, authType: .enterprise), animated: true) | |
| 83 | -// } | |
| 84 | -// if indexPath.section == 2 { | |
| 85 | -// self.navigationController?.pushViewController(CNLiveMineInputViewController.init(listModel: _listModel, authType: .agency), animated: true) | |
| 86 | -// } | |
| 138 | +} | |
| 139 | + | |
| 140 | +extension CNLiveMineAuthFormViewController { | |
| 141 | + func image(forEmptyDataSet scrollView: UIScrollView) -> UIImage? { | |
| 142 | + return UIImage(named: "mine_list_source_unusual_empty") | |
| 143 | + } | |
| 144 | + | |
| 145 | + func title(forEmptyDataSet scrollView: UIScrollView) -> NSAttributedString? { | |
| 146 | + return NSAttributedString(string: "您已添加此身份,请直接使用", attributes: [.font: Font_17,.foregroundColor: HexColor("#666666")!]) | |
| 87 | 147 | } |
| 88 | 148 | } |
| 89 | 149 | |
| 150 | +typealias clickWithClickBlock = (_ indexPath: IndexPath,_ view: UIView) -> Void | |
| 90 | 151 | class MineAuthFormTableViewCell: UITableViewCell { |
| 91 | 152 | |
| 92 | 153 | lazy var mainView: UIImageView = { |
| ... | ... | @@ -103,9 +164,71 @@ class MineAuthFormTableViewCell: UITableViewCell { |
| 103 | 164 | view.backgroundColor = .white |
| 104 | 165 | view.layer.masksToBounds = true |
| 105 | 166 | view.layer.cornerRadius = adapt_length(length: 10) |
| 167 | + view.isUserInteractionEnabled = true | |
| 168 | + view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(clickWithWhiteAction))) | |
| 106 | 169 | return view |
| 107 | 170 | }() |
| 108 | 171 | |
| 172 | + lazy var headerImageView: UIImageView = { | |
| 173 | + let headerImageView = UIImageView.init() | |
| 174 | + headerImageView.backgroundColor = .white | |
| 175 | + headerImageView.contentMode = .scaleAspectFill | |
| 176 | + headerImageView.layer.masksToBounds = true | |
| 177 | + return headerImageView | |
| 178 | + }() | |
| 179 | + | |
| 180 | + lazy var titleLabel: UILabel = { | |
| 181 | + let titleLabel = UILabel.init() | |
| 182 | + titleLabel.tag = 1000 | |
| 183 | + titleLabel.textColor = HexColor("#333333") | |
| 184 | + titleLabel.font = semibold_adapt_font(pointSize: 16) | |
| 185 | + return titleLabel | |
| 186 | + }() | |
| 187 | + | |
| 188 | + lazy var descLabel: UILabel = { | |
| 189 | + let descLabel = UILabel.init() | |
| 190 | + descLabel.textColor = HexColor("#999999") | |
| 191 | + descLabel.font = regular_adapt_font(pointSize: 14) | |
| 192 | + return descLabel | |
| 193 | + }() | |
| 194 | + | |
| 195 | + lazy var whiteView01: UIView = { | |
| 196 | + let view = UIView.init() | |
| 197 | + view.backgroundColor = .white | |
| 198 | + view.isHidden = true | |
| 199 | + view.layer.masksToBounds = true | |
| 200 | + view.layer.cornerRadius = adapt_length(length: 10) | |
| 201 | + view.isUserInteractionEnabled = true | |
| 202 | + view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(clickWithWhite01Action))) | |
| 203 | + return view | |
| 204 | + }() | |
| 205 | + | |
| 206 | + lazy var headerImageView01: UIImageView = { | |
| 207 | + let headerImageView = UIImageView.init() | |
| 208 | + headerImageView.backgroundColor = .white | |
| 209 | + headerImageView.contentMode = .scaleAspectFill | |
| 210 | + headerImageView.layer.masksToBounds = true | |
| 211 | + return headerImageView | |
| 212 | + }() | |
| 213 | + | |
| 214 | + lazy var titleLabel01: UILabel = { | |
| 215 | + let titleLabel = UILabel.init() | |
| 216 | + titleLabel.tag = 1000 | |
| 217 | + titleLabel.textColor = HexColor("#333333") | |
| 218 | + titleLabel.font = semibold_adapt_font(pointSize: 16) | |
| 219 | + return titleLabel | |
| 220 | + }() | |
| 221 | + | |
| 222 | + lazy var descLabel01: UILabel = { | |
| 223 | + let descLabel = UILabel.init() | |
| 224 | + descLabel.textColor = HexColor("#999999") | |
| 225 | + descLabel.font = regular_adapt_font(pointSize: 12) | |
| 226 | + return descLabel | |
| 227 | + }() | |
| 228 | + | |
| 229 | + var indexPath: IndexPath! | |
| 230 | + var clickBlock: clickWithClickBlock! | |
| 231 | + | |
| 109 | 232 | override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { |
| 110 | 233 | super.init(style: style, reuseIdentifier: reuseIdentifier) |
| 111 | 234 | contentView.backgroundColor = .clear |
| ... | ... | @@ -121,7 +244,65 @@ class MineAuthFormTableViewCell: UITableViewCell { |
| 121 | 244 | |
| 122 | 245 | contentView.addSubview(whiteView) |
| 123 | 246 | whiteView.snp.makeConstraints { make in |
| 247 | + make.bottom.equalToSuperview().offset(-adapt_length(length: 20)) | |
| 248 | + make.left.equalToSuperview().offset(adapt_length(length: 30)) | |
| 249 | + make.right.equalToSuperview().offset(-adapt_length(length: 30)) | |
| 250 | + make.height.equalTo(adapt_length(length: 80)) | |
| 251 | + } | |
| 252 | + | |
| 253 | + whiteView.addSubview(headerImageView) | |
| 254 | + headerImageView.snp.makeConstraints { make in | |
| 255 | + make.centerY.equalToSuperview() | |
| 256 | + make.left.equalToSuperview().offset(adapt_length(length: 5)) | |
| 257 | + make.size.equalTo(adapt_length(length: 70)) | |
| 258 | + } | |
| 259 | + whiteView.addSubview(titleLabel) | |
| 260 | + titleLabel.snp.makeConstraints { make in | |
| 261 | + make.top.equalTo(headerImageView.snp.top).offset(adapt_length(length: 10)) | |
| 262 | + make.left.equalTo(headerImageView.snp.right).offset(adapt_length(length: 10)) | |
| 263 | + make.right.equalToSuperview().offset(-adapt_length(length: 10)) | |
| 124 | 264 | } |
| 265 | + whiteView.addSubview(descLabel) | |
| 266 | + descLabel.snp.makeConstraints { make in | |
| 267 | + make.bottom.equalTo(headerImageView.snp.bottom).offset(-adapt_length(length: 10)) | |
| 268 | + make.left.equalTo(headerImageView.snp.right).offset(adapt_length(length: 10)) | |
| 269 | + make.right.equalToSuperview().offset(-adapt_length(length: 10)) | |
| 270 | + } | |
| 271 | + | |
| 272 | + contentView.addSubview(whiteView01) | |
| 273 | + whiteView01.snp.makeConstraints { make in | |
| 274 | + make.bottom.equalTo(whiteView.snp.top).offset(-adapt_length(length: 10)) | |
| 275 | + make.left.equalToSuperview().offset(adapt_length(length: 30)) | |
| 276 | + make.right.equalToSuperview().offset(-adapt_length(length: 30)) | |
| 277 | + make.height.equalTo(adapt_length(length: 80)) | |
| 278 | + } | |
| 279 | + | |
| 280 | + whiteView01.addSubview(headerImageView01) | |
| 281 | + headerImageView01.snp.makeConstraints { make in | |
| 282 | + make.centerY.equalToSuperview() | |
| 283 | + make.left.equalToSuperview().offset(adapt_length(length: 5)) | |
| 284 | + make.size.equalTo(adapt_length(length: 70)) | |
| 285 | + } | |
| 286 | + whiteView01.addSubview(titleLabel01) | |
| 287 | + titleLabel01.snp.makeConstraints { make in | |
| 288 | + make.top.equalTo(headerImageView01.snp.top).offset(adapt_length(length: 10)) | |
| 289 | + make.left.equalTo(headerImageView01.snp.right).offset(adapt_length(length: 10)) | |
| 290 | + make.right.equalToSuperview().offset(-adapt_length(length: 10)) | |
| 291 | + } | |
| 292 | + whiteView01.addSubview(descLabel01) | |
| 293 | + descLabel01.snp.makeConstraints { make in | |
| 294 | + make.bottom.equalTo(headerImageView01.snp.bottom).offset(-adapt_length(length: 10)) | |
| 295 | + make.left.equalTo(headerImageView01.snp.right).offset(adapt_length(length: 10)) | |
| 296 | + make.right.equalToSuperview().offset(-adapt_length(length: 10)) | |
| 297 | + } | |
| 298 | + } | |
| 299 | + | |
| 300 | + @objc func clickWithWhiteAction() { | |
| 301 | + self.clickBlock(indexPath,whiteView) | |
| 302 | + } | |
| 303 | + | |
| 304 | + @objc func clickWithWhite01Action() { | |
| 305 | + self.clickBlock(indexPath,whiteView01) | |
| 125 | 306 | } |
| 126 | 307 | |
| 127 | 308 | required init?(coder: NSCoder) { | ... | ... |
metaCode/Classes/Main/MinePage/ViewModel/CNLiveMineBaseModel.swift
| ... | ... | @@ -155,7 +155,7 @@ final class StandListModel: BaseModel {//, TableCodable { |
| 155 | 155 | var upType: Int = 0//下滑类型1:h5 2:原生页面 3店铺详情 4 店铺控制台 |
| 156 | 156 | var downType: Int = 0//上滑类型1:h5 2:原生页面 3店铺详情 4 店铺控制台 |
| 157 | 157 | var downPath: String = ""//底部h5url 或原生页面pageId- |
| 158 | - var userAuth: Bool = false//是否显示个人认证 | |
| 158 | + var userAuth: Bool = true//是否显示个人认证 | |
| 159 | 159 | var enterpriseAuth: Bool = false//是否显示企业认证 |
| 160 | 160 | var agencyAuth: Bool = false//是否显示机构认证 |
| 161 | 161 | var auth: Bool = false//身份是否验证 | ... | ... |
metaCode/Supporting Files/Assets.xcassets/MinePage/mine_persion_auth_btn.imageset/Contents.json renamed to metaCode/Supporting Files/Assets.xcassets/MinePage/mine_form_auth_btn_agency_icon.imageset/Contents.json
| ... | ... | @@ -5,12 +5,12 @@ |
| 5 | 5 | "scale" : "1x" |
| 6 | 6 | }, |
| 7 | 7 | { |
| 8 | - "filename" : "mine_persion_auth_btn@2x.png", | |
| 8 | + "filename" : "mine_form_auth_btn_agency_icon@2x.png", | |
| 9 | 9 | "idiom" : "universal", |
| 10 | 10 | "scale" : "2x" |
| 11 | 11 | }, |
| 12 | 12 | { |
| 13 | - "filename" : "mine_persion_auth_btn@3x.png", | |
| 13 | + "filename" : "mine_form_auth_btn_agency_icon@3x.png", | |
| 14 | 14 | "idiom" : "universal", |
| 15 | 15 | "scale" : "3x" |
| 16 | 16 | } | ... | ... |
metaCode/Supporting Files/Assets.xcassets/MinePage/mine_form_auth_btn_agency_icon.imageset/mine_form_auth_btn_agency_icon@2x.png
0 → 100644
7.48 KB
metaCode/Supporting Files/Assets.xcassets/MinePage/mine_form_auth_btn_agency_icon.imageset/mine_form_auth_btn_agency_icon@3x.png
0 → 100644
14.8 KB
metaCode/Supporting Files/Assets.xcassets/MinePage/mine_form_auth_btn_enterprise_icon.imageset/Contents.json
0 → 100644
| 1 | +{ | |
| 2 | + "images" : [ | |
| 3 | + { | |
| 4 | + "idiom" : "universal", | |
| 5 | + "scale" : "1x" | |
| 6 | + }, | |
| 7 | + { | |
| 8 | + "filename" : "mine_form_auth_btn_enterprise_icon@2x.png", | |
| 9 | + "idiom" : "universal", | |
| 10 | + "scale" : "2x" | |
| 11 | + }, | |
| 12 | + { | |
| 13 | + "filename" : "mine_form_auth_btn_enterprise_icon@3x.png", | |
| 14 | + "idiom" : "universal", | |
| 15 | + "scale" : "3x" | |
| 16 | + } | |
| 17 | + ], | |
| 18 | + "info" : { | |
| 19 | + "author" : "xcode", | |
| 20 | + "version" : 1 | |
| 21 | + } | |
| 22 | +} | ... | ... |
metaCode/Supporting Files/Assets.xcassets/MinePage/mine_form_auth_btn_enterprise_icon.imageset/mine_form_auth_btn_enterprise_icon@2x.png
0 → 100644
8.13 KB
metaCode/Supporting Files/Assets.xcassets/MinePage/mine_form_auth_btn_enterprise_icon.imageset/mine_form_auth_btn_enterprise_icon@3x.png
0 → 100644
15.7 KB
metaCode/Supporting Files/Assets.xcassets/MinePage/mine_form_auth_btn_persion_icon.imageset/Contents.json
0 → 100644
| 1 | +{ | |
| 2 | + "images" : [ | |
| 3 | + { | |
| 4 | + "idiom" : "universal", | |
| 5 | + "scale" : "1x" | |
| 6 | + }, | |
| 7 | + { | |
| 8 | + "filename" : "mine_form_auth_btn_persion_icon@2x.png", | |
| 9 | + "idiom" : "universal", | |
| 10 | + "scale" : "2x" | |
| 11 | + }, | |
| 12 | + { | |
| 13 | + "filename" : "mine_form_auth_btn_persion_icon@3x.png", | |
| 14 | + "idiom" : "universal", | |
| 15 | + "scale" : "3x" | |
| 16 | + } | |
| 17 | + ], | |
| 18 | + "info" : { | |
| 19 | + "author" : "xcode", | |
| 20 | + "version" : 1 | |
| 21 | + } | |
| 22 | +} | ... | ... |
metaCode/Supporting Files/Assets.xcassets/MinePage/mine_form_auth_btn_persion_icon.imageset/mine_form_auth_btn_persion_icon@2x.png
0 → 100644
7.72 KB
metaCode/Supporting Files/Assets.xcassets/MinePage/mine_form_auth_btn_persion_icon.imageset/mine_form_auth_btn_persion_icon@3x.png
0 → 100644
15.3 KB
metaCode/Supporting Files/Assets.xcassets/MinePage/mine_persion_auth_btn.imageset/mine_persion_auth_btn@2x.png deleted
100644 → 0
206 KB
metaCode/Supporting Files/Assets.xcassets/MinePage/mine_persion_auth_btn.imageset/mine_persion_auth_btn@3x.png deleted
100644 → 0
464 KB