|
@@ -28,6 +28,7 @@ import { requestToast } from '../../../core/utils/common'
|
|
|
import { omit, pick } from 'radash'
|
|
|
import UploadEvo from '@/components/upload-evo.vue'
|
|
|
import { DataFormSchema } from '../../../components/data-form'
|
|
|
+import { messages } from '../../../core/libs/messages'
|
|
|
|
|
|
const { alert } = useMessage()
|
|
|
const router = useRouter()
|
|
@@ -108,25 +109,57 @@ const setReferrerExisting = (value: string) => {
|
|
|
}
|
|
|
const handleSubmit = async () => {
|
|
|
console.log(formData.value)
|
|
|
- if (!userAuthInfo.value) {
|
|
|
- if (formData.value.channelSource !== '4') {
|
|
|
- const { data, code: status } = await requestToast(() =>
|
|
|
- validateReferrerCode({
|
|
|
- code: formData.value.referrer,
|
|
|
- channelSource: formData.value.channelSource,
|
|
|
- }),
|
|
|
- )
|
|
|
- if (data === false || status !== 0) {
|
|
|
- uni.showToast({ title: '推荐人编号不正确', icon: 'none' })
|
|
|
- return
|
|
|
- }
|
|
|
+ if (formData.value.channelSource && formData.value.channelSource !== '4') {
|
|
|
+ if ((formData.value.referrer ?? '') === '') {
|
|
|
+ uni.showToast({ title: messages.mine.authentication.referrerErrorText, icon: 'none' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const { data, code: status } = await requestToast(() =>
|
|
|
+ validateReferrerCode({
|
|
|
+ code: formData.value.referrer,
|
|
|
+ channelSource: formData.value.channelSource,
|
|
|
+ }),
|
|
|
+ )
|
|
|
+ if (data === false || status !== 0) {
|
|
|
+ uni.showToast({ title: '推荐人编号不正确', icon: 'none' })
|
|
|
+ return
|
|
|
}
|
|
|
+ }
|
|
|
+ const body = {
|
|
|
+ ...formData.value,
|
|
|
+ spatialExpertiseType: formData.value.spatialExpertiseType?.join(','),
|
|
|
+ attachment: attachment.value,
|
|
|
+ }
|
|
|
+ const rules = {
|
|
|
+ channelSource: { required: true, message: messages.mine.authentication.channelSourceErrorText },
|
|
|
+ // referrer: { required: true, message: messages.mine.authentication.referrerErrorText },
|
|
|
+ designerName: { required: true, message: messages.mine.authentication.designerNameErrorText },
|
|
|
+ employer: { required: true, message: messages.mine.authentication.employerErrorText },
|
|
|
+ spatialExpertiseType: {
|
|
|
+ required: true,
|
|
|
+ message: messages.mine.authentication.spatialExpertiseTypeErrorText,
|
|
|
+ },
|
|
|
+ attachment: { required: true, message: messages.mine.authentication.attachmentErrorText },
|
|
|
+ }
|
|
|
+ // 校验上述字段
|
|
|
+ const errors = Object.entries(rules)
|
|
|
+ .filter(([key, value]) => (body[key] ?? '') === '')
|
|
|
+ .map(([key, value]) => value.message)
|
|
|
+ console.log(errors)
|
|
|
+ if (errors.length > 0) {
|
|
|
+ uni.showToast({ title: errors[0], icon: 'none' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!userAuthInfo.value) {
|
|
|
+ console.log(3333)
|
|
|
+
|
|
|
const { code, msg } = await createUserAuthInfo({
|
|
|
gender: userInfo.value.sex,
|
|
|
attachment: attachment.value,
|
|
|
userId: userInfo.value.userId,
|
|
|
...formData.value,
|
|
|
- spatialExpertiseType: formData.value.spatialExpertiseType.join(','),
|
|
|
+ spatialExpertiseType: formData.value.spatialExpertiseType?.join(','),
|
|
|
})
|
|
|
if (code === 0) {
|
|
|
router.replace(`/pages/mine/authentication/submit/success/index`)
|
|
@@ -134,21 +167,9 @@ const handleSubmit = async () => {
|
|
|
error(msg)
|
|
|
}
|
|
|
} else {
|
|
|
- if (formData.value.channelSource !== '4') {
|
|
|
- const { data, code: status } = await requestToast(() =>
|
|
|
- validateReferrerCode({
|
|
|
- code: formData.value.referrer,
|
|
|
- channelSource: formData.value.channelSource,
|
|
|
- }),
|
|
|
- )
|
|
|
- if (data === false || status !== 0) {
|
|
|
- uni.showToast({ title: '推荐人编号不正确', icon: 'none' })
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
const toBeUpdate = {
|
|
|
...omit(formData.value, ['spatialExpertiseType']),
|
|
|
- spatialExpertiseType: formData.value.spatialExpertiseType.join(','),
|
|
|
+ spatialExpertiseType: formData.value.spatialExpertiseType?.join(','),
|
|
|
attachment: attachment.value,
|
|
|
id: userAuthInfo.value.id,
|
|
|
gender: userInfo.value.sex,
|