| 
					
				 | 
			
			
				@@ -1,21 +1,25 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { defineComponent } from "vue";
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import { CellGroup, Field, Button, CountDown } from "vant";
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import { CellGroup, Field, Button, CountDown, Row, Col, Toast } from "vant";
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import ImgCode from "@/components/ImgCode";
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import { checkPhone } from "@/helpers/validate";
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import request from "@/helpers/request";
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import { setLogin, state } from "@/student/state";
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import { setLogin, state } from "@/state";
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { removeAuth, setAuth } from "@/helpers/utils";
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import styles from "./login.module.less";
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 type loginType = 'PWD' | 'SMS';
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 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 +30,6 @@ export default defineComponent({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       } else {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         this.username && this.smsCode && (status = false);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      console.log(status, this.loginType)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       return status;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     },
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   },
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -49,7 +52,7 @@ export default defineComponent({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     async onLogin() {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       try {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let res: any;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if(this.loginType === 'PWD') {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (this.loginType === 'PWD') {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           res = await request.post('/api-auth/usernameLogin', {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             data: {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				               username: this.username,
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -79,10 +82,16 @@ export default defineComponent({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         setLogin(userCash.data)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         this.directNext();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      } catch{
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } catch {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     },
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    async onSendCode() { // 发送验证码
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if(!checkPhone(this.username)) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return Toast('请输入正确的手机号码');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      this.imgCodeStatus = true
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    },
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     onCodeSend() {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       this.countDownStatus = false;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       this.countDownRef.start();
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -92,53 +101,69 @@ export default defineComponent({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       this.countDownRef.reset();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     },
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     onChange() {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      if(this.loginType === 'PWD') {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if (this.loginType === 'PWD') {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         this.loginType = 'SMS'
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      } else if(this.loginType === 'SMS') {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } else if (this.loginType === 'SMS') {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         this.loginType = 'PWD'
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    },
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   },
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   render() {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return (
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      <div class="login">
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <CellGroup inset>
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          <Field
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            v-model={this.username}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            name="手机号"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            label="手机号"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            placeholder="手机号"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            type="tel"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            maxlength={11}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          />
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          { this.loginType === 'PWD' ? <Field
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            v-model={this.password}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            type="password"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            name="密码"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            label="密码"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            placeholder="密码"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          /> : <Field
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            v-model={this.smsCode}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            name="验证码"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            label="验证码"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            placeholder="验证码"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            type="tel"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            maxlength={6}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // @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秒" />
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              )
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          /> }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      <div class={styles.login}>
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <div class={styles.loginTitle}>您好,<br /> 欢迎使用酷乐秀</div>
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <CellGroup class={styles.margin34} border={false}>
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          <Row style={{ marginBottom: '16px' }}>
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <Col span={24} class={styles.formTitle}>手机号</Col>
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <Col span={24} class="van-hairline--bottom">
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              <Field
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                v-model={this.username}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                name="手机号"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                placeholder="请输入您的手机号"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                type="tel"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                maxlength={11}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              />
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </Col>
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          </Row>
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          {this.loginType === 'PWD' ? <Row>
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <Col span={24} class={styles.formTitle}>密码</Col>
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <Col span={24} class="van-hairline--bottom">
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              <Field
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                v-model={this.password}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                type="password"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                name="密码"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                placeholder="请输入密码"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              />
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </Col>
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          </Row> : <Row>
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <Col span={24} class={styles.formTitle}>密码</Col>
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <Col span={24} class="van-hairline--bottom">
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              <Field
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                v-model={this.smsCode}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                name="验证码"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                placeholder="请输入验证码"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                type="tel"
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                maxlength={6}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // @ts-ignore
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                vSlots={{
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                  button: () => (
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    this.countDownStatus ? <span class={styles.codeText} onClick={this.onSendCode}>获取验证码</span> : <CountDown ref={this.countDownRef} auto-start={false} time={this.countDownTime} onFinish={this.onFinished} format="ss秒" />
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                  )
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              />
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </Col>
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          </Row>}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </CellGroup>
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        <div style="margin: 16px;">
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <div class={styles.margin34}>
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           <Button round block type="primary" disabled={this.codeDisable} onClick={this.onLogin}>
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             提交
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           </Button>
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          <Button plain onClick={this.onChange}>{ this.loginType === 'PWD' ? '验证码登录' : '密码登录' }</Button>
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          <Button block round color="#F5F7FB" 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>
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     )
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   }
 
			 |