|
@@ -29,7 +29,8 @@ import { checkPhone } from '@/helpers/validate'
|
|
|
import OUpload from '@/components/o-upload'
|
|
|
import router from '@/router'
|
|
|
import dayjs from 'dayjs'
|
|
|
-import { browser } from '@/helpers/utils'
|
|
|
+import { browser, getUrlCode } from '@/helpers/utils'
|
|
|
+import qs from 'query-string'
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'companion-teacher-register',
|
|
@@ -74,7 +75,8 @@ export default defineComponent({
|
|
|
countDownTime: 120, // 倒计时时间
|
|
|
countDownRef: null as any, // 倒计时实例
|
|
|
imgCodeStatus: false,
|
|
|
- showPopup: false
|
|
|
+ showPopup: false,
|
|
|
+ code: '' // 授权码
|
|
|
})
|
|
|
|
|
|
const onSubmit = async () => {
|
|
@@ -97,6 +99,7 @@ export default defineComponent({
|
|
|
await request.post('/api-school/open/schoolTeacherStudent/registerTeacher', {
|
|
|
data: {
|
|
|
...forms,
|
|
|
+ code: state.code,
|
|
|
subjectIds: forms.subjectIds.join(','),
|
|
|
schoolId: state.id
|
|
|
}
|
|
@@ -194,10 +197,28 @@ export default defineComponent({
|
|
|
}
|
|
|
|
|
|
// 判断是否是微信,只能微信中打开
|
|
|
- // if (!browser().weixin) {
|
|
|
- // state.showPopup = true
|
|
|
- // return
|
|
|
- // }
|
|
|
+ if (!browser().weixin) {
|
|
|
+ state.showPopup = true
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ //授权
|
|
|
+ const code = getUrlCode()
|
|
|
+ if (!code) {
|
|
|
+ const { returnUrl, ...rest } = route.query
|
|
|
+ const newUrl =
|
|
|
+ window.location.origin +
|
|
|
+ window.location.pathname +
|
|
|
+ '#' +
|
|
|
+ returnUrl +
|
|
|
+ '?' +
|
|
|
+ qs.stringify({
|
|
|
+ ...rest
|
|
|
+ })
|
|
|
+ getAppIdAndCode(newUrl)
|
|
|
+ } else {
|
|
|
+ state.code = code
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
// t: route.query.t, // 过期时间
|
|
|
try {
|
|
@@ -269,11 +290,21 @@ export default defineComponent({
|
|
|
}
|
|
|
})
|
|
|
|
|
|
- const onPreview = () => {
|
|
|
- window.open(
|
|
|
- window.location.origin + window.location.pathname + '#/preview-protocol',
|
|
|
- '_blank'
|
|
|
- )
|
|
|
+ const onPreview = (type: any) => {
|
|
|
+ if (type === 'REGISTER') {
|
|
|
+ window.open(
|
|
|
+ window.location.origin + window.location.pathname + '#/preview-protocol',
|
|
|
+ '_blank'
|
|
|
+ )
|
|
|
+ } else if (type === 'PRIVACY') {
|
|
|
+ window.open(
|
|
|
+ window.location.origin + window.location.pathname + '#/privacyProtocol',
|
|
|
+ '_blank'
|
|
|
+ )
|
|
|
+ } else if (type === 'WITHDRAW') {
|
|
|
+ //
|
|
|
+ window.open(window.location.origin + window.location.pathname + '#/cashProtocol', '_blank')
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const formRef = ref()
|
|
@@ -288,6 +319,30 @@ export default defineComponent({
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ const getAppIdAndCode = async (url?: string) => {
|
|
|
+ try {
|
|
|
+ const { data } = await request.get('/api-school/open/paramConfig/wechatAppId')
|
|
|
+ // 判断是否有微信appId
|
|
|
+ if (data) {
|
|
|
+ closeToast()
|
|
|
+ goAuth(data, url)
|
|
|
+ }
|
|
|
+ } catch {
|
|
|
+ //
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const goAuth = (wxAppId: string, urlString?: string) => {
|
|
|
+ // 用户授权
|
|
|
+ console.log(urlString || window.location.href, 'urlString || window.location.href')
|
|
|
+ const urlNow = encodeURIComponent(urlString || window.location.href)
|
|
|
+ console.log(urlNow, 'urlNow')
|
|
|
+ const scope = 'snsapi_base' //snsapi_userinfo //静默授权 用户无感知
|
|
|
+ const appid = wxAppId || 'wx8654c671631cfade'
|
|
|
+ const url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${urlNow}&response_type=code&scope=${scope}&state=STATE&connect_redirect=1#wechat_redirect`
|
|
|
+ window.location.replace(url)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 反显数据
|
|
|
const getTeacherDetails = async () => {
|
|
|
try {
|
|
|
if (!state.forms.phone) return
|
|
@@ -380,7 +435,6 @@ export default defineComponent({
|
|
|
name="realName"
|
|
|
placeholder="请填写真实姓名"
|
|
|
maxlength="5"
|
|
|
- disabled={state.checkPhone}
|
|
|
></Field>
|
|
|
|
|
|
<Field
|
|
@@ -397,7 +451,6 @@ export default defineComponent({
|
|
|
name="idCardNo"
|
|
|
maxlength={18}
|
|
|
placeholder="请输入身份证号码"
|
|
|
- disabled={state.checkPhone}
|
|
|
></Field>
|
|
|
|
|
|
<Field label="性别" name="gender" rules={[{ required: true, message: '请选择性别' }]}>
|
|
@@ -407,7 +460,6 @@ export default defineComponent({
|
|
|
checked-color="#FF8057"
|
|
|
v-model={state.forms.gender}
|
|
|
direction="horizontal"
|
|
|
- disabled={state.checkPhone}
|
|
|
>
|
|
|
<Tag
|
|
|
size="large"
|
|
@@ -447,7 +499,6 @@ export default defineComponent({
|
|
|
<OUpload
|
|
|
style={{ width: '100%' }}
|
|
|
tips="上传身份证正面"
|
|
|
- disabled={state.checkPhone}
|
|
|
v-model:modelValue={state.forms.idcardFrontImg}
|
|
|
/>
|
|
|
)
|
|
@@ -466,7 +517,6 @@ export default defineComponent({
|
|
|
<OUpload
|
|
|
style={{ width: '100%' }}
|
|
|
tips="上传身份证反面"
|
|
|
- disabled={state.checkPhone}
|
|
|
v-model:modelValue={state.forms.idcardBackImg}
|
|
|
/>
|
|
|
)
|
|
@@ -477,25 +527,20 @@ export default defineComponent({
|
|
|
label="学历"
|
|
|
v-model={state.forms.educationBackground}
|
|
|
readonly
|
|
|
- disabled={state.checkPhone}
|
|
|
name="educationBackground"
|
|
|
onClick={() => {
|
|
|
- if (state.checkPhone) return
|
|
|
state.showEducation = true
|
|
|
}}
|
|
|
rules={[{ required: true, message: '请选择学历', trigger: 'onChange' }]}
|
|
|
placeholder="请选择学历"
|
|
|
>
|
|
|
{{
|
|
|
- 'right-icon': () => (
|
|
|
- <Icon name="arrow" color={state.checkPhone ? '#aaa' : '#323233'} size="16"></Icon>
|
|
|
- )
|
|
|
+ 'right-icon': () => <Icon name="arrow" color={'#323233'} size="16"></Icon>
|
|
|
}}
|
|
|
</Field>
|
|
|
|
|
|
<Field
|
|
|
label="毕业学校"
|
|
|
- disabled={state.checkPhone}
|
|
|
v-model={state.forms.graduateSchool}
|
|
|
rules={[{ required: true, message: '请输入毕业学校' }]}
|
|
|
name="graduateSchool"
|
|
@@ -506,19 +551,15 @@ export default defineComponent({
|
|
|
label="所在城市"
|
|
|
v-model={state.forms.cityCodeName}
|
|
|
readonly
|
|
|
- disabled={state.checkPhone}
|
|
|
name="cityCodeName"
|
|
|
onClick={() => {
|
|
|
- if (state.checkPhone) return
|
|
|
state.showPicker = true
|
|
|
}}
|
|
|
rules={[{ required: true, message: '请选择所在城市', trigger: 'onChange' }]}
|
|
|
placeholder="请选择所在城市"
|
|
|
>
|
|
|
{{
|
|
|
- 'right-icon': () => (
|
|
|
- <Icon name="arrow" color={state.checkPhone ? '#aaa' : '#323233'} size="16"></Icon>
|
|
|
- )
|
|
|
+ 'right-icon': () => <Icon name="arrow" color={'#323233'} size="16"></Icon>
|
|
|
}}
|
|
|
</Field>
|
|
|
|
|
@@ -527,18 +568,14 @@ export default defineComponent({
|
|
|
v-model={state.forms.showSubjectIds}
|
|
|
readonly
|
|
|
name="showSubjectIds"
|
|
|
- disabled={state.checkPhone}
|
|
|
onClick={() => {
|
|
|
- if (state.checkPhone) return
|
|
|
state.showSubject = true
|
|
|
}}
|
|
|
rules={[{ required: true, message: '请选择声部', trigger: 'onChange' }]}
|
|
|
placeholder="请选择声部"
|
|
|
>
|
|
|
{{
|
|
|
- 'right-icon': () => (
|
|
|
- <Icon name="arrow" color={state.checkPhone ? '#aaa' : '#323233'} size="16"></Icon>
|
|
|
- ),
|
|
|
+ 'right-icon': () => <Icon name="arrow" color={'#323233'} size="16"></Icon>,
|
|
|
input: () => (
|
|
|
<>
|
|
|
{state.forms.subjectIds.length <= 0 ? (
|
|
@@ -575,20 +612,12 @@ export default defineComponent({
|
|
|
rules={[{ required: true, message: '请输入验证码', trigger: 'onChange' }]}
|
|
|
placeholder="请输入验证码"
|
|
|
maxlength={6}
|
|
|
- disabled={state.checkPhone}
|
|
|
type="tel"
|
|
|
>
|
|
|
{{
|
|
|
button: () =>
|
|
|
state.countDownStatus ? (
|
|
|
- <Button
|
|
|
- type="primary"
|
|
|
- round
|
|
|
- size="small"
|
|
|
- disabled={state.checkPhone}
|
|
|
- color="#ff8057"
|
|
|
- onClick={onSendCode}
|
|
|
- >
|
|
|
+ <Button type="primary" round size="small" color="#ff8057" onClick={onSendCode}>
|
|
|
发送验证码
|
|
|
</Button>
|
|
|
) : (
|
|
@@ -614,16 +643,26 @@ export default defineComponent({
|
|
|
style="margin-right: 6px"
|
|
|
checked-color="#FF8057"
|
|
|
></Checkbox>
|
|
|
- <span
|
|
|
- onClick={() => {
|
|
|
- state.checked = !state.checked
|
|
|
- }}
|
|
|
- >
|
|
|
- 请认真阅读并勾选
|
|
|
- </span>
|
|
|
- <span class={styles.c} onClick={onPreview}>
|
|
|
- 《乐团伴学指导注册协议》
|
|
|
- </span>
|
|
|
+ <div>
|
|
|
+ <span
|
|
|
+ onClick={() => {
|
|
|
+ state.checked = !state.checked
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 请认真阅读并勾选
|
|
|
+ </span>
|
|
|
+ <span class={styles.c} onClick={() => onPreview('REGISTER')}>
|
|
|
+ 《管乐团用户注册协议》
|
|
|
+ </span>
|
|
|
+ 、
|
|
|
+ <span class={styles.c} onClick={() => onPreview('PRIVACY')}>
|
|
|
+ 《隐私协议》
|
|
|
+ </span>
|
|
|
+ 、
|
|
|
+ <span class={styles.c} onClick={() => onPreview('WITHDRAW')}>
|
|
|
+ 《共享经济平台注册经营者协议》
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
|
|
|
<Button
|
|
@@ -634,7 +673,7 @@ export default defineComponent({
|
|
|
color="#FF8057"
|
|
|
loading={state.btnLoading}
|
|
|
native-type="submit"
|
|
|
- disabled={state.checkPhone || state.btnLoading}
|
|
|
+ disabled={state.btnLoading}
|
|
|
>
|
|
|
完成
|
|
|
</Button>
|