Commit b63089ba6c1ca54723f50ee89cee6da305dfc0ff

Authored by “张旭”
1 parent 84ef1fb5

更改手机号 , 功能未测试

metaCode.xcodeproj/project.pbxproj
@@ -131,6 +131,7 @@ @@ -131,6 +131,7 @@
131 19C0F76B2BDB432A0097CC8F /* CNLiveMineBindingManagerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19C0F76A2BDB432A0097CC8F /* CNLiveMineBindingManagerController.swift */; }; 131 19C0F76B2BDB432A0097CC8F /* CNLiveMineBindingManagerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19C0F76A2BDB432A0097CC8F /* CNLiveMineBindingManagerController.swift */; };
132 19C0F76D2BDB48750097CC8F /* CNBindingManageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19C0F76C2BDB48750097CC8F /* CNBindingManageCell.swift */; }; 132 19C0F76D2BDB48750097CC8F /* CNBindingManageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19C0F76C2BDB48750097CC8F /* CNBindingManageCell.swift */; };
133 19C0F76F2BDB4CE10097CC8F /* CNBindingManageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19C0F76E2BDB4CE10097CC8F /* CNBindingManageModel.swift */; }; 133 19C0F76F2BDB4CE10097CC8F /* CNBindingManageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19C0F76E2BDB4CE10097CC8F /* CNBindingManageModel.swift */; };
  134 + 19C0F7712BDE1A3B0097CC8F /* CNLiveMineChangePhoneController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19C0F7702BDE1A3B0097CC8F /* CNLiveMineChangePhoneController.swift */; };
134 19CC4D472ADD006600308E2A /* CNDownSlideSingleCourseCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19CC4D462ADD006600308E2A /* CNDownSlideSingleCourseCell.swift */; }; 135 19CC4D472ADD006600308E2A /* CNDownSlideSingleCourseCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19CC4D462ADD006600308E2A /* CNDownSlideSingleCourseCell.swift */; };
135 19CC4D492ADD06C500308E2A /* UITableView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19CC4D482ADD06C500308E2A /* UITableView+Extension.swift */; }; 136 19CC4D492ADD06C500308E2A /* UITableView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19CC4D482ADD06C500308E2A /* UITableView+Extension.swift */; };
136 19CC4D4B2ADD086F00308E2A /* CNUpSlideDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19CC4D4A2ADD086F00308E2A /* CNUpSlideDetailViewController.swift */; }; 137 19CC4D4B2ADD086F00308E2A /* CNUpSlideDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19CC4D4A2ADD086F00308E2A /* CNUpSlideDetailViewController.swift */; };
@@ -411,6 +412,7 @@ @@ -411,6 +412,7 @@
411 19C0F76A2BDB432A0097CC8F /* CNLiveMineBindingManagerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveMineBindingManagerController.swift; sourceTree = "<group>"; }; 412 19C0F76A2BDB432A0097CC8F /* CNLiveMineBindingManagerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveMineBindingManagerController.swift; sourceTree = "<group>"; };
412 19C0F76C2BDB48750097CC8F /* CNBindingManageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNBindingManageCell.swift; sourceTree = "<group>"; }; 413 19C0F76C2BDB48750097CC8F /* CNBindingManageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNBindingManageCell.swift; sourceTree = "<group>"; };
413 19C0F76E2BDB4CE10097CC8F /* CNBindingManageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNBindingManageModel.swift; sourceTree = "<group>"; }; 414 19C0F76E2BDB4CE10097CC8F /* CNBindingManageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNBindingManageModel.swift; sourceTree = "<group>"; };
  415 + 19C0F7702BDE1A3B0097CC8F /* CNLiveMineChangePhoneController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveMineChangePhoneController.swift; sourceTree = "<group>"; };
414 19CC4D462ADD006600308E2A /* CNDownSlideSingleCourseCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNDownSlideSingleCourseCell.swift; sourceTree = "<group>"; }; 416 19CC4D462ADD006600308E2A /* CNDownSlideSingleCourseCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNDownSlideSingleCourseCell.swift; sourceTree = "<group>"; };
415 19CC4D482ADD06C500308E2A /* UITableView+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITableView+Extension.swift"; sourceTree = "<group>"; }; 417 19CC4D482ADD06C500308E2A /* UITableView+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITableView+Extension.swift"; sourceTree = "<group>"; };
416 19CC4D4A2ADD086F00308E2A /* CNUpSlideDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNUpSlideDetailViewController.swift; sourceTree = "<group>"; }; 418 19CC4D4A2ADD086F00308E2A /* CNUpSlideDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNUpSlideDetailViewController.swift; sourceTree = "<group>"; };
@@ -1141,6 +1143,7 @@ @@ -1141,6 +1143,7 @@
1141 79E672022AFDFA9C00F2F768 /* CNLiveMineSignOutViewController.swift */, 1143 79E672022AFDFA9C00F2F768 /* CNLiveMineSignOutViewController.swift */,
1142 79DC67632B5FB60900261A94 /* CNLiveMineAuthFormViewController.swift */, 1144 79DC67632B5FB60900261A94 /* CNLiveMineAuthFormViewController.swift */,
1143 19C0F76A2BDB432A0097CC8F /* CNLiveMineBindingManagerController.swift */, 1145 19C0F76A2BDB432A0097CC8F /* CNLiveMineBindingManagerController.swift */,
  1146 + 19C0F7702BDE1A3B0097CC8F /* CNLiveMineChangePhoneController.swift */,
