index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <view class="certification-main">
  3. <Step :step="step" />
  4. <view v-if="data.appStatus === '3'" class="certification-error">
  5. <view class="appStatus-error-icon"></view>
  6. <view>审核失败。</view>
  7. </view>
  8. <view class="certification-scroll">
  9. <view>
  10. <view class="certification-content">
  11. <!-- 上传资质 -->
  12. <view class="flex_c_l certification-title"><text class="text-red" v-if="viewStatus">*</text>{{
  13. viewStatus ? '请选择' : '' }}发布服务类目:</view>
  14. <!-- 服务类目 -->
  15. <Category />
  16. <view class="flex_c_l certification-title"><text class="text-red" v-if="viewStatus">*</text>{{
  17. viewStatus ? '请填写' : '' }}服务信息:</view>
  18. <CategoryInfo />
  19. <CategoryImags />
  20. <!-- 规格信息 -->
  21. <Specifications :viewStatus="viewStatus"/>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="certification-footer flex_c_c">
  26. <view v-if="[0].includes(step)">
  27. <view class="btn-w certification-btn flex_c_c" @click="goNext">提交</view>
  28. </view>
  29. <view v-if="[1].includes(step)" class="flex_c_c flex-gap">
  30. <view class="certification-btn-bols flex_c_c btn-p2" @click="returnStep" >删除</view>
  31. <view class="certification-btn flex_c_c btn-p" @click="onSubmit">修改</view>
  32. </view>
  33. <view v-if="[2].includes(step)" class="flex_c_c flex-gap-30 step-more-main">
  34. <view class="more-btns" v-if="moreBtn">
  35. <view class="more-btn" @click="onDelete">删除</view>
  36. <view class="more-btn" @click="onAdd">新增</view>
  37. </view>
  38. <view class="more-box" @click="moreBtn = !moreBtn">
  39. <view :class="[moreBtn ? 'icon-down' : 'icon-up']"></view>
  40. 更多</view>
  41. <view class="certification-btn-bols flex_c_c btn-p2" @click="onDown" v-if="data.appStatus === '2'">下线</view>
  42. <view class="certification-btn flex_c_c btn-p" @click="onEdit" v-if="data.appStatus === '2'">修改</view>
  43. <view class="certification-btn-bols flex_c_c btn-p3" @click="onEdit" v-if="data.appStatus === '3'">修改</view>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script setup>
  49. import { computed, ref, reactive, watch } from 'vue';
  50. import { provide, inject } from 'vue'
  51. import { onLoad } from '@dcloudio/uni-app';
  52. import store from '@/store'
  53. import Step from './Step.vue';
  54. import Category from './Category.vue';
  55. import CategoryInfo from './CategoryInfo.vue';
  56. import CategoryImags from './CategoryImags.vue';
  57. import Specifications from './Specifications.vue';
  58. const step = ref(0);
  59. const moreBtn = ref(false);
  60. // true: 显示1、2步骤 false: 2、3步骤(查看)
  61. const viewStatus = computed(() => {
  62. return ![1, 2].includes(step.value)
  63. })
  64. provide('viewStatus', viewStatus);
  65. const data = reactive({
  66. //服务
  67. project: {
  68. id: '13',
  69. businessName: '居家陪伴',
  70. parentId: '1',
  71. isFiles: true,//上传文件
  72. },
  73. activeProjects: [
  74. {
  75. id: '13',
  76. businessName: '居家陪伴',
  77. parentId: '1',
  78. isFiles: true,//上传文件
  79. },
  80. {
  81. id: '14',
  82. businessName: '出行陪伴',
  83. parentId: '1',
  84. isFiles: false,//上传文件
  85. }
  86. ],
  87. // 是否展示资质
  88. whether: '1',
  89. // 请上传个人形象照
  90. volunteerPicture: null,
  91. projectImages:['https://leromro.oss-cn-hangzhou.aliyuncs.com/test/684a38246f14b870873333c3.png','https://leromro.oss-cn-hangzhou.aliyuncs.com/test/684a38246f14b870873333c3.png'],//图片 注:第一张用于封面展示
  92. appStatus: '1', //审批状态 1待审批2已通过3已驳回
  93. businessName:'致力于解决行动不便患者就医难题,让专业医疗服务突破空间限制,直达患者身边。',//服务名称
  94. businessDescribe:'依托先进的便携式检测设备与专业检测技术,打破传统检测的时空限制,可提供上门检测服务,让客户在舒适的环境中完成健康筛查',//服务描述
  95. businessSpecifications:[{}],//服务规格
  96. });
  97. provide('formData', data);
  98. watch(data, (newVal, oldVal) => {
  99. uni.$u.debounce(storageData, 500)
  100. })
  101. const storageData = () => {
  102. console.log('存储数据', data);
  103. store.dispatch('handlerCertificationInfo', data)
  104. }
  105. //服务必选验证
  106. const projectVerify = async () => {
  107. return new Promise((resolve, reject) => {
  108. if (data.businessName.trim().length === 0) reject('请填写服务名称');
  109. if (data.businessDescribe.trim().length === 0) reject('请填写服务描述');
  110. if (data.projectImages.length === 0) reject('请上传服务相关图片');
  111. //服务规格描述校验
  112. const isVer = data.businessSpecifications && data.businessSpecifications.length > 0;
  113. if (!isVer) reject('请完成服务规格信息的填写');
  114. resolve(true)
  115. })
  116. }
  117. const goNext = async () => {
  118. try {
  119. if (step.value === 0) {
  120. const verify = await projectVerify();
  121. verify && onSubmit()
  122. }
  123. step.value = step.value + 1;
  124. } catch (error) {
  125. uni.showToast({
  126. title: error,
  127. icon: 'none'
  128. })
  129. console.log("TCL: goNext -> error", error)
  130. }
  131. }
  132. const returnStep = () => {
  133. step.value = 0;
  134. }
  135. const onSubmit = () => {
  136. console.log('提交', data);
  137. }
  138. const getServeDetails = async () => {
  139. // data.appStatus = '2';
  140. // step.value = 3;
  141. }
  142. const onDelete = async () => {
  143. try {
  144. } catch (error) {
  145. console.log("TCL: onDelete -> error", error)
  146. }
  147. }
  148. const onAdd = async () => {
  149. try {
  150. } catch (error) {
  151. console.log("TCL: onAdd -> error", error)
  152. }
  153. }
  154. const onEdit = async () => {
  155. try {
  156. } catch (error) {
  157. console.log("TCL: onDown -> onEdit", error)
  158. }
  159. }
  160. const onDown = async () => {
  161. try {
  162. } catch (error) {
  163. console.log("TCL: onDown -> error", error)
  164. }
  165. }
  166. //选取服务返回
  167. const activeProjectBack = (options) => {
  168. if (options.serves) {
  169. const serves = JSON.parse(decodeURIComponent(options.serves));
  170. Object.assign(data, { project: serves });
  171. }
  172. }
  173. // 初始化数据
  174. const initData = () => {
  175. try {
  176. const initD = store.state.business.certificationInfo;
  177. if (initD) {
  178. Object.assign(data, initD);
  179. }
  180. } catch (error) {
  181. console.log("TCL: initData -> error", error)
  182. }
  183. }
  184. onLoad((options) => {
  185. console.log("TCL: options", options)
  186. initData();
  187. })
  188. getServeDetails();
  189. defineExpose({ activeProjectBack });
  190. </script>
  191. <style lang="scss" scoped>
  192. @import "./index.scss";
  193. </style>