index.vue 5.3 KB

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