index.tsx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import { Button, Toast } from "vant";
  2. import { defineComponent } from "vue";
  3. import styles from './index.module.less';
  4. import CertInfo from "./cert-info";
  5. import ColProtocol from "@/components/col-protocol";
  6. import { teacherState } from "./teacherState";
  7. import Steps from './steps';
  8. import CertOne from './cert-one'
  9. import CertTwo from './cert-two'
  10. import CertThree from "./cert-three";
  11. import { checkIDCard } from "@/helpers/validate";
  12. import request from "@/helpers/request";
  13. import ColResult from "@/components/col-result";
  14. export default defineComponent({
  15. name: 'teacherCert',
  16. data() {
  17. const query = this.$route.query;
  18. return {
  19. authStatus: query.authStatus || null as any,
  20. agreeStatus: false,
  21. }
  22. },
  23. methods: {
  24. async next() {
  25. const realName = teacherState.teacherCert.realName
  26. if(!realName) {
  27. Toast('请填写真实姓名')
  28. return
  29. }
  30. const idCardNo = teacherState.teacherCert.idCardNo
  31. if (!checkIDCard(idCardNo || '')) {
  32. Toast('请填写正确的身份证号码');
  33. return false;
  34. }
  35. if (!this.agreeStatus) {
  36. Toast('请阅读并同意协议');
  37. return
  38. }
  39. if(!teacherState.teacherCert.birthdate) {
  40. Toast('请选择出生日期')
  41. return
  42. }
  43. try {
  44. let res = await request.post('/api-teacher/TeacherAuthEntryRecord/realNameAuth', {
  45. data: {
  46. realName,
  47. idCardNo
  48. }
  49. })
  50. console.log(res)
  51. } catch {
  52. //
  53. }
  54. teacherState.active = 2;
  55. },
  56. next2() {
  57. teacherState.active = 3;
  58. },
  59. async onSubmit() {
  60. try {
  61. await request.post('/api-teacher/TeacherAuthEntryRecord/doApply', {
  62. data: teacherState.teacherCert
  63. })
  64. Toast('提交成功')
  65. } catch {
  66. //
  67. }
  68. },
  69. prev() {
  70. teacherState.active = teacherState.active - 1;
  71. }
  72. },
  73. render() {
  74. return (
  75. <div class={styles['teacher-cert']}>
  76. {!teacherState.authStatus ? <CertInfo authStatus={this.authStatus} /> : <div>
  77. <Steps style={{ marginBottom: '12px' }} />
  78. {teacherState.active === 1 ? (
  79. <>
  80. <CertOne />
  81. <div class={styles.btnGroup}>
  82. <ColProtocol v-model:value={this.agreeStatus} style={{ paddingLeft: 0, paddingRight: 0 }} />
  83. <Button block round onClick={this.next} type="primary" text="下一步" />
  84. </div>
  85. </>
  86. ) : null }
  87. {teacherState.active === 2 ? <>
  88. <CertTwo />
  89. <div class={[styles.btnGroup, styles.btnMore]}>
  90. <Button block round type="primary" plain onClick={this.prev}>上一步</Button>
  91. <Button block round onClick={this.next2} type="primary" text="下一步" />
  92. </div>
  93. </> : null }
  94. {teacherState.active === 3 ? <>
  95. <CertThree />
  96. <div class={[styles.btnGroup, styles.btnMore]}>
  97. <Button block round type="primary" plain onClick={this.prev}>上一步</Button>
  98. <Button block round onClick={this.onSubmit} type="primary" text="提交审核" />
  99. </div>
  100. </> : null }
  101. {/* 提交完数据之后显示状态页 */}
  102. {teacherState.active === 4 ? <ColResult tips="开通成功" /> : null }
  103. </div>}
  104. </div>
  105. )
  106. }
  107. })