|
@@ -15,6 +15,7 @@ import {
|
|
|
createUserAuthInfo,
|
|
|
getByDictType,
|
|
|
getUserAuthInfo,
|
|
|
+ updateUserAuthInfo,
|
|
|
validateReferrerCode,
|
|
|
} from '../../../core/libs/requests'
|
|
|
import { DictType } from '../../../core/models/moment'
|
|
@@ -25,6 +26,8 @@ import { storeToRefs } from 'pinia'
|
|
|
import { useMessage, useToast } from 'wot-design-uni'
|
|
|
import { useRouter } from '../../../core/utils/router'
|
|
|
import { requestToast } from '../../../core/utils/common'
|
|
|
+import { omit, pick } from 'radash'
|
|
|
+import UploadEvo from '@/components/upload-evo.vue'
|
|
|
|
|
|
const { alert } = useMessage()
|
|
|
const router = useRouter()
|
|
@@ -32,10 +35,9 @@ const userStore = useUserStore()
|
|
|
const { userInfo, isDesigner } = storeToRefs(userStore)
|
|
|
const { error } = useToast()
|
|
|
const formData = ref<any>({})
|
|
|
+const attachment = ref()
|
|
|
const formInited = ref(false)
|
|
|
-const { data: userAuthInfo, run: setUserAuthInfo } = useRequest(() => getUserAuthInfo(), {
|
|
|
- initialData: {},
|
|
|
-})
|
|
|
+const { data: userAuthInfo, run: setUserAuthInfo } = useRequest(() => getUserAuthInfo())
|
|
|
const schema = ref({
|
|
|
channelSource: {
|
|
|
type: 'Select',
|
|
@@ -44,6 +46,7 @@ const schema = ref({
|
|
|
labelWidth: '126rpx',
|
|
|
placeholder: '请选择通过哪个渠道入驻的筑巢荟',
|
|
|
columns: [],
|
|
|
+ disabled: userAuthInfo != null,
|
|
|
},
|
|
|
},
|
|
|
referrer: {
|
|
@@ -52,6 +55,7 @@ const schema = ref({
|
|
|
props: {
|
|
|
labelWidth: '126rpx',
|
|
|
placeholder: '请如实填写推荐人编号,设计师会员编号或渠道编号',
|
|
|
+ disabled: userAuthInfo != null,
|
|
|
},
|
|
|
},
|
|
|
designerName: {
|
|
@@ -90,29 +94,52 @@ const schema = ref({
|
|
|
})
|
|
|
const handleSubmit = async () => {
|
|
|
console.log(formData.value)
|
|
|
- const { data, code: status } = await requestToast(() =>
|
|
|
- validateReferrerCode({ code: formData.value.referrer }),
|
|
|
- )
|
|
|
- if (data === false || status !== 0) {
|
|
|
- uni.showToast({ title: '推荐人编号不正确', icon: 'none' })
|
|
|
- return
|
|
|
- }
|
|
|
- const { code, msg } = await createUserAuthInfo({
|
|
|
- gender: userInfo.value.sex,
|
|
|
- attachment: 'https://via.placeholder.com/319x204',
|
|
|
- userId: userInfo.value.userId,
|
|
|
- ...formData.value,
|
|
|
- })
|
|
|
- if (code === 0) {
|
|
|
- router.replace(`/pages/mine/authentication/submit/success/index`)
|
|
|
+ if (!userAuthInfo.value) {
|
|
|
+ const { data, code: status } = await requestToast(() =>
|
|
|
+ validateReferrerCode({ code: formData.value.referrer }),
|
|
|
+ )
|
|
|
+ if (data === false || status !== 0) {
|
|
|
+ uni.showToast({ title: '推荐人编号不正确', icon: 'none' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const { code, msg } = await createUserAuthInfo({
|
|
|
+ gender: userInfo.value.sex,
|
|
|
+ attachment: 'https://via.placeholder.com/319x204',
|
|
|
+ userId: userInfo.value.userId,
|
|
|
+ ...formData.value,
|
|
|
+ })
|
|
|
+ if (code === 0) {
|
|
|
+ router.replace(`/pages/mine/authentication/submit/success/index`)
|
|
|
+ } else {
|
|
|
+ error(msg)
|
|
|
+ }
|
|
|
} else {
|
|
|
- error(msg)
|
|
|
+ const toBeUpdate = {
|
|
|
+ ...omit(formData.value, []),
|
|
|
+ attachment: attachment.value,
|
|
|
+ id: userAuthInfo.value.id,
|
|
|
+ gender: userInfo.value.sex,
|
|
|
+ }
|
|
|
+ const { code } = await requestToast(() => updateUserAuthInfo({ ...toBeUpdate, auditStatus: 1 }))
|
|
|
+ if (code === 0) {
|
|
|
+ router.replace(`/pages/mine/authentication/submit/success/index`)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
onMounted(async () => {
|
|
|
await setUserAuthInfo()
|
|
|
if (userAuthInfo.value) {
|
|
|
console.log(userAuthInfo.value)
|
|
|
+ formData.value = pick(userAuthInfo.value, [
|
|
|
+ 'channelSource',
|
|
|
+ 'referrer',
|
|
|
+ 'designerName',
|
|
|
+ 'designerName',
|
|
|
+ 'mobile',
|
|
|
+ 'employer',
|
|
|
+ 'spatialExpertiseType',
|
|
|
+ ])
|
|
|
+ attachment.value = userAuthInfo.value.attachment
|
|
|
}
|
|
|
const { data } = await getByDictType('member_channel_source')
|
|
|
const { data: res } = await getByDictType(DictType.memberSpatialExpertiseType)
|
|
@@ -162,13 +189,20 @@ defineExpose({})
|
|
|
custom-class="mb-4"
|
|
|
></SectionHeading>
|
|
|
<div class="h-0.25 bg-[#e1e1e1] mb-5"></div>
|
|
|
- <wd-upload></wd-upload>
|
|
|
+ <!-- <wd-upload></wd-upload> -->
|
|
|
+ <UploadEvo v-if="formInited" v-model="attachment"></UploadEvo>
|
|
|
</Card>
|
|
|
<div class="flex-1"></div>
|
|
|
<div>
|
|
|
- <wd-button block :round="false" :disabled="isDesigner" @click="handleSubmit">
|
|
|
+ <wd-button
|
|
|
+ block
|
|
|
+ :round="false"
|
|
|
+ :disabled="isDesigner || userInfo.userAuthStatus === 1"
|
|
|
+ @click="handleSubmit"
|
|
|
+ >
|
|
|
提交
|
|
|
</wd-button>
|
|
|
+ <!-- <wd-button @click="handleSubmit">test</wd-button> -->
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|