|
@@ -1,5 +1,6 @@
|
|
|
import { defineComponent } from "vue";
|
|
|
import { CellGroup, Field, Button, CountDown } from "vant";
|
|
|
+import ImgCode from "@/components/imgCode";
|
|
|
import request from "@/helpers/request";
|
|
|
import { setLogin, state } from "@/student/state";
|
|
|
import { removeAuth, setAuth } from "@/helpers/utils";
|
|
@@ -9,13 +10,14 @@ export default defineComponent({
|
|
|
name: 'login',
|
|
|
data() {
|
|
|
return {
|
|
|
- loginType: 'PWD' as loginType,
|
|
|
+ loginType: 'SMS' as loginType,
|
|
|
username: '',
|
|
|
password: '',
|
|
|
smsCode: '',
|
|
|
countDownStatus: true, // 是否发送验证码
|
|
|
countDownTime: 1000 * 120, // 倒计时时间
|
|
|
countDownRef: null as any, // 倒计时实例
|
|
|
+ imgCodeStatus: false,
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -26,7 +28,6 @@ export default defineComponent({
|
|
|
} else {
|
|
|
this.username && this.smsCode && (status = false);
|
|
|
}
|
|
|
- console.log(status, this.loginType)
|
|
|
return status;
|
|
|
},
|
|
|
},
|
|
@@ -83,6 +84,12 @@ export default defineComponent({
|
|
|
|
|
|
}
|
|
|
},
|
|
|
+ async onSendCode() { // 发送验证码
|
|
|
+ // if(!checkPhone(this.phoneNumber)) {
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ this.imgCodeStatus = true
|
|
|
+ },
|
|
|
onCodeSend() {
|
|
|
this.countDownStatus = false;
|
|
|
this.countDownRef.start();
|
|
@@ -97,7 +104,7 @@ export default defineComponent({
|
|
|
} else if(this.loginType === 'SMS') {
|
|
|
this.loginType = 'PWD'
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
},
|
|
|
render() {
|
|
|
return (
|
|
@@ -127,7 +134,7 @@ export default defineComponent({
|
|
|
// @ts-ignore
|
|
|
vSlots={{
|
|
|
button: () => (
|
|
|
- this.countDownStatus ? <Button size="small" round type="primary" onClick={this.onCodeSend}>发送验证码</Button> : <CountDown ref={this.countDownRef} auto-start="false" time={this.countDownTime} onFinish={this.onFinished} format="ss秒" />
|
|
|
+ this.countDownStatus ? <Button size="small" round type="primary" onClick={this.onSendCode}>发送验证码</Button> : <CountDown ref={this.countDownRef} auto-start="false" time={this.countDownTime} onFinish={this.onFinished} format="ss秒" />
|
|
|
)
|
|
|
}}
|
|
|
/> }
|
|
@@ -139,6 +146,8 @@ export default defineComponent({
|
|
|
</Button>
|
|
|
<Button plain onClick={this.onChange}>{ this.loginType === 'PWD' ? '验证码登录' : '密码登录' }</Button>
|
|
|
</div>
|
|
|
+
|
|
|
+ { this.imgCodeStatus ? <ImgCode v-model:value={this.imgCodeStatus} phone={this.username} onClose={() => { this.imgCodeStatus = false }} onSendCode={this.onCodeSend} /> : null }
|
|
|
</div>
|
|
|
)
|
|
|
}
|