1144 ); 1147 );
1145 path = Controller; 1148 path = Controller;
1146 sourceTree = "<group>"; 1149 sourceTree = "<group>";
@@ -1998,6 +2001,7 @@ @@ -1998,6 +2001,7 @@
1998 79A212C22B0B5D0700BFA8E3 /* CNLiveShopBodyCouponManagerView.swift in Sources */, 2001 79A212C22B0B5D0700BFA8E3 /* CNLiveShopBodyCouponManagerView.swift in Sources */,
1999 794FF1072B01FC9800385E85 /* CNLiveShopOrderSearchListViewController.swift in Sources */, 2002 794FF1072B01FC9800385E85 /* CNLiveShopOrderSearchListViewController.swift in Sources */,
2000 798A44E82A30134400815935 /* CNLiveMineHeaderView.swift in Sources */, 2003 798A44E82A30134400815935 /* CNLiveMineHeaderView.swift in Sources */,
  2004 + 19C0F7712BDE1A3B0097CC8F /* CNLiveMineChangePhoneController.swift in Sources */,
2001 7C49312D2A2DB9FA000E44B4 /* UITabBar+CNLiveExtensions.swift in Sources */, 2005 7C49312D2A2DB9FA000E44B4 /* UITabBar+CNLiveExtensions.swift in Sources */,
2002 79A267832AF8D7BC0088D9F6 /* CNLiveShopBodyCustomView.swift in Sources */, 2006 79A267832AF8D7BC0088D9F6 /* CNLiveShopBodyCustomView.swift in Sources */,
2003 1917335E2B328495007BCC04 /* CNLiveCouponListTableViewCell.swift in Sources */, 2007 1917335E2B328495007BCC04 /* CNLiveCouponListTableViewCell.swift in Sources */,
metaCode/Classes/Config/CNLiveConfigUserInfo.swift
@@ -18,6 +18,7 @@ class UserInfoModel: BaseModel { @@ -18,6 +18,7 @@ class UserInfoModel: BaseModel {
18 var bigFaceUrl:String = "" 18 var bigFaceUrl:String = ""
19 var birthday:String = "" 19 var birthday:String = ""
20 var countryCode:String = "" 20 var countryCode:String = ""
  21 + var countryName:String = ""
21 var email:String = "" 22 var email:String = ""
22 var extInfo:String = "" 23 var extInfo:String = ""
23 var faceUrl:String = "" 24 var faceUrl:String = ""
metaCode/Classes/Main/LoginPage/Controller/CNLiveLoginViewController.swift
@@ -431,7 +431,7 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate { @@ -431,7 +431,7 @@ class CNLiveLoginViewController : CNLiveBaseViewController, UITextViewDelegate {
431 extension CNLiveLoginViewController { 431 extension CNLiveLoginViewController {
432 432
433 @objc func changeCityNumberMothod(sender : UIButton) { 433 @objc func changeCityNumberMothod(sender : UIButton) {
434 - CNLiveLoginPickerView.showSelectView { [weak self] text in 434 + CNLiveLoginPickerView.showSelectView { [weak self] text,countryStr in
435 self!.countryCode = text 435 self!.countryCode = text
436 self!.areaButton.setTitle("+\(text)", for: .normal) 436 self!.areaButton.setTitle("+\(text)", for: .normal)
437 self!.areaButton.setTitle("+\(text)", for: .highlighted) 437 self!.areaButton.setTitle("+\(text)", for: .highlighted)
metaCode/Classes/Main/LoginPage/Controller/CNThreeLoginViewController.swift
@@ -238,7 +238,7 @@ class CNThreeLoginViewController:CNLiveBaseViewController{ @@ -238,7 +238,7 @@ class CNThreeLoginViewController:CNLiveBaseViewController{
238 } 238 }
239 239
240 @objc func changeCityNumberMothod(sender : UIButton) { 240 @objc func changeCityNumberMothod(sender : UIButton) {
241 - CNLiveLoginPickerView.showSelectView { [weak self] text in 241 + CNLiveLoginPickerView.showSelectView { [weak self] text,countryStr in
242 self!.countryCode = text 242 self!.countryCode = text
243 self!.areaButton.setTitle("+\(text)", for: .normal) 243 self!.areaButton.setTitle("+\(text)", for: .normal)
244 self!.areaButton.setTitle("+\(text)", for: .highlighted) 244 self!.areaButton.setTitle("+\(text)", for: .highlighted)
metaCode/Classes/Main/LoginPage/View/CNLiveLoginPickerView.swift
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 7
8 import Foundation 8 import Foundation
9 9
10 -typealias CloseClickResultBlock = (_ text: String) ->Void 10 +typealias CloseClickResultBlock = (_ text: String,_ countryStr: String) ->Void
11 11
12 class CNLiveLoginPickerView : UIView, UIPickerViewDelegate,UIPickerViewDataSource { 12 class CNLiveLoginPickerView : UIView, UIPickerViewDelegate,UIPickerViewDataSource {
13 13
@@ -66,6 +66,7 @@ class CNLiveLoginPickerView : UIView, UIPickerViewDelegate,UIPickerViewDataSourc @@ -66,6 +66,7 @@ class CNLiveLoginPickerView : UIView, UIPickerViewDelegate,UIPickerViewDataSourc
66 66
67 var resutBlock : CloseClickResultBlock? 67 var resutBlock : CloseClickResultBlock?
68 var result_string : String = "" 68 var result_string : String = ""
  69 + var result_Countrystring : String = ""
69 70
70 override init(frame: CGRect) { 71 override init(frame: CGRect) {
71 super.init(frame: frame) 72 super.init(frame: frame)
@@ -172,6 +173,7 @@ extension CNLiveLoginPickerView { @@ -172,6 +173,7 @@ extension CNLiveLoginPickerView {
172 func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { 173 func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
173 let param = country_array[row] as! NSDictionary 174 let param = country_array[row] as! NSDictionary
174 result_string = param["code"] as! String 175 result_string = param["code"] as! String
  176 + result_Countrystring = param["name"] as! String
175 } 177 }
176 } 178 }
177 179
@@ -182,9 +184,11 @@ extension CNLiveLoginPickerView { @@ -182,9 +184,11 @@ extension CNLiveLoginPickerView {
182 if result_string == ""{ 184 if result_string == ""{
183 let param = country_array[0] as! NSDictionary 185 let param = country_array[0] as! NSDictionary
184 let code = param["code"] as? String 186 let code = param["code"] as? String
  187 + let country = param["name"] as? String
  188 + result_Countrystring = country ?? ""
185 result_string = code ?? "" 189 result_string = code ?? ""
186 } 190 }
187 - resutBlock(result_string) 191 + resutBlock(result_string, result_Countrystring)
188 } 192 }
189 disMissView() 193 disMissView()
190 } 194 }
metaCode/Classes/Main/LoginPage/ViewModel/CNLiveLoginViewModel.swift
@@ -67,6 +67,50 @@ class CNLiveLoginViewModel : NSObject { @@ -67,6 +67,50 @@ class CNLiveLoginViewModel : NSObject {
67 } 67 }
68 } 68 }
69 69
  70 + /// 修改手机号获取验证码
  71 + /// - Parameters:
  72 + /// - phone: 手机号
  73 + /// - code: 验证码
  74 + static func requestChangePhoneVerCodeAction(phone: String, code: String, resultBlock: @escaping resultCodeBlock) {
  75 +
  76 + if !phone.isNotBlank() {
  77 + showMessage(message: "请输入手机号")
  78 + return
  79 + }
  80 + if phone.lengthOfBytes(using: .utf8) >= 20 {
  81 + showMessage(message: "手机号格式不正确")
  82 + return
  83 + }
  84 + if !phone.isPurnInt() {
  85 + showMessage(message: "手机号格式不正确")
  86 + return
  87 + }
  88 + showLoading(message: "")
  89 + let param = ["mobile":phone,"countryCode":code,"clientPlat":"i"]
  90 + let custom_param = NSMutableDictionary()
  91 + custom_param.setValue(CNLiveMCEnvironmentManager.shared.appId, forKey: "appId")
  92 + custom_param.setValue(CNLiveMCEnvironmentManager.shared.appKey, forKey: "appKey")
  93 + CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
  94 + CNLiveNetworking.setAllowRequestDefaultArgument(true)
  95 + CNLiveNetworking.setupShowDataResult(false)
  96 + CNLiveNetworking.setupShowResult(true)
  97 + CNLiveNetworking.requestNetwork(with: .POST, urlString: CNLiveMCEnvironmentManager.shared.loginHost+"/open/api2/user/sendVerifyCodeForUnRegistered", param: param, cacheType: .networkOnly) { task, result, error in
  98 + hiddenLoading()
  99 + if (error == nil) {
  100 + let resp = result as! NSDictionary
  101 + let errorCode = resp["errorCode"]
  102 + if (errorCode as! String == "0") {
  103 + showMessage(message: "验证码已发送")
  104 + resultBlock()
  105 + } else {
  106 + showMessage(message: resp["errorMessage"] as! String)
  107 + }
  108 + } else{
  109 + showMessage(message: "获取验证码失败")
  110 + }
  111 + }
  112 + }
  113 +
70 /// 登陆 114 /// 登陆
71 /// - Parameters: 115 /// - Parameters:
72 /// - userName: 手机号 116 /// - userName: 手机号
metaCode/Classes/Main/MinePage/Controller/CNLiveMineBindingManagerController.swift
@@ -86,7 +86,7 @@ class CNLiveMineBindingManagerController:CNLiveBaseViewController, UITableViewDa @@ -86,7 +86,7 @@ class CNLiveMineBindingManagerController:CNLiveBaseViewController, UITableViewDa
86 func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 86 func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
87 if indexPath.row == 0{ 87 if indexPath.row == 0{
88 //跳转绑定手机号页面 88 //跳转绑定手机号页面
89 - 89 + self.navigationController?.pushViewController(CNLiveMineChangePhoneController(), animated: true)
90 } 90 }
91 } 91 }
92 } 92 }
metaCode/Classes/Main/MinePage/Controller/CNLiveMineChangePhoneController.swift 0 → 100644
  1 +//
  2 +// CNLiveMineChangePhoneController.swift
  3 +// metaCode
  4 +//
  5 +// Created by zx on 2024/4/28.
  6 +// 更换手机号
  7 +
  8 +import Foundation
  9 +import APButton
  10 +import SnapKit
  11 +
  12 +class CNLiveMineChangePhoneController:CNLiveBaseViewController{
  13 +
  14 + lazy var countryView :UIView = {
  15 + let countryView = UIView()
  16 + countryView.backgroundColor = .white
  17 + countryView.layer.cornerRadius = 9
  18 + countryView.clipsToBounds = true
  19 + return countryView
  20 + }()
  21 +
  22 + lazy var countryLabel: UILabel = {
  23 + let titleLabel = UILabel()
  24 + titleLabel.textColor = HexColor("#333333")
  25 + titleLabel.text = "国家"
  26 + titleLabel.font = Font_15
  27 + return titleLabel
  28 + }()
  29 +
  30 + lazy var moreImgView :UIImageView = {
  31 + let moreImgView = UIImageView()
  32 + moreImgView.image = UIImage(named: "mine_set_band_detail")
  33 + return moreImgView
  34 + }()
  35 +
  36 + lazy var areaButton : UIButton = {
  37 + let areaButton = UIButton(type: .custom)
  38 + areaButton.backgroundColor = .white
  39 + areaButton.setTitle("+86", for: .normal)
  40 + areaButton.setTitle("+86", for: .highlighted)
  41 + areaButton.titleLabel?.font = BoldFont_16
  42 + areaButton.setTitleColor(HexColor("#333333"), for: .normal)
  43 + areaButton.setTitleColor(HexColor("#333333"), for: .highlighted)
  44 + areaButton.addTarget(self, action: #selector(changeCityNumberMothod), for: .touchUpInside)
  45 + return areaButton
  46 + }()
  47 +
  48 + lazy var phoneCodeView :UIView = {
  49 + let countryView = UIView()
  50 + countryView.backgroundColor = .white
  51 + countryView.layer.cornerRadius = 9
  52 + countryView.clipsToBounds = true
  53 + return countryView
  54 + }()
  55 +
  56 + lazy var phoneLabel: UILabel = {
  57 + let titleLabel = UILabel()
  58 + titleLabel.textColor = HexColor("#333333")
  59 + titleLabel.text = "手机号"
  60 + titleLabel.font = Font_15
  61 + return titleLabel
  62 + }()
  63 +
  64 + lazy var phoneText : UITextField = {
  65 + let phoneText = UITextField.init()
  66 + phoneText.backgroundColor = .white
  67 + phoneText.placeholder = "输入手机号"
  68 + phoneText.font = BoldFont_16_Fit
  69 + phoneText.keyboardType = .numberPad
  70 + phoneText.clearButtonMode = .whileEditing
  71 + return phoneText
  72 + }()
  73 +
  74 + lazy var phoneLineView :UIView = {
  75 + let countryView = UIView()
  76 + countryView.backgroundColor = HexColor("#F3F3F3")
  77 + return countryView
  78 + }()
  79 +
  80 + lazy var codeLabel: UILabel = {
  81 + let titleLabel = UILabel()
  82 + titleLabel.textColor = HexColor("#333333")
  83 + titleLabel.text = "验证码"
  84 + titleLabel.font = Font_15
  85 + return titleLabel
  86 + }()
  87 +
  88 + lazy var veriText: UITextField = {
  89 + let veriText = UITextField.init()
  90 + veriText.backgroundColor = .white
  91 + veriText.placeholder = "输入验证码"
  92 + veriText.font = BoldFont_16_Fit
  93 + veriText.keyboardType = .numberPad
  94 + veriText.clearButtonMode = .whileEditing
  95 + return veriText
  96 + }()
  97 +
  98 + lazy var loginButton: APButton = {
  99 + let loginButton = APButton()
  100 + loginButton.setTitle("更换手机号", for: .normal)
  101 + loginButton.setTitleColor(.white, for: .normal)
  102 + loginButton.titleLabel?.font = BoldFont_16_Fit
  103 + loginButton.layer.cornerRadius = 20
  104 + loginButton.activityIndicator.color = .white
  105 + loginButton.layer.masksToBounds = true
  106 + loginButton.addTarget(self, action: #selector(sendLoginActionMothod), for: .touchUpInside)
  107 + return loginButton
  108 + }()
  109 +
  110 + var countryCode: String = "86"
  111 + var countryStr: String = "中国"
  112 + var timeOut = 30//多少秒计时器
  113 +
  114 + override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
  115 + super.init(nibName: nil, bundle: nil)
  116 + }
  117 + required init?(coder: NSCoder) {
  118 + fatalError("init(coder:) has not been implemented")
  119 + }
  120 +
  121 + override func viewDidLoad() {
  122 + super.viewDidLoad()
  123 + setNeedsStatusBarAppearanceUpdate()
  124 + view.backgroundColor = HexColor(kCNDownSlideBackgroundColorHex)
  125 + navigationBarHidden = false
  126 + titleName = "更换手机号"
  127 +
  128 + self.setupCountryView()
  129 + self.setupPhoneView()
  130 + self.setupVeriCodeView()
  131 + self.setupLoginButtonView()
  132 + }
  133 +
  134 + deinit {
  135 + print("已经销毁了")
  136 + }
  137 +
  138 + override var preferredStatusBarStyle: UIStatusBarStyle {
  139 + return .lightContent
  140 + }
  141 +
  142 + func setupCountryView() {
  143 + self.view.addSubview(self.countryView)
  144 + self.countryView.snp.makeConstraints { make in
  145 + make.left.equalToSuperview().offset(15)
  146 + make.right.equalToSuperview().offset(-15)
  147 + make.top.equalTo(KNavigationHeight+15)
  148 + make.height.equalTo(61)
  149 + }
  150 +
  151 + self.countryView.addSubview(self.countryLabel)
  152 + self.countryLabel.snp.makeConstraints { make in
  153 + make.centerY.equalToSuperview()
  154 + make.left.equalToSuperview().offset(15)
  155 + }
  156 +
  157 + self.countryView.addSubview(self.moreImgView)
  158 + self.moreImgView.snp.makeConstraints { make in
  159 + make.centerY.equalToSuperview()
  160 + make.right.equalToSuperview().offset(-15)
  161 + make.width.height.equalTo(13)
  162 + }
  163 +
  164 + self.countryView.addSubview(self.areaButton)
  165 + self.areaButton.snp.makeConstraints { make in
  166 + make.centerY.equalToSuperview()
  167 + make.right.equalTo(self.moreImgView.snp.left)
  168 + make.width.lessThanOrEqualTo(50)
  169 + }
  170 +
  171 + }
  172 + func setupPhoneView() {
  173 +
  174 + self.view.addSubview(self.phoneCodeView)
  175 + self.phoneCodeView.snp.makeConstraints { make in
  176 + make.left.equalToSuperview().offset(15)
  177 + make.right.equalToSuperview().offset(-15)
  178 + make.top.equalTo(self.countryView.snp.bottom).offset(15)
  179 + make.height.equalTo(118)
  180 + }
  181 +
  182 + self.phoneCodeView.addSubview(self.phoneLabel)
  183 + self.phoneLabel.snp.makeConstraints { make in
  184 + make.left.equalToSuperview().offset(15)
  185 + make.top.equalToSuperview().offset(20)
  186 + make.width.equalTo(50)
  187 + make.height.equalTo(21)
  188 + }
  189 +
  190 + self.phoneCodeView.addSubview(self.phoneText)
  191 + self.phoneText.snp.makeConstraints { make in
  192 + make.centerY.equalTo(phoneLabel.snp.centerY)
  193 + make.left.equalTo(phoneLabel.snp.right).offset(19)
  194 + make.height.equalTo(21)
  195 + make.right.equalToSuperview().offset(-15)
  196 + }
  197 +
  198 + self.phoneCodeView.addSubview(self.phoneLineView)
  199 + self.phoneLineView.snp.makeConstraints { make in
  200 + make.left.equalToSuperview().offset(15)
  201 + make.right.equalToSuperview().offset(-15)
  202 + make.centerY.equalToSuperview()
  203 + make.height.equalTo(0.5)
  204 + }
  205 + }
  206 +
  207 + func setupVeriCodeView() {
  208 + self.phoneCodeView.addSubview(self.codeLabel)
  209 + self.codeLabel.snp.makeConstraints { make in
  210 + make.left.equalToSuperview().offset(15)
  211 + make.top.equalTo(self.phoneLineView.snp.bottom).offset(15)
  212 + make.width.equalTo(50)
  213 + make.height.equalTo(21)
  214 + }
  215 +
  216 + let codeButton = UIButton(type: .custom)
  217 + codeButton.backgroundColor = .white
  218 + codeButton.setTitle("获取验证码", for: .normal)
  219 + codeButton.setTitle("获取验证码", for: .highlighted)
  220 + codeButton.titleLabel?.font = Font_13
  221 + codeButton.setTitleColor(HexColor("#FEFFFF"), for: .normal)
  222 + codeButton.setTitleColor(HexColor("#FEFFFF"), for: .highlighted)
  223 + codeButton.layer.cornerRadius = 15.5
  224 + codeButton.clipsToBounds = true
  225 + // fillCode
  226 + let bgLayer1 = CAGradientLayer()
  227 + bgLayer1.colors = [UIColor(red: 1, green: 0.84, blue: 0.38, alpha: 1).cgColor, UIColor(red: 1, green: 0.55, blue: 0.21, alpha: 1).cgColor]
  228 + bgLayer1.locations = [0, 1]
  229 + bgLayer1.frame = CGRect(x: 0, y: 0, width: 100, height: 31)
  230 + bgLayer1.startPoint = CGPoint(x: 0, y: 0.5)
  231 + bgLayer1.endPoint = CGPoint(x: 0.5, y: 0.5)
  232 + codeButton.layer.insertSublayer(bgLayer1, at: 0)
  233 + codeButton.addTarget(self, action: #selector(sendVerifiCodeMothod), for: .touchUpInside)
  234 + self.phoneCodeView.addSubview(codeButton)
  235 + codeButton.snp.makeConstraints { make in
  236 + make.centerY.equalTo(self.codeLabel.snp.centerY)
  237 + make.right.equalToSuperview().offset(-15)
  238 + make.width.lessThanOrEqualTo(100)
  239 + make.height.equalTo(31)
  240 + }
  241 +
  242 + self.phoneCodeView.addSubview(veriText)
  243 + veriText.snp.makeConstraints { make in
  244 + make.centerY.equalTo(self.codeLabel.snp.centerY)
  245 + make.right.equalTo(codeButton.snp.left).offset(-20)
  246 + make.height.equalTo(codeButton.snp.height)
  247 + make.left.equalTo(self.codeLabel.snp.right).offset(19)
  248 + }
  249 + }
  250 + func setupLoginButtonView() {
  251 +
  252 + view.addSubview(loginButton)
  253 + loginButton.snp.makeConstraints { make in
  254 + make.centerX.equalTo(view)
  255 + make.top.equalTo(veriText.snp.bottom).offset(adapt_length(length: 105))
  256 + make.left.equalTo(40)
  257 + make.right.equalTo(-40)
  258 + make.height.equalTo(40)
  259 + }
  260 +
  261 + loginButton.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))
  262 +
  263 + }
  264 +
  265 + @objc func changeCityNumberMothod(sender : UIButton) {
  266 + CNLiveLoginPickerView.showSelectView { [weak self] codeStr,countryStr in
  267 + self!.countryCode = codeStr
  268 + self!.countryStr = countryStr
  269 + self!.areaButton.setTitle("+\(codeStr)", for: .normal)
  270 + self!.areaButton.setTitle("+\(codeStr)", for: .highlighted)
  271 + self?.countryLabel.text = countryStr
  272 + }
  273 + }
  274 +
  275 + @objc func sendVerifiCodeMothod(sender : UIButton) {
  276 + view.endEditing(true)
  277 + CNLiveLoginViewModel.requestChangePhoneVerCodeAction(phone: phoneText.text ?? "", code: countryCode) { [weak self] in
  278 + self!.setupCountdownAction(sender: sender)
  279 + }
  280 + }
  281 +
  282 + @objc func sendLoginActionMothod(sender : UIButton) {
  283 + view.endEditing(true)
  284 + if phoneText.text ?? "" == ""{
  285 + showMessage(message: "请输入手机号")
  286 + return
  287 + }
  288 + if veriText.text ?? "" == ""{
  289 + showMessage(message: "请输入验证码")
  290 + return
  291 + }
  292 + if veriText.text?.count != 6{
  293 + showMessage(message: "请输入正确的验证码")
  294 + return
  295 + }
  296 + showLoading(message: "")
  297 + // 绑定手机号请求登录
  298 + CNLiveMineViewModel.sendChangePhone(mobile: phoneText.text ?? "", countryCode: self.countryCode, verificationCode: veriText.text ?? "") { result, status in
  299 + if status == .success{
  300 +
  301 + let userInfo = UserInfoManager.shared.userInfo
  302 + userInfo.mobile = self.phoneText.text ?? ""
  303 + userInfo.countryName = self.countryStr
  304 + userInfo.countryCode = self.countryCode
  305 + UserInfoManager.cacheUserInfo(userInfo: userInfo)
  306 + showMessage(message: "更改成功")
  307 + self.navigationController?.popViewController(animated: true)
  308 + }else{
  309 +
  310 + }
  311 + }
  312 +
  313 +
  314 + }
  315 +
  316 + /// 设置发送验证码按钮
  317 + /// - Parameter sender: 按钮
  318 + private func setupCountdownAction(sender : UIButton) {
  319 + var timeOut = self.timeOut
  320 + let queue: DispatchQueue = DispatchQueue.global(qos: DispatchQoS.QoSClass.default)
  321 + let _timer: DispatchSource = DispatchSource.makeTimerSource(flags: [], queue: queue) as! DispatchSource
  322 + _timer.schedule(wallDeadline: DispatchWallTime.now(), repeating: .seconds(1))
  323 + //一秒执行
  324 + _timer.setEventHandler(handler: { () -> Void in
  325 + if timeOut <= 0 {
  326 + _timer.cancel()
  327 + DispatchQueue.main.sync(execute: { () -> Void in
  328 + sender.setTitle("获取验证码", for: .normal)
  329 + sender.isEnabled = true
  330 + })
  331 + } else {
  332 + let seconds = timeOut
  333 + DispatchQueue.main.sync(execute: {() -> Void in
  334 + let str = String(describing: seconds)
  335 + sender.setTitle("\(str)s重新获取", for: .normal)
  336 + sender.isEnabled = false
  337 + })
  338 + timeOut -= 1
  339 + }
  340 + })
  341 + _timer.resume()
  342 + }
  343 +
  344 +}
metaCode/Classes/Main/MinePage/ViewModel/CNLiveMineViewModel.swift
@@ -206,6 +206,42 @@ class CNLiveMineViewModel: NSObject { @@ -206,6 +206,42 @@ class CNLiveMineViewModel: NSObject {
206 } 206 }
207 } 207 }
208 208
  209 + /// 更换手机号
  210 + static func sendChangePhone(mobile: String,countryCode: String,verificationCode: String, resultBlock: @escaping downSlideResultBlock) {
  211 +
  212 + let param = NSMutableDictionary.init()
  213 + param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "uid")
  214 + param.setValue(mobile, forKey: "mobile")
  215 + param.setValue(countryCode, forKey: "countryCode")
  216 + param.setValue(verificationCode, forKey: "verificationCode")
  217 + param.setValue(UserInfoManager.shared.userInfo.token, forKey: "token")
  218 + param.setValue("i", forKey: "clientPlat")
  219 + let custom_param = NSMutableDictionary()
  220 + custom_param.setValue(CNLiveMCEnvironmentManager.shared.appId, forKey: "appId")
  221 + custom_param.setValue(CNLiveMCEnvironmentManager.shared.appKey, forKey: "appKey")
  222 + CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
  223 + CNLiveNetworking.setAllowRequestDefaultArgument(true)
  224 + CNLiveNetworking.setupShowDataResult(false)
  225 + CNLiveNetworking.setupShowResult(true)
  226 + CNLiveNetworking.requestNetwork(with: .POST, urlString: APPLoginHost+"/open/api2/user/updateMobileById", param: param as! [String : Any], cacheType: .networkOnly) { task, result, error in
  227 + hiddenLoading()
  228 + if (error == nil) {
  229 + let resp = result as! NSDictionary
  230 + let errorCode = resp["errorCode"]
  231 + if (errorCode as! String == "0") {
  232 +
  233 + resultBlock(resp, .success)
  234 + } else {
  235 + showMessage(message: resp["errorMessage"] as! String)
  236 + resultBlock(NSNull(), .failed)
  237 + }
  238 + } else {
  239 + showMessage(message: "更换手机号失败")
  240 + resultBlock(NSNull(), .failed)
  241 + }
  242 + }
  243 + }
  244 +
209 /// 提交更新用户单项数据 245 /// 提交更新用户单项数据
210 /// - Parameters: 246 /// - Parameters:
211 /// - type: nickName-昵称,gender-性别,email-邮箱, location-联系方式,birthday-生日yyyy-MM-dd 247 /// - type: nickName-昵称,gender-性别,email-邮箱, location-联系方式,birthday-生日yyyy-MM-dd