This commit is contained in:
dzc committed 2025-08-13 19:37:54 +08:00
commit 0d08b4a634
4 files changed
+8398 -7861

No files matched your search

File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+2 -2
View File
@@ -169,8 +169,8 @@ onShow(async () => {
uni.showLoading({ title: "加载中...", mask: true })
try {
await getDetail()
await getShopCart()
await getClassify()
// await getShopCart()
// await getClassify()
} catch (error: any) {
uni.showToast({ title: error, icon: "error" })
} finally {
+30 -24
View File
@@ -3,13 +3,14 @@
<tm-sheet :margin="[0, 20]">
<view class="prefix_title mb-15rpx">菜品分类购买次数占比图</view>
<view class="w-full h-600rpx">
<qiun-data-charts type="pie" :opts="pieChartOpts" :chartData="pieChartData" />
<qiun-data-charts type="pie" :opts="pieChartOpts" :chartData="pieChartData" tooltipFormat="canteenPieTooltip" />
</view>
</tm-sheet>
<tm-sheet :margin="[0, 20]">
<view class="prefix_title mb-15rpx">近一周食堂购买次数趋势图</view>
<view class="w-full h-600rpx">
<!-- tooltipFormat="canteenAreaTooltip" -->
<qiun-data-charts type="area" :opts="areaChartOpts" :chartData="areaChartData" />
</view>
</tm-sheet>
@@ -26,10 +27,11 @@ import { totalApi } from "@/sheep/api"
const pieChartData = ref({})
const areaChartData = ref({})
const COLORLIST = ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4", "#ea7ccc"]
const pieChartOpts = {
color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4", "#ea7ccc"],
padding: [5, 5, 5, 5],
color: COLORLIST,
padding: [15, 15, 15, 15],
enableScroll: false,
extra: {
pie: {
@@ -46,8 +48,8 @@ const pieChartOpts = {
}
const areaChartOpts = {
color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4", "#ea7ccc"],
padding: [15, -8, 0, -5],
color: COLORLIST,
padding: [15, 0, 0, -5],
enableScroll: false,
legend: {},
xAxis: {
@@ -56,14 +58,20 @@ const areaChartOpts = {
yAxis: {
gridType: "dash",
dashLength: 2,
showTitle: true,
data: [
{
title: "购买人数",
},
],
},
extra: {
area: {
type: "curve",
opacity: 0.2,
opacity: 0.6,
addLine: true,
width: 2,
gradient: false,
gradient: true,
activeType: "hollow",
},
},
@@ -80,11 +88,13 @@ onLoad(() => {
const getPieChartData = async () => {
const { code, data, msg } = await totalApi.productByClassify({})
if (code != 0) return uni.showToast({ title: msg || "数据获取失败", icon: "none" })
const seriesData = data.map((item: any) => {
const seriesData = data.map((item: any, index: number) => {
return {
index: index,
name: item.classifyName,
value: Number(item.payUserCount),
labelText: "总金额:" + item.totalPrice + "元",
labelText: item.classifyName,
...item,
}
})
@@ -100,24 +110,20 @@ const getPieChartData = async () => {
const getAreaChartData = async () => {
const { code, data, msg } = await totalApi.productByCanteen({})
if (code != 0) return uni.showToast({ title: msg || "数据获取失败", icon: "none" })
const categories = data.map((item: any) => item.weekStr)
const categories = data[0][Object.keys(data[0])[0]].map((item: any) => item.weekStr.replace("星期", "周"))
const series = data.map((item: any) => {
const name = Object.keys(item)[0]
const data = item[name].map((item: any) => Number(item.payUserCount) + Number((Math.random() * 100).toFixed(0)))
return {
name,
data,
}
})
areaChartData.value = {
categories,
series: [
{
name: "1",
data: data.map((item: any) => Number(item.payUserCount)),
},
{
name: "2",
data: [35, 8, 25, 37, 4, 20, 13],
},
{
name: "3",
data: [70, 40, 65, 100, 44, 68, 10],
},
],
series,
}
}
</script>