mall-app-t/pages/index/index.vue

290 lines
7.4 KiB
Vue
Raw Permalink Normal View History

2024-05-22 15:42:13 +08:00
<template>
2024-08-28 18:36:22 +08:00
<pb-layout navbar="inner" tabbar="/pages/index/index" :bgStyle="bgStyle" :leftIcon="''">
<view class="dashboard-module ss-p-x-30">
<view class="merchant-info flex align-center justify-between">
<view class="flex align-center ss-gap-10">
<image class="logo" :src="merchantInfo?.logo" mode="aspectFill"></image>
<view class="detail flex flex-column justify-center gap-10">
<view class="name ss-font-26">{{ merchantInfo.name }}</view>
<view class="description ss-font-26">{{ merchantInfo?.contactPhone }}</view>
</view>
2024-05-23 18:04:40 +08:00
</view>
2024-08-28 18:36:22 +08:00
<view @tap="checkVerifi">
<text style="color: #fff; font-size: 32px" class="cicon-scan"></text>
</view>
</view>
<view class="statistic ss-m-t-24">
<view class="title ss-font-24 ss-m-b-20">
2024-09-19 16:23:19 +08:00
{{ `今日收款金额` }}
2024-08-28 18:36:22 +08:00
</view>
<view class="income flex justify-between align-center">
<view class="left flex align-center">
<view class="unit self-start"></view>
2024-09-19 16:23:19 +08:00
<view class="sincome ss-font-60">{{ fen2yuan(state.statistic.todaySales || 0) }}</view>
2024-08-28 18:36:22 +08:00
</view>
<!-- <button class="right-btn ss-reset-button">查看详情</button> -->
</view>
<view class="des ss-m-t-20">
2024-09-19 16:23:19 +08:00
总订单数 {{ state.statistic.total }} | 已完成订单 {{ state.statistic.countCompleted }} | 总付款额
{{ fen2yuan(state.statistic.totalPayPrice) }}
</view>
<view class="des ss-m-t-20">
取消订单 {{ state.statistic.countCanceled }} | 退款金额 {{ fen2yuan(state.statistic.totalRefundPrice) }}
2024-08-28 18:36:22 +08:00
</view>
</view>
2024-09-12 18:23:14 +08:00
<view class="more ss-m-t-80">
<view class="title ss-m-b-30">今日数据</view>
2024-08-28 18:36:22 +08:00
<view class="items">
2024-09-12 18:23:14 +08:00
<view class="item" v-for="(item, index) in state.now" :key="item.name">
<view class="label">{{ item.name }}</view>
2024-09-19 16:23:19 +08:00
<view class="value">{{ index.name?.includes('金额') ? fen2yuan(item.value) : item.value }}</view>
2024-09-12 18:23:14 +08:00
<!-- <view class="last"> 昨日 {{ index === 0 ? fen2yuan(item.last) : item.last ? item.last : 0 }} </view> -->
</view>
</view>
</view>
2024-09-19 16:23:19 +08:00
<view class="more ss-m-t-40" style="margin-bottom: 40rpx">
2024-09-12 18:23:14 +08:00
<view class="title ss-m-b-30">昨日数据</view>
<view class="items">
<view class="item" v-for="(item, index) in state.yesterday" :key="item.name">
2024-08-28 18:36:22 +08:00
<view class="label">{{ item.name }}</view>
<view class="value">{{ index !== 0 ? item.value : fen2yuan(item.value) }}</view>
</view>
</view>
</view>
</view>
</pb-layout>
2024-05-22 15:42:13 +08:00
</template>
<script setup>
2024-05-29 17:07:37 +08:00
import { ref, computed } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app'
2024-05-23 23:42:33 +08:00
import peach from '@/peach'
2024-05-29 17:07:37 +08:00
import $store from '@/peach/store'
2024-08-21 18:09:07 +08:00
import { fen2yuan } from '@/peach/hooks/useGoods'
2024-05-29 17:07:37 +08:00
import UserUtil from '@/peach/api/member/user'
2024-08-21 18:09:07 +08:00
import OrderUtil from '@/peach/api/trade/order'
2024-05-24 17:24:44 +08:00
import bg from '@/static/bg-page.png'
2024-05-23 18:04:40 +08:00
2024-05-22 15:42:13 +08:00
const bgStyle = {
2024-08-28 18:36:22 +08:00
backgroundImage: bg,
imageType: 'local',
backgroundColor: '#fff',
description: '',
2024-05-22 15:42:13 +08:00
}
2024-05-23 18:04:40 +08:00
const state = ref({
2024-08-28 18:36:22 +08:00
statistic: {
2024-09-19 16:23:19 +08:00
todaySales: 0,
countCompleted: 0, // 总完成订单笔数
total: 0, // 总订单
totalPayPrice: 0, // 总付款额
countCanceled: 0, // 总取消订单
totalRefundPrice: 0, // 总退款金额
2024-08-28 18:36:22 +08:00
},
2024-09-12 18:23:14 +08:00
now: [
2024-08-28 18:36:22 +08:00
{
name: '销售金额',
2024-09-19 16:23:19 +08:00
key: 'todaySales',
2024-08-28 18:36:22 +08:00
value: 0,
2024-05-24 17:24:44 +08:00
},
2024-08-28 18:36:22 +08:00
{
name: '订单数',
2024-09-19 16:23:19 +08:00
key: 'todayOrders',
value: 0,
},
{
name: '待支付订单',
key: 'countPayTodo',
2024-08-28 18:36:22 +08:00
value: 0,
},
{
name: '待核销',
2024-09-19 16:23:19 +08:00
key: 'countTodoUnverified',
2024-08-28 18:36:22 +08:00
value: 0,
},
{
name: '待配送',
2024-09-19 16:23:19 +08:00
key: 'countTodoWaitingDelivery',
value: 0,
},
{
name: '退款笔数',
key: 'todayRefunds',
2024-08-28 18:36:22 +08:00
value: 0,
},
],
2024-09-12 18:23:14 +08:00
yesterday: [
{
name: '销售金额',
2024-09-19 16:23:19 +08:00
key: 'yesterdaySales',
2024-09-12 18:23:14 +08:00
value: 0,
},
{
name: '订单数',
2024-09-19 16:23:19 +08:00
key: 'yesterdayOrders',
value: 0,
},
{
name: '退款金额',
key: 'yesterdayRefunds',
2024-09-12 18:23:14 +08:00
value: 0,
},
],
2024-05-23 18:04:40 +08:00
})
2024-05-29 17:07:37 +08:00
const userStore = $store('user')
const merchantInfo = computed(() => {
2024-08-28 18:36:22 +08:00
return userStore.userInfo?.particulars
2024-05-29 17:07:37 +08:00
})
async function getStatistic() {
2024-08-28 18:36:22 +08:00
let res = await UserUtil.getHomeStatistics()
for (let key of Object.keys(state.value.statistic)) {
state.value.statistic[key] = res.data[key]
}
2024-09-19 16:23:19 +08:00
for (let obj of state.value.now) {
obj.value = res.data[obj.key] ?? 0
}
for (let obj of state.value.yesterday) {
obj.value = res.data[obj.key] ?? 0
}
2024-05-29 17:07:37 +08:00
}
2024-06-17 18:16:46 +08:00
/**
* @author Ankkaya
* @description 核销
* @param {Type} -
* @returns {Type}
*/
2024-08-21 18:09:07 +08:00
function checkVerifi() {
2024-08-28 18:36:22 +08:00
// 扫描二维码
uni.scanCode({
success: (res) => {
uni.showModal({
title: '提示',
content: '是否核销该订单',
success: function (sres) {
if (sres.confirm) {
OrderUtil.orderVerification({
verifyCode: res.result,
}).then((res) => {
uni.showToast({
title: '订单核销成功',
icon: 'success',
})
setTimeout(() => {
peach.$router.go('/pages/order/detail', {
id: res.data,
})
}, 500)
2024-08-21 18:09:07 +08:00
})
2024-08-28 18:36:22 +08:00
}
2024-08-21 18:09:07 +08:00
},
2024-08-28 18:36:22 +08:00
})
},
fail: (err) => {
console.log(err)
},
})
2024-08-21 18:09:07 +08:00
}
2024-06-17 18:16:46 +08:00
2024-05-29 17:07:37 +08:00
onShow(() => {
2024-08-28 18:36:22 +08:00
getStatistic()
2024-05-29 17:07:37 +08:00
})
2024-05-22 15:42:13 +08:00
</script>
2024-05-23 23:42:33 +08:00
<style lang="scss" scoped>
.dashboard-module {
2024-08-28 18:36:22 +08:00
.merchant-info {
.logo {
width: 80rpx;
height: 80rpx;
margin-right: 20rpx;
2024-05-23 23:42:33 +08:00
}
2024-08-28 18:36:22 +08:00
.detail {
.name {
color: #fff;
}
.description {
color: #fff;
opacity: 0.4;
}
}
}
.statistic {
2024-09-19 16:23:19 +08:00
// height: 200rpx;
2024-08-28 18:36:22 +08:00
background-color: #fffefe;
opacity: 0.9;
border-radius: 26rpx;
padding: 31rpx 40rpx;
.title {
font-weight: 500;
color: var(--ui-TC);
}
.income {
.left {
font-weight: 600;
flex: 1;
color: var(--ui-BG-Main);
.unit {
position: relative;
top: 4px;
2024-05-24 17:24:44 +08:00
}
2024-08-28 18:36:22 +08:00
}
.right-btn {
width: 161rpx;
height: 63rpx;
background-color: var(--ui-BG-Main);
color: #fff;
}
}
2024-05-29 17:07:37 +08:00
2024-08-28 18:36:22 +08:00
.des {
color: var(--ui-TC-2);
font-size: 24rpx;
2024-05-24 17:24:44 +08:00
}
2024-08-28 18:36:22 +08:00
}
2024-05-24 17:24:44 +08:00
2024-08-28 18:36:22 +08:00
.more {
.title {
font-weight: 600;
}
.items {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 30rpx 30rpx;
.item {
background: linear-gradient(90deg, #ffebeb 0%, #ffffff 100%);
border-radius: 18rpx;
padding: 19rpx 32rpx;
display: flex;
flex-direction: column;
2024-09-12 18:23:14 +08:00
justify-content: space-around;
height: 120rpx;
2024-08-28 18:36:22 +08:00
.name {
font-weight: 600;
color: var(--ui-TC);
}
.value {
font-weight: 600;
font-size: 31rpx;
color: var(--ui-TC);
2024-05-24 17:24:44 +08:00
}
2024-08-28 18:36:22 +08:00
.last {
font-weight: 400;
color: var(--ui-TC-2);
2024-05-24 17:24:44 +08:00
}
2024-08-28 18:36:22 +08:00
}
2024-05-24 17:24:44 +08:00
}
2024-08-28 18:36:22 +08:00
}
2024-05-23 23:42:33 +08:00
}
</style>