| xqd
@@ -11,7 +11,7 @@
|
|
|
<wInput v-model="phoneData" type="text" maxlength="11" placeholder="手机号"></wInput>
|
|
|
<wInput v-show="!ispwdlogin" v-model="verCode" type="number" maxlength="4" placeholder="验证码" isShowCode ref="runCode"
|
|
|
@setCode="getVerCode()"></wInput>
|
|
|
- <wInput v-show="ispwdlogin" v-model="password" type="password" maxlength="6" placeholder="请输入密码" isShowPass></wInput>
|
|
|
+ <wInput v-show="ispwdlogin" v-model="password" type="password" maxlength="7" placeholder="请输入密码" isShowPass></wInput>
|
|
|
</view>
|
|
|
|
|
|
<wButton class="wbutton" text="登 录" :rotate="isRotate" @click.native="startReg()"></wButton>
|
| xqd
@@ -112,7 +112,7 @@
|
|
|
_this = this;
|
|
|
},
|
|
|
methods: {
|
|
|
- getVerCode() {
|
|
|
+ getVerCode:async function() {
|
|
|
//获取验证码
|
|
|
if (_this.phoneData.length != 11) {
|
|
|
uni.showToast({
|
| xqd
@@ -122,17 +122,35 @@
|
|
|
});
|
|
|
return false;
|
|
|
}
|
|
|
- this.$refs.runCode.$emit('runCode'); //触发倒计时(一般用于请求成功验证码后调用)
|
|
|
- setTimeout(function() {
|
|
|
- _this.$refs.runCode.$emit('runCode', 0); //假装模拟下需要 终止倒计时
|
|
|
+ let res = await this.$request.post("common/putverfiy",{'phone':_this.phoneData});
|
|
|
+ if(res.status==0){
|
|
|
+ uni.setStorageSync('verfiyCode',res.data);
|
|
|
uni.showToast({
|
|
|
icon: 'none',
|
|
|
position: 'bottom',
|
|
|
- title: '模拟倒计时终止'
|
|
|
+ title: '验证码发送,请查收'
|
|
|
});
|
|
|
- }, 3000)
|
|
|
+ this.$refs.runCode.$emit('runCode'); //触发倒计时(一般用于请求成功验证码后调用)
|
|
|
+ setTimeout(function() {
|
|
|
+ _this.$refs.runCode.$emit('runCode', 0); //假装模拟下需要 终止倒计时
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ position: 'bottom',
|
|
|
+ title: '模拟倒计时终止'
|
|
|
+ });
|
|
|
+ }, 3000)
|
|
|
+ }else{
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ position: 'bottom',
|
|
|
+ title: '请求失败'
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
},
|
|
|
- startReg() {
|
|
|
+ startReg:async function() {
|
|
|
//注册
|
|
|
if (this.isRotate) {
|
|
|
//判断是否加载中,避免重复点击请求
|
| xqd
@@ -146,23 +164,114 @@
|
|
|
});
|
|
|
return false;
|
|
|
}
|
|
|
- if (this.verCode.length != 4) {
|
|
|
- uni.showToast({
|
|
|
- icon: 'none',
|
|
|
- position: 'bottom',
|
|
|
- title: '验证码不正确'
|
|
|
- });
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (this.password !== 6) {
|
|
|
- uni.showToast({
|
|
|
- icon: 'none',
|
|
|
- position: 'bottom',
|
|
|
- title: '密码位数不低于6位'
|
|
|
- });
|
|
|
- return false;
|
|
|
+ if(this.ispwdlogin){
|
|
|
+ // 账号密码登陆
|
|
|
+ if (this.password < 6) {
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ position: 'bottom',
|
|
|
+ title: '密码位数不低于6位'
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // 发送登陆
|
|
|
+ let res = await this.$request.post('common/passLogin',{'phone':this.phoneData,'password':this.password});
|
|
|
+ if(res.status==0){
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ position: 'bottom',
|
|
|
+ title:'登陆成功'
|
|
|
+ });
|
|
|
+ store.commit('setJwt', res.data.token);
|
|
|
+ store.commit('setUser', res.data);
|
|
|
+ store.commit('login');
|
|
|
+ // 写一个跳转到首页
|
|
|
+ setTimeout(function() {
|
|
|
+ uni.navigateBack({
|
|
|
+ delta: 1
|
|
|
+ })
|
|
|
+ uni.switchTab({
|
|
|
+ url: "../index/index"
|
|
|
+ })
|
|
|
+ }, 2000)
|
|
|
+ return false;
|
|
|
+ }else{
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ position: 'bottom',
|
|
|
+ title: res.message
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }else{
|
|
|
+ if (this.verCode.length != 4) {
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ position: 'bottom',
|
|
|
+ title: '验证码不正确'
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ let code = uni.getStorageSync('verfiyCode')
|
|
|
+
|
|
|
+ if(code==null || code==''){
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ position: 'bottom',
|
|
|
+ title: '验证码错误'
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }else{
|
|
|
+ if(this.verCode==code){
|
|
|
+ // 发送登陆
|
|
|
+ let res = await this.$request.post('common/phoneLogin',{'phone':this.phoneData});
|
|
|
+
|
|
|
+ if(res.status==0){
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ position: 'bottom',
|
|
|
+ title:'登陆成功'
|
|
|
+ });
|
|
|
+ uni.removeStorage('verfiyCode')
|
|
|
+ store.commit('setJwt', res.data.token);
|
|
|
+ store.commit('setUser', res.data);
|
|
|
+ store.commit('login');
|
|
|
+
|
|
|
+ // 写一个跳转到首页
|
|
|
+ setTimeout(function() {
|
|
|
+ uni.navigateBack({
|
|
|
+ delta: 1
|
|
|
+ })
|
|
|
+ uni.switchTab({
|
|
|
+ url: "../index/index"
|
|
|
+ })
|
|
|
+ }, 2000)
|
|
|
+ return false;
|
|
|
+ }else{
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ position: 'bottom',
|
|
|
+ title: res.message
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ position: 'bottom',
|
|
|
+ title: '验证码错误'
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- console.log("注册成功")
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
_this.isRotate = true
|
|
|
setTimeout(function() {
|
|
|
_this.isRotate = false
|