86 lines
2.7 KiB
JavaScript
86 lines
2.7 KiB
JavaScript
import { baseUrl } from "../../../request";
|
|
|
|
// pages/dashboardModule/overviewPerformance/overviewPerformance.js
|
|
Page({
|
|
data: {
|
|
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: '', // 用户角色
|
|
isShowArr: [],
|
|
widthRate: '30%'
|
|
},
|
|
|
|
onLoad(options) {
|
|
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 });
|
|
if (options.role === 'manager') this.setData({isShowArr: [true, true, true]})
|
|
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%'})
|
|
},
|
|
|
|
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'
|
|
});
|
|
}
|
|
});
|
|
}
|
|
});
|