import request from '@/helpers/request' import { verifyIdCard } from '@/helpers/toolsValidate' import { postMessage } from '@/helpers/native-message' import { state } from '@/state' import { Button, CellGroup, Checkbox, Field, Form, Icon, showToast, Toast } from 'vant' import { defineComponent } from 'vue' import activeButtonIcon from '@common/images/icon_checkbox.png' import inactiveButtonIcon from '@common/images/icon_checkbox_default.png' import styles from './index.module.less' import OHeader from '@/components/o-header' export default defineComponent({ name: 'UserAuth', props: { onSuccess: { // 实名成功 type: Function, default: () => {} }, exists: { type: Boolean, default: false }, hideHeader: { type: Boolean, default: false } }, data() { return { form: { realName: '', idCardNo: '' }, checked: false } }, mounted() { // exists this.checked = this.checked || this.exists // 初始化数据 const users = state.user.data this.form.realName = users?.realName // this.form.idCardNo = users?.idCardNo }, methods: { async onSubmit() { try { if (!this.checked) { showToast('请先阅读并同意《用户注册协议》') return } const url = state.platformType === 'STUDENT' ? '/api-student/student/realNameAuth' : '/api-teacher/teacher/realNameAuth' await request.post(url, { data: { ...this.form, contract: true, save: true } }) showToast('实名成功') state.user.data.realName = this.form.realName state.user.data.idCardNo = this.form.idCardNo setTimeout(() => { this.onSuccess() }, 500) } catch { // } }, getContractDetail() { // 查看协议 const client = state.platformType === 'STUDENT' ? 'student' : 'teacher' postMessage({ api: 'openWebView', content: { url: `${location.origin}/${client}/#/previewProtocol`, orientation: 1, isHideTitle: false } }) } }, render() { return (
) } })