Files
qingcheng-xiaochengxu/pages/dashboardModule/overviewPerformance/overviewPerformance.js

86 lines
2.7 KiB
JavaScript
Raw Normal View History

2025-08-04 16:27:52 +08:00
import { baseUrl } from "../../../request";
2025-07-20 18:22:59 +08:00
// pages/dashboardModule/overviewPerformance/overviewPerformance.js
Page({
data: {
2025-08-04 16:27:52 +08:00
totalAmount: 0, // 订单总金额
netAmount: 0, // 净成交
promoCount: 0, // 客户数量
superCount: 0, // 主管数量
empCount: 0, // 员工数量
orderCount: 0, // 下单数量
toRelease: 0, // 待释放
toSettle: 0, // 可结算
settled: 0, // 已结算
refunded: 0, // 已退回
todayOrderCount: 0, // 今日下单数量
todayOrderAmount: 0, // 今日下单总金额
todayRefundCount: 0, // 今日退款数量
todayRefundAmount: 0, // 今日退款总金额
todayPromotionCount: 0, // 今日推广数量
monthOrderCount: 0, // 本月下单数量
monthOrderAmount: 0, // 本月下单总金额
monthRefundCount: 0, // 本月退款数量
monthRefundAmount: 0, // 本月退款总金额
monthPromotionCount: 0, // 本月推广数量
userRole: '', // 用户角色
2025-08-07 19:56:53 +08:00
isShowArr: [],
widthRate: '30%'
2025-07-20 18:22:59 +08:00
},
onLoad(options) {
2025-08-04 16:27:52 +08:00
console.log('--->',options);
this.fetchPerformance();
this.setData({
userRole: options.role
})
let showRole = '';
switch (options.role) {
case 'manager':
showRole = '经理';
break;
case 'supervisor':
showRole = '主管';
break;
case 'staff':
showRole = '员工';
break;
}
this.setData({ showRole });
2025-08-08 13:48:37 +08:00
if (options.role === 'manager') this.setData({isShowArr: [true, true, true]})
2025-08-07 19:56:53 +08:00
else if (options.role === 'supervisor') this.setData({isShowArr: [false, true, true]})
else if (options.role === 'staff') this.setData({isShowArr: [false, false, true]})
const trueCount = this.data.isShowArr.filter(v => v === true).length;
if (trueCount === 3) this.setData({widthRate: '30%'})
else if (trueCount === 2) this.setData({widthRate: '47.5%'})
else if (trueCount === 1) this.setData({widthRate: '100%'})
2025-07-20 18:22:59 +08:00
},
2025-08-04 16:27:52 +08:00
fetchPerformance() {
wx.request({
url: baseUrl + '/perform/mini/query/dashboard',
method: 'POST',
header: {
Authorization: wx.getStorageSync('token')
},
success: (res) => {
if (res.data.code === 1) {
// 直接把后端 data 对象铺平到页面 data
this.setData(res.data.data);
} else {
wx.showToast({
title: res.data.message || '获取数据失败',
icon: 'none'
});
}
},
fail: () => {
wx.showToast({
title: '请求失败',
icon: 'none'
});
}
});
2025-07-20 18:22:59 +08:00
}
2025-08-04 16:27:52 +08:00
});