Browse Source

首页换成后台配置

Huanyi 1 day ago
parent
commit
cd1bd217a9
3 changed files with 57 additions and 21 deletions
  1. 12 0
      api/system/applet/categories.js
  2. 12 0
      api/system/applet/slideshow.js
  3. 33 21
      pages/index/index.vue

+ 12 - 0
api/system/applet/categories.js

@@ -0,0 +1,12 @@
+import request from '@/utils/request'
+
+/**
+ * 查询全部精选分类
+ * @Author: Trae
+ */
+export function listCategories() {
+  return request({
+    url: '/system/applet/categories/list',
+    method: 'get'
+  })
+}

+ 12 - 0
api/system/applet/slideshow.js

@@ -0,0 +1,12 @@
+import request from '@/utils/request'
+
+/**
+ * 查询全部轮播图
+ * @Author: Trae
+ */
+export function listSlideshow() {
+  return request({
+    url: '/system/applet/slideshow/list',
+    method: 'get'
+  })
+}

+ 33 - 21
pages/index/index.vue

@@ -109,6 +109,8 @@ import ErpTabBar from '@/components/erp-tab-bar.vue';
 import ErpNavBar from '@/components/erp-nav-bar.vue';
 import assets from '@/utils/assets.js';
 import { getPhone } from '@/api/system/phone.js';
+import { listSlideshow } from '@/api/system/applet/slideshow.js';
+import { listCategories } from '@/api/system/applet/categories.js';
 
 export default {
 	components: { ErpTabBar, ErpNavBar },
@@ -118,32 +120,42 @@ export default {
 			statusBarHeight: 0,
 			currentBanner: 0,
 			expertPhone: '13888888888',
-			banners: [
-				{
-					url: '/static/index/banner1.jpg',
-					tag: '领航品质',
-					title: '工业铝型材定制',
-					subTitle: '提供一站式工业型材解决方案'
-				},
-				{
-					url: '/static/index/banner2.jpg',
-					tag: '建筑美学',
-					title: '高端系统门窗',
-					subTitle: '智造美好生活空间'
-				}
-			],
-			cubeProducts: [
-				{ name: '建筑铝材', desc: '门窗/幕墙/家装', image: '/static/index/cube1.jpg' },
-				{ name: '工业型材', desc: '光伏/轨道/汽配', image: '/static/index/cube2.jpg' },
-				{ name: '特种定制', desc: '精密开模/特种合金', image: '/static/index/cube3.jpg' },
-				{ name: '深加工', desc: '切割/冲压/CNC', image: '/static/index/cube4.jpg' }
-			]
+			banners: [],
+			cubeProducts: []
 		}
 	},
 	onLoad() {
-		this.loadPhone();
+		this.loadData();
 	},
 	methods: {
+		async loadData() {
+			await Promise.all([this.loadSlideshow(), this.loadCategories(), this.loadPhone()]);
+		},
+		async loadSlideshow() {
+			try {
+				const res = await listSlideshow();
+				this.banners = (res.data || []).map(item => ({
+					url: item.ossUrl || '',
+					tag: '',
+					title: '',
+					subTitle: ''
+				}));
+			} catch (e) {
+				console.error('加载轮播图失败', e);
+			}
+		},
+		async loadCategories() {
+			try {
+				const res = await listCategories();
+				this.cubeProducts = (res.data || []).map(item => ({
+					name: item.title || '',
+					desc: item.remark || '',
+					image: item.backgroundUrl || ''
+				}));
+			} catch (e) {
+				console.error('加载精选分类失败', e);
+			}
+		},
 		async loadPhone() {
 			try {
 				const res = await getPhone();