index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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 pageHeaderBg from '@designer-hub/assets/src/assets/svgs/pageHeaderBg'
  24. import pageHeaderFilter from '@designer-hub/assets/src/assets/svgs/pageHeaderFilter'
  25. import { storeToRefs } from 'pinia'
  26. import { useMessage, useToast } from 'wot-design-uni'
  27. import { useRouter } from '../../../core/utils/router'
  28. import { requestToast } from '../../../core/utils/common'
  29. import { omit, pick } from 'radash'
  30. import UploadEvo from '@/components/upload-evo.vue'
  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>({})
  37. const attachment = ref()
  38. const formInited = ref(false)
  39. const { data: userAuthInfo, run: setUserAuthInfo } = useRequest(() => getUserAuthInfo())
  40. const schema = ref({
  41. channelSource: {
  42. type: 'Select',
  43. label: '来源',
  44. props: {
  45. labelWidth: '126rpx',
  46. placeholder: '请选择通过哪个渠道入驻的筑巢荟',
  47. columns: [],
  48. disabled: userAuthInfo != null,
  49. },
  50. },
  51. referrer: {
  52. type: 'TextField',
  53. label: '推荐人',
  54. props: {
  55. labelWidth: '126rpx',
  56. placeholder: '请如实填写推荐人编号,设计师会员编号或渠道编号',
  57. disabled: userAuthInfo != null,
  58. },
  59. },
  60. designerName: {
  61. type: 'TextField',
  62. label: '姓名',
  63. props: {
  64. labelWidth: '126rpx',
  65. placeholder: '请输入真实姓名',
  66. },
  67. },
  68. mobile: {
  69. type: 'TextField',
  70. label: '电话',
  71. props: {
  72. labelWidth: '126rpx',
  73. placeholder: '请输入电话号码',
  74. },
  75. },
  76. employer: {
  77. type: 'TextField',
  78. label: '公司',
  79. props: {
  80. labelWidth: '126rpx',
  81. placeholder: '请输入所在公司或自己公司名称',
  82. },
  83. },
  84. spatialExpertiseType: {
  85. type: 'Radio',
  86. label: '擅长空间类型',
  87. props: {
  88. labelWidth: '170rpx',
  89. placeholder: ' ',
  90. columns: [],
  91. },
  92. },
  93. })
  94. const handleSubmit = async () => {
  95. console.log(formData.value)
  96. if (!userAuthInfo.value) {
  97. const { data, code: status } = await requestToast(() =>
  98. validateReferrerCode({ code: formData.value.referrer }),
  99. )
  100. if (data === false || status !== 0) {
  101. uni.showToast({ title: '推荐人编号不正确', icon: 'none' })
  102. return
  103. }
  104. const { code, msg } = await createUserAuthInfo({
  105. gender: userInfo.value.sex,
  106. attachment: 'https://via.placeholder.com/319x204',
  107. userId: userInfo.value.userId,
  108. ...formData.value,
  109. })
  110. if (code === 0) {
  111. router.replace(`/pages/mine/authentication/submit/success/index`)
  112. } else {
  113. error(msg)
  114. }
  115. } else {
  116. const toBeUpdate = {
  117. ...omit(formData.value, []),
  118. attachment: attachment.value,
  119. id: userAuthInfo.value.id,
  120. gender: userInfo.value.sex,
  121. }
  122. const { code } = await requestToast(() => updateUserAuthInfo({ ...toBeUpdate, auditStatus: 1 }))
  123. if (code === 0) {
  124. router.replace(`/pages/mine/authentication/submit/success/index`)
  125. }
  126. }
  127. }
  128. onMounted(async () => {
  129. await setUserAuthInfo()
  130. if (userAuthInfo.value) {
  131. console.log(userAuthInfo.value)
  132. formData.value = pick(userAuthInfo.value, [
  133. 'channelSource',
  134. 'referrer',
  135. 'designerName',
  136. 'designerName',
  137. 'mobile',
  138. 'employer',
  139. 'spatialExpertiseType',
  140. ])
  141. attachment.value = userAuthInfo.value.attachment
  142. }
  143. const { data } = await getByDictType('member_channel_source')
  144. const { data: res } = await getByDictType(DictType.memberSpatialExpertiseType)
  145. console.log(res)
  146. schema.value.channelSource.props.columns = data
  147. schema.value.spatialExpertiseType.props.columns = res
  148. formInited.value = true
  149. if (userInfo.value.userAuthStatus === 1) {
  150. alert({
  151. msg: '您的认证申请已提交,请耐心等待审核,审核通过后您将获得通知',
  152. title: '提示',
  153. confirmButtonText: '我知道了',
  154. })
  155. }
  156. if (userInfo.value.userAuthStatus === 2) {
  157. alert({
  158. title: '审核不通过',
  159. msg: '由于系统原因,您提交的认证暂时无法通过,请修改后重新提交',
  160. })
  161. }
  162. })
  163. defineExpose({})
  164. </script>
  165. <template>
  166. <div class="flex-grow">
  167. <div class="relative aspect-[3.6/1]">
  168. <div class="absolute top-0 left-0 right-0 bottom--18.5">
  169. <wd-img width="100%" height="100%" :src="pageHeaderBg"></wd-img>
  170. </div>
  171. <div class="absolute top-0 left-0 right-0 bottom--18.5">
  172. <wd-img width="100%" height="100%" :src="pageHeaderFilter"></wd-img>
  173. </div>
  174. </div>
  175. <NavBarEvo transparent dark title="设计师认证"></NavBarEvo>
  176. <div class="flex-grow flex flex-col p-3.5 gap-3.5 relative">
  177. <Card>
  178. <SectionHeading size="base" title="基本信息" custom-class="mb-4"></SectionHeading>
  179. <template v-if="formInited">
  180. <DataForm v-model="formData" :schema="schema" direction="horizontal"></DataForm>
  181. </template>
  182. </Card>
  183. <Card>
  184. <SectionHeading
  185. size="base"
  186. title="上传附件"
  187. subtitle="请上传名片或者获奖信息凭证"
  188. custom-class="mb-4"
  189. ></SectionHeading>
  190. <div class="h-0.25 bg-[#e1e1e1] mb-5"></div>
  191. <!-- <wd-upload></wd-upload> -->
  192. <UploadEvo v-if="formInited" v-model="attachment"></UploadEvo>
  193. </Card>
  194. <div class="flex-1"></div>
  195. <div>
  196. <wd-button
  197. block
  198. :round="false"
  199. :disabled="isDesigner || userInfo.userAuthStatus === 1"
  200. @click="handleSubmit"
  201. >
  202. 提交
  203. </wd-button>
  204. <!-- <wd-button @click="handleSubmit">test</wd-button> -->
  205. </div>
  206. </div>
  207. </div>
  208. </template>