info.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <!-- 网站信息 -->
  2. <template>
  3. <div class="website-information">
  4. <div style="display: flex">
  5. <div style="width: 50%;">
  6. <el-form ref="formRef" :model="formData" label-width="120px">
  7. <el-card shadow="never" class="!border-none">
  8. <div class="text-xl font-medium mb-[20px]">店铺信息</div>
  9. <el-form-item label="店铺名称" prop="name">
  10. <div class="w-80">
  11. <el-input
  12. v-model="formData.name"
  13. placeholder="请输入店铺名称"
  14. maxlength="20"
  15. show-word-limit
  16. ></el-input>
  17. </div>
  18. </el-form-item>
  19. <el-form-item label="店铺简介" prop="intro">
  20. <div class="w-80">
  21. <el-input
  22. v-model="formData.intro"
  23. :rows="5"
  24. type="textarea"
  25. placeholder="请输入店铺介绍"
  26. maxlength="90"
  27. show-word-limit
  28. ></el-input>
  29. </div>
  30. </el-form-item>
  31. <el-form-item label="店铺公告" prop="notice">
  32. <div class="w-80">
  33. <el-input
  34. v-model="formData.notice"
  35. :rows="5"
  36. type="textarea"
  37. placeholder="请输入店铺公告"
  38. maxlength="100"
  39. show-word-limit
  40. ></el-input>
  41. </div>
  42. </el-form-item>
  43. <el-form-item label="店铺图片" prop="image">
  44. <div>
  45. <material-picker v-model="formData.image" :limit="1"/>
  46. <div class="form-tips">建议尺寸:100*100像素,支持jpg,jpeg,png格式</div>
  47. </div>
  48. </el-form-item>
  49. <el-form-item label="banner图片" prop="banner">
  50. <div>
  51. <material-picker v-model="formData.banner" :limit="3"/>
  52. <div class="form-tips">建议尺寸:100*100像素,支持jpg,jpeg,png格式</div>
  53. </div>
  54. </el-form-item>
  55. <!-- <el-form-item label="预支付" prop="prePay">
  56. <el-switch v-model="formData.prePay" :active-value="1" :inactive-value="0"/>
  57. </el-form-item>-->
  58. </el-card>
  59. </el-form>
  60. </div>
  61. <div style="width: 50%;">
  62. <el-form label-width="120px">
  63. <el-card shadow="never" class="!border-none">
  64. <div class="text-xl font-medium mb-[20px]">&nbsp;</div>
  65. <el-form-item label="联系人" prop="contactPsn">
  66. <div class="w-80">
  67. <el-input
  68. v-model="formData.contactPsn"
  69. placeholder="请输入联系人"
  70. clearable
  71. />
  72. </div>
  73. </el-form-item>
  74. <el-form-item label="联系方式" prop="contactTel">
  75. <div class="w-80">
  76. <el-input
  77. v-model="formData.contactTel"
  78. placeholder="请输入联系方式"
  79. clearable
  80. />
  81. </div>
  82. </el-form-item>
  83. <el-form-item label="身份证照">
  84. <div style="display: flex">
  85. <material-picker v-model="formData.idCardFront" :limit="1"/>
  86. <material-picker v-model="formData.idCardBack" :limit="1"/>
  87. </div>
  88. </el-form-item>
  89. <el-form-item label="资质证件">
  90. <div style="display: flex">
  91. <material-picker v-model="formData.businessLicense" :limit="1"/>
  92. <material-picker v-model="formData.operatingLicense" :limit="1"/>
  93. </div>
  94. </el-form-item>
  95. <el-form-item label="地址" prop="address">
  96. <div class="w-80">
  97. <el-input
  98. v-model="formData.address"
  99. placeholder="请输入地址"
  100. clearable
  101. />
  102. </div>
  103. </el-form-item>
  104. <el-form-item label="店铺状态" prop="status">
  105. <el-switch v-model="formData.status" :active-value="1" :inactive-value="0"
  106. active-text="开始营业" inactive-text="暂停营业"/>
  107. </el-form-item>
  108. </el-card>
  109. </el-form>
  110. </div>
  111. </div>
  112. <footer-btns v-perms="['setting:website:save']">
  113. <el-button type="primary" @click="handleSubmit">保存</el-button>
  114. </footer-btns>
  115. </div>
  116. </template>
  117. <script lang="ts" setup name="webInformation">
  118. import {getShopConfig, saveShopConfig} from '@/api/shop'
  119. import feedback from '@/utils/feedback'
  120. import type {FormInstance} from 'element-plus'
  121. import cache from "@/utils/cache";
  122. import {ACCOUNT_KEY, SHOP_ID} from "@/enums/cacheEnums";
  123. import useAppStore from "@/stores/modules/app";
  124. const appStore = useAppStore()
  125. const config = computed(() => appStore.config)
  126. const formRef = ref<FormInstance>()
  127. // 表单数据
  128. const formData = reactive({
  129. id: null,
  130. name: '', // 店铺名称
  131. intro: '',
  132. notice: '',
  133. image: '',
  134. status: '',
  135. prePay: '',
  136. banner: '',
  137. contactPsn: '',
  138. contactTel: '',
  139. address: '',
  140. idCardFront: '',
  141. idCardBack: '',
  142. businessLicense: '',
  143. operatingLicense: '',
  144. userRelationId: null,
  145. })
  146. // 获取店铺信息
  147. const getData = async () => {
  148. const shopId = cache.get(SHOP_ID);
  149. let account = ''
  150. if(!shopId){
  151. const accountCache = cache.get(ACCOUNT_KEY)
  152. if (accountCache) {
  153. account = JSON.parse(accountCache).value.account
  154. }
  155. }
  156. var params = {
  157. "shopId": cache.get(SHOP_ID),
  158. "contactTel": account
  159. }
  160. const data = await getShopConfig(params)
  161. for (const key in formData) {
  162. //@ts-ignore
  163. formData[key] = data[key]
  164. }
  165. formData.userRelationId = data?data['shopUserRelationId']:''
  166. if (formData.banner) {
  167. formData.banner = formData.banner.split(',')
  168. } else {
  169. formData.banner = '';
  170. }
  171. if (!formData.image) {//不能是null,会报错
  172. formData.image = '';
  173. }
  174. if (!formData.idCardFront) {//不能是null,会报错
  175. formData.idCardFront = '';
  176. }
  177. if (!formData.idCardBack) {//不能是null,会报错
  178. formData.idCardBack = '';
  179. }
  180. if (!formData.businessLicense) {//不能是null,会报错
  181. formData.businessLicense = '';
  182. }
  183. if (!formData.operatingLicense) {//不能是null,会报错
  184. formData.operatingLicense = '';
  185. }
  186. cache.set(SHOP_ID, formData.id)
  187. config.value.webName = formData.name
  188. if(formData.image){
  189. config.value.webLogo = formData.image
  190. }
  191. }
  192. // 保存店铺信息
  193. const handleSubmit = async () => {
  194. console.log(formData)
  195. if(formData.banner){
  196. formData.banner = formData.banner.join(',')
  197. }
  198. await saveShopConfig(formData)
  199. feedback.msgSuccess('操作成功')
  200. getData()
  201. }
  202. getData()
  203. </script>
  204. <style lang="scss" scoped>
  205. .website-information{
  206. background: #fff;
  207. }
  208. </style>