|
|
@ -12,8 +12,7 @@ |
|
|
|
<view class="input-content"> |
|
|
|
<view class="select_lay"> |
|
|
|
|
|
|
|
<text :class="{'select_lay_text1':selectKey===0}" |
|
|
|
@click="selectType(0)">账号登录</text> |
|
|
|
<text :class="{'select_lay_text1':selectKey===0}" @click="selectType(0)">账号登录</text> |
|
|
|
<text style="margin-left: 20px;" :class="{'select_lay_text1':selectKey===1}" |
|
|
|
@click="selectType(1)">短信登录</text> |
|
|
|
|
|
|
@ -58,11 +57,11 @@ |
|
|
|
<!-- #ifdef APP-PLUS --> |
|
|
|
<view class="input-content"> |
|
|
|
<view class="select_lay"> |
|
|
|
|
|
|
|
<text :class="{'select_lay_text1':selectKey===0}" |
|
|
|
@click="selectType(0)">账号登录</text> |
|
|
|
|
|
|
|
<text style="margin-left: 20px;" :class="{'select_lay_text1':selectKey===1}" @click="selectType(1)">短信登录</text> |
|
|
|
<text :class="{'select_lay_text1':selectKey===0}" @click="selectType(0)">账号登录</text> |
|
|
|
|
|
|
|
<text style="margin-left: 20px;" :class="{'select_lay_text1':selectKey===1}" |
|
|
|
@click="selectType(1)">短信登录</text> |
|
|
|
|
|
|
|
</view> |
|
|
|
|
|
|
@ -160,7 +159,7 @@ |
|
|
|
}, |
|
|
|
// 获取验证码 |
|
|
|
async getCode() { |
|
|
|
var myreg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/; |
|
|
|
var myreg = /^1[1-9][0-9]\d{8}$/; |
|
|
|
if (!myreg.test(this.phone)) { |
|
|
|
uni.showToast({ |
|
|
|
icon: 'none', |
|
|
@ -491,45 +490,56 @@ |
|
|
|
async toLogin() { |
|
|
|
var that = this; |
|
|
|
let phoneReg = /^1[1-9][0-9]\d{8}$/; |
|
|
|
|
|
|
|
try { |
|
|
|
if (this.phone == '') { |
|
|
|
throw '请填写手机号'; |
|
|
|
} |
|
|
|
if (!phoneReg.test(this.phone)) { |
|
|
|
throw '手机号格式有误'; |
|
|
|
} |
|
|
|
if (this.password == '') { |
|
|
|
throw '请填写密码'; |
|
|
|
} |
|
|
|
} catch (err) { |
|
|
|
this.$api.msg(err); |
|
|
|
return; |
|
|
|
} |
|
|
|
console.log("1111111111"); |
|
|
|
this.logining = false; |
|
|
|
if (that.selectKey == 1) { |
|
|
|
// 短信登录 |
|
|
|
uni.showToast({ |
|
|
|
icon: 'none', |
|
|
|
title: '暂不支持此登录方式' |
|
|
|
}); |
|
|
|
return; |
|
|
|
// uni.showToast({ |
|
|
|
// icon: 'none', |
|
|
|
// title: '暂不支持此登录方式' |
|
|
|
// }); |
|
|
|
// return; |
|
|
|
let params = { |
|
|
|
phone: this.phone, |
|
|
|
authCode: this.code |
|
|
|
}; |
|
|
|
let data = await Api.apiCall('post', Api.index.loginByCode, params); |
|
|
|
//this.logining = false; |
|
|
|
if (data) { |
|
|
|
console.log(data); |
|
|
|
that.login(data) |
|
|
|
uni.setStorageSync('userInfos', data.userInfo); |
|
|
|
uni.setStorageSync('token', data.tokenHead + data.token); |
|
|
|
console.log(uni.getStorageSync('token')) |
|
|
|
uni.switchTab({ |
|
|
|
url: '/pages/index/user' |
|
|
|
}); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 账号登录 |
|
|
|
|
|
|
|
try { |
|
|
|
if (this.phone == '') { |
|
|
|
throw '请填写手机号'; |
|
|
|
} |
|
|
|
if (!phoneReg.test(this.phone)) { |
|
|
|
throw '手机号格式有误'; |
|
|
|
} |
|
|
|
if (this.password == '') { |
|
|
|
throw '请填写密码'; |
|
|
|
} |
|
|
|
} catch (err) { |
|
|
|
this.$api.msg(err); |
|
|
|
return; |
|
|
|
} |
|
|
|
console.log("1111111111"); |
|
|
|
this.logining = false; |
|
|
|
let params = { |
|
|
|
phone: this.phone, |
|
|
|
password: this.password |
|
|
|
}; |
|
|
|
let data = await Api.apiCall('post', Api.index.login, params); |
|
|
|
//this.logining = false; |
|
|
|
console.log("1111111111"); |
|
|
|
if (data) { |
|
|
|
console.log(data); |
|
|
|
console.log("22222222222"); |
|
|
|
that.login(data); |
|
|
|
console.log("33333333333333"); |
|
|
|
uni.setStorageSync('userInfos', data.userInfo); |
|
|
|
uni.setStorageSync('token', data.tokenHead + data.token); |
|
|
|
// uni.setStorageSync('adminToken', data.tokenHead + data.token); |
|
|
@ -704,9 +714,7 @@ |
|
|
|
margin-bottom: 15upx; |
|
|
|
align-items: center; |
|
|
|
|
|
|
|
.select_lay_text { |
|
|
|
|
|
|
|
} |
|
|
|
.select_lay_text {} |
|
|
|
|
|
|
|
.select_lay_text1 { |
|
|
|
font-size: 30upx; |
|
|
|