index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <div class="app-config-setting">
  3. <!-- 顶部提示信息 -->
  4. <div class="setting-hint">
  5. <el-alert :closable="false" type="info" class="custom-alert">
  6. <template #title>
  7. <div class="alert-content">
  8. <el-icon class="info-icon"><InfoFilled /></el-icon>
  9. <span>在此配置移动端APP的展示信息,分为多个端进行独立配置。</span>
  10. </div>
  11. </template>
  12. </el-alert>
  13. </div>
  14. <!-- 配置表单区 -->
  15. <div class="setting-body">
  16. <el-tabs v-model="activeTab" type="border-card" class="premium-tabs">
  17. <!-- 履约守护配置 -->
  18. <el-tab-pane label="履约守护" name="fulfiller">
  19. <el-form ref="fulfillerFormRef" :model="fulfillerForm" :rules="fulfillerRules" label-width="160px" label-position="right" class="premium-setting-form">
  20. <!-- 登录图标 -->
  21. <el-form-item label="登录页图标:" prop="loginIcon">
  22. <image-upload v-model="fulfillerForm.loginIcon" :limit="1" :can-delete="false" />
  23. <div class="form-tip">建议尺寸:200x200,支持 png/jpg 格式</div>
  24. </el-form-item>
  25. <!-- 登录页背景图 -->
  26. <el-form-item label="登录页背景:" prop="loginBackground">
  27. <image-upload v-model="fulfillerForm.loginBackground" :limit="1" :can-delete="false" />
  28. <div class="form-tip">建议尺寸:1080x1920(9:16),支持 jpg/png 格式</div>
  29. </el-form-item>
  30. <!-- 保存按钮 -->
  31. <el-form-item class="action-item">
  32. <el-button type="primary" class="save-btn" :loading="buttonLoading" @click="submitFulfillerForm">保存修改</el-button>
  33. </el-form-item>
  34. </el-form>
  35. </el-tab-pane>
  36. <!-- 好萌友配置 -->
  37. <el-tab-pane label="好萌友" name="merchant">
  38. <el-form ref="merchantFormRef" :model="merchantForm" label-width="160px" label-position="right" class="premium-setting-form">
  39. <!-- 首页轮播图 -->
  40. <el-form-item label="首页轮播图:" prop="homeBanner">
  41. <image-upload v-model="merchantForm.homeBanner" :limit="10" />
  42. <div class="form-tip">建议尺寸:750x320,支持多张,用于商户端首页轮播展示</div>
  43. </el-form-item>
  44. <!-- 保存按钮 -->
  45. <el-form-item class="action-item">
  46. <el-button type="primary" class="save-btn" :loading="buttonLoading" @click="submitMerchantForm">保存修改</el-button>
  47. </el-form-item>
  48. </el-form>
  49. </el-tab-pane>
  50. </el-tabs>
  51. </div>
  52. </div>
  53. </template>
  54. <script setup name="AppConfig" lang="ts">
  55. // @Author: Antigravity
  56. import { getAppSetting, updateAppSetting } from '@/api/system/appSetting';
  57. import { AppSettingForm } from '@/api/system/appSetting/types';
  58. import { InfoFilled } from '@element-plus/icons-vue';
  59. import ImageUpload from '@/components/ImageUpload/index.vue';
  60. import { ref, onMounted, getCurrentInstance, ComponentInternalInstance } from 'vue';
  61. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  62. const buttonLoading = ref(false);
  63. const activeTab = ref('fulfiller');
  64. const fulfillerFormRef = ref<any>();
  65. const merchantFormRef = ref<any>();
  66. const fulfillerForm = ref<any>({
  67. id: 1,
  68. loginIcon: undefined,
  69. loginBackground: undefined
  70. });
  71. const merchantForm = ref<any>({
  72. id: 2,
  73. homeBanner: undefined
  74. });
  75. const fulfillerRules = {
  76. loginIcon: [{ required: true, message: "登录页图标不能为空", trigger: "change" }],
  77. loginBackground: [{ required: true, message: "登录页背景不能为空", trigger: "change" }],
  78. };
  79. /** 加载配置 */
  80. const loadConfig = async () => {
  81. try {
  82. // 加载履约守护配置 (ID 1)
  83. const res1 = await getAppSetting(1);
  84. if (res1.data) {
  85. fulfillerForm.value.loginIcon = res1.data.loginIcon ? String(res1.data.loginIcon) : undefined;
  86. fulfillerForm.value.loginBackground = res1.data.loginBackground ? String(res1.data.loginBackground) : undefined;
  87. }
  88. // 加载好萌友配置 (ID 2)
  89. const res2 = await getAppSetting(2);
  90. if (res2.data) {
  91. merchantForm.value.homeBanner = res2.data.homeBanner ? String(res2.data.homeBanner) : undefined;
  92. }
  93. } catch (error) {
  94. console.error('加载APP配置失败', error);
  95. }
  96. };
  97. /** 提交履约守护配置 */
  98. const submitFulfillerForm = () => {
  99. fulfillerFormRef.value?.validate(async (valid: boolean) => {
  100. if (valid) {
  101. buttonLoading.value = true;
  102. try {
  103. await updateAppSetting(fulfillerForm.value);
  104. proxy?.$modal.msgSuccess("履约守护配置保存成功");
  105. loadConfig();
  106. } finally {
  107. buttonLoading.value = false;
  108. }
  109. }
  110. });
  111. };
  112. /** 提交好萌友配置 */
  113. const submitMerchantForm = async () => {
  114. buttonLoading.value = true;
  115. try {
  116. await updateAppSetting(merchantForm.value);
  117. proxy?.$modal.msgSuccess("好萌友配置保存成功");
  118. loadConfig();
  119. } finally {
  120. buttonLoading.value = false;
  121. }
  122. };
  123. onMounted(() => {
  124. loadConfig();
  125. });
  126. </script>
  127. <style scoped lang="scss">
  128. .app-config-setting {
  129. padding: 8px 0;
  130. }
  131. .setting-hint {
  132. margin-bottom: 24px;
  133. .custom-alert {
  134. background-color: #e8f4ff;
  135. border: none;
  136. border-radius: 8px;
  137. padding: 12px 16px;
  138. .alert-content {
  139. display: flex;
  140. align-items: center;
  141. gap: 10px;
  142. color: #1890ff;
  143. font-size: 14px;
  144. line-height: 1.5;
  145. .info-icon {
  146. font-size: 18px;
  147. }
  148. }
  149. }
  150. }
  151. .setting-body {
  152. padding: 0 20px;
  153. }
  154. .premium-tabs {
  155. border: none;
  156. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  157. border-radius: 12px;
  158. overflow: hidden;
  159. :deep(.el-tabs__header) {
  160. background-color: #f8fafc;
  161. border-bottom: 1px solid #e5e6eb;
  162. }
  163. :deep(.el-tabs__item.is-active) {
  164. background-color: #fff;
  165. border-right-color: #e5e6eb;
  166. border-left-color: #e5e6eb;
  167. }
  168. }
  169. .premium-setting-form {
  170. padding: 24px 0;
  171. :deep(.el-form-item__label) {
  172. font-weight: 500;
  173. color: #4e5969;
  174. padding-right: 24px;
  175. }
  176. .form-tip {
  177. font-size: 13px;
  178. color: #86909c;
  179. margin-top: 8px;
  180. line-height: 1.4;
  181. display: block;
  182. width: 100%;
  183. }
  184. .action-item {
  185. margin-top: 40px;
  186. }
  187. .save-btn {
  188. padding: 12px 32px;
  189. height: auto;
  190. font-size: 15px;
  191. font-weight: 500;
  192. border-radius: 6px;
  193. box-shadow: 0 4px 10px rgba(64, 158, 255, 0.2);
  194. }
  195. }
  196. </style>