Browse Source

老师认证

lex-xin 3 years ago
parent
commit
74d9a4eec3

+ 6 - 0
src/components/col-protocol/index.tsx

@@ -21,11 +21,17 @@ export default defineComponent({
     }
   },
   mounted() {
+    this.checked = this.value;
     window.addEventListener('hashchange', this.onHash, false)
   },
   unmounted() {
     window.removeEventListener('hashchange', this.onHash, false)
   },
+  watch: {
+    checked(val) {
+      this.$emit('update:value', val)
+    }
+  },
   methods: {
     onHash() {
       this.popupStatus = false;

+ 10 - 0
src/components/col-result/index.module.less

@@ -0,0 +1,10 @@
+.col-result {
+  padding: 30px 14px 14px;
+  text-align: center;
+
+  .tips {
+    font-size: 14px;
+    color: #333;
+    padding: 20px 0;
+  }
+}

+ 44 - 0
src/components/col-result/index.tsx

@@ -0,0 +1,44 @@
+import { defineComponent } from "vue";
+import styles from './index.module.less';
+import empty from '@common/images/icon_nodata.png';
+import { Button, Image } from "vant";
+import { postMessage } from "@/helpers/native-message";
+
+
+export default defineComponent({
+  name: 'col-result',
+  props: {
+    tips: {
+      type: String
+    },
+    img: {
+      type: String,
+      default: empty
+    },
+    buttonText: {
+      type: String,
+      default: '我知道了'
+    },
+    onClick: Function
+  },
+  methods: {
+    onResult() {
+      if(this.onClick) {
+        this.onClick()
+      } else {
+        postMessage({ api: 'back', content: {} })
+      }
+    }
+  },
+  render() {
+    return (
+      <div class={styles['col-result']}>
+        <Image fit="cover" width="100%" src={this.img} />
+
+        { this.tips && <p class={styles.tips}>{ this.tips }</p> }
+
+        <Button class={styles.btn} round block type="primary" onClick={this.onResult}>我知道了</Button>
+      </div>
+    )
+  }
+})

+ 1 - 1
src/components/col-upload/index.tsx

@@ -40,7 +40,7 @@ export default defineComponent({
         file.message = '上传中...';
         let formData = new FormData();
         formData.append('file', file.file);
-        let res = await request.post('/api-web/uploadFile', {
+        let res = await request.post('/api-teacher/uploadFile', {
           data: formData
         })
         this.$emit('update:value', res.data.url);

+ 1 - 1
src/helpers/request.ts

@@ -11,7 +11,7 @@ export interface SearchInitParams {
 }
 
 const request = extend({
-  requestType: 'form',
+  // requestType: 'form',
   timeout: 10000
 });
 

+ 2 - 2
src/helpers/validate.ts

@@ -24,11 +24,11 @@ export function checkPhone(phone: string) {
 }
 
 // 身份证号验证
-export function checkIDCard(idCardNo: string) {
+export function checkIDCard(idCardNo?: string) {
   let result = true;
   //
   const idCardReg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
-  if (idCardReg.test(idCardNo) === false) {
+  if (idCardReg.test(idCardNo || '') === false) {
     result = false;
   }
   return result;

+ 2 - 1
src/teacher/layout/auth.tsx

@@ -35,7 +35,8 @@ export default defineComponent({
       if ((state.user.status === 'init' || state.user.status === 'error')) {
         this.loading = true
         try {
-          let res = await request.get('/api-student/userCashAccount/get', {
+          let res = await request.get('/api-auth/api/queryUserInfo', {
+            requestType: "form",
             initRequest: true // 初始化接口
           })
           // console.log(res)

+ 2 - 0
src/teacher/layout/login.tsx

@@ -54,6 +54,7 @@ export default defineComponent({
         let res: any;
         if (this.loginType === 'PWD') {
           res = await request.post('/api-auth/usernameLogin', {
+            requestType: "form",
             data: {
               username: this.username,
               password: this.password,
@@ -63,6 +64,7 @@ export default defineComponent({
           });
         } else {
           res = await request.post('/api-auth/smsLogin', {
+            requestType: "form",
             data: {
               clientId: 'teacher',
               clientSecret: 'teacher',

+ 2 - 8
src/teacher/teacher-cert/cert-info.module.less

@@ -6,17 +6,10 @@
   padding-bottom: 75px;
 
   h2 {
-    font-size: 18px;
-  }
-
-  h3 {
     font-size: 16px;
-  }
-
-  h2, h3 {
     padding: 8px 0;
     font-weight: 600;
-    color: black;
+    color: #333333;
     line-height: 1.5;
   }
 
@@ -24,6 +17,7 @@
     font-size: 13px;
     line-height: 1.3;
     padding-bottom: 12px;
+    color: #999999;
   }
 
   .cert-img {

+ 8 - 5
src/teacher/teacher-cert/cert-info.tsx

@@ -5,6 +5,9 @@ import { teacherState } from "./teacherState";
 
 export default defineComponent({
   name: 'cert-info',
+  props: {
+    authStatus: String
+  },
   methods: {
     onClick() {
       teacherState.authStatus = true
@@ -21,7 +24,7 @@ export default defineComponent({
             <Image src="https://daya.ks3-cn-beijing.ksyun.com/202110/Sn76BUQ.png" width="100%" height="150px" fit="cover" />
           </p>
 
-        <h3>线上授课</h3>
+        <h2>线上授课</h2>
         <p class={styles['cert-text']}>
           认证成为酷乐秀老师后,可设置您的空闲时间为平台中的求学者进行1对1的线上课程指导。
         </p>
@@ -29,7 +32,7 @@ export default defineComponent({
           <Image src="https://daya.ks3-cn-beijing.ksyun.com/202110/Sn76BUQ.png" width="100%" height="150px" fit="cover" />
         </p>
 
-        <h3>个人风采展示</h3>
+        <h2>个人风采展示</h2>
         <p class={styles['cert-text']}>
         可发布自己的专业经历、获奖记录及音视频资料对求学者展示,让学员更加深入的了解您的专业技能,从而提高约课率。
         </p>
@@ -37,7 +40,7 @@ export default defineComponent({
           <Image src="https://daya.ks3-cn-beijing.ksyun.com/202110/Sn76BUQ.png" width="100%" height="150px" fit="cover" />
         </p>
 
-        <h3>曲谱上传</h3>
+        <h2>曲谱上传</h2>
         <p class={styles['cert-text']}>
         可上传您制作的MIDI乐谱为求学者提供学习曲目的途径,并从中获得收益。
         </p>
@@ -45,7 +48,7 @@ export default defineComponent({
           <Image src="https://daya.ks3-cn-beijing.ksyun.com/202110/Sn76BUQ.png" width="100%" height="150px" fit="cover" />
         </p>
 
-        <h3>收益提现</h3>
+        <h2>收益提现</h2>
         <p class={styles['cert-text']}>
         在您授课及上传曲谱销售后,经过平台核算,将您获得的收益发放至您的个人账户下,您可随时将自己获得的收益提现。
         </p>
@@ -56,7 +59,7 @@ export default defineComponent({
         </p>
 
         <div class={styles["btn-group"]}>
-          <Button round block type="primary" onClick={this.onClick}>立即认证</Button>
+          <Button round block type="primary" disabled={this.authStatus === '1'} onClick={this.onClick}>立即认证</Button>
         </div>
       </div>
     )

+ 40 - 3
src/teacher/teacher-cert/cert-one.tsx

@@ -1,6 +1,7 @@
-import { Cell, CellGroup, Col, DatetimePicker, Field, Popup, Row } from "vant"
+import { Cell, CellGroup, Col, DatetimePicker, Field, Popup, Row, Toast } from "vant"
 import { defineComponent } from "vue";
 import dayjs from "dayjs";
+import { checkIDCard } from "@/helpers/validate";
 import ColField from "@/components/col-field";
 import { teacherState } from "./teacherState";
 import styles from './cert-one.module.less';
@@ -15,6 +16,39 @@ export default defineComponent({
     }
   },
   methods: {
+    onIdCardValidate() {
+      const idCardNo = teacherState.teacherCert.idCardNo
+      if (!checkIDCard(idCardNo || '')) {
+        Toast('请填写正确的身份证号码');
+        return false;
+      }
+
+      console.log(this.getSex(idCardNo))
+      teacherState.teacherCert.birthdate = this.getBirth(idCardNo)
+      teacherState.teacherCert.gender = this.getSex(idCardNo)
+    },
+    getBirth(idCard: string | null) {
+      let birthday = "";
+      if (idCard != null && idCard != "") {
+        if (idCard.length == 15) {
+          birthday = "19" + idCard.slice(6, 12);
+        } else if (idCard.length == 18) {
+          birthday = idCard.slice(6, 14);
+        }
+        birthday = birthday.replace(/(.{4})(.{2})/, "$1-$2-");
+        //通过正则表达式来指定输出格式为:1990-01-01
+      }
+      return birthday;
+    },
+    getSex(idCard: string | null) {
+      let sex = null;
+      if (idCard && parseInt(idCard.slice(-2, -1)) % 2 == 1) {
+        sex = 1;
+      } else {
+        sex = 0;
+      }
+      return sex;
+    },
     onConfirm(_date: any) {
       teacherState.teacherCert.birthdate = dayjs(this.popupDate).format('YYYY-MM-DD')
       this.popupShow = false;
@@ -38,15 +72,18 @@ export default defineComponent({
         <CellGroup border={false}>
           <ColField title="真实姓名" required>
             <Field
-              v-model={teacherState.teacherCert.realname}
+              v-model={teacherState.teacherCert.realName}
               name="真实姓名"
+              maxlength={10}
               placeholder="请输入您的真实姓名"
             />
           </ColField>
           <ColField title="身份证号" required>
             <Field
-              v-model={teacherState.teacherCert.idcardNo}
+              v-model={teacherState.teacherCert.idCardNo}
               name="身份证号"
+              maxlength={18}
+              onBlur={this.onIdCardValidate}
               placeholder="请输入您的身份证号码"
             />
           </ColField>

+ 10 - 0
src/teacher/teacher-cert/index.module.less

@@ -1,5 +1,15 @@
 .teacher-cert {
   .btnGroup {
     padding: 0 14px;
+    margin-bottom: 15px;
+  }
+  .btnMore {
+    display: flex;
+    justify-content: space-between;
+    :global {
+      .van-button {
+        width: 48%;
+      }
+    }
   }
 }

+ 80 - 12
src/teacher/teacher-cert/index.tsx

@@ -9,36 +9,104 @@ import Steps from './steps';
 import CertOne from './cert-one'
 import CertTwo from './cert-two'
 import CertThree from "./cert-three";
-
+import { checkIDCard } from "@/helpers/validate";
+import request from "@/helpers/request";
+import ColResult from "@/components/col-result";
 
 export default defineComponent({
   name: 'teacherCert',
   data() {
+    const query = this.$route.query;
     return {
+      authStatus: query.authStatus || null as any,
+      agreeStatus: false,
     }
   },
   methods: {
-    next() {
-      const checked = (this as any).$refs.eleRef.checked;
-      if (!checked) {
+    async next() {
+      const realName = teacherState.teacherCert.realName
+      if(!realName) {
+        Toast('请填写真实姓名')
+        return
+      }
+
+      const idCardNo = teacherState.teacherCert.idCardNo
+      if (!checkIDCard(idCardNo || '')) {
+        Toast('请填写正确的身份证号码');
+        return false;
+      }
+      if (!this.agreeStatus) {
         Toast('请阅读并同意协议');
         return
       }
+
+      if(!teacherState.teacherCert.birthdate) {
+        Toast('请选择出生日期')
+        return
+      }
+
+      try {
+        let res = await request.post('/api-teacher/TeacherAuthEntryRecord/realNameAuth', {
+          data: {
+            realName,
+            idCardNo
+          }
+        })
+        console.log(res)
+      } catch {
+        //
+      } 
+
+      teacherState.active = 2;
+    },
+    next2() {
+      teacherState.active = 3;
+    },
+    async onSubmit() {
+      try {
+        await request.post('/api-teacher/TeacherAuthEntryRecord/doApply', {
+          data: teacherState.teacherCert
+        })
+        Toast('提交成功')
+      } catch {
+        //
+      }
+    },
+    prev() {
+      teacherState.active = teacherState.active - 1;
     }
   },
   render() {
     return (
       <div class={styles['teacher-cert']}>
-        {!teacherState.authStatus ? <CertInfo /> : <div>
+        {!teacherState.authStatus ? <CertInfo authStatus={this.authStatus} /> : <div>
           <Steps style={{ marginBottom: '12px' }} />
-          {teacherState.active === 1 ? <CertOne /> : null }
-          {teacherState.active === 2 ? <CertTwo /> : null }
-          {teacherState.active === 3 ? <CertThree /> : null }
+          {teacherState.active === 1 ? (
+            <>
+              <CertOne />
+              <div class={styles.btnGroup}>
+                <ColProtocol v-model:value={this.agreeStatus} style={{ paddingLeft: 0, paddingRight: 0 }} />
+                <Button block round onClick={this.next} type="primary" text="下一步" />
+              </div>
+            </>
+          ) : null }
+          {teacherState.active === 2 ? <>
+            <CertTwo />
+            <div class={[styles.btnGroup, styles.btnMore]}>
+              <Button block round type="primary" plain onClick={this.prev}>上一步</Button>
+              <Button block round onClick={this.next2} type="primary" text="下一步" />
+            </div>
+          </> : null }
+          {teacherState.active === 3 ? <>
+            <CertThree />
+            <div class={[styles.btnGroup, styles.btnMore]}>
+              <Button block round type="primary" plain onClick={this.prev}>上一步</Button>
+              <Button block round onClick={this.onSubmit} type="primary" text="提交审核" />
+            </div>
+          </> : null }
 
-          <div class={styles.btnGroup}>
-            <ColProtocol ref='eleRef' style={{ paddingLeft: 0, paddingRight: 0 }} />
-            <Button block round onClick={this.next} type="primary" text="下一步" />
-          </div>
+          {/* 提交完数据之后显示状态页 */}
+          {teacherState.active === 4 ? <ColResult tips="开通成功" /> : null }
         </div>}
       </div>
     )

+ 2 - 2
src/teacher/teacher-cert/teacherState.ts

@@ -4,8 +4,8 @@ export const teacherState = reactive({
   authStatus: false, // 是否立即认证
   active: 1,
   teacherCert: {
-    realname: null,
-    idcardNo: null,
+    realName: null,
+    idCardNo: null,
     gender: 1,
     birthdate: null as any,
     subjectId: null,