From c2978b30dbb13a8153a529456a2d668dba9dfe99 Mon Sep 17 00:00:00 2001
From: BAKEYi <16298417+bakeyi@user.noreply.gitee.com>
Date: Fri, 22 May 2026 15:51:48 +0800
Subject: [PATCH] 1
---
pages/home/home.vue | 219 ++++++++++++++++++++++++++++++++++----------
1 file changed, 171 insertions(+), 48 deletions(-)
diff --git a/pages/home/home.vue b/pages/home/home.vue
index 11a7fac..02740e1 100644
--- a/pages/home/home.vue
+++ b/pages/home/home.vue
@@ -18,7 +18,7 @@
-
+
{{ item.name }}
@@ -29,7 +29,7 @@
@@ -54,7 +54,7 @@
@@ -177,38 +177,26 @@ export default {
displayScore: 0,
animationTimer: null,
- // 通知公告数据:预留接口,支持最新6条轮播
+ // 通知公告数据
noticeList: [
- { id: 1, title: '商家券更新了!品牌专区上新了!', url: '/pages/...' },
- { id: 2, title: '系统维护通知:今晚凌晨将进行升级', url: '/pages/...' },
- { id: 3, title: '平台新政策发布,请及时查看', url: '/pages/...' }
+ { id: 0, title: '暂无最新公告', url: '' }
],
quickActions: [
- { name: '扫码验券', icon: 'https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/b128e423-e4b5-4ad6-bdf5-522de7a9bc68.png' },
- { name: '服务管理', icon: 'https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/a90f02a2-9d39-440a-ad20-a4337bcd1b38.png' },
- { name: '工位管理', icon: 'https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/4c503603-6c2f-4a7a-9329-5e54b8ca769e.png' },
- { name: '财务管理', icon: 'https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/728c659e-e395-4473-b83e-7e04539f7ec6.png' }
+ { name: '扫码验券', icon: 'https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/b128e423-e4b5-4ad6-bdf5-522de7a9bc68.png' , path: 'scan'},
+ { name: '服务管理', icon: 'https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/a90f02a2-9d39-440a-ad20-a4337bcd1b38.png' , path: '/pages/artisan/service-list'},
+ { name: '工位管理', icon: 'https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/4c503603-6c2f-4a7a-9329-5e54b8ca769e.png' , path: '/pages/shop/workSpace/list'},
+ { name: '财务管理', icon: 'https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/728c659e-e395-4473-b83e-7e04539f7ec6.png' , path: '/pages/wallet/wallet'}
],
- orderBasic: { updateTime: '15:30', waitStart: 23, waitFinish: 43, finished: 234 },
- orderDetail: { updateTime: '15:30', score: '82.2', visitors: 0, yVisitors: 100, orders: 234, yOrders: 1000, amount: '1.34', yAmount: '1.4' },
+ orderBasic: { updateTime: '--:--', waitStart: 0, waitFinish: 0, finished: 0 },
+ orderDetail: { updateTime: '--:--', score: '0.0', visitors: 0, yVisitors: 0, orders: 0, yOrders: 0, amount: '0.00', yAmount: '0.00' },
- brands: [
- { name: '蜜丝卡伦美甲美睫', bgSrc: 'https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/d02b2d8b-0e01-4c6d-bbee-c60dccf4867c.jpg', avatar: 'https://dummyimage.com/100x100/ccc/fff.png&text=Avatar', tagKeys: ['franchise', 'recruit'] },
- { name: 'ALNL 清莲爱丽', bgSrc: 'https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/d02b2d8b-0e01-4c6d-bbee-c60dccf4867c.jpg', avatar: 'https://dummyimage.com/100x100/ccc/fff.png&text=Avatar', tagKeys: ['recruit'] },
- { name: 'IL COLPO依宝美容', bgSrc: 'https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/d02b2d8b-0e01-4c6d-bbee-c60dccf4867c.jpg', avatar: 'https://dummyimage.com/100x100/ccc/fff.png&text=Avatar', tagKeys: ['franchise'] },
- { name: '蜜丝卡伦美甲美睫', bgSrc: 'https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/d02b2d8b-0e01-4c6d-bbee-c60dccf4867c.jpg', avatar: 'https://dummyimage.com/100x100/ccc/fff.png&text=Avatar', tagKeys: ['more'] }
- ],
- skills: [
- { title: '穿戴甲的操作视频扫码验券操作123564798', type: '平台课程', views: '83.6万', time: '7小时前', coverSrc: 'https://dummyimage.com/200x150/ccc/fff.png&text=Video' },
- { title: '脸部按摩操作步骤详情', type: '脸缘品牌', views: '8334', time: '1天前', coverSrc: 'https://dummyimage.com/200x150/ccc/fff.png&text=Video' },
- { title: '全身SPA的操作视频操作教程', type: '平台课程', views: '2344', time: '3天前', coverSrc: 'https://dummyimage.com/200x150/ccc/fff.png&text=Video' },
- { title: '穿戴甲的操作视频扫码验券操作...', type: '平台课程', views: '836', time: '4月26日', coverSrc: 'https://dummyimage.com/200x150/ccc/fff.png&text=Video' }
- ]
+ brands: [],
+ skills: []
};
},
computed: {
- // 状态管理判定
+ // 💡 状态管理核心判定
// 是否已入驻 (0: 未入驻, -1: 入驻第一步, >0: 已认证) 只要不等于0,说明已经开启了入驻流程
isSettled() {
if (!this.isLogin || !this.userInfo) return false;
@@ -251,18 +239,18 @@ export default {
}
},
onShow() {
- // 登录判定逻辑
+ // 继承 1.0 的登录判定逻辑
this.isLogin = uni.getStorageSync("accessToken") ? true : false;
if (this.isLogin) {
this.getUserInfo();
}
+ // 通知、品牌、技能 这三个接口不强依赖登录,无论登没登录都获取
+ this.fetchNoticeList();
+ this.fetchBrandList();
+ this.fetchSkillList();
},
onLoad() {
uni.hideTabBar();
- this.getNoticeList(); // 获取最新通知
- },
- mounted() {
- this.animateScore();
},
watch: {
'orderDetail.score'() {
@@ -270,28 +258,160 @@ export default {
}
},
methods: {
+ // 处理金刚区点击事件 (包含扫码验券核心逻辑)
+ handleQuickAction(item) {
+ if (item.name === '扫码验券') {
+ uni.scanCode({
+ success: (res) => {
+ const code = res.result;
+ if (code) {
+ uni.showLoading({ title: '查询订单中...' });
+ request.post('/sj/poster/getOrderByCode', { server_code: code }).then(result => {
+ uni.hideLoading();
+ if (result.code === 200 && result.data) {
+ // TODO: 这里扫码成功获取到订单数据(result.data),后续可弹窗或跳转到核销确认页
+ // 预留核销接口调用逻辑: request.post('/sj/poster/useOrderServerCode', { id: result.data.order_id, order_type: result.data.order_type, server_code: code })
+ uni.showToast({ title: '获取订单成功', icon: 'success' });
+ } else {
+ uni.showToast({ title: result.msg || '未找到该订单', icon: 'none' });
+ }
+ }).catch(() => {
+ uni.hideLoading();
+ uni.showToast({ title: '网络异常', icon: 'none' });
+ });
+ }
+ }
+ });
+ } // 2. 通用跳转逻辑
+ else if (item.path) {
+ uni.navigateTo({
+ url: item.path,
+ fail: () => {
+ uni.showToast({ title: '页面开发中...', icon: 'none' });
+ }
+ });
+ }
+ },
+
+ // 格式化时间 (提取 HH:mm)
+ formatTime(dateTimeStr) {
+ if (!dateTimeStr) return '--:--';
+ const arr = dateTimeStr.split(' ');
+ if (arr.length > 1) {
+ return arr[1].substring(0, 5); // 截取 HH:mm
+ }
+ return dateTimeStr;
+ },
+
getUserInfo() {
request.post("/sj/user/getUser").then((result) => {
- this.userInfo = result.data;
- uni.setStorageSync("syrId", result.data.id);
- this.syrId = result.data.id;
+ if(result.code === 200 && result.data) {
+ this.userInfo = result.data;
+ uni.setStorageSync("syrId", result.data.id);
+ this.syrId = result.data.id;
- // 获取完用户信息后,初始化营业开关的状态
- this.initStoreStatus();
+ // 获取完用户信息后,初始化营业开关的状态
+ this.initStoreStatus();
+
+ // 如果已入驻,才获取接单管理和实时数据
+ if (this.isSettled) {
+ this.fetchOrderNum();
+ this.fetchRealTimeData();
+ }
+ }
});
},
- // 接口预留:获取通知公告(仅拉取当前角色关联的最新6条)
- getNoticeList() {
- // request.post('/api/notice/getLatest', { role: 'merchant', limit: 6 }).then(res => {
- // this.noticeList = res.data;
- // })
+ // 获取:接单管理不同状态订单数量
+ fetchOrderNum() {
+ request.post("/sj/poster/orderNum").then(res => {
+ if(res.code === 200 && res.data) {
+ this.orderBasic = {
+ updateTime: this.formatTime(res.data.now_date),
+ waitStart: res.data.dfw || 0,
+ waitFinish: res.data.dwc || 0,
+ finished: res.data.yqx || 0 // 备注:接口返回只有dfw, dwc, yqx(已取消)。暂时将第三个坑位放为yqx,或你后期让后端加字段
+ };
+ }
+ });
+ },
+
+ // 获取:首页实时数据
+ fetchRealTimeData() {
+ request.post("/sj/poster/realTimeData").then(res => {
+ if(res.code === 200 && res.data) {
+ const today = res.data.today || {};
+ const yesterday = res.data.yesterday || {};
+
+ this.orderDetail = {
+ updateTime: this.formatTime(res.data.now_date),
+ score: today.rating_num || 0,
+ visitors: today.visitor_num || 0,
+ yVisitors: yesterday.visitor_num || 0,
+ orders: today.place_order || 0,
+ yOrders: yesterday.place_order || 0,
+ amount: today.deal_money || 0,
+ yAmount: yesterday.deal_money || 0
+ };
+ }
+ });
+ },
+
+ // 获取:通知公告列表
+ fetchNoticeList() {
+ request.post('/sj/notice/list', { page: 1, limit: 6 }).then(res => {
+ if(res.code === 200 && res.data && res.data.list.length > 0) {
+ this.noticeList = res.data.list;
+ }
+ });
+ },
+
+ // 获取:品牌列表
+ fetchBrandList() {
+ // 假设首页只拉取推荐的前4条
+ request.post('/sj/brand/list', { page: 1, limit: 4 }).then(res => {
+ if(res.code === 200 && res.data && res.data.list) {
+ this.brands = res.data.list.map(item => {
+ let tags = [];
+ // 根据接口字段动态生成标签映射
+ if (item.franchise_state === 1) tags.push('franchise');
+ if (item.student_state === 1) tags.push('recruit');
+ if (tags.length === 0) tags.push('more');
+
+ return {
+ id: item.id,
+ name: item.name,
+ bgSrc: item.cover_img || 'https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/d02b2d8b-0e01-4c6d-bbee-c60dccf4867c.jpg',
+ avatar: item.logo_img || 'https://dummyimage.com/100x100/ccc/fff.png&text=Avatar',
+ tagKeys: tags
+ };
+ });
+ }
+ });
+ },
+
+ // 获取:技能集市列表
+ fetchSkillList() {
+ request.post('/sj/skill/list', { page: 1, limit: 4 }).then(res => {
+ if(res.code === 200 && res.data && res.data.list) {
+ this.skills = res.data.list.map(item => {
+ return {
+ id: item.id,
+ title: item.name,
+ type: item.link_name || '平台课程',
+ views: item.browse_num || 0,
+ time: item.create_time ? item.create_time.split(' ')[0] : '', // 只取日期
+ coverSrc: item.cover_img || 'https://dummyimage.com/200x150/ccc/fff.png&text=Video'
+ };
+ });
+ }
+ });
},
- // 跳转:通知详情页
+ // 💡 跳转:通知详情页
goToNotice(msg) {
- if(msg.url) {
- uni.navigateTo({ url: msg.url });
+ if(msg.id) {
+ uni.navigateTo({ url: `/pages/notice/detail?id=${msg.id}` });
}
},
@@ -316,7 +436,7 @@ export default {
}
},
- // 营业中 / 休息中 按钮逻辑判断
+ // 💡 营业中 / 休息中 按钮逻辑判断
toggleStatus() {
// 1、入驻未认证 (id_type == -1),弹窗提示未完善项,引导完善
if (!this.isCertified) {
@@ -345,8 +465,11 @@ export default {
// 3、认证通过并配置时间,仅作为开关,不跳转页面
if (this.isCertified && this.hasBusinessTime) {
this.isOpenStore = !this.isOpenStore;
- // 预留接口:发送请求同步给后端当前状态
- // request.post('/api/store/toggleStatus', { status: this.isOpenStore ? 1 : 0 });
+ // 同步给后端当前状态
+ const newState = this.isOpenStore ? 1 : 0;
+ // request.post('/api/store/toggleStatus', { self_state: newState }).then(() => {
+ // uni.showToast({ title: this.isOpenStore ? '已开启营业' : '已休息', icon: 'none' });
+ // });
}
},
@@ -591,7 +714,7 @@ export default {
.guide-btn {
width: 534rpx;
height: 70rpx;
- border-radius: 55rpx;
+ border-radius: 35rpx;
border: 1rpx solid #FF4767;
color: #FF4767;