This commit is contained in:
Gdpao
2020-09-04 19:52:43 +08:00
parent c4114bcfc5
commit 0824d97080
4 changed files with 200 additions and 14 deletions

View File

@@ -11,10 +11,10 @@
商家登录
</view>
<view v-bind:class="[state==1 ? 'show' : '']" @click="changetab(1)">
达人登录
商家达人
</view>
<view v-bind:class="[state==2 ? 'show' : '']" @click="changetab(2)">
平台达人登录
平台达人
</view>
</view>
<view class="" v-if="state==0">
@@ -45,7 +45,9 @@
<view class="labales">
<image src="../../static/image/login/safe.png"></image>
<input v-model="code" type="number" placeholder="请输入验证码" />
<u-button class="get-code">获取验证码</u-button>
<u-button class="get-code" :class=" is_sendcode ? 'stopClick' : '' " :disabled="is_sendcode" @click="getCode">
{{ is_sendcode ? time_count + "后可以重新发送" : "发送验证码" }}
</u-button>
</view>
</view>
</view>
@@ -77,7 +79,11 @@ export default {
phone: "",
code: "",
state:0,
clickstate:false
clickstate:false,
// 时间
timer: null,
is_sendcode: false, // 60s
time_count: 60,
};
},
methods: {
@@ -98,10 +104,30 @@ export default {
},
// 获取验证码倒计时
getCode() {
console.log('11');
this.loading();
if (!this.$u.test.mobile(this.phone)) {
this.$refs.uToast.show({
title: '手机号码有误!',
})
return;
}
this.$u.api.getCode({
member_mobile: this.phone,
}).then(res => {
console.log(res);
if (res.errCode == 0) {
this.$refs.uToast.show({
title: res.message,
type: 'success',
})
this.getSendCode();
} else {
this.$refs.uToast.show({
title: res.message,
type: "warning"
})
}
})
},
loading() {},
logins() {
// 判断是否可以点击
// console.log(this.zhanghao);
@@ -137,7 +163,38 @@ export default {
});
}
});
}else{
} if (this.state == 2) {
if (!this.$u.test.mobile(this.phone)) {
this.$refs.uToast.show({
title: '手机号码有误!',
})
return;
}
if (this.code.length < 4) {}
this.$u.api.starLogin({
member_mobile: this.phone,
sms_code: this.code,
}).then(res => {
if (res.errCode == 0) {
this.$refs.uToast.show({
title: res.message,
type: 'success',
})
uni.setStorageSync('token', res.data.token);
uni.setStorageSync('userinfo', res.data);
uni.setStorageSync('rongyun', res.data.rongcloud_token);
this.$u.route({
url: '/pages/user/myinfo',
type:"redirect"
});
} else {
this.$refs.uToast.show({
title: res.message,
type: "warning"
})
}
})
} else{
this.$u.api.shoplogin({ member_name: this.zhanghao, member_password: this.mima }).then(res => {
console.log(JSON.stringify(res))
if (res.errCode != 0) {
@@ -159,6 +216,23 @@ export default {
});
}
},
// 60s
getSendCode() {
const TIME_COUNT = 60;
if (!this.timer) {
this.time_count = TIME_COUNT;
this.is_sendcode = true;
this.timer = setInterval(() => {
if (this.time_count > 0 && this.time_count <= TIME_COUNT) {
this.time_count--;
} else {
this.is_sendcode = false;
clearInterval(this.timer);
this.timer = null;
}
}, 1000);
}
},
moveHandle(){
return;
}
@@ -267,9 +341,10 @@ export default {
}
.get-code {
width: 250rpx !important;
width: auto !important;
height: 60rpx !important;
font-size: 30rpx !important;
padding: 0 30rpx !important;
font-size: 24rpx !important;
line-height: 60rpx !important;
color: #fff !important;
border: none !important;