diff --git a/JC-Salon-WeChat/pages/profile/index.js b/JC-Salon-WeChat/pages/profile/index.js
index bb0799ab..0f48b262 100644
--- a/JC-Salon-WeChat/pages/profile/index.js
+++ b/JC-Salon-WeChat/pages/profile/index.js
@@ -2,6 +2,10 @@ const { BRAND_CONFIG } = require('../../utils/config')
const userApi = require('../../api/user')
const auth = require('../../utils/auth')
const { chooseImageFilePath, uploadProfileImage } = require('../../utils/upload')
+const planningApi = require('../../api/planning')
+const employeesApi = require('../../api/employees')
+const shopApi = require('../../api/shop')
+const dateUtil = require('../../utils/date')
function resolveRoleText(type) {
const role = Number(type)
@@ -27,6 +31,17 @@ Page({
wechatId: '',
signature: ''
},
+ overviewLoading: false,
+ overview: {
+ date: '',
+ todayAppointments: 0,
+ pendingAppointments: 0,
+ upcomingAppointments: 0,
+ availableEmployees: 0,
+ scheduleExceptions: 0,
+ shopOpen: true,
+ shopStatus: '营业中'
+ },
menus: [
{ title: '个人信息', action: 'editProfile' },
{ title: '店铺设置', url: '/pages/shop-settings/index' },
@@ -39,6 +54,56 @@ Page({
onShow() {
this.refreshFromSession()
this.loadProfile()
+ this.loadOverview()
+ },
+
+ async loadOverview() {
+ const today = dateUtil.formatDate(new Date())
+ this.setData({ overviewLoading: true })
+ try {
+ const [calendar, shop] = await Promise.all([
+ planningApi.calendar({ startDate: today, endDate: today }),
+ shopApi.settings()
+ ])
+ const appointments = Array.isArray(calendar.appointments) ? calendar.appointments : []
+ const now = Date.now()
+ const upcomingAppointments = appointments.filter(item => {
+ const appointmentTime = new Date(String(item.appointmentTime || item.startTime || '').replace(/-/g, '/')).getTime()
+ return Number.isFinite(appointmentTime) && appointmentTime >= now
+ }).length
+ const artists = Array.isArray(calendar.artists) ? calendar.artists : []
+ const scheduleRules = await Promise.all(artists.map(artist => employeesApi.scheduleRule({ artistId: artist.id })))
+ const scheduleExceptions = scheduleRules.reduce((total, setting) => {
+ const exceptions = Array.isArray(setting && setting.exceptions) ? setting.exceptions : []
+ return total + exceptions.filter(item => item.workDate === today).length
+ }, 0)
+ const shopOpen = Number(shop && shop.status) !== 0
+ this.setData({
+ overview: {
+ date: `${today.slice(5, 7)}月${today.slice(8, 10)}日`,
+ todayAppointments: appointments.length,
+ pendingAppointments: appointments.filter(item => Number(item.status) === 0).length,
+ upcomingAppointments,
+ availableEmployees: artists.filter(item => Number(item.status) !== 0).length,
+ scheduleExceptions,
+ shopOpen,
+ shopStatus: shopOpen ? '营业中' : '已暂停'
+ }
+ })
+ } catch (error) {
+ wx.showToast({ title: error.message || '今日概览加载失败', icon: 'none' })
+ } finally {
+ this.setData({ overviewLoading: false })
+ }
+ },
+
+ goOverviewAction(event) {
+ const action = event.currentTarget.dataset.action
+ if (action === 'scheduleExceptions') {
+ wx.navigateTo({ url: '/pages/leave-management/index' })
+ return
+ }
+ wx.switchTab({ url: '/pages/planning/index' })
},
refreshFromSession() {
diff --git a/JC-Salon-WeChat/pages/profile/index.wxml b/JC-Salon-WeChat/pages/profile/index.wxml
index dca10981..37fda680 100644
--- a/JC-Salon-WeChat/pages/profile/index.wxml
+++ b/JC-Salon-WeChat/pages/profile/index.wxml
@@ -10,6 +10,41 @@
{{roleText}}
+
+
+ 店铺今日概览
+ {{overview.date}}
+
+ 正在加载今日数据...
+
+
+ {{overview.todayAppointments}}
+ 今日预约
+
+
+ {{overview.pendingAppointments}}
+ 待确认预约
+
+
+ {{overview.upcomingAppointments}}
+ 即将开始
+
+
+ {{overview.availableEmployees}}
+ 今日可预约员工
+
+
+ {{overview.scheduleExceptions}}
+ 请假/调班待处理
+
+
+
+ {{overview.shopStatus}}
+ 店铺当前状态
+
+
+
+