master
xingyy 11 months ago
parent b614ca7766
commit 3d9a85083f

@ -21,7 +21,8 @@
<view style="position: relative" v-if="!loginStatus" class="t-a"> <view style="position: relative" v-if="!loginStatus" class="t-a">
<text class="txt">验证码</text> <text class="txt">验证码</text>
<input name="code" maxlength="18" placeholder="请输入您的验证码" v-model="code" /> <input name="code" maxlength="18" placeholder="请输入您的验证码" v-model="code" />
<view class="sendCode" @click="send1" >发送</view> <view v-if="showText" class="sendCode" @click="send1" >发送</view>
<view v-else class="sendCode" >{{second}}</view>
</view> </view>
<view class="reg" @tap="switchLogin()">{{loginStatus?'':''}}</view> <view class="reg" @tap="switchLogin()">{{loginStatus?'':''}}</view>
<button @tap="login1()"> </button> <button @tap="login1()"> </button>
@ -37,6 +38,8 @@ export default {
data() { data() {
return { return {
showText:true,
second:60,
loading:false, loading:false,
loginStatus:true, loginStatus:true,
phone: '', // phone: '', //
@ -47,30 +50,49 @@ export default {
onLoad() {}, onLoad() {},
methods: { methods: {
async send1(){ async send1(){
if (!this.phone) {
uni.showToast({ title: '请输入您的手机号', icon: 'none' });
return;
}
const data={ const data={
telNum:this.phone telNum:this.phone
} }
const res= await send(data) const res= await send(data)
console.log(res,'send') if (res.code===200){
let interval = setInterval(() => {
this.showText = false;
this.second = this.second - 1;
}, 1000);
setTimeout(() => {
clearInterval(interval);
this.second = 60;
this.showText = true;
}, 60000);
uni.showToast({ title:'发送成功', icon: 'none' });
}else {
uni.showToast({ title:res.err, icon: 'none' });
}
}, },
// //
async login1() { async login1() {
this.loading=true
if (!this.phone) { if (!this.phone) {
uni.showToast({ title: '请输入您的手机号', icon: 'none' }); uni.showToast({ title: '请输入您的手机号', icon: 'none' });
return; return;
} }
/* if (!/^[1][3,4,5,7,8,9][0-9]{9}$/.test(this.phone)) { if (this.loginStatus&&!this.pwd) {
uni.showToast({ title: '请输入正确手机号', icon: 'none' });
return;
}*/
if (!this.pwd) {
uni.showToast({ title: '请输入您的密码', icon: 'none' }); uni.showToast({ title: '请输入您的密码', icon: 'none' });
return; return;
} }
if (!this.loginStatus&&!this.code) {
uni.showToast({ title: '请输入您的验证码', icon: 'none' });
return;
}
this.loading=true
const data={ const data={
code:this.loginStatus?'':this.code,
telNum:this.phone, telNum:this.phone,
password:this.pwd password:this.loginStatus?this.pwd:''
} }
const res=await login(data) const res=await login(data)
if (res.code===0){ if (res.code===0){

Loading…
Cancel
Save