index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <route lang="json">
  2. {
  3. "style": {
  4. "navigationBarTitleText": "设计师认证",
  5. "navigationStyle": "custom"
  6. }
  7. }
  8. </route>
  9. <script lang="ts" setup>
  10. import Card from '@/components/card.vue'
  11. import DataForm from '@/components/data-form.vue'
  12. import NavBarEvo from '@/components/navbar-evo.vue'
  13. import SectionHeading from '@/components/section-heading.vue'
  14. import {
  15. createUserAuthInfo,
  16. getByDictType,
  17. getUserAuthInfo,
  18. updateUserAuthInfo,
  19. validateReferrerCode,
  20. } from '../../../core/libs/requests'
  21. import { DictType } from '../../../core/libs/models'
  22. import { useUserStore } from '../../../store'
  23. import pageHeaderFilter from '@designer-hub/assets/src/assets/svgs/pageHeaderFilter'
  24. import { storeToRefs } from 'pinia'
  25. import { useMessage, useToast } from 'wot-design-uni'
  26. import { useRouter } from '../../../core/utils/router'
  27. import { requestToast } from '../../../core/utils/common'
  28. import { omit, pick } from 'radash'
  29. import UploadEvo from '@/components/upload-evo.vue'
  30. import { DataFormSchema } from '../../../components/data-form'
  31. const { alert } = useMessage()
  32. const router = useRouter()
  33. const userStore = useUserStore()
  34. const { userInfo, isDesigner } = storeToRefs(userStore)
  35. const { error } = useToast()
  36. const formData = ref<any>({ mobile: userInfo.value?.mobile })
  37. const attachment = ref()
  38. const formInited = ref(false)
  39. const { data: userAuthInfo, run: setUserAuthInfo } = useRequest(() => getUserAuthInfo())
  40. const schema = ref<DataFormSchema>({
  41. channelSource: {
  42. type: 'Select',
  43. label: '来源',
  44. labelWidth: 63,
  45. props: {
  46. placeholder: '请选择通过哪个渠道入驻的筑巢荟',
  47. columns: [],
  48. disabled: userAuthInfo.value != null,
  49. 'onUpdate:modelValue': (value) => setReferrerExisting(value),
  50. },
  51. },
  52. referrer: {
  53. type: 'TextField',
  54. label: '推荐人',
  55. existing: true,
  56. labelWidth: 63,
  57. props: {
  58. placeholder: '请填写推荐人编号',
  59. disabled: userAuthInfo.value != null,
  60. },
  61. },
  62. designerName: {
  63. type: 'TextField',
  64. label: '姓名',
  65. labelWidth: 63,
  66. props: {
  67. placeholder: '请输入真实姓名',
  68. },
  69. },
  70. mobile: {
  71. type: 'TextField',
  72. label: '电话',
  73. labelWidth: 63,
  74. props: {
  75. placeholder: '请输入电话号码',
  76. disabled: true,
  77. },
  78. },
  79. employer: {
  80. type: 'TextField',
  81. label: '公司',
  82. labelWidth: 63,
  83. props: {
  84. placeholder: '请输入所在公司或自己公司名称',
  85. },
  86. },
  87. spatialExpertiseType: {
  88. type: 'Checkbox',
  89. label: '擅长空间类型',
  90. labelWidth: 84,
  91. props: {
  92. placeholder: ' ',
  93. columns: [],
  94. },
  95. },
  96. })
  97. const setReferrerExisting = (value: string) => {
  98. if (value === '4') {
  99. schema.value.referrer.existing = false
  100. } else {
  101. schema.value.referrer.existing = true
  102. schema.value.referrer.props.placeholder = {
  103. '1': '请填写渠道邀请码',
  104. '2': '请填写设计师会员号',
  105. }[value]
  106. }
  107. }
  108. const handleSubmit = async () => {
  109. console.log(formData.value)
  110. if (!userAuthInfo.value) {
  111. if (formData.value.channelSource !== '4') {
  112. const { data, code: status } = await requestToast(() =>
  113. validateReferrerCode({
  114. code: formData.value.referrer,
  115. channelSource: formData.value.channelSource,
  116. }),
  117. )
  118. if (data === false || status !== 0) {
  119. uni.showToast({ title: '推荐人编号不正确', icon: 'none' })
  120. return
  121. }
  122. }
  123. const { code, msg } = await createUserAuthInfo({
  124. gender: userInfo.value.sex,
  125. attachment: attachment.value,
  126. userId: userInfo.value.userId,
  127. ...formData.value,
  128. spatialExpertiseType: formData.value.spatialExpertiseType.join(','),
  129. })
  130. if (code === 0) {
  131. router.replace(`/pages/mine/authentication/submit/success/index`)
  132. } else {
  133. error(msg)
  134. }
  135. } else {
  136. if (formData.value.channelSource !== '4') {
  137. const { data, code: status } = await requestToast(() =>
  138. validateReferrerCode({
  139. code: formData.value.referrer,
  140. channelSource: formData.value.channelSource,
  141. }),
  142. )
  143. if (data === false || status !== 0) {
  144. uni.showToast({ title: '推荐人编号不正确', icon: 'none' })
  145. return
  146. }
  147. }
  148. const toBeUpdate = {
  149. ...omit(formData.value, ['spatialExpertiseType']),
  150. spatialExpertiseType: formData.value.spatialExpertiseType.join(','),
  151. attachment: attachment.value,
  152. id: userAuthInfo.value.id,
  153. gender: userInfo.value.sex,
  154. }
  155. const { code } = await requestToast(() => updateUserAuthInfo({ ...toBeUpdate, auditStatus: 1 }))
  156. if (code === 0) {
  157. router.replace(`/pages/mine/authentication/submit/success/index`)
  158. }
  159. }
  160. }
  161. onMounted(async () => {
  162. await setUserAuthInfo()
  163. console.log(userAuthInfo.value)
  164. console.log(userAuthInfo.value)
  165. if (userAuthInfo.value) {
  166. console.log(userAuthInfo.value)
  167. formData.value = {
  168. ...pick(userAuthInfo.value, [
  169. 'channelSource',
  170. 'referrer',
  171. 'designerName',
  172. 'designerName',
  173. 'mobile',
  174. 'employer',
  175. ]),
  176. spatialExpertiseType: userAuthInfo.value.spatialExpertiseType?.split(','),
  177. }
  178. setReferrerExisting(userAuthInfo.value.channelSource.toString())
  179. attachment.value = userAuthInfo.value.attachment
  180. }
  181. const { data } = await getByDictType('member_channel_source')
  182. const { data: res } = await getByDictType(DictType.memberSpatialExpertiseType)
  183. console.log(res)
  184. schema.value.channelSource.props.columns = data
  185. schema.value.spatialExpertiseType.props.columns = res
  186. formInited.value = true
  187. if (userInfo.value.userAuthStatus === 1) {
  188. alert({
  189. msg: '您的认证申请已提交,请耐心等待审核,审核通过后您将获得通知',
  190. title: '提示',
  191. confirmButtonText: '我知道了',
  192. })
  193. }
  194. if (userInfo.value.userAuthStatus === 2) {
  195. alert({
  196. title: '审核不通过',
  197. msg: userAuthInfo.value?.remark || '由于系统原因,您提交的认证暂时无法通过,请修改后重新提交',
  198. })
  199. }
  200. })
  201. defineExpose({})
  202. </script>
  203. <template>
  204. <div class="flex-grow">
  205. <div class="relative aspect-[3.6/1]">
  206. <div class="absolute top-0 left--1 right--1 bottom--18.5">
  207. <wd-img
  208. width="100%"
  209. height="100%"
  210. :src="'https://image.zhuchaohui.com/zhucaohui/21d6584cb711834f037a763855d05572433f776b308596d94aca97dd37e6cfa.png'"
  211. ></wd-img>
  212. </div>
  213. <div class="absolute top-0 left-0 right-0 bottom--18.5">
  214. <wd-img width="100%" height="100%" :src="pageHeaderFilter"></wd-img>
  215. </div>
  216. </div>
  217. <NavBarEvo transparent dark title="设计师认证"></NavBarEvo>
  218. <div class="flex-grow flex flex-col p-3.5 gap-3.5 relative">
  219. <Card>
  220. <SectionHeading size="base" title="基本信息" custom-class="mb-4"></SectionHeading>
  221. <template v-if="formInited">
  222. <DataForm v-model="formData" :schema="schema" direction="horizontal"></DataForm>
  223. </template>
  224. </Card>
  225. <Card>
  226. <SectionHeading
  227. size="base"
  228. title="上传附件"
  229. subtitle="请上传名片或者获奖信息凭证"
  230. custom-class="mb-4"
  231. ></SectionHeading>
  232. <div class="h-0.25 bg-[#e1e1e1] mb-5"></div>
  233. <!-- <wd-upload></wd-upload> -->
  234. <UploadEvo v-if="formInited" v-model="attachment"></UploadEvo>
  235. </Card>
  236. <div class="flex-1"></div>
  237. <div>
  238. <wd-button
  239. block
  240. :round="false"
  241. :disabled="isDesigner || userInfo.userAuthStatus === 1"
  242. @click="handleSubmit"
  243. >
  244. 提交
  245. </wd-button>
  246. <!-- <wd-button @click="handleSubmit">test</wd-button> -->
  247. </div>
  248. </div>
  249. </div>
  250. </template>