Commit 7fc9094308aa3a75335492d4e33ad29c21318133
Merge branch 'master' of http://bj.gitlab.cnlive.com/ios-team/CNLiveMateCode
Showing
16 changed files
with
445 additions
and
39 deletions
metaCode/Classes/Config/CNLiveConfigUserInfo.swift
| ... | ... | @@ -97,7 +97,11 @@ class UserInfoManager: NSObject { |
| 97 | 97 | /// - Returns: 用户数据 |
| 98 | 98 | static public func readUserInfo() -> UserInfoModel { |
| 99 | 99 | let user_info = UserDefaults.standard.object(forKey: "mateCode_userInfo") |
| 100 | - if user_info == nil && (user_info as! String).count == 0 { | |
| 100 | + if user_info == nil { | |
| 101 | + print("获取用户信息失败") | |
| 102 | + return UserInfoModel() | |
| 103 | + } | |
| 104 | + if (user_info as! String).count == 0 { | |
| 101 | 105 | print("获取用户信息失败") |
| 102 | 106 | return UserInfoModel() |
| 103 | 107 | } | ... | ... |
metaCode/Classes/Environment/CNLiveEnvironment.swift
| ... | ... | @@ -17,6 +17,8 @@ let APPLoginHost: String! = CNLiveEnvironmentManager.shared.loginHost |
| 17 | 17 | let APPSecret: String = CNLiveEnvironmentManager.shared.appSecret |
| 18 | 18 | ///当前应用的部分请求接口 |
| 19 | 19 | let APPBaseMCUrl: String = CNLiveEnvironmentManager.shared.base_mc_url |
| 20 | +/// 网家家内接口 | |
| 21 | +let APPBaseWjjUrl: String = CNLiveEnvironmentManager.shared.base_wjj_url | |
| 20 | 22 | |
| 21 | 23 | ///当前APP的环境 |
| 22 | 24 | let APPCurrentEnvironment: CNLiveEnvironment = CNLiveEnvironmentManager.shared.currentEnvironment |
| ... | ... | @@ -51,6 +53,8 @@ class CNLiveEnvironmentManager: NSObject{ |
| 51 | 53 | var loginHost: String |
| 52 | 54 | /// 码云项目的主域名 |
| 53 | 55 | var base_mc_url: String |
| 56 | + /// 网家家域名请求 | |
| 57 | + var base_wjj_url: String | |
| 54 | 58 | /// 获取IM token 请求域名 |
| 55 | 59 | var img_token_url: String |
| 56 | 60 | |
| ... | ... | @@ -65,6 +69,7 @@ class CNLiveEnvironmentManager: NSObject{ |
| 65 | 69 | self.appSecret = "" |
| 66 | 70 | self.base_mc_url = "" |
| 67 | 71 | self.img_token_url = "" |
| 72 | + self.base_wjj_url = "" | |
| 68 | 73 | self.currentEnvironment = .development |
| 69 | 74 | } |
| 70 | 75 | //重新copy 和 mutableCopy 方法 |
| ... | ... | @@ -99,6 +104,7 @@ class CNLiveEnvironmentManager: NSObject{ |
| 99 | 104 | self.loginHost = "https://api.cnlive.com" |
| 100 | 105 | self.img_token_url = "https://api.cnlive.com/open/api2" |
| 101 | 106 | self.base_mc_url = "https://metacode.cnlive.com/api" |
| 107 | + self.base_wjj_url = "https://apiwjj.cnlive.com" | |
| 102 | 108 | } |
| 103 | 109 | //testFlight 环境配置 |
| 104 | 110 | func testFlightEnvironment(){ |
| ... | ... | @@ -108,6 +114,7 @@ class CNLiveEnvironmentManager: NSObject{ |
| 108 | 114 | self.loginHost = "https://api.cnlive.com" |
| 109 | 115 | self.img_token_url = "https://api.cnlive.com/open/api2" |
| 110 | 116 | self.base_mc_url = "https://metacode.cnlive.com/api" |
| 117 | + self.base_wjj_url = "https://apiwjj.cnlive.com" | |
| 111 | 118 | } |
| 112 | 119 | //production 生产环境配置 |
| 113 | 120 | func productionEnvironment(){ |
| ... | ... | @@ -117,6 +124,7 @@ class CNLiveEnvironmentManager: NSObject{ |
| 117 | 124 | self.loginHost = "https://api.cnlive.com" |
| 118 | 125 | self.img_token_url = "https://api.cnlive.com/open/api2" |
| 119 | 126 | self.base_mc_url = "https://metacode.cnlive.com/api" |
| 127 | + self.base_wjj_url = "https://apiwjj.cnlive.com" | |
| 120 | 128 | } |
| 121 | 129 | |
| 122 | 130 | } | ... | ... |
metaCode/Classes/Main/MinePage/Controller/CNLiveMineAuthResultViewController.swift
| ... | ... | @@ -75,7 +75,17 @@ class CNLiveMineAuthResultViewController: CNLiveBaseViewController { |
| 75 | 75 | |
| 76 | 76 | override func viewWillAppear(_ animated: Bool) { |
| 77 | 77 | super.viewWillAppear(animated) |
| 78 | - | |
| 78 | + if _show_type == .result_failer || _show_type == .result_success { | |
| 79 | + let tempArray = NSMutableArray.init() | |
| 80 | + self.navigationController?.viewControllers.forEach({ item in | |
| 81 | + if (item.isKind(of: CNLiveMineInputViewController.self)) { | |
| 82 | + tempArray.remove(item) | |
| 83 | + }else{ | |
| 84 | + tempArray.add(item) | |
| 85 | + } | |
| 86 | + }) | |
| 87 | + self.navigationController?.viewControllers = tempArray as! [CNLiveBaseViewController] | |
| 88 | + } | |
| 79 | 89 | } |
| 80 | 90 | |
| 81 | 91 | override func viewDidLoad() { |
| ... | ... | @@ -126,13 +136,14 @@ class CNLiveMineAuthResultViewController: CNLiveBaseViewController { |
| 126 | 136 | |
| 127 | 137 | CNLiveMineViewModel.startKeepTimeWithStand(id: "\(_listModel.id)") { [weak self] result, respStatue in |
| 128 | 138 | if respStatue == .success { |
| 139 | + let listBaseModel = result as! MineStandInfoBaseModel | |
| 129 | 140 | self?.titleLabel.textColor = .black |
| 130 | 141 | self?.leftBtnWhite = false |
| 131 | 142 | self?.mainView.isHidden = true |
| 132 | 143 | self?.iDCardView.isHidden = false |
| 133 | 144 | self?.iDCardView.idModel = self?._listModel |
| 134 | 145 | self?.tipName.text = "恭喜您通过认证" |
| 135 | - self?.tipDesc.text = "您已是中国网公益服务志愿者!" | |
| 146 | + self?.tipDesc.text = listBaseModel.name!.count > 0 ? "您已是\(listBaseModel.name ?? "")!" : "恭喜您通过认证" | |
| 136 | 147 | self?._status = .default |
| 137 | 148 | self?.setNeedsStatusBarAppearanceUpdate() |
| 138 | 149 | }else{ |
| ... | ... | @@ -150,17 +161,6 @@ class CNLiveMineAuthResultViewController: CNLiveBaseViewController { |
| 150 | 161 | } |
| 151 | 162 | |
| 152 | 163 | @objc func sendInfoActionMothod() { |
| 153 | - if _show_type == .result_failer || _show_type == .result_success { | |
| 154 | - let tempArray = NSMutableArray.init() | |
| 155 | - self.navigationController?.viewControllers.forEach({ item in | |
| 156 | - if (item.isKind(of: CNLiveMineInputViewController.self)) { | |
| 157 | - tempArray.remove(item) | |
| 158 | - }else{ | |
| 159 | - tempArray.add(item) | |
| 160 | - } | |
| 161 | - }) | |
| 162 | - self.navigationController?.viewControllers = tempArray as! [CNLiveBaseViewController] | |
| 163 | - self.navigationController?.popViewController(animated: true) | |
| 164 | - } | |
| 164 | + self.navigationController?.popViewController(animated: true) | |
| 165 | 165 | } |
| 166 | 166 | } | ... | ... |
metaCode/Classes/Main/MinePage/Controller/CNLiveMineExchangeViewController.swift
| ... | ... | @@ -6,14 +6,13 @@ |
| 6 | 6 | // |
| 7 | 7 | |
| 8 | 8 | import Foundation |
| 9 | +import SnapKit | |
| 9 | 10 | |
| 10 | -class CNLiveMineExchangeViewController : CNLiveBaseViewController { | |
| 11 | +class CNLiveMineExchangeViewController : CNLiveBaseViewController, UITextFieldDelegate { | |
| 11 | 12 | |
| 12 | 13 | lazy var backView : UIImageView = { |
| 13 | 14 | let backView = UIImageView.init() |
| 14 | - backView.image = UIImage(named: "mine_header_icon_back") | |
| 15 | 15 | backView.contentMode = .scaleToFill |
| 16 | - backView.backgroundColor = HexColor("#F7F8FA") | |
| 17 | 16 | backView.clipsToBounds = true |
| 18 | 17 | return backView |
| 19 | 18 | }() |
| ... | ... | @@ -46,10 +45,13 @@ class CNLiveMineExchangeViewController : CNLiveBaseViewController { |
| 46 | 45 | lazy var numberField: UITextField = { |
| 47 | 46 | let numberField = UITextField.init() |
| 48 | 47 | numberField.placeholder = "最低兑换100积分" |
| 49 | - numberField.font = Font_16_Fit | |
| 50 | - numberField.keyboardType = .numberPad | |
| 48 | + numberField.font = BoldFont_18_Fit | |
| 49 | + numberField.keyboardType = .decimalPad | |
| 51 | 50 | numberField.clearButtonMode = .whileEditing |
| 52 | 51 | numberField.backgroundColor = .white |
| 52 | + numberField.textColor = .black | |
| 53 | + numberField.delegate = self | |
| 54 | + numberField.addTarget(self, action: #selector(numberChangeAction), for: .editingChanged) | |
| 53 | 55 | return numberField |
| 54 | 56 | }() |
| 55 | 57 | |
| ... | ... | @@ -59,12 +61,74 @@ class CNLiveMineExchangeViewController : CNLiveBaseViewController { |
| 59 | 61 | return lineLabel |
| 60 | 62 | }() |
| 61 | 63 | |
| 62 | -// lazy var views: NSArray = { | |
| 63 | -// let views = NSMutableArray.init() | |
| 64 | -// | |
| 65 | -// return views | |
| 66 | -// }() | |
| 64 | + lazy var tagView: UIView = { | |
| 65 | + let tagView = UIView.init() | |
| 66 | + tagView.backgroundColor = .white | |
| 67 | + return tagView | |
| 68 | + }() | |
| 69 | + | |
| 70 | + lazy var bottemView: UIView = { | |
| 71 | + let bottemView = UIView.init() | |
| 72 | + bottemView.backgroundColor = .white | |
| 73 | + bottemView.layer.cornerRadius = 8 | |
| 74 | + bottemView.layer.masksToBounds = true | |
| 75 | + return bottemView | |
| 76 | + }() | |
| 77 | + | |
| 78 | + lazy var bottemTipLabel: UILabel = { | |
| 79 | + let bottemTipLabel = UILabel.init() | |
| 80 | + bottemTipLabel.backgroundColor = .white | |
| 81 | + bottemTipLabel.textColor = .black | |
| 82 | + bottemTipLabel.font = BoldFont_14_Fit | |
| 83 | + bottemTipLabel.text = "元码余额 (元)" | |
| 84 | + return bottemTipLabel | |
| 85 | + }() | |
| 86 | + | |
| 87 | + lazy var priceLabel: UILabel = { | |
| 88 | + let priceLabel = UILabel.init() | |
| 89 | + priceLabel.text = "0.00" | |
| 90 | + priceLabel.textColor = HexColor("#F5A623") | |
| 91 | + priceLabel.font = BoldFont_Fit(24) | |
| 92 | + priceLabel.backgroundColor = .white | |
| 93 | + return priceLabel | |
| 94 | + }() | |
| 95 | + | |
| 96 | + lazy var tipBtn: UIButton = { | |
| 97 | + let tipBtn = UIButton.init(type: .custom) | |
| 98 | + tipBtn.setTitle("至少兑换100积分", for: .normal) | |
| 99 | + tipBtn.setTitleColor(HexColor("#E02020"), for: .normal) | |
| 100 | + tipBtn.setImage(UIImage(named: "mine_header_quest_tip_red"), for: .normal) | |
| 101 | + tipBtn.titleLabel?.font = Font_11 | |
| 102 | + tipBtn.contentHorizontalAlignment = .left | |
| 103 | + tipBtn.isHidden = true | |
| 104 | + tipBtn.setupButtonImageAndTitlePossitionWith(padding: 3, style: .left) | |
| 105 | + return tipBtn | |
| 106 | + }() | |
| 107 | + | |
| 108 | + lazy var descBtn: UIButton = { | |
| 109 | + let descBtn = UIButton.init(type: .custom) | |
| 110 | + descBtn.setTitle("最低100积分,不足100的积分将原路返回", for: .normal) | |
| 111 | + descBtn.setTitleColor(HexColor("#999999"), for: .normal) | |
| 112 | + descBtn.setImage(UIImage(named: "mine_header_quest_tip_black"), for: .normal) | |
| 113 | + descBtn.titleLabel?.font = Font_11 | |
| 114 | + descBtn.contentHorizontalAlignment = .left | |
| 115 | + descBtn.setupButtonImageAndTitlePossitionWith(padding: 3, style: .left) | |
| 116 | + return descBtn | |
| 117 | + }() | |
| 67 | 118 | |
| 119 | + lazy var sendButton: UIButton = { | |
| 120 | + let sendButton = UIButton(type: .custom) | |
| 121 | + sendButton.setTitle("立即兑换", for: .normal) | |
| 122 | + sendButton.setTitleColor(.white, for: .normal) | |
| 123 | + sendButton.titleLabel?.font = BoldFont_16_Fit | |
| 124 | + sendButton.layer.cornerRadius = 20 | |
| 125 | + sendButton.layer.masksToBounds = true | |
| 126 | + sendButton.addTarget(self, action: #selector(sendInfoActionMothod), for: .touchUpInside) | |
| 127 | + return sendButton | |
| 128 | + }() | |
| 129 | + | |
| 130 | + var tempBtn: UIButton! | |
| 131 | + var tempString: String! | |
| 68 | 132 | override func viewDidLoad() { |
| 69 | 133 | super.viewDidLoad() |
| 70 | 134 | navigationBarHidden = false |
| ... | ... | @@ -80,35 +144,44 @@ class CNLiveMineExchangeViewController : CNLiveBaseViewController { |
| 80 | 144 | topView.addSubview(descL) |
| 81 | 145 | topView.addSubview(numberField) |
| 82 | 146 | topView.addSubview(lineLabel) |
| 83 | - | |
| 147 | + topView.addSubview(tagView) | |
| 148 | + topView.addSubview(tipBtn) | |
| 149 | + view.addSubview(bottemView) | |
| 150 | + bottemView.addSubview(bottemTipLabel) | |
| 151 | + bottemView.addSubview(priceLabel) | |
| 152 | + view.addSubview(descBtn) | |
| 153 | + view.addSubview(sendButton) | |
| 154 | + setupWithContent() | |
| 84 | 155 | setupConstraints() |
| 156 | + | |
| 157 | + setupWithSendBtnStatue(statue: false) | |
| 85 | 158 | } |
| 86 | 159 | |
| 87 | 160 | func setupConstraints() { |
| 88 | 161 | backView.snp.makeConstraints { make in |
| 89 | 162 | make.left.right.top.equalToSuperview() |
| 90 | - make.height.equalTo(300) | |
| 163 | + make.height.equalTo(210) | |
| 91 | 164 | } |
| 92 | 165 | topView.snp.makeConstraints { make in |
| 93 | 166 | make.centerX.equalToSuperview() |
| 94 | 167 | make.top.equalTo(get_system_nav_height()+30) |
| 95 | 168 | make.left.equalToSuperview().offset(20) |
| 96 | 169 | make.right.equalToSuperview().offset(-20) |
| 97 | - make.height.equalTo(200) | |
| 170 | + make.height.equalTo(150) | |
| 98 | 171 | } |
| 99 | 172 | tipLabel.snp.makeConstraints { make in |
| 100 | - make.top.equalToSuperview().offset(20) | |
| 101 | - make.left.equalToSuperview().offset(10) | |
| 173 | + make.top.equalToSuperview().offset(15) | |
| 174 | + make.left.equalToSuperview().offset(20) | |
| 102 | 175 | } |
| 103 | 176 | descL.snp.makeConstraints { make in |
| 104 | - make.top.equalToSuperview().offset(20) | |
| 105 | - make.right.equalToSuperview().offset(-10) | |
| 177 | + make.top.equalToSuperview().offset(15) | |
| 178 | + make.right.equalToSuperview().offset(-20) | |
| 106 | 179 | } |
| 107 | 180 | numberField.snp.makeConstraints { make in |
| 108 | 181 | make.centerX.equalToSuperview() |
| 109 | 182 | make.top.equalTo(tipLabel.snp.bottom).offset(20) |
| 110 | - make.left.equalToSuperview().offset(10) | |
| 111 | - make.right.equalToSuperview().offset(-10) | |
| 183 | + make.left.equalToSuperview().offset(20) | |
| 184 | + make.right.equalToSuperview().offset(-20) | |
| 112 | 185 | make.height.equalTo(40) |
| 113 | 186 | } |
| 114 | 187 | lineLabel.snp.makeConstraints { make in |
| ... | ... | @@ -118,13 +191,229 @@ class CNLiveMineExchangeViewController : CNLiveBaseViewController { |
| 118 | 191 | make.height.equalTo(0.5) |
| 119 | 192 | make.top.equalTo(numberField.snp.bottom) |
| 120 | 193 | } |
| 194 | + tagView.snp.makeConstraints { make in | |
| 195 | + make.centerX.equalToSuperview() | |
| 196 | + make.left.equalToSuperview().offset(10) | |
| 197 | + make.right.equalToSuperview().offset(-10) | |
| 198 | + make.height.equalTo(30) | |
| 199 | + make.top.equalTo(lineLabel.snp.bottom).offset(10) | |
| 200 | + } | |
| 201 | + tipBtn.snp.makeConstraints { make in | |
| 202 | + make.left.equalToSuperview().offset(20) | |
| 203 | + make.top.equalTo(tagView.snp.bottom).offset(10) | |
| 204 | + make.height.equalTo(15) | |
| 205 | + make.width.equalTo(180) | |
| 206 | + } | |
| 207 | + | |
| 208 | + bottemView.snp.makeConstraints { make in | |
| 209 | + make.centerX.equalToSuperview() | |
| 210 | + make.top.equalTo(topView.snp.bottom).offset(20) | |
| 211 | + make.left.equalToSuperview().offset(20) | |
| 212 | + make.right.equalToSuperview().offset(-20) | |
| 213 | + make.height.equalTo(90) | |
| 214 | + } | |
| 215 | + bottemTipLabel.snp.makeConstraints { make in | |
| 216 | + make.left.top.equalToSuperview().offset(20) | |
| 217 | + } | |
| 218 | + priceLabel.snp.makeConstraints { make in | |
| 219 | + make.left.equalToSuperview().offset(20) | |
| 220 | + make.bottom.equalToSuperview().offset(-10) | |
| 221 | + } | |
| 222 | + | |
| 223 | + descBtn.snp.makeConstraints { make in | |
| 224 | + make.left.equalToSuperview().offset(30) | |
| 225 | + make.right.equalToSuperview().offset(-20) | |
| 226 | + make.top.equalTo(bottemView.snp.bottom).offset(10) | |
| 227 | + make.height.equalTo(15) | |
| 228 | + make.width.equalTo(180) | |
| 229 | + } | |
| 230 | + sendButton.snp.makeConstraints { make in | |
| 231 | + make.top.equalTo(descBtn.snp.bottom).offset(50) | |
| 232 | + make.left.equalToSuperview().offset(20) | |
| 233 | + make.right.equalToSuperview().offset(-20) | |
| 234 | + make.height.equalTo(40) | |
| 235 | + } | |
| 236 | + backView.setGradient(colors: [UIColor(red: 0/255.0, green: 106/255.0, blue: 229/255.0, alpha: 1),UIColor(red: 247/255.0, green: 248/255.0, blue: 250/255.0, alpha: 1)], startPoint: CGPoint(x: 0.5, y: 0), endPoint: CGPoint(x: 0.5, y: 1)) | |
| 121 | 237 | } |
| 122 | 238 | |
| 123 | 239 | func setupWithContent() { |
| 124 | - | |
| 240 | + let array: NSArray = ["1000","2000","3000","全部兑换"] | |
| 241 | + for (index,item) in array.enumerated() { | |
| 242 | + let w = (KSreenWidth-90)/4 | |
| 243 | + let x = (index * Int(w))+(index * 10) | |
| 244 | + let numberBtn = UIButton.init(type: .custom) | |
| 245 | + numberBtn.frame = CGRect(x: Int(x), y: 0, width: Int(w), height: 30) | |
| 246 | + numberBtn.backgroundColor = HexColor("#F7F8FA") | |
| 247 | + numberBtn.setTitle((item as! String), for: .normal) | |
| 248 | + numberBtn.layer.cornerRadius = 5 | |
| 249 | + numberBtn.layer.masksToBounds = true | |
| 250 | + numberBtn.tag = 1000 + index | |
| 251 | + numberBtn.titleLabel?.font = Font_14_Fit | |
| 252 | + numberBtn.setTitleColor(HexColor("#999999"), for: .normal) | |
| 253 | + numberBtn.addTarget(self, action: #selector(numberAction), for: .touchUpInside) | |
| 254 | + tagView.addSubview(numberBtn) | |
| 255 | + } | |
| 256 | + } | |
| 257 | + | |
| 258 | + private func setupWithSendBtnStatue(statue: Bool) { | |
| 259 | + var alpha = 0.3 | |
| 260 | + if statue { | |
| 261 | + alpha = 1 | |
| 262 | + } | |
| 263 | + sendButton.setGradient(colors: [UIColor(red: 103/255.0, green: 197/255.0, blue: 255/255.0, alpha: alpha),UIColor(red: 96/255.0, green: 154/255.0, blue: 255/255.0, alpha: alpha)], startPoint: CGPoint(x: 0, y: 0.5), endPoint: CGPoint(x: 1, y: 0.5)) | |
| 264 | + sendButton.isUserInteractionEnabled = statue | |
| 125 | 265 | } |
| 126 | 266 | |
| 127 | 267 | override var preferredStatusBarStyle: UIStatusBarStyle { |
| 128 | 268 | return .lightContent |
| 129 | 269 | } |
| 270 | + | |
| 271 | + @objc func sendInfoActionMothod() { | |
| 272 | + | |
| 273 | + } | |
| 274 | + | |
| 275 | + @objc func numberAction(sender: UIButton) { | |
| 276 | + showErrorMessage(message: "", clear: true) | |
| 277 | + sender.backgroundColor = HexColor("#FFF8EE") | |
| 278 | + sender.layer.borderColor = HexColor("#F5A623")?.cgColor | |
| 279 | + sender.layer.borderWidth = 1 | |
| 280 | + sender.setTitleColor(HexColor("#F5A623"), for: .normal) | |
| 281 | + if tempBtn != nil { | |
| 282 | + tempBtn.backgroundColor = HexColor("#F7F8FA") | |
| 283 | + tempBtn.layer.borderColor = HexColor("#F7F8FA")?.cgColor | |
| 284 | + tempBtn.layer.borderWidth = 0 | |
| 285 | + tempBtn.setTitleColor(HexColor("#999999"), for: .normal) | |
| 286 | + } | |
| 287 | + if sender.tag == 1000 { | |
| 288 | + numberField.text = "1000" | |
| 289 | + } | |
| 290 | + if sender.tag == 1001 { | |
| 291 | + numberField.text = "2000" | |
| 292 | + } | |
| 293 | + if sender.tag == 1002 { | |
| 294 | + numberField.text = "3000" | |
| 295 | + } | |
| 296 | + if sender.tag == 1003 { | |
| 297 | + numberField.text = "全部" | |
| 298 | + } | |
| 299 | + tempBtn = sender | |
| 300 | + } | |
| 301 | +} | |
| 302 | + | |
| 303 | +extension CNLiveMineExchangeViewController { | |
| 304 | + | |
| 305 | + @objc func numberChangeAction(textField: UITextField) { | |
| 306 | + if textField.text?.count == 0 { | |
| 307 | + tempString = "" | |
| 308 | + } | |
| 309 | + if isPurerFloat(str: textField.text!) { | |
| 310 | + textField.text = tempString | |
| 311 | + } | |
| 312 | + if !isPurerFloat(str: textField.text!) && textField.text!.count <= 10 { | |
| 313 | + tempString = textField.text | |
| 314 | + } | |
| 315 | + } | |
| 316 | + | |
| 317 | + func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { | |
| 318 | + if textField == numberField { | |
| 319 | + if !checkDecimal(str: textField.text?.appending(string) ?? "") { | |
| 320 | + if textField.text!.count > 0 && string == "." && !textField.text!.contains(".") { | |
| 321 | + return true | |
| 322 | + } | |
| 323 | + return string == "" | |
| 324 | + } | |
| 325 | + } | |
| 326 | + return true | |
| 327 | + } | |
| 328 | + | |
| 329 | + func textFieldShouldEndEditing(_ textField: UITextField) -> Bool { | |
| 330 | + if textField == numberField && !textField.text!.isEmpty && textField.text!.count > 10 { | |
| 331 | + if !textField.text!.contains(".") { | |
| 332 | + textField.text = textField.text!.prefix(10).lowercased() | |
| 333 | + }else{ | |
| 334 | + let range = textField.text!.range(of: ".") | |
| 335 | + let new_text = textField.text!.suffix(from: range!.upperBound) | |
| 336 | + if new_text.count == 0 { | |
| 337 | + textField.text = textField.text!+"00" | |
| 338 | + } | |
| 339 | + if new_text.count == 1 { | |
| 340 | + textField.text = textField.text!+"0" | |
| 341 | + } | |
| 342 | + } | |
| 343 | + } | |
| 344 | + return true | |
| 345 | + } | |
| 346 | + | |
| 347 | + /// 已经结束输入的时候调用 | |
| 348 | + /// - Parameter textField: textField | |
| 349 | + func textFieldDidEndEditing(_ textField: UITextField) { | |
| 350 | + if textField == numberField { | |
| 351 | + let number = (textField.text! as NSString).floatValue | |
| 352 | + if number < 100 { | |
| 353 | + showErrorMessage(message: "至少兑换100积分") | |
| 354 | + } | |
| 355 | + if number > 10000 { | |
| 356 | + showErrorMessage(message: "超过已经拥有积分数") | |
| 357 | + } | |
| 358 | + } | |
| 359 | + } | |
| 360 | + | |
| 361 | + /// 开始显示的时候去掉提示 | |
| 362 | + /// - Parameter textField: textField | |
| 363 | + /// - Returns: | |
| 364 | + func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool { | |
| 365 | + showErrorMessage(message: "", clear: true) | |
| 366 | + return true | |
| 367 | + } | |
| 368 | + | |
| 369 | + /// 显示下面的提示框 | |
| 370 | + /// - Parameters: | |
| 371 | + /// - message: 提示消息 | |
| 372 | + /// - clear: 是否情况消息 | |
| 373 | + private func showErrorMessage(message: String,clear: Bool = false) { | |
| 374 | + if clear { | |
| 375 | + tipBtn.isHidden = true | |
| 376 | + topView.snp.remakeConstraints { make in | |
| 377 | + make.centerX.equalToSuperview() | |
| 378 | + make.top.equalTo(get_system_nav_height()+30) | |
| 379 | + make.left.equalToSuperview().offset(20) | |
| 380 | + make.right.equalToSuperview().offset(-20) | |
| 381 | + make.height.equalTo(150) | |
| 382 | + } | |
| 383 | + return | |
| 384 | + } | |
| 385 | + tipBtn.setTitle(message, for: .normal) | |
| 386 | + tipBtn.isHidden = false | |
| 387 | + topView.snp.remakeConstraints { make in | |
| 388 | + make.centerX.equalToSuperview() | |
| 389 | + make.top.equalTo(get_system_nav_height()+30) | |
| 390 | + make.left.equalToSuperview().offset(20) | |
| 391 | + make.right.equalToSuperview().offset(-20) | |
| 392 | + make.height.equalTo(170) | |
| 393 | + } | |
| 394 | + } | |
| 395 | + | |
| 396 | + /// 判断是不是小数 | |
| 397 | + /// - Parameter str: 需要判断的字符串 | |
| 398 | + /// - Returns: 返回 | |
| 399 | + private func isPurerFloat(str: String) -> Bool { | |
| 400 | + let scan = Scanner(string: str) | |
| 401 | + var val: Float = 0.0 | |
| 402 | + if scan.scanHexFloat(&val) && scan.isAtEnd { | |
| 403 | + if Float(str)! >= 0 { | |
| 404 | + return true | |
| 405 | + } else { | |
| 406 | + return false | |
| 407 | + } | |
| 408 | + } | |
| 409 | + return false | |
| 410 | + } | |
| 411 | + | |
| 412 | + /// 判断是不是两位小数 | |
| 413 | + /// - Parameter str: str | |
| 414 | + private func checkDecimal(str: String) -> Bool { | |
| 415 | + let pred = NSPredicate(format: "SELF MATCHES %@", "^[0-9]+(\\.[0-9]{1,2})?$") | |
| 416 | + return pred.evaluate(with: str) | |
| 417 | + } | |
| 418 | + | |
| 130 | 419 | } | ... | ... |
metaCode/Classes/Main/MinePage/Controller/CNLiveMineViewController.swift
| ... | ... | @@ -69,10 +69,18 @@ class CNLiveMineViewController : CNLiveBaseViewController, UITableViewDelegate, |
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | + public func loadDataWithPoint() { | |
| 73 | + CNLiveMineViewModel.requestWithCheckIn { [weak self] result, respStatue in | |
| 74 | + print("\(result)") | |
| 75 | +// if respStatue == .succ | |
| 76 | + } | |
| 77 | + } | |
| 78 | + | |
| 72 | 79 | override func viewWillAppear(_ animated: Bool) { |
| 73 | 80 | super.viewWillAppear(animated) |
| 74 | 81 | headerView.updateHeaderView() |
| 75 | 82 | tableView.reloadData() |
| 83 | + loadDataWithPoint() | |
| 76 | 84 | } |
| 77 | 85 | |
| 78 | 86 | override var preferredStatusBarStyle: UIStatusBarStyle { | ... | ... |
metaCode/Classes/Main/MinePage/View/CNLiveMineBodyListView.swift
| ... | ... | @@ -55,7 +55,6 @@ class MineBodyOneListViewCell : UITableViewCell { |
| 55 | 55 | return tipLabel |
| 56 | 56 | }() |
| 57 | 57 | |
| 58 | - | |
| 59 | 58 | override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { |
| 60 | 59 | super.init(style: style, reuseIdentifier: reuseIdentifier) |
| 61 | 60 | self.selectionStyle = .none |
| ... | ... | @@ -66,7 +65,6 @@ class MineBodyOneListViewCell : UITableViewCell { |
| 66 | 65 | headerView.addSubview(nameLabel) |
| 67 | 66 | mainView.addSubview(tipLabel) |
| 68 | 67 | mainView.addSubview(lookBtn) |
| 69 | - | |
| 70 | 68 | setupConstraints() |
| 71 | 69 | } |
| 72 | 70 | |
| ... | ... | @@ -129,6 +127,7 @@ class MineBodyOneListViewCell : UITableViewCell { |
| 129 | 127 | make.width.equalTo(80) |
| 130 | 128 | make.height.equalTo(30) |
| 131 | 129 | } |
| 130 | + | |
| 132 | 131 | lookBtn.setGradient(colors: [UIColor(red: 103/255.0, green: 197/255.0, blue: 255/255.0, alpha: 1),UIColor(red: 96/255.0, green: 154/255.0, blue: 255/255.0, alpha: 1)], startPoint: CGPoint(x: 0, y: 0.5), endPoint: CGPoint(x: 1, y: 0.5)) |
| 133 | 132 | } |
| 134 | 133 | } | ... | ... |
metaCode/Classes/Main/MinePage/View/CNLiveMineHeaderView.swift
| ... | ... | @@ -496,6 +496,7 @@ class MineEarnHeaderView: UIView { |
| 496 | 496 | exChangeBtn.setTitle("去兑换", for: .normal) |
| 497 | 497 | exChangeBtn.setImage(UIImage(named: "mine_list_icon_right_white_more"), for: .normal) |
| 498 | 498 | exChangeBtn.setupButtonImageAndTitlePossitionWith(padding: 0, style: .right) |
| 499 | + exChangeBtn.sizeToFit() | |
| 499 | 500 | exChangeBtn.addTarget(self, action: #selector(pushExChangeMethod), for: .touchUpInside) |
| 500 | 501 | return exChangeBtn |
| 501 | 502 | }() | ... | ... |
metaCode/Classes/Main/MinePage/ViewModel/CNLiveMineBaseModel.swift
| ... | ... | @@ -287,5 +287,12 @@ final class MineAuthListModel: BaseModel , TableCodable { |
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - | |
| 290 | +// !!!: /Daren/integral/checkIn.action 数据返回 | |
| 291 | +class MinePointCheckInModel: BaseModel { | |
| 292 | + var scores = [String]() | |
| 293 | + var status: String? = "" | |
| 294 | + var score: String? = "" | |
| 295 | + var times: String? = "" | |
| 296 | + var url: String? = "" | |
| 297 | +} | |
| 291 | 298 | ... | ... |
metaCode/Classes/Main/MinePage/ViewModel/CNLiveMineViewModel.swift
| ... | ... | @@ -566,7 +566,7 @@ class CNLiveMineViewModel: NSObject { |
| 566 | 566 | CNLiveMineViewModel.requestsStandInfo(identityId: id, type: .effect) { result, respStatue in |
| 567 | 567 | if respStatue == .success { |
| 568 | 568 | let listBaseModel = result as! MineStandInfoBaseModel |
| 569 | - if listBaseModel.authTime > 0 { | |
| 569 | + if listBaseModel.authTime > 0 || listBaseModel.code!.count > 0 { | |
| 570 | 570 | showMessage(message: listBaseModel.name!.count > 0 ? "恭喜您通过认证,您已是\(listBaseModel.name ?? "")" : "恭喜您通过认证") |
| 571 | 571 | resultBlock(listBaseModel, .success) |
| 572 | 572 | NotificationCenter.default.post(name: Notification.Name.StandAuth.StandAuthNotificationSuccess, object: nil) |
| ... | ... | @@ -584,6 +584,45 @@ class CNLiveMineViewModel: NSObject { |
| 584 | 584 | codeTimer.resume() |
| 585 | 585 | } |
| 586 | 586 | |
| 587 | +//!!!: 积分相关接口请求 | |
| 588 | + | |
| 589 | + /// 获取积分余额相关数据接口 | |
| 590 | + /// - Parameter resultBlock: 返回 | |
| 591 | + static func requestWithCheckIn(resultBlock: @escaping resultNewsBlock) { | |
| 592 | + let param = NSMutableDictionary() | |
| 593 | + param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid") | |
| 594 | + CNLiveNetworking.setAllowRequestDefaultArgument(true) | |
| 595 | + CNLiveNetworking.setupShowDataResult(false) | |
| 596 | + CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseWjjUrl+"/Daren/integral/checkIn.action", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in | |
| 597 | + hiddenLoading() | |
| 598 | + if (error == nil) { | |
| 599 | + let resp = result as! NSDictionary | |
| 600 | + let errorCode = "\(resp["errorCode"] ?? "0")" | |
| 601 | + if (errorCode == "0") { | |
| 602 | + let listModel = dictionaryToModel(resp as! [String : Any], MinePointCheckInModel.self,"data") as! MinePointCheckInModel | |
| 603 | + resultBlock(listModel,.success) | |
| 604 | + } else { | |
| 605 | + showMessage(message: resp["errorMessage"] as! String) | |
| 606 | + resultBlock(NSNull(),.failed) | |
| 607 | + } | |
| 608 | + } else { | |
| 609 | + if CNLiveNetworking.isNetworking() { | |
| 610 | + showMessage(message: "获取失败") | |
| 611 | + resultBlock(NSNull(),.failed) | |
| 612 | + } else { | |
| 613 | + showMessage(message: "似乎与网络断开链接") | |
| 614 | + resultBlock(NSNull(),.noNetwork) | |
| 615 | + } | |
| 616 | + } | |
| 617 | + } | |
| 618 | + } | |
| 619 | + | |
| 620 | + /// 获取任务列表接口 | |
| 621 | + /// - Parameter resultBlock: 返回 | |
| 622 | + static func requestWithTaskList(resultBlock: @escaping resultNewsBlock) { | |
| 623 | + | |
| 624 | + } | |
| 625 | + | |
| 587 | 626 | /// 获取十位时间戳 |
| 588 | 627 | static var timeStamp: Int { |
| 589 | 628 | let timeInterval: TimeInterval = NSDate().timeIntervalSince1970 | ... | ... |
metaCode/Classes/Other/AppDelegate.swift
| ... | ... | @@ -68,11 +68,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate { |
| 68 | 68 | let ver : String = Bundle.main.infoDictionary?["CFBundleVersion"] as! String |
| 69 | 69 | let p : Dictionary = ["platform_id":kAppBundleID,"uuid":uuid,"plat":"i","ver":ver,"appId":APPId,"timestamp":String(NSNumber(floatLiteral: Date().timeIntervalSince1970).intValue),"clientPlat":"i","frmId":"ios"] |
| 70 | 70 | CNLiveNetworking.setupDefaultParam(p) |
| 71 | + | |
| 72 | + let shop_dic : Dictionary = ["Phone-Model":"iPhone","Uid":UserInfoManager.shared.userInfo.uid ?? "","CFBundleShortVersionString":ver,"Shop-Version":"0.6.2"] | |
| 73 | + CNLiveNetworking.setupDSShopParam(shop_dic) | |
| 74 | + | |
| 71 | 75 | CNLiveNetworking.setupShowDataResult(false) |
| 72 | 76 | CNLiveNetworking.setupSignKey(APPKey) |
| 73 | 77 | CNLiveNetworking.setAllowRequestDefaultArgument(true) |
| 74 | 78 | CNLiveNetworking.setResponseSerializerType(.JSON) |
| 75 | 79 | CNLiveNetworking.setupBaseURL(APPLoginHost) |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 76 | 83 | } |
| 77 | 84 | |
| 78 | 85 | ... | ... |
metaCode/Supporting Files/Assets.xcassets/MinePage/mine_header_quest_tip_black.imageset/Contents.json
0 → 100644
| 1 | +{ | |
| 2 | + "images" : [ | |
| 3 | + { | |
| 4 | + "idiom" : "universal", | |
| 5 | + "scale" : "1x" | |
| 6 | + }, | |
| 7 | + { | |
| 8 | + "filename" : "mine_header_quest_tip_black@2x.png", | |
| 9 | + "idiom" : "universal", | |
| 10 | + "scale" : "2x" | |
| 11 | + }, | |
| 12 | + { | |
| 13 | + "filename" : "mine_header_quest_tip_black@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_header_quest_tip_black.imageset/mine_header_quest_tip_black@2x.png
0 → 100644
604 Bytes
metaCode/Supporting Files/Assets.xcassets/MinePage/mine_header_quest_tip_black.imageset/mine_header_quest_tip_black@3x.png
0 → 100644
1.13 KB
metaCode/Supporting Files/Assets.xcassets/MinePage/mine_header_quest_tip_red.imageset/Contents.json
0 → 100644
| 1 | +{ | |
| 2 | + "images" : [ | |
| 3 | + { | |
| 4 | + "idiom" : "universal", | |
| 5 | + "scale" : "1x" | |
| 6 | + }, | |
| 7 | + { | |
| 8 | + "filename" : "mine_header_quest_tip_red@2x.png", | |
| 9 | + "idiom" : "universal", | |
| 10 | + "scale" : "2x" | |
| 11 | + }, | |
| 12 | + { | |
| 13 | + "filename" : "mine_header_quest_tip_red@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_header_quest_tip_red.imageset/mine_header_quest_tip_red@2x.png
0 → 100644
625 Bytes
metaCode/Supporting Files/Assets.xcassets/MinePage/mine_header_quest_tip_red.imageset/mine_header_quest_tip_red@3x.png
0 → 100644
1.15 KB