index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <view class="register-main">
  3. <up-alert description="您的注册被驳回,请查看驳回原因" type="warning" showIcon closable
  4. v-if="details.appStatus === 3"></up-alert>
  5. <up-alert description="您已完成账户注册" type="success" showIcon closable
  6. v-if="!isAdd && details.appStatus !== 3"></up-alert>
  7. <view class="register-user-info">
  8. <FontTitle title="请完成注册信息填报" />
  9. <CustForm :column="com_column" ref="cust_form_ref" :isCode="isAdd" />
  10. </view>
  11. <view class="register-card" v-if="details.appStatus === 3">
  12. <view class="font-title">驳回原因</view>
  13. <view class="info-list">
  14. {{ details.rejectReason }}
  15. </view>
  16. </view>
  17. <view v-for="item in updata_list" :key="item.key" class="updata-imgs">
  18. <UpdataImgs :fileList="file_url[item.key]" :data="item" ref="zsImg"
  19. v-if="item.permission.includes(data.key)" @onSubmit="onChange" />
  20. </view>
  21. <up-button type="primary" text="确定" @click="onSubmit" v-if="isAdd"></up-button>
  22. </view>
  23. </template>
  24. <script setup>
  25. import { ref, reactive, onMounted, nextTick } from 'vue';
  26. import { onLoad } from '@dcloudio/uni-app';
  27. import FontTitle from "@/components/font-title/index.vue";
  28. import CustForm from "@/components/cust-form/index";
  29. import UpdataImgs from "@/components/updata-imgs/index.vue";
  30. import { chatting, education, clean } from "./data";
  31. import { add, getVolunteerInfo } from "@/api/volunteer";
  32. import { computed } from 'vue';
  33. const userImg = ref(null);
  34. const zsImg = ref(null);
  35. const updata_list = [
  36. {
  37. title: '上传头像',
  38. text: '上传您的头像',
  39. img: '/static/img/updata-user-img.png',
  40. key: 'volunteerPicture',
  41. ref: userImg,
  42. permission: [1, 2],
  43. required: true
  44. },
  45. {
  46. title: '个人身份证',
  47. text: '上传您的个人身份证',
  48. img: '/static/img/updata-user-img.png',
  49. key: 'idCardPicture',
  50. ref: zsImg,
  51. permission: [1, 2],
  52. required: true
  53. },
  54. {
  55. title: '职业、资质证书',
  56. text: '上传您的职业、资质证书',
  57. img: '/static/img/updata-user-img.png',
  58. key: 'certificationPicture',
  59. ref: zsImg,
  60. permission: [1, 2],
  61. required: false
  62. }
  63. ]
  64. const cust_form_ref = ref(null);
  65. const data = ref(null);
  66. const file_url = reactive({});
  67. const isAdd = ref(true);//是否已经注册
  68. const details = ref({});//详情数据
  69. const sex_status = {
  70. '男': 0,
  71. '女': 1
  72. }
  73. const register_column = {
  74. 1: chatting,
  75. 2: education,
  76. 5: clean
  77. }
  78. //根据类型获取表单item 值
  79. const com_column = computed(() => {
  80. let column_list = data.value ? register_column[data.value.key] : [];
  81. return column_list
  82. })
  83. function onSubmit() {
  84. try {
  85. // return;
  86. // 校验表单并获取数据
  87. cust_form_ref.value.onSubmit().then(async (res) => {
  88. console.log('===res===>', res, file_url);
  89. //文件必传校验
  90. for (let i = 0; i < updata_list.length; i++) {
  91. const element = updata_list[i];
  92. console.log(element.required, element.permission.includes(data.value.key), file_url[element.key]);
  93. const type = element.required && element.permission.includes(data.value.key) && !file_url[element.key];
  94. console.log('element', element, type);
  95. if (type) {
  96. uni.showToast({
  97. title: '请上传' + element.title,
  98. icon: 'error'
  99. })
  100. return;
  101. }
  102. }
  103. const parmas = {
  104. serviceCategory: data.value.key,
  105. ...file_url
  106. };
  107. for (const key in res) {
  108. parmas[key] = key == 'sex' ? sex_status[res[key]] : res[key];
  109. if(key === 'businessManagementIdkey' ){
  110. parmas['businessManagementId'] = res[key]
  111. delete parmas['businessManagementIdkey'];
  112. }
  113. }
  114. console.log('提交', parmas);
  115. return;
  116. // 提交接口,注册人员
  117. const submit_res = await add(parmas);
  118. if (submit_res.code == 200) {
  119. uni.showToast({
  120. title: '注册成功',
  121. icon: 'success',
  122. success: () => {
  123. setTimeout(() => {
  124. uni.navigateBack();
  125. }, 1000)
  126. }
  127. })
  128. return;
  129. }
  130. uni.showToast({
  131. title: res.msg,
  132. icon: 'none'
  133. })
  134. console.log('==submit_res====>', submit_res);
  135. })
  136. } catch (error) {
  137. console.log('error', error);
  138. } finally {
  139. }
  140. }
  141. function onChange({ key, url }) {
  142. console.log('onChange', key, url);
  143. Object.assign(file_url, {
  144. [key]: url
  145. })
  146. }
  147. async function getRegister() {
  148. try {
  149. uni.showLoading({
  150. title: '数据加载中...'
  151. });
  152. const res = await getVolunteerInfo({ serviceCategory: data.value.key });
  153. if (res.data) {
  154. cust_form_ref.value.setData(res.data);
  155. details.value = res.data;
  156. Object.assign(file_url, {
  157. volunteerPicture: res.data.volunteerPicture,
  158. idCardPicture: res.data.idCardPicture,
  159. certificationPicture: res.data.certificationPicture
  160. })
  161. isAdd.value = false;
  162. }
  163. } catch (error) {
  164. console.log('error', error);
  165. uni.showToast({
  166. title: error.msg,
  167. icon: 'error',
  168. });
  169. } finally {
  170. uni.hideLoading();
  171. }
  172. }
  173. // onMounted(() => {
  174. // nextTick(() => {
  175. // });
  176. // })
  177. onLoad((options) => {
  178. const option = JSON.parse(decodeURIComponent(options.data));
  179. data.value = option;
  180. console.log("option", option);
  181. uni.setNavigationBarTitle({
  182. title: option.name // 根据业务逻辑调整
  183. });
  184. setTimeout(() => {
  185. getRegister();
  186. }, 500);
  187. })
  188. </script>
  189. <style lang="scss" scoped>
  190. .register-main {
  191. padding: 12px;
  192. background-color: rgba(245, 245, 245, 1);
  193. // height: 100vh;
  194. .register-user-info {
  195. margin-bottom: 12px;
  196. background-color: #fff;
  197. border-radius: 8px;
  198. padding: 18px 16px;
  199. }
  200. .updata-imgs {
  201. margin-bottom: 12px;
  202. }
  203. }
  204. .register-card {
  205. margin-bottom: 12px;
  206. background-color: #fff;
  207. border-radius: 8px;
  208. padding: 18px 16px;
  209. }
  210. .info-list {
  211. flex: 1;
  212. font-size: 14px;
  213. font-weight: 500;
  214. letter-spacing: 0px;
  215. line-height: 23.27px;
  216. color: rgba(51, 51, 51, 1);
  217. }
  218. </style>