Commit d5d6a059 authored by ljh's avatar ljh

手机登录完成

parent 428f8454
......@@ -124,5 +124,7 @@
<string>Warehouse/IoGoodsDetail</string>
<key>商品出库审核详情(未审核状态)</key>
<string>Warehouse/OutGoodsDetail</string>
<key>手机号登录</key>
<string>Passport/mobileLogin</string>
</dict>
</plist>
......@@ -160,3 +160,13 @@ func saveFile(image: UIImage,_ params:[String:Any],success:@escaping (_ res:Any)
failture(error)
}
}
//MARK:--手机号登
//params-key(mobile(手机号),auth_code(登录验证码(必须先发送验证码) ))
func mobileLogin(_ params:[String:Any],success:@escaping (_ res:Any)->(),failture:@escaping(_ error:Error)->()) {
NetworkRequest.sharedInstance.postRequest("登录", params, { (rep:DataResponse<LoginModel>) in
}, success: { (data) in
success(data)
}) { (error) in
failture(error)
}
}
......@@ -114,8 +114,37 @@ class LoginViewController: BaseViewController, CodeViewDelegate,GeliAlertViewDel
}
//MARK: - 手机登录,获取验证码方法
@IBAction func getLoginCodeAction(_ sender: Any) {
@IBOutlet weak var phoneCodeBtn: UIButton!
@IBAction func getLoginCodeAction(_ sender: UIButton) {
print("get phone login Code")
if phoneLogInputTF.text?.count == 0 {
HUD.flash(.label("请填写手机号码"), delay: 1.2)
return
}
sendSmsCaptcha(["phone":phoneLogInputTF.text as Any,"type":"3"], success: { (data) in
let dataM = data as! UpDataModel
if dataM.code == 1 {
sender.isUserInteractionEnabled = false
sender.setTitle("60s", for: .normal);
Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(self.timeCounting), userInfo: nil, repeats: true);
}
}) { (error) in
}
}
var timeCount:Int = 60
@objc func timeCounting(sender:Timer){
timeCount -= 1
phoneCodeBtn.setTitle("\(timeCount)"+"s", for: .normal)
if timeCount == 0{
phoneCodeBtn.setTitle("获取验证码", for: .normal)
phoneCodeBtn.isUserInteractionEnabled = true
timeCount = 60
sender.invalidate()
}
}
//MARK: -跳转忘记密码,登录
@IBAction func forgetPasswordAction(_ sender: Any) {
......@@ -184,9 +213,29 @@ class LoginViewController: BaseViewController, CodeViewDelegate,GeliAlertViewDel
}else{
//MARK:- 手机验证码登录
if phoneLogInputTF.text?.count == 0 {
HUD.flash(.label("请填写手机号码"), delay: 1.2)
return
}
if phoneLogCodeTF.text?.count == 0 {
HUD.flash(.label("请填写验证码"), delay: 1.2)
return
}
loginBtn.isLoading = true
mobileLogin(["mobile":phoneLogInputTF.text as Any,"auth_code":phoneLogCodeTF.text as Any], success: { (data) in
let dataM = data as! LoginModel
UserDefaults.standard.set(dataM.data?.user_token, forKey: "user_token")
UserDefaults.standard.synchronize()
self.loginBtn.isLoading = false
self.delegate?.successLogin()
// JPUSHService.setAlias(self.phoneTF.text, completion: { (resCode, alias, num) in
//
// }, seq: 1433223)
}) { (error) in
self.loginBtn.isLoading = false
}
}
......
......@@ -20,6 +20,7 @@
<outlet property="loginBtn" destination="I08-S6-beg" id="bDZ-w8-CrS"/>
<outlet property="passLoginBg" destination="iYx-nR-RL7" id="EoY-gn-H5i"/>
<outlet property="passTF" destination="hBD-M4-Ne6" id="Ej7-K3-hF0"/>
<outlet property="phoneCodeBtn" destination="dAd-O1-Cr9" id="mtO-nC-R40"/>
<outlet property="phoneLogCodeTF" destination="AYx-AF-7cc" id="Zyy-sv-lbI"/>
<outlet property="phoneLogInputTF" destination="lQM-jb-VSM" id="HZz-Gp-xzs"/>
<outlet property="phoneLoginBG" destination="Wdn-1F-VeB" id="AkQ-Hp-pVQ"/>
......@@ -206,7 +207,7 @@
<color key="titleColor" name="蓝色字体颜色"/>
</state>
<connections>
<action selector="getLoginCodeAction:" destination="-1" eventType="touchUpInside" id="QFf-Hw-aQZ"/>
<action selector="getLoginCodeAction:" destination="-1" eventType="touchUpInside" id="KjG-WO-8ZL"/>
</connections>
</button>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请输入您的手机号" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="lQM-jb-VSM">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment