部分问题修复,修改数据统计接口

This commit is contained in:
2025-11-24 15:48:06 +08:00
parent e4f5cc8519
commit 679207521d
20 changed files with 2610 additions and 2134 deletions

View File

@@ -2,40 +2,55 @@
<my-model ref="model" :title="title" iconColor="#000" @close="resetForm"> <my-model ref="model" :title="title" iconColor="#000" @close="resetForm">
<template #desc> <template #desc>
<view class="u-text-left u-p-30 color-666"> <view class="u-text-left u-p-30 color-666">
<view class="u-m-t-32 u-flex "> <view class="u-m-t-32 u-flex">
<view>应付金额</view> <view>应付金额</view>
<view class="u-m-l-32"> <view class="u-m-l-32">
{{form.price}} {{ form.price }}
</view> </view>
</view> </view>
<view class="u-m-t-40 u-flex "> <view class="u-m-t-40 u-flex">
<view>实收金额</view> <view>实收金额</view>
<view class="u-m-l-32 border u-p-l-10 u-p-r-10 u-flex-1"> <view class="u-m-l-32 border u-p-l-10 u-p-r-10 u-flex-1">
<uni-easyinput type="number" @input="currentPriceInput" @change="currentPriceChange" paddingNone :inputBorder="false" <uni-easyinput
type="number"
@input="currentPriceInput"
@change="currentPriceChange"
paddingNone
:inputBorder="false"
v-model="form.currentPrice" v-model="form.currentPrice"
placeholder="输入实际金额"></uni-easyinput> placeholder="输入实际金额"
></uni-easyinput>
</view> </view>
</view> </view>
<view class="u-m-t-54 u-flex "> <view class="u-m-t-54 u-flex">
<view>优惠折扣</view> <view>优惠折扣</view>
<view class="u-m-l-32 u-flex-1 u-flex border u-p-l-10 u-p-r-10"> <view class="u-m-l-32 u-flex-1 u-flex border u-p-l-10 u-p-r-10">
<view class="u-flex-1"> <view class="u-flex-1">
<uni-easyinput type="number" @input="discountInput" @change="discountChange" paddingNone :inputBorder="false" <uni-easyinput
type="number"
@input="discountInput"
@change="discountChange"
paddingNone
:inputBorder="false"
v-model="form.discount" v-model="form.discount"
placeholder="输入折扣"></uni-easyinput> placeholder="输入折扣"
></uni-easyinput>
</view> </view>
<view class="u-font-32 color-333">%</view> <view class="u-font-32 color-333">%</view>
</view> </view>
</view> </view>
</view> </view>
</template> </template>
<template #btn> <template #btn>
<view class="u-p-30"> <view class="u-p-30">
<view class="u-m-t-10"> <view class="u-m-t-10">
<my-button @tap="confirm" shape="circle" fontWeight="700" >修改</my-button> <my-button @tap="confirm" shape="circle" fontWeight="700"
>修改</my-button
>
<view class=""> <view class="">
<my-button @tap="close" type="cancel" bgColor="#fff" >取消</my-button> <my-button @tap="close" type="cancel" bgColor="#fff"
>取消</my-button
>
</view> </view>
</view> </view>
</view> </view>
@@ -44,114 +59,121 @@
</template> </template>
<script setup> <script setup>
import { reactive, nextTick, ref,watch } from 'vue'; import { reactive, nextTick, ref, watch } from "vue";
import myModel from '@/components/my-components/my-model.vue' import myModel from "@/components/my-components/my-model.vue";
import myButton from '@/components/my-components/my-button.vue' import myButton from "@/components/my-components/my-button.vue";
import infoBox from '@/commons/utils/infoBox.js' import infoBox from "@/commons/utils/infoBox.js";
const props = defineProps({ const props = defineProps({
title: { title: {
type: String, type: String,
default: '' default: "",
}, },
discount:{ discount: {
type: [Number,String], type: [Number, String],
default:100 default: 100,
}, },
price: { price: {
type: [Number,String], type: [Number, String],
default: 0 default: 0,
}, },
});
function currentPriceInput(newval) {
form.discount = ((newval * 100) / form.price).toFixed(2);
}
function discountInput(newval) {
const currentPrice = uni.$utils.isMoney((form.price * newval) / 100) * 1;
form.currentPrice = currentPrice.toFixed(2);
}
function currentPriceChange(newval) {
if (newval < 0) {
form.currentPrice = "0.00";
form.discount = 100;
return infoBox.showToast("实收金额不能小于0");
}
console.log(props.price);
console.log(newval);
if (newval > props.price) {
const currentPrice = uni.$utils.isMoney(props.price * 1);
form.currentPrice = currentPrice.toFixed(2);
form.discount = 0;
return infoBox.showToast("实收金额不能大于应付金额");
}
}
function discountChange(newval) {
if (newval < 0) {
form.currentPrice = props.price;
form.discount = 0;
return infoBox.showToast("优惠折扣不能小于0");
}
if (newval > 100) {
form.discount = 100;
form.currentPrice = 0;
return infoBox.showToast("优惠折扣不能大于100");
}
}
}) const $form = {
function currentPriceInput(newval){
form.discount = (newval*100/form.price).toFixed(2)
}
function discountInput(newval){
form.currentPrice= uni.$utils.isMoney(form.price*newval/100).toFixed(2)
}
function currentPriceChange(newval){
if(newval<0){
form.currentPrice = '0.00'
form.discount=100
return infoBox.showToast('实收金额不能小于0')
}
console.log(props.price)
console.log(newval)
if(newval > props.price){
form.currentPrice = (uni.$utils.isMoney(props.price)*1).toFixed(2)
form.discount=0
return infoBox.showToast('实收金额不能大于应付金额')
}
}
function discountChange(newval){
if(newval<0){
form.currentPrice=props.price
form.discount=0
return infoBox.showToast('优惠折扣不能小于0')
}
if(newval>100){
form.discount=100
form.currentPrice=0
return infoBox.showToast('优惠折扣不能大于100')
}
}
const $form = {
price: props.price, price: props.price,
currentPrice: props.price, currentPrice: props.price,
discount: 100 discount: 100,
};
const form = reactive({
...$form,
});
watch(
() => props.price,
(newval) => {
form.price = (newval * 1).toFixed(2);
form.currentPrice = newval;
} }
const form = reactive({ );
...$form function resetForm() {
})
watch(()=>props.price,(newval)=>{
form.price = (newval*1).toFixed(2)
form.currentPrice=newval
})
function resetForm() {
Object.assign(form, { Object.assign(form, {
...$form ...$form,
}) });
} }
const model = ref(null) const model = ref(null);
function open() { function open() {
model.value.open() model.value.open();
form.price= (props.price*1).toFixed(2) form.price = (props.price * 1).toFixed(2);
form.discount=props.discount form.discount = props.discount;
form.currentPrice=(props.discount*props.price/100).toFixed(2) form.currentPrice = ((props.discount * props.price) / 100).toFixed(2);
console.log(form) console.log(form);
} }
function close() { function close() {
model.value.close() model.value.close();
} }
const emits = defineEmits(['confirm']) const emits = defineEmits(["confirm"]);
function confirm() { function confirm() {
emits('confirm',{...form,currentPrice:Number(form.currentPrice).toFixed(2)}) emits("confirm", {
close() ...form,
} currentPrice: Number(form.currentPrice).toFixed(2),
defineExpose({ });
close();
}
defineExpose({
open, open,
close close,
}) });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.border{ .border {
border-radius: 8rpx; border-radius: 8rpx;
overflow: hidden; overflow: hidden;
border-color: #999; border-color: #999;
} }
.lh34 { .lh34 {
line-height: 34rpx; line-height: 34rpx;
} }
.tag { .tag {
background-color: #fff; background-color: #fff;
border: 1px solid #E5E5E5; border: 1px solid #e5e5e5;
line-height: inherit; line-height: inherit;
font-size: 24rpx; font-size: 24rpx;
color: #666666; color: #666666;
@@ -159,43 +181,43 @@
border-radius: 8rpx; border-radius: 8rpx;
&.active { &.active {
border-color: #E6F0FF; border-color: #e6f0ff;
color: $my-main-color; color: $my-main-color;
} }
} }
.hover-class { .hover-class {
background-color: #E5E5E5; background-color: #e5e5e5;
} }
.discount { .discount {
.u-absolute { .u-absolute {
top: 0; top: 0;
bottom: 0; bottom: 0;
right: 0; right: 0;
} }
} }
.bg1 { .bg1 {
background: #F7F7FA; background: #f7f7fa;
} }
.tab { .tab {
padding: 0 80rpx; padding: 0 80rpx;
} }
.border { .border {
border: 1px solid #E5E5E5; border: 1px solid #e5e5e5;
border-radius: 4rpx; border-radius: 4rpx;
} }
.input-box { .input-box {
padding: 22rpx 32rpx; padding: 22rpx 32rpx;
font-size: 28rpx; font-size: 28rpx;
color: #666; color: #666;
} }
.placeholder-class { .placeholder-class {
font-size: 28rpx; font-size: 28rpx;
} }
</style> </style>

33
data/index.js Normal file
View File

@@ -0,0 +1,33 @@
import dayjs from "dayjs";
export const timeList = [
{
label: "今天",
value: "today",
beginDate: dayjs().format("YYYY-MM-DD"),
endDate: dayjs().format("YYYY-MM-DD"),
},
{
label: "昨天",
value: "yesterday",
beginDate: dayjs().subtract(1, "day").format("YYYY-MM-DD"),
endDate: dayjs().subtract(1, "day").format("YYYY-MM-DD"),
},
{
label: "本周",
value: "this_week",
beginDate: dayjs().startOf("week").format("YYYY-MM-DD"),
endDate: dayjs().endOf("week").format("YYYY-MM-DD"),
},
{
label: "本月",
value: "this_month",
beginDate: dayjs().startOf("month").format("YYYY-MM-DD"),
endDate: dayjs().endOf("month").format("YYYY-MM-DD"),
},
{
label: "自定义",
value: "custom",
beginDate: "",
endDate: "",
},
];

View File

@@ -0,0 +1,13 @@
import http from "@/http/http.js";
const request = http.request;
const urlType = "account";
export function tableOrderStatistic(data) {
return request({
url: `${urlType}/admin/tableOrderStatistic`,
method: "GET",
data: {
...data,
},
});
}

23
http/api/order/summary.js Normal file
View File

@@ -0,0 +1,23 @@
import http from "@/http/http.js";
const request = http.request;
const urlType = "order";
export function tableSummaryList(data) {
return request({
url: `${urlType}/admin/table/summary/list`,
method: "GET",
data: {
...data,
},
});
}
export function saleSummaryPage(data) {
return request({
url: `${urlType}/admin/sale/summary/page`,
method: "GET",
data: {
...data,
},
});
}

View File

@@ -15,8 +15,8 @@ import infoBox from "@/commons/utils/infoBox.js";
import go from "@/commons/utils/go.js"; import go from "@/commons/utils/go.js";
import { reject } from "lodash"; import { reject } from "lodash";
// 设置node环境 // 设置node环境
// envConfig.changeEnv(storageManage.env('production')) // envConfig.changeEnv(storageManage.env('production')) //正式
envConfig.changeEnv(storageManage.env("development")); envConfig.changeEnv(storageManage.env("development")); //测试
// 测试服 // 测试服
// #ifdef H5 // #ifdef H5

View File

@@ -10,6 +10,9 @@ import * as Pinia from 'pinia';
import { import {
createUnistorage createUnistorage
} from "pinia-plugin-unistorage"; } from "pinia-plugin-unistorage";
uni.$utils=utils
// 设置node环境 // 设置node环境
envConfig.changeEnv(storageManage.env()) envConfig.changeEnv(storageManage.env())

View File

@@ -7,7 +7,10 @@
<view class="color-333 font-bold">霸王餐</view> <view class="color-333 font-bold">霸王餐</view>
<view class="color-666 u-m-t-4 u-font-24">设置充值消费的N倍当前订单立即免单</view> <view class="color-666 u-m-t-4 u-font-24">设置充值消费的N倍当前订单立即免单</view>
</view> </view>
<up-switch v-model="form.enable" size="18"></up-switch> <up-switch v-model="form.enable" size="18"
:active-value="1"
:inactive-value="0"
></up-switch>
</view> </view>
</view> </view>
<view class="boxconstantbox" <view class="boxconstantbox"

View File

@@ -66,7 +66,7 @@
class="number-box" class="number-box"
placeholder="请输入" placeholder="请输入"
placeholder-class="color-999 u-font-28" placeholder-class="color-999 u-font-28"
type="number" type="digit"
v-model="form.payAmount" v-model="form.payAmount"
/> />

View File

@@ -271,7 +271,13 @@ function cancel(){
} }
onLoad(()=>{ onLoad(()=>{
showDetailListSwitch.value=distributionStore.config.levelConfigList.map(()=>true) showDetailListSwitch.value=distributionStore.config.levelConfigList.map(()=>true)
form.levelConfigList=[...distributionStore.config.levelConfigList||[]] const levelConfigList=[...distributionStore.config.levelConfigList||[]]
form.levelConfigList=levelConfigList.length?levelConfigList:[
{ name:'',
levelOneCommission:'',
inviteCount:'',
costAmount:''}
]
form.upgradeType=distributionStore.config.upgradeType form.upgradeType=distributionStore.config.upgradeType
}) })
</script> </script>

View File

@@ -157,7 +157,7 @@
<script setup> <script setup>
import Modal from "@/pageMarket/components/modal.vue"; import Modal from "@/pageMarket/components/modal.vue";
import { ref, reactive, computed, watch, onMounted } from "vue"; import { ref, reactive, computed, watch, onMounted ,nextTick} from "vue";
import { useNewUserDiscountStore } from "@/store/market.js"; import { useNewUserDiscountStore } from "@/store/market.js";
const isLoading = ref(false); const isLoading = ref(false);
@@ -299,7 +299,10 @@ async function init() {
}; };
console.log(data); console.log(data);
Object.assign(form, data); Object.assign(form, data);
nextTick(() => {
isLoading.value = false; isLoading.value = false;
})
} }
onMounted(() => { onMounted(() => {

View File

@@ -6,23 +6,33 @@
<view class="close" @tap="close"> <view class="close" @tap="close">
<uni-icons type="closeempty" size="24"></uni-icons> <uni-icons type="closeempty" size="24"></uni-icons>
</view> </view>
</view> </view>
<!-- <view class="u-p-30 u-flex u-flex-wrap gap-20 fastTime"> <!-- <view class="u-p-30 u-flex u-flex-wrap gap-20 fastTime">
<view class="item" v-for="(item,index) in fastTime" :key="index" @tap="changeTime(item.key)"> <view class="item" v-for="(item,index) in fastTime" :key="index" @tap="changeTime(item.key)">
{{item.title}} {{item.title}}
</view> </view>
</view> --> </view> -->
<picker-view :immediate-change="true" @pickend="pickend" :value="value" @change="bindChange" <picker-view
class="picker-view"> :immediate-change="true"
@pickend="pickend"
:value="value"
@change="bindChange"
class="picker-view"
>
<picker-view-column> <picker-view-column>
<view class="item" v-for="(item,index) in years" :key="index">{{item}}</view> <view class="item" v-for="(item, index) in years" :key="index"
>{{ item }}</view
>
</picker-view-column> </picker-view-column>
<picker-view-column> <picker-view-column>
<view class="item" v-for="(item,index) in months" :key="index">{{item}}</view> <view class="item" v-for="(item, index) in months" :key="index"
>{{ item }}</view
>
</picker-view-column> </picker-view-column>
<picker-view-column> <picker-view-column>
<view class="item" v-for="(item,index) in days" :key="index">{{item}}</view> <view class="item" v-for="(item, index) in days" :key="index"
>{{ item }}</view
>
</picker-view-column> </picker-view-column>
<!-- <picker-view-column> <!-- <picker-view-column>
<view class="item" v-for="(item,index) in hours" :key="index">{{item}}</view> <view class="item" v-for="(item,index) in hours" :key="index">{{item}}</view>
@@ -35,16 +45,27 @@
</picker-view-column> --> </picker-view-column> -->
</picker-view> </picker-view>
<view class="u-text-center color-999"></view> <view class="u-text-center color-999"></view>
<picker-view :immediate-change="true" :value="value1" @pickend="pickend1" @change="bindChange1" <picker-view
class="picker-view"> :immediate-change="true"
:value="value1"
@pickend="pickend1"
@change="bindChange1"
class="picker-view"
>
<picker-view-column> <picker-view-column>
<view class="item" v-for="(item,index) in years" :key="index">{{item}}</view> <view class="item" v-for="(item, index) in years" :key="index"
>{{ item }}</view
>
</picker-view-column> </picker-view-column>
<picker-view-column> <picker-view-column>
<view class="item" v-for="(item,index) in months" :key="index">{{item}}</view> <view class="item" v-for="(item, index) in months" :key="index"
>{{ item }}</view
>
</picker-view-column> </picker-view-column>
<picker-view-column> <picker-view-column>
<view class="item" v-for="(item,index) in days1" :key="index">{{item}}</view> <view class="item" v-for="(item, index) in days1" :key="index"
>{{ item }}</view
>
</picker-view-column> </picker-view-column>
<!-- <picker-view-column> <!-- <picker-view-column>
<view class="item" v-for="(item,index) in hours" :key="index">{{item}}</view> <view class="item" v-for="(item,index) in hours" :key="index">{{item}}</view>
@@ -58,363 +79,371 @@
</picker-view> </picker-view>
<!-- 站位 --> <!-- 站位 -->
<view style="height: 80px;"></view> <view style="height: 80px"></view>
<view class="fixed_b"> <view class="fixed_b">
<my-button shape="circle" @tap="confirm">确定</my-button> <my-button shape="circle" @tap="confirm">确定</my-button>
</view> </view>
</view> </view>
</view> </view>
</template> </template>
<script setup> <script setup>
import myButton from "@/components/my-components/my-button.vue" import dayjs from "dayjs";
import { import myButton from "@/components/my-components/my-button.vue";
reactive, import { reactive, ref } from "vue";
ref const $nowDate = new Date();
} from 'vue'; const nowDate = {
const $nowDate = new Date()
const nowDate = {
year: $nowDate.getFullYear(), year: $nowDate.getFullYear(),
month: $nowDate.getMonth() + 1, month: $nowDate.getMonth() + 1,
day: $nowDate.getDate(), day: $nowDate.getDate(),
hours: $nowDate.getHours(), hours: $nowDate.getHours(),
minutes: $nowDate.getMinutes(), minutes: $nowDate.getMinutes(),
seconds: $nowDate.getSeconds() seconds: $nowDate.getSeconds(),
} };
const yearsLen = 30 const yearsLen = 30;
const years = new Array(yearsLen).fill(1).map((v, index) => { const years = new Array(yearsLen)
return nowDate.year - index .fill(1)
}).reverse() .map((v, index) => {
const months = new Array(12).fill(1).map((v, index) => { return nowDate.year - index;
return index + 1
}) })
const days = ref(new Array(getMonthArea($nowDate, 'end').getDate()).fill(1).map((v, index) => { .reverse();
return index + 1 const months = new Array(12).fill(1).map((v, index) => {
})) return index + 1;
const days1 = ref(new Array(getMonthArea($nowDate, 'end').getDate()).fill(1).map((v, index) => { });
return index + 1 const days = ref(
})) new Array(getMonthArea($nowDate, "end").getDate()).fill(1).map((v, index) => {
const hours = new Array(24).fill(1).map((v, index) => { return index + 1;
return index
}) })
const minutes = new Array(60).fill(1).map((v, index) => { );
return index const days1 = ref(
new Array(getMonthArea($nowDate, "end").getDate()).fill(1).map((v, index) => {
return index + 1;
}) })
const seconds = new Array(60).fill(1).map((v, index) => { );
return index const hours = new Array(24).fill(1).map((v, index) => {
}) return index;
const fastTime = reactive([{ });
title: '今日', const minutes = new Array(60).fill(1).map((v, index) => {
key: 'now' return index;
});
const seconds = new Array(60).fill(1).map((v, index) => {
return index;
});
const fastTime = reactive([
{
title: "今日",
key: "now",
}, },
{ {
title: '昨日', title: "昨日",
key: 'prve' key: "prve",
}, },
{ {
title: '本月', title: "本月",
key: 'nowMonth' key: "nowMonth",
}, },
{ {
title: '上月', title: "上月",
key: 'prveMonth' key: "prveMonth",
} },
]) ]);
function setPrveDay() {}
function setNowMoneth() {}
function setPrveDay() { function setprveMoneth() {}
} function setDay(start, end) {
value.value = [start.year, start.month, start.day, 0, 0, 0];
value1.value = [end.year, end.month, end.day, 23, 59, 59];
}
function setNowMoneth() { function changeTime(key) {
const yearIndex = years.findIndex((v) => v == nowDate.year);
} const prveyearIndex = years.findIndex((v) => v == nowDate.year) - 1;
const nowMonthIndex = nowDate.month - 1;
function setprveMoneth() { const nowDayIndex = nowDate.day - 1;
}
function setDay(start, end) {
value.value = [
start.year,
start.month,
start.day,
0,
0,
0,
]
value1.value = [
end.year,
end.month,
end.day,
23,
59,
59,
]
}
function changeTime(key) {
const yearIndex = years.findIndex(v => v == nowDate.year)
const prveyearIndex = years.findIndex(v => v == nowDate.year) - 1
const nowMonthIndex = nowDate.month - 1
const nowDayIndex = nowDate.day - 1
const dataMap = { const dataMap = {
now: function() { now: function () {
return { return {
start: { start: {
year: yearIndex, year: yearIndex,
month: nowMonthIndex, month: nowMonthIndex,
day: nowDayIndex day: nowDayIndex,
}, },
end: { end: {
year: yearIndex, year: yearIndex,
month: nowMonthIndex, month: nowMonthIndex,
day: nowDayIndex day: nowDayIndex,
}
}
}, },
prve: function() { };
const oneDay=1000*60*60*24 },
const date=new Date(new Date(nowDate.year,nowDate.month,nowDate.day,0,0,0).getTime()-oneDay) prve: function () {
const oneDay = 1000 * 60 * 60 * 24;
const date = new Date(
new Date(nowDate.year, nowDate.month, nowDate.day, 0, 0, 0).getTime() -
oneDay
);
return { return {
start: { start: {
year:years.findIndex(v=>v==date.getFullYear()), year: years.findIndex((v) => v == date.getFullYear()),
month:date.getMonth()-1<0?11:date.getMonth()-1, month: date.getMonth() - 1 < 0 ? 11 : date.getMonth() - 1,
day: date.getDate()-1 day: date.getDate() - 1,
}, },
end: { end: {
year:years.findIndex(v=>v==date.getFullYear()), year: years.findIndex((v) => v == date.getFullYear()),
month:date.getMonth()-1<0?11:date.getMonth()-1, month: date.getMonth() - 1 < 0 ? 11 : date.getMonth() - 1,
day: date.getDate()-1 day: date.getDate() - 1,
}
}
}, },
nowMonth: function() { };
},
nowMonth: function () {
return { return {
start: { start: {
year:yearIndex, year: yearIndex,
month:nowMonthIndex, month: nowMonthIndex,
day: 0 day: 0,
}, },
end: { end: {
year:yearIndex, year: yearIndex,
month:nowMonthIndex, month: nowMonthIndex,
day:new Date(nowDate.year, nowDate.month , 0).getDate() - 1 day: new Date(nowDate.year, nowDate.month, 0).getDate() - 1,
}
}
}, },
prveMonth: function() { };
const oneDay=1000*60*60*24 },
const date=new Date(new Date(nowDate.year, nowDate.month-1,0,0,0).getTime()-oneDay) prveMonth: function () {
const oneDay = 1000 * 60 * 60 * 24;
const date = new Date(
new Date(nowDate.year, nowDate.month - 1, 0, 0, 0).getTime() - oneDay
);
console.log(date.getMonth()); console.log(date.getMonth());
return { return {
start: { start: {
year:years.findIndex(v=>v==date.getFullYear()), year: years.findIndex((v) => v == date.getFullYear()),
month:date.getMonth(), month: date.getMonth(),
day: 0 day: 0,
}, },
end: { end: {
year:years.findIndex(v=>v==date.getFullYear()), year: years.findIndex((v) => v == date.getFullYear()),
month:date.getMonth(), month: date.getMonth(),
day: date.getDate() day: date.getDate(),
} },
} };
} },
} };
const data = dataMap[key]() const data = dataMap[key]();
setDay(data.start, data.end) setDay(data.start, data.end);
changeDays(false,value.value) changeDays(false, value.value);
changeDays(true,value1.value) changeDays(true, value1.value);
console.log(value1.value); console.log(value1.value);
const start = returnDateString(value.value) const start = returnDateString(value.value);
const end = returnDateString(value1.value) const end = returnDateString(value1.value);
emits('confirm', { emits("confirm", {
text: `${start}——${end}`, text: `${start}——${end}`,
start, start,
end end,
}) });
close() close();
} }
let value = ref([ let value = ref([
years.length - 1, years.length - 1,
nowDate.month - 1, nowDate.month - 1,
nowDate.day - 1, nowDate.day - 1,
0, 0,
0, 0,
0, 0,
]) ]);
let value1 = ref([ let value1 = ref([
years.length - 1, years.length - 1,
nowDate.month - 1, nowDate.month - 1,
nowDate.day - 1, nowDate.day - 1,
23, 23,
59, 59,
59, 59,
]) ]);
let show = ref(false) let show = ref(false);
const emits = defineEmits('close', 'open', 'confirm') const emits = defineEmits("close", "open", "confirm");
function toggle() { function toggle() {
show.value = !show.value show.value = !show.value;
if (show.value) { if (show.value) {
emits('open', true) emits("open", true);
} else { } else {
emits('close', false) emits("close", false);
}
} }
}
function close() { function close() {
show.value = false show.value = false;
emits('close', false) emits("close", false);
} }
function open() { function open() {
show.value = true show.value = true;
emits('open', true) emits("open", true);
} }
function returnDateString(arr) { function returnDateString(arr) {
const year = years[arr[0]] const year = years[arr[0]];
const month = arr[1] + 1 const month = ("0" + (arr[1] + 1)).slice(-2);
const day = arr[2] + 1 const day = ("0" + (arr[2] + 1)).slice(-2);
const hour = ('0' + arr[3]).slice(-2) const hour = ("0" + arr[3]).slice(-2);
const min = ('0' + arr[4]).slice(-2) const min = ("0" + arr[4]).slice(-2);
const sen = ('0' + arr[5]).slice(-2) const sen = ("0" + arr[5]).slice(-2);
return `${year}-${month}-${day} ${hour}:${min}:${sen}`
}
return `${year}-${month}-${day} ${hour}:${min}:${sen}`;
}
function confirm(e) { function confirm(e) {
const start = returnDateString(value.value) const start = returnDateString(value.value);
const end = returnDateString(value1.value) const end = returnDateString(value1.value);
console.log(start); console.log(start);
console.log(end); console.log(end);
emits('confirm', { //如果结尾时间小于开始时间
if (new Date(start).getTime() > new Date(end).getTime()) {
return uni.showToast({
title: "结束时间不能小于开始时间",
icon: "none",
});
}
emits("confirm", {
text: `${start}——${end}`, text: `${start}——${end}`,
start, start,
end end,
}) });
close() close();
} }
function returnMonthStart(arr) { function returnMonthStart(arr) {
return new Date(years[arr[0]], months[arr[1]] - 1, 1).getDate(); return new Date(years[arr[0]], months[arr[1]] - 1, 1).getDate();
} }
function returnMonthEnd(arr) { function returnMonthEnd(arr) {
return new Date(years[arr[0]], months[arr[1]], 0).getDate(); return new Date(years[arr[0]], months[arr[1]], 0).getDate();
} }
function changeDays(isDays1,arr){ function changeDays(isDays1, arr) {
const end = returnMonthEnd(arr) const end = returnMonthEnd(arr);
if (end) { if (end) {
if(isDays1){ if (isDays1) {
days1.value= new Array(end).fill(1).map((v, days1.value = new Array(end).fill(1).map((v, index) => {
index) => { return index + 1;
return index + 1 });
}) } else {
}else{ days.value = new Array(end).fill(1).map((v, index) => {
days.value= new Array(end).fill(1).map((v, return index + 1;
index) => { });
return index + 1
})
} }
}
}
} function bindChange(e) {
} value.value = e.detail.value;
changeDays(false, e.detail.value);
}
function bindChange(e) { function bindChange1(e) {
value.value = e.detail.value value1.value = e.detail.value;
changeDays(false, e.detail.value) changeDays(true, e.detail.value);
} }
function bindChange1(e) { function getDayDate(date = new Date(), type) {
value1.value = e.detail.value const now = date;
changeDays(true, e.detail.value) if (type === "start") {
const startOfDay = new Date(
now.getFullYear(),
now.getMonth(),
now.getDate()
);
return startOfDay;
} }
if (type === "end") {
function getDayDate(date = new Date(), type) { const endOfDay = new Date(
const now = date now.getFullYear(),
if (type === 'start') { now.getMonth(),
const startOfDay = new Date(now.getFullYear(), now.getMonth(), now.getDate()); now.getDate(),
return startOfDay 23,
} 59,
if (type === 'end') { 59,
const endOfDay = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999); 999
);
return endOfDay; return endOfDay;
} }
} }
function getMonthArea(date = new Date(), type) { function getMonthArea(date = new Date(), type) {
let now = date let now = date;
let currentMonthStart = new Date(now.getFullYear(), now.getMonth(), 1); let currentMonthStart = new Date(now.getFullYear(), now.getMonth(), 1);
let currentMonthEnd = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59, 999); let currentMonthEnd = new Date(
if (type === 'start') { now.getFullYear(),
return currentMonthStart now.getMonth() + 1,
0,
23,
59,
59,
999
);
if (type === "start") {
return currentMonthStart;
} }
if (type === 'end') { if (type === "end") {
return currentMonthEnd; return currentMonthEnd;
} }
return { return {
start: currentMonthStart, start: currentMonthStart,
end: currentMonthEnd end: currentMonthEnd,
}; };
} }
function nullFunction() { function nullFunction() {}
} function pickend(e) {
function pickend(e) {
console.log(e); console.log(e);
} }
function pickend1(e) { function pickend1(e) {
console.log(e); console.log(e);
} }
defineExpose({ defineExpose({
close, close,
open, open,
confirm, confirm,
toggle toggle,
}) });
</script> </script>
<style lang="scss"> <style lang="scss">
.fastTime { .fastTime {
.item { .item {
background-color: rgb(247, 247, 247); background-color: rgb(247, 247, 247);
padding: 6rpx 40rpx; padding: 6rpx 40rpx;
border-radius: 6rpx; border-radius: 6rpx;
font-size: 32rpx; font-size: 32rpx;
} }
} }
.top { .top {
border-bottom: 1px solid #eee; border-bottom: 1px solid #eee;
} }
.close { .close {
position: absolute; position: absolute;
top: 50%; top: 50%;
transform: translateY(-50%); transform: translateY(-50%);
right: 30rpx; right: 30rpx;
} }
.mask { .mask {
position: fixed; position: fixed;
left: 0; left: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
top: 0; top: 0;
background-color: rgba(0, 0, 0, .7); background-color: rgba(0, 0, 0, 0.7);
.box { .box {
position: absolute; position: absolute;
@@ -424,9 +453,9 @@
right: 0; right: 0;
border-radius: 16rpx 16rpx 0 0; border-radius: 16rpx 16rpx 0 0;
} }
} }
.fixed_b { .fixed_b {
position: absolute; position: absolute;
left: 0; left: 0;
right: 0; right: 0;
@@ -434,15 +463,15 @@
padding: 30rpx; padding: 30rpx;
z-index: 100; z-index: 100;
background-color: #fff; background-color: #fff;
} }
.picker-view { .picker-view {
width: 750rpx; width: 750rpx;
height: 300rpx; height: 300rpx;
} }
.item { .item {
line-height: 34px; line-height: 34px;
text-align: center; text-align: center;
} }
</style> </style>

View File

@@ -1,42 +1,55 @@
<template> <template>
<view class="time-wrapper"> <view class="time-wrapper">
<view v-for="(v, i) in timeList" :key="i" class="timelistbox"> <view v-for="(v, i) in timeList" :key="i" class="timelistbox">
<view class="time-item" @tap="changeTime(v.value)" :class="{ 'time-selected':v.value==selected }"> <view
{{v.label}} class="time-item"
@tap="changeTime(v.value)"
:class="[v.value == selected ? 'time-selected' : '']"
>
{{ v.label }}
</view> </view>
<view class="xian" v-if="v.value==selected "> </view> <view class="xian" v-if="v.value == selected"> </view>
</view> </view>
</view> </view>
<view class="pageSalesSummaryContent"> <view class="pageSalesSummaryContent">
<view class=""> <view class="">
<view class=""> 实收金额() </view> <view class=""> 实收金额() </view>
<view class=""> {{list.saleAmount?list.saleAmount:0}} </view> <view class=""> {{ list.saleAmount ? list.saleAmount : 0 }} </view>
</view> </view>
<view class=""> <view class="">
<view class=""> 优惠金额() </view> <view class=""> 优惠金额() </view>
<view class=""> {{list.discountAmount?list.discountAmount:0}} </view> <view class="">
{{ list.discountAmount ? list.discountAmount : 0 }}
</view>
</view> </view>
<view class=""> <view class="">
<view class=""> 客单价() </view> <view class=""> 客单价() </view>
<view class=""> {{list.customerUnitPrice?list.customerUnitPrice:0}} </view> <view class="">
{{ list.customerUnitPrice ? list.customerUnitPrice : 0 }}
</view>
</view> </view>
<view class=""> <view class="">
<view class=""> 会员消费() </view> <view class=""> 会员消费() </view>
<view class=""> {{list.memberPayAmount?list.memberPayAmount:0}} </view> <view class="">
{{ list.memberPayAmount ? list.memberPayAmount : 0 }}
</view>
</view> </view>
<view class=""> <view class="">
<view class=""> 新增会员() </view> <view class=""> 新增会员() </view>
<view class=""> {{list.newMemberCount?list.newMemberCount:0}} </view> <view class="">
{{ list.newMemberCount ? list.newMemberCount : 0 }}
</view>
</view> </view>
<view class=""> <view class="">
<view class=""> 翻台率(%) </view> <view class=""> 翻台率(%) </view>
<view class=""> {{list.tableTurnoverRate?list.tableTurnoverRate:0}} </view> <view class="">
{{ list.tableTurnoverRate ? list.tableTurnoverRate : 0 }}
</view>
</view> </view>
</view> </view>
<view class="table-scroll"> <view class="table-scroll">
<template> <view class="color-333 u-font-28 bg-gray default-box-padding">
<view class="color-333 u-font-28 bg-gray default-box-padding" style="padding-top:80px;">
<scroll-view :scroll-x="true" class="bg-fff table u-text-center"> <scroll-view :scroll-x="true" class="bg-fff table u-text-center">
<view class="bg-fff border-r-12 u-flex no-wrap u-col-top"> <view class="bg-fff border-r-12 u-flex no-wrap u-col-top">
<view class="constantbox"> <view class="constantbox">
@@ -45,218 +58,181 @@
<view class="head">总数量</view> <view class="head">总数量</view>
<view class="head">金额</view> <view class="head">金额</view>
</view> </view>
<view class="constantboxitem" v-for="(item,index) in tableList" :key="index" <view
@click="toDetail(item)"> class="constantboxitem"
<view class="head" style="padding-left: 16rpx;"> v-for="(item, index) in tableList"
<image v-if="index==0" src="../pageTable/index/images/1.png" :key="index"
style="width: 22rpx;height: 30rpx;" mode=""></image> @click="toDetail(item)"
<image v-else-if="index==1" src="../pageTable/index/images/2.png" >
style="width: 22rpx;height: 30rpx;" mode=""></image> <view class="head" style="padding-left: 16rpx">
<image v-else-if="index==2" src="../pageTable/index/images/3.png" <image
style="width: 22rpx;height: 30rpx;" mode=""></image> v-if="index == 0"
&nbsp;&nbsp;{{item.productName}} src="../pageTable/index/images/1.png"
style="width: 22rpx; height: 30rpx"
mode=""
></image>
<image
v-else-if="index == 1"
src="../pageTable/index/images/2.png"
style="width: 22rpx; height: 30rpx"
mode=""
></image>
<image
v-else-if="index == 2"
src="../pageTable/index/images/3.png"
style="width: 22rpx; height: 30rpx"
mode=""
></image>
&nbsp;&nbsp;{{ item.productName }}
</view> </view>
<view class="head">{{item.number}}</view> <view class="head">{{ item.saleCount || 0 }}</view>
<view class="head">{{item.amount || '无'}}</view> <view class="head">{{ item.saleAmount || 0 }}</view>
</view> </view>
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
</template>
</view> </view>
<view class="bottombtn" @tap="toUrl"> <view class="bottombtn" @tap="toUrl">
更多 <uni-icons type="right" size="16"></uni-icons> 更多 <uni-icons type="right" size="16"></uni-icons>
</view> </view>
<datePickerview @confirm="datePickerConfirm" ref="datePicker"></datePickerview> <datePickerview
@confirm="datePickerConfirm"
ref="datePicker"
></datePickerview>
</template> </template>
<script setup> <script setup>
import { onMounted, ref } from 'vue'; import { onMounted, ref } from "vue";
import datePickerview from './components/my-date-pickerview.vue' import datePickerview from "./components/my-date-pickerview.vue";
import dayjs from 'dayjs' //时间格式库 import dayjs from "dayjs"; //时间格式库
import go from '@/commons/utils/go.js' import go from "@/commons/utils/go.js";
import { getTrade, productSaleDate } from '@/http/api/summary.js' import { getTrade } from "@/http/api/summary.js";
import { saleSummaryPage } from "@/http/api/order/summary.js";
import { timeList } from "@/data/index.js";
const datePicker=ref() const datePicker = ref();
const timeList = [{
label: '今天',
value: 'today'
},
{
label: '昨天',
value: 'yesterday'
},
{
label: '本周',
value: 'circumference'
}, {
label: '本月',
value: 'moon'
},
{
label: '自定义',
value: 'custom'
}
]
let selected = ref('today')
let list = ref({})
let tableList = ref([])
let day = ref(1)
onMounted(() => {
getlist()
gettableData()
})
/** let selected = ref("today");
let list = ref({});
let tableList = ref([]);
let day = ref(1);
onMounted(() => {
getData();
});
/**
* 获取营业数据 * 获取营业数据
* @param {Object} start * @param {Object} beginDate
* @param {Object} end * @param {Object} endDate
*/ */
function getlist(start, end) { function getlist(beginDate, endDate) {
let startTime, endTime;
if (selected.value == 'today') {
startTime = dayjs().format('YYYY-MM-DD') + ' 00:00:00'
endTime = dayjs().format('YYYY-MM-DD') + ' 23:59:59'
} else if (selected.value == 'yesterday') {
startTime = formatTime() + ' 00:00:00'
endTime = formatTime() + ' 23:59:59'
} else if (selected.value == 'circumference') {
var now = new Date();
var nowTime = now.getTime();
var day = now.getDay();
var oneDayTime = 24 * 60 * 60 * 1000;
//显示周一
var MondayTime = nowTime - (day - 1) * oneDayTime;
//显示周日
var SundayTime = nowTime + (7 - day) * oneDayTime;
startTime = dayjs(MondayTime).format('YYYY-MM-DD 00:00:00')
endTime = dayjs(SundayTime).format('YYYY-MM-DD 23:59:59')
} else if (selected.value == 'moon') {
startTime = dayjs().startOf('month').format('YYYY-MM-DD') + ' 00:00:00'
endTime = dayjs().endOf('month').format('YYYY-MM-DD') + ' 23:59:59'
} else if (selected.value == 'custom') {
let s = start.substring(0, start.indexOf(' '))
let e = end.substring(0, end.indexOf(' '))
startTime = s + ' 00:00:00'
endTime = e + ' 23:59:59'
}
getTrade({ getTrade({
beginDate: startTime, beginDate,
endDate: endTime, endDate,
rangeType: selected.value,
}).then((res) => { }).then((res) => {
list.value = res list.value = res;
}) });
} }
/** /**
* 获取销售数据 * 获取销售数据
* @param {Object} beginDate
* @param {Object} endDate
*/ */
function gettableData() { function gettableData(beginDate, endDate) {
if (selected.value == 'today') { saleSummaryPage({
day.value = 1 beginDate,
} else if (selected.value == 'yesterday') { endDate,
day.value = 1 rangeType: selected.value,
} else if (selected.value == 'circumference') {
day.value = 7
} else if (selected.value == 'moon') {
day.value = 30
} else if (selected.value == 'custom') {
day.value = 30
}
productSaleDate({
day: day.value,
page: 1,
size: 5
}).then((res) => { }).then((res) => {
tableList.value = res.records tableList.value = (res || []).slice(0, 5);
}) });
}
} /**
/**
* 获取当前时间
*/
function getdate() {
const dt = new Date();
const y = dt.getFullYear();
const m = (dt.getMonth() + 1 + "").padStart(2, "0");
const d = (dt.getDate() + "").padStart(2, "0");
const hh = (dt.getHours() + "").padStart(2, "0");
const mm = (dt.getMinutes() + "").padStart(2, "0");
const ss = (dt.getSeconds() + "").padStart(2, "0");
return `${y}-${m}-${d}`;
}
/**
* 获取昨天时间
*/
const formatTime = () => {
let strDate = getdate()
let dateFormat = new Date(strDate);
dateFormat = dateFormat.setDate(dateFormat.getDate() - 1);
dateFormat = new Date(dateFormat);
let y = dateFormat.getFullYear()
let m = (dateFormat.getMonth() + 1).toString().padStart(2, '0')
let d = dateFormat.getDate().toString().padStart(2, '0')
return `${y}-${m}-${d}`
}
/**
* 时间切换 * 时间切换
* @param {Object} e * @param {Object} e
*/ */
function changeTime(e) { function changeTime(e) {
selected.value = e selected.value = e;
if (e == 'custom') { if (e == "custom") {
datePicker.value.toggle() datePicker.value.toggle();
} else { } else {
getlist() getData();
gettableData()
}
} }
}
/** const datePickerData = ref({
beginDate: "",
endDate: "",
});
/**
* 自定义确认 * 自定义确认
* @param {Object} e * @param {Object} e
*/ */
function datePickerConfirm(e) { function datePickerConfirm(e) {
console.log(e) datePickerData.value.beginDate = e.start;
getlist(e.start, e.end) datePickerData.value.endDate = e.end;
gettableData() getData(e.start, e.end);
}
function getData(start, end) {
let beginDate, endDate;
if (selected.value == "custom") {
beginDate = start.substring(0, start.indexOf(" "));
endDate = end.substring(0, end.indexOf(" "));
} else {
beginDate = timeList.find((item) => item.value == selected.value).beginDate;
endDate = timeList.find((item) => item.value == selected.value).endDate;
} }
getlist(beginDate, endDate);
/** gettableData(beginDate, endDate);
}
/**
* 更多 * 更多
*/ */
function toUrl() { function toUrl() {
go.to('PAGES_PRODUCT_SALES_RANKING', { let beginDate, endDate;
day: day.value if (selected.value == "custom") {
}) beginDate = datePickerData.value.beginDate.substring(
0,
datePickerData.value.beginDate.indexOf(" ")
);
endDate = datePickerData.value.endDate.substring(
0,
datePickerData.value.endDate.indexOf(" ")
);
} else {
beginDate = timeList.find((item) => item.value == selected.value).beginDate;
endDate = timeList.find((item) => item.value == selected.value).endDate;
} }
go.to("PAGES_PRODUCT_SALES_RANKING", {
beginDate,
endDate,
rangeType: selected.value,
});
}
</script> </script>
<style> <style>
page { page {
background: #f6f6f6; background: #f6f6f6;
} }
</style> </style>
<style lang="scss" scoped> <style lang="scss" scoped>
.fixed-top {
.fixed-top {
padding: 32rpx 28rpx; padding: 32rpx 28rpx;
z-index: 100; z-index: 100;
} }
.bottom { .bottom {
background-color: transparent; background-color: transparent;
bottom: 84rpx; bottom: 84rpx;
left: 28rpx; left: 28rpx;
right: 28rpx; right: 28rpx;
} }
.table { .table {
border-radius: 12rpx 12rpx 0rpx 0rpx; border-radius: 12rpx 12rpx 0rpx 0rpx;
overflow: hidden; overflow: hidden;
font-size: 24rpx; font-size: 24rpx;
@@ -291,24 +267,24 @@
} }
.constantboxitem:nth-child(odd) { .constantboxitem:nth-child(odd) {
background: #F7F6FB; background: #f7f6fb;
} }
.constantboxitem:nth-child(1) { .constantboxitem:nth-child(1) {
background: #AEBAD2; background: #aebad2;
color: #fff; color: #fff;
font-size: 24rpx; font-size: 24rpx;
} }
} }
.item:nth-of-type(2n+1) { .item:nth-of-type(2n + 1) {
background-color: rgb(249, 249, 249); background-color: rgb(249, 249, 249);
} }
} }
</style> </style>
<style scoped lang="less"> <style scoped lang="less">
.time-wrapper { .time-wrapper {
display: flex; display: flex;
justify-content: space-around; justify-content: space-around;
padding-bottom: 16rpx; padding-bottom: 16rpx;
@@ -330,7 +306,7 @@
.xian { .xian {
width: 40rpx; width: 40rpx;
height: 3rpx; height: 3rpx;
background-color: #318AFE; background-color: #318afe;
// position: absolute; // position: absolute;
// left: 16rpx; // left: 16rpx;
// bottom: 0; // bottom: 0;
@@ -341,86 +317,85 @@
color: #318afe; color: #318afe;
font-size: 32rpx !important; font-size: 32rpx !important;
} }
} }
.pageSalesSummaryContent { .pageSalesSummaryContent {
height: 320rpx; height: 320rpx;
margin: 20rpx 28rpx; margin: 20rpx 28rpx;
background-image: url('./svg/bgimg.svg'); background-image: url("./svg/bgimg.svg");
background-size: 694rpx 320rpx; background-size: 694rpx 320rpx;
padding: 48rpx 28rpx; padding: 48rpx 28rpx;
.df; .df;
justify-content: space-between; justify-content: space-between;
flex-wrap: wrap; flex-wrap: wrap;
>view { > view {
padding-right: 52rpx; padding-right: 52rpx;
color: #fff; color: #fff;
font-family: Source Han Sans CN, Source Han Sans CN; font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400; font-weight: 400;
font-size: 28rpx; font-size: 28rpx;
} }
} }
// 表格 // 表格
.table-scroll { .table-scroll {
// width: calc(100% - 5px); // width: calc(100% - 5px);
overflow-x: scroll; overflow-x: scroll;
white-space: nowrap; white-space: nowrap;
margin: 32rpx 28rpx; margin: 32rpx 28rpx;
margin-right: 30rpx; margin-right: 30rpx;
border-radius: 30rpx 30rpx 0 0; border-radius: 30rpx 30rpx 0 0;
}
} .table-scroll .table {
.table-scroll .table {
table-layout: fixed; table-layout: fixed;
// width: calc(100% - 10rpx); // width: calc(100% - 10rpx);
} }
.table-scroll .thead { .table-scroll .thead {
display: table-row; display: table-row;
background-color: bisque; background-color: bisque;
font-size: 24rpx; font-size: 24rpx;
} }
.table-scroll .tbody { .table-scroll .tbody {
overflow-y: scroll; overflow-y: scroll;
overflow-x: hidden; overflow-x: hidden;
display: block; display: block;
// width: 1040rpx; // width: 1040rpx;
width: 100%; width: 100%;
// width: calc(100% ); // width: calc(100% );
} }
// .table-scroll th, // .table-scroll th,
// td { // td {
// height: 82rpx; // height: 82rpx;
// overflow: hidden; // overflow: hidden;
// text-overflow: ellipsis; // text-overflow: ellipsis;
// width: 250rpx; // width: 250rpx;
// // border: 0.7rpx solid red; // // border: 0.7rpx solid red;
// border: 0.7rpx solid rgba(126, 155, 212, 0.27); // border: 0.7rpx solid rgba(126, 155, 212, 0.27);
// } // }
.bottombtn { .bottombtn {
width: 694rpx; width: 694rpx;
height: 56rpx; height: 56rpx;
line-height: 56rpx; line-height: 56rpx;
text-align: center; text-align: center;
margin: 0rpx auto; margin: 0rpx auto;
background: #F1F1F1; background: #f1f1f1;
font-size: 24rpx; font-size: 24rpx;
border-radius: 0rpx 0rpx 28rpx 28rpx; border-radius: 0rpx 0rpx 28rpx 28rpx;
} }
.df() { .df() {
display: flex; display: flex;
align-items: center; align-items: center;
} }
</style> </style>
<style> <style>
.min-page{ .min-page {
height: 20vh; height: 20vh;
} }
</style> </style>

View File

@@ -1,6 +1,5 @@
<template> <template>
<template> <view class="color-333 u-font-28 bg-gray default-box-padding">
<view class="color-333 u-font-28 bg-gray default-box-padding" >
<scroll-view :scroll-x="true" class="bg-fff table u-text-center"> <scroll-view :scroll-x="true" class="bg-fff table u-text-center">
<view class="bg-fff border-r-12 u-flex no-wrap u-col-top"> <view class="bg-fff border-r-12 u-flex no-wrap u-col-top">
<view class="constantbox"> <view class="constantbox">
@@ -9,99 +8,103 @@
<view class="head">总数量</view> <view class="head">总数量</view>
<view class="head">金额</view> <view class="head">金额</view>
</view> </view>
<view class="constantboxitem" v-for="(item,index) in tableList" :key="index" <view
@click="toDetail(item)"> class="constantboxitem"
<view class="head">{{item.productName}}</view> v-for="(item, index) in tableList"
<view class="head">{{item.number}}</view> :key="index"
<view class="head">{{item.amount || '无'}}</view> @click="toDetail(item)"
>
<view class="head">{{ item.productName }}</view>
<view class="head">{{ item.saleCount || 0 }}</view>
<view class="head">{{ item.saleAmount || 0 }}</view>
</view> </view>
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
</template>
</template> </template>
<script setup> <script setup>
import { onMounted, ref } from 'vue'; import { onLoad } from "@dcloudio/uni-app";
import { productSaleDate } from '@/http/api/summary.js' import { onMounted, reactive, ref } from "vue";
import { saleSummaryPage } from "@/http/api/order/summary.js";
let tableList = ref([]) let tableList = ref([]);
let props = defineProps({ let props = defineProps({
day: { day: {
type: Number type: Number,
} },
}) });
const options = reactive({
beginDate: "",
endDate: "",
rangeType: "",
});
onLoad((opt) => {
console.log(opt);
Object.assign(options, opt);
gettableData();
});
onMounted(() => { /**
gettableData()
})
/**
* 获取销售数据 * 获取销售数据
*/ */
function gettableData() { function gettableData() {
productSaleDate({ saleSummaryPage(options).then((res) => {
day: props.day, tableList.value = res || [];
page: 1, });
size: 50 }
}).then((res) => {
tableList.value = res.records
})
}
</script> </script>
<style> <style>
.table-scroll { .table-scroll {
overflow-x: scroll; overflow-x: scroll;
white-space: nowrap; white-space: nowrap;
margin: 32rpx 28rpx; margin: 32rpx 28rpx;
margin-right: 30rpx; margin-right: 30rpx;
border-radius: 30rpx 30rpx 0 0; border-radius: 30rpx 30rpx 0 0;
}
} .table-scroll table {
.table-scroll table {
table-layout: fixed; table-layout: fixed;
} }
.table-scroll thead { .table-scroll thead {
display: table-row; display: table-row;
background-color: bisque; background-color: bisque;
font-size: 24rpx; font-size: 24rpx;
} }
.table-scroll tbody { .table-scroll tbody {
overflow-y: scroll; overflow-y: scroll;
overflow-x: hidden; overflow-x: hidden;
display: block; display: block;
width: 100%; width: 100%;
} }
.table-scroll th, .table-scroll th,
td { td {
height: 82rpx; height: 82rpx;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
width: 250rpx; width: 250rpx;
border: 0.7rpx solid rgba(126, 155, 212, 0.27); border: 0.7rpx solid rgba(126, 155, 212, 0.27);
} }
</style> </style>
<style lang="scss" scoped> <style lang="scss" scoped>
.fixed-top {
.fixed-top {
padding: 32rpx 28rpx; padding: 32rpx 28rpx;
z-index: 100; z-index: 100;
} }
.bottom { .bottom {
background-color: transparent; background-color: transparent;
bottom: 84rpx; bottom: 84rpx;
left: 28rpx; left: 28rpx;
right: 28rpx; right: 28rpx;
} }
.table { .table {
border-radius: 12rpx 12rpx 0rpx 0rpx; border-radius: 12rpx 12rpx 0rpx 0rpx;
overflow: hidden; overflow: hidden;
font-size: 24rpx; font-size: 24rpx;
@@ -136,18 +139,18 @@
} }
.constantboxitem:nth-child(odd) { .constantboxitem:nth-child(odd) {
background: #F7F6FB; background: #f7f6fb;
} }
.constantboxitem:nth-child(1) { .constantboxitem:nth-child(1) {
background: #AEBAD2; background: #aebad2;
color: #fff; color: #fff;
font-size: 24rpx; font-size: 24rpx;
} }
} }
.item:nth-of-type(2n+1) { .item:nth-of-type(2n + 1) {
background-color: rgb(249, 249, 249); background-color: rgb(249, 249, 249);
} }
} }
</style> </style>

346
pageSalesSummary/table.vue Normal file
View File

@@ -0,0 +1,346 @@
<template>
<view class="time-wrapper">
<view v-for="(v, i) in timeList" :key="i" class="timelistbox">
<view
class="time-item"
@tap="changeTime(v.value)"
:class="[v.value == selected ? 'time-selected' : '']"
>
{{ v.label }}
</view>
<view class="xian" v-if="v.value == selected"> </view>
</view>
</view>
<view class="table-scroll">
<view class="color-333 u-font-28 bg-gray">
<scroll-view :scroll-x="true" class="bg-fff table u-text-center">
<view class="bg-fff border-r-12 u-flex no-wrap u-col-top">
<view class="constantbox">
<view class="constantboxitem">
<view class="head">区域名称</view>
<view class="head">台桌号</view>
<view class="head">订单数量</view>
<view class="head">订单金额</view>
</view>
<view
class="constantboxitem"
v-for="(item, index) in tableList"
:key="index"
@click="toDetail(item)"
>
<view class="head" style="padding-left: 16rpx">
<image
v-if="index == 0"
src="../pageTable/index/images/1.png"
style="width: 22rpx; height: 30rpx"
mode=""
></image>
<image
v-else-if="index == 1"
src="../pageTable/index/images/2.png"
style="width: 22rpx; height: 30rpx"
mode=""
></image>
<image
v-else-if="index == 2"
src="../pageTable/index/images/3.png"
style="width: 22rpx; height: 30rpx"
mode=""
></image>
&nbsp;&nbsp;{{ item.areaName }}
</view>
<view class="head">{{ item.tableName || "" }}</view>
<view class="head">{{ item.orderCount || 0 }}</view>
<view class="head">{{ item.orderAmount || 0 }}</view>
</view>
</view>
</view>
</scroll-view>
</view>
</view>
<view style="height: 80rpx;"></view>
<!-- <view class="bottombtn" @tap="toUrl">
更多 <uni-icons type="right" size="16"></uni-icons>
</view> -->
<datePickerview
@confirm="datePickerConfirm"
ref="datePicker"
></datePickerview>
</template>
<script setup>
import { onMounted, ref } from "vue";
import datePickerview from "./components/my-date-pickerview.vue";
import dayjs from "dayjs"; //时间格式库
import go from "@/commons/utils/go.js";
import { getTrade, productSaleDate } from "@/http/api/summary.js";
import { timeList } from "@/data/index.js";
import { tableSummaryList } from "@/http/api/order/summary.js";
const datePicker = ref();
let selected = ref("today");
let list = ref({});
let tableList = ref([]);
let day = ref(1);
onMounted(() => {
gettableData();
});
/**
* 获取销售数据
*/
function gettableData(start, end) {
let beginDate, endDate;
if (selected.value == "custom") {
beginDate = start.substring(0, start.indexOf(" "));
endDate = end.substring(0, end.indexOf(" "));
} else {
beginDate = timeList.find((item) => item.value == selected.value).beginDate;
endDate = timeList.find((item) => item.value == selected.value).endDate;
}
tableSummaryList({
beginDate: beginDate,
endDate: endDate,
rangeType: selected.value,
}).then((res) => {
tableList.value = res || [];
});
}
/**
* 获取当前时间
*/
function getdate() {
const dt = new Date();
const y = dt.getFullYear();
const m = (dt.getMonth() + 1 + "").padStart(2, "0");
const d = (dt.getDate() + "").padStart(2, "0");
const hh = (dt.getHours() + "").padStart(2, "0");
const mm = (dt.getMinutes() + "").padStart(2, "0");
const ss = (dt.getSeconds() + "").padStart(2, "0");
return `${y}-${m}-${d}`;
}
/**
* 时间切换
* @param {Object} e
*/
function changeTime(e) {
selected.value = e;
if (e == "custom") {
datePicker.value.toggle();
} else {
gettableData();
}
}
/**
* 自定义确认
* @param {Object} e
*/
function datePickerConfirm(e) {
console.log(e);
gettableData(e.start, e.end);
}
/**
* 更多
*/
function toUrl() {
go.to("PAGES_PRODUCT_SALES_RANKING", {
day: day.value,
});
}
</script>
<style>
page {
background: #f6f6f6;
}
</style>
<style lang="scss" scoped>
.fixed-top {
padding: 32rpx 28rpx;
z-index: 100;
}
.bottom {
background-color: transparent;
bottom: 84rpx;
left: 28rpx;
right: 28rpx;
}
.table {
border-radius: 12rpx 12rpx 0rpx 0rpx;
overflow: hidden;
font-size: 24rpx;
.constantbox {
.constantboxitem {
display: flex;
.head {
width: 220rpx;
padding: 32rpx 24rpx;
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 24rpx;
color: #333333;
overflow: hidden; //超出的文本隐藏
text-overflow: ellipsis; //溢出用省略号显示
white-space: nowrap; //溢出不换行
}
.head:nth-child(4) {
width: 300rpx;
}
.head:nth-child(5) {
width: 300rpx;
}
}
.constantboxitem:nth-child(even) {
background: #fff;
}
.constantboxitem:nth-child(odd) {
background: #f7f6fb;
}
.constantboxitem:nth-child(1) {
background: #aebad2;
color: #fff;
font-size: 24rpx;
}
}
.item:nth-of-type(2n + 1) {
background-color: rgb(249, 249, 249);
}
}
</style>
<style scoped lang="less">
.time-wrapper {
display: flex;
justify-content: space-around;
padding-bottom: 16rpx;
padding-top: 16rpx;
background-color: #fff;
.timelistbox {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
.time-item {
font-size: 28rpx;
text-align: center;
padding-bottom: 10rpx;
}
.xian {
width: 40rpx;
height: 3rpx;
background-color: #318afe;
// position: absolute;
// left: 16rpx;
// bottom: 0;
}
}
.time-selected {
color: #318afe;
font-size: 32rpx !important;
}
}
.pageSalesSummaryContent {
height: 320rpx;
margin: 20rpx 28rpx;
background-image: url("./svg/bgimg.svg");
background-size: 694rpx 320rpx;
padding: 48rpx 28rpx;
.df;
justify-content: space-between;
flex-wrap: wrap;
> view {
padding-right: 52rpx;
color: #fff;
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 28rpx;
}
}
// 表格
.table-scroll {
// width: calc(100% - 5px);
overflow-x: scroll;
white-space: nowrap;
margin: 32rpx 28rpx;
margin-right: 30rpx;
border-radius: 30rpx 30rpx 0 0;
}
.table-scroll .table {
table-layout: fixed;
// width: calc(100% - 10rpx);
}
.table-scroll .thead {
display: table-row;
background-color: bisque;
font-size: 24rpx;
}
.table-scroll .tbody {
overflow-y: scroll;
overflow-x: hidden;
display: block;
// width: 1040rpx;
width: 100%;
// width: calc(100% );
}
// .table-scroll th,
// td {
// height: 82rpx;
// overflow: hidden;
// text-overflow: ellipsis;
// width: 250rpx;
// // border: 0.7rpx solid red;
// border: 0.7rpx solid rgba(126, 155, 212, 0.27);
// }
.bottombtn {
width: 694rpx;
height: 56rpx;
line-height: 56rpx;
text-align: center;
margin: 0rpx auto;
background: #f1f1f1;
font-size: 24rpx;
border-radius: 0rpx 0rpx 28rpx 28rpx;
}
.df() {
display: flex;
align-items: center;
}
</style>
<style>
.min-page {
height: 20vh;
}
</style>

View File

@@ -401,7 +401,16 @@
"style": { "style": {
"navigationBarTitleText": "商品销售排行" "navigationBarTitleText": "商品销售排行"
} }
}] },
{
"pageId": "PAGES_TABLE_SALES_RANKING",
"path": "table",
"style": {
"navigationBarTitleText": "桌台统计"
}
}
]
}, },
{ {
"root": "pageLineUp", "root": "pageLineUp",

View File

@@ -58,7 +58,7 @@ const menuList = ref([
{ {
title: '新客立减', title: '新客立减',
icon: '', icon: '',
pageUrl: 'PAGES_ORDER_INDEX', pageUrl: 'PAGES_MARKET_NEW_USER_DISCOUNT',
intro: '首单下单减免金额' intro: '首单下单减免金额'
}, },
{ {

View File

@@ -3,8 +3,11 @@
<view class="index-selected"> <view class="index-selected">
<view class="index-time"> <view class="index-time">
<block v-for="v in timeList" :key="v.value"> <block v-for="v in timeList" :key="v.value">
<view class="time-item flex-center" :class="{ 'time-active': vdata.timeSelected == v.value }" <view
@tap.stop="changeTimeFunc(v.value)"> class="time-item flex-center"
:class="{ 'time-active': vdata.timeSelected == v.value }"
@tap.stop="changeTimeFunc(v.value)"
>
{{ v.title }} {{ v.title }}
</view> </view>
</block> </block>
@@ -15,30 +18,34 @@
</view> </view>
<view class="receipts-money"> <view class="receipts-money">
<text class="money-title">成交金额 ()</text> <text class="money-title">成交金额 ()</text>
<view class="money-num">{{ list?list.sale.incomeAmountAll:0}}</view> <view class="money-num">{{ list ? list.sale.incomeAmountAll : 0 }}</view>
</view> </view>
<view class="money-list"> <view class="money-list">
<view class="money-item"> <view class="money-item">
<text class="money-title">消费笔数</text> <text class="money-title">消费笔数</text>
<view class="money-num">{{ list?list.vip.useNum:0 }}</view> <view class="money-num">{{ list ? list.vip.useNum : 0 }}</view>
</view> </view>
<view class="money-item"> <view class="money-item">
<text class="money-title">退款金额 ()</text> <text class="money-title">退款金额 ()</text>
<view class="money-num">{{ list?list.sale.outAmount:0}}</view> <view class="money-num">{{ list ? list.sale.outAmount : 0 }}</view>
</view> </view>
<view class="money-item"> <view class="money-item">
<text class="money-title">消费金额</text> <text class="money-title">消费金额</text>
<view class="money-num">{{ list?list.vip.useAmount:0 }}</view> <view class="money-num">{{ list ? list.vip.useAmount : 0 }}</view>
</view> </view>
</view> </view>
<view class="money-list" v-if="vdata.memberIsShow"> <view class="money-list" v-if="vdata.memberIsShow">
<view class="money-item"> <view class="money-item">
<text class="money-title">会员充值()</text> <text class="money-title">会员充值()</text>
<view class="money-num">{{ cal.cert2Dollar(memberData.payAmount) }}</view> <view class="money-num">{{
cal.cert2Dollar(memberData.payAmount)
}}</view>
</view> </view>
<view class="money-item"> <view class="money-item">
<text class="money-title">会员消费()</text> <text class="money-title">会员消费()</text>
<view class="money-num">{{ cal.cert2Dollar(Math.abs(memberData.changeAmount)) }}</view> <view class="money-num">{{
cal.cert2Dollar(Math.abs(memberData.changeAmount))
}}</view>
</view> </view>
<view class="money-item"> <view class="money-item">
@@ -53,89 +60,74 @@
</template> </template>
<script setup> <script setup>
import { ref, reactive, onMounted } from 'vue'; import { ref, reactive, onMounted } from "vue";
import cal from '@/commons/utils/cal.js'; import cal from "@/commons/utils/cal.js";
import go from '@/commons/utils/go.js'; import go from "@/commons/utils/go.js";
import ent from '@/commons/utils/ent.js'; import ent from "@/commons/utils/ent.js";
import unionScan from '@/commons/utils/unionScan.js'; import unionScan from "@/commons/utils/unionScan.js";
import storageManage from '@/commons/utils/storageManage.js'; import storageManage from "@/commons/utils/storageManage.js";
import dayjs from 'dayjs' //时间格式库 import dayjs from "dayjs"; //时间格式库
import { timeList } from '@/data/index.js'
import { getTrade } from '@/http/api/summary.js' import { getTrade } from "@/http/api/summary.js";
onMounted(() => { onMounted(() => {
vdata.memberIsShow = ent.has('ENT_MCH_MEMBER') && storageManage.userInfo().isHasMemberEnt; vdata.memberIsShow =
if (ent.has('ENT_MCH_MEMBER') && storageManage.userInfo().isHasMemberEnt) { ent.has("ENT_MCH_MEMBER") && storageManage.userInfo().isHasMemberEnt;
if (ent.has("ENT_MCH_MEMBER") && storageManage.userInfo().isHasMemberEnt) {
getMemberData(); getMemberData();
} }
getList() getList();
}); });
const emits = defineEmits(['click']); const emits = defineEmits(["click"]);
const timeList = [{ let list = ref();
title: '今天', const vdata = reactive({
value: 'today' timeSelected: "today", // 当前时间选择器的
},
{
title: '昨天',
value: 'yesterday'
},
{
title: '近7天',
value: 'circumference'
},
{
title: '近30天',
value: 'moon'
}
];
let list = ref()
const vdata = reactive({
timeSelected: 'today', // 当前时间选择器的
payAmount: -1, // 实收金额 payAmount: -1, // 实收金额
payCount: -1, // 交易笔数 payCount: -1, // 交易笔数
refundAmount: -1, // 退款金额 refundAmount: -1, // 退款金额
refundCount: -1, // 退款笔数 refundCount: -1, // 退款笔数
memberIsShow: false //是否开启会员模块 memberIsShow: false, //是否开启会员模块
}); });
const memberData = reactive({}); const memberData = reactive({});
function getList() { function getList() {
let startTime, endTime; let startTime, endTime;
if (vdata.timeSelected == 'today') { if (vdata.timeSelected == "today") {
startTime = dayjs().format('YYYY-MM-DD') + ' 00:00:00' startTime = dayjs().format("YYYY-MM-DD") + " 00:00:00";
endTime = dayjs().format('YYYY-MM-DD') + ' 23:59:59' endTime = dayjs().format("YYYY-MM-DD") + " 23:59:59";
} else if (vdata.timeSelected == 'yesterday') { } else if (vdata.timeSelected == "yesterday") {
startTime = formatTime() + ' 00:00:00' startTime = formatTime() + " 00:00:00";
endTime = formatTime() + ' 23:59:59' endTime = formatTime() + " 23:59:59";
} else if (vdata.timeSelected == 'circumference') { } else if (vdata.timeSelected == "circumference") {
startTime = dayjs().add(-7, 'day').format('YYYY-MM-DD 00:00:00') startTime = dayjs().add(-7, "day").format("YYYY-MM-DD 00:00:00");
endTime = dayjs().format('YYYY-MM-DD 23:59:59') endTime = dayjs().format("YYYY-MM-DD 23:59:59");
} else if (vdata.timeSelected == 'moon') { } else if (vdata.timeSelected == "moon") {
startTime = dayjs().add(-30, 'day').format('YYYY-MM-DD 00:00:00') startTime = dayjs().add(-30, "day").format("YYYY-MM-DD 00:00:00");
endTime = dayjs().format('YYYY-MM-DD 23:59:59') endTime = dayjs().format("YYYY-MM-DD 23:59:59");
} else if (vdata.timeSelected == 'custom') { } else if (vdata.timeSelected == "custom") {
startTime = start startTime = start;
endTime = end endTime = end;
} }
getTrade({ getTrade({
shopId: uni.getStorageSync('shopId'), shopId: uni.getStorageSync("shopId"),
startTime, startTime,
endTime, endTime,
}).then((res) => { }).then((res) => {
list.value = res list.value = res;
}) });
} }
// 切换 时间卡片 // 切换 时间卡片
function changeTimeFunc(val) { function changeTimeFunc(val) {
vdata.timeSelected = val; vdata.timeSelected = val;
getList() getList();
// refData(); // refData();
// if (vdata.memberIsShow) { // if (vdata.memberIsShow) {
// getMemberData(); // getMemberData();
// } // }
} }
// 根据选择请求数据 // 根据选择请求数据
function refData() { function refData() {
// 获取 统计数据 // 获取 统计数据
// $indexStatistics(vdata.timeSelected).then(({ // $indexStatistics(vdata.timeSelected).then(({
// bizData // bizData
@@ -145,28 +137,28 @@
// vdata.refundAmount = bizData.totalRefundAmt; // vdata.refundAmount = bizData.totalRefundAmt;
// vdata.refundCount = bizData.totalRefundNum; // vdata.refundCount = bizData.totalRefundNum;
// }); // });
} }
// 扫码动作 // 扫码动作
function scanFunc() { function scanFunc() {
unionScan.scan(true).then((res) => { unionScan.scan(true).then((res) => {
// 登录类型 // 登录类型
if (res.type == unionScan.QR_TYPE_LOGIN) { if (res.type == unionScan.QR_TYPE_LOGIN) {
return go.to('PAGES_SCAN_LOGIN', { return go.to("PAGES_SCAN_LOGIN", {
qrcodeNo: res.originQrVal qrcodeNo: res.originQrVal,
}); });
} }
// 二维码 // 二维码
if (res.type == unionScan.QR_TYPE_QRC) { if (res.type == unionScan.QR_TYPE_QRC) {
return go.to('PAGES_APP_CODE_BIND', { return go.to("PAGES_APP_CODE_BIND", {
qrcId: res.bizValue qrcId: res.bizValue,
}); });
} }
}); });
} }
// 获取当前时间 // 获取当前时间
function getdate() { function getdate() {
const dt = new Date(); const dt = new Date();
const y = dt.getFullYear(); const y = dt.getFullYear();
const m = (dt.getMonth() + 1 + "").padStart(2, "0"); const m = (dt.getMonth() + 1 + "").padStart(2, "0");
@@ -175,19 +167,19 @@
const mm = (dt.getMinutes() + "").padStart(2, "0"); const mm = (dt.getMinutes() + "").padStart(2, "0");
const ss = (dt.getSeconds() + "").padStart(2, "0"); const ss = (dt.getSeconds() + "").padStart(2, "0");
return `${y}-${m}-${d}`; return `${y}-${m}-${d}`;
} }
// 获取昨天时间 // 获取昨天时间
const formatTime = () => { const formatTime = () => {
let strDate = getdate() let strDate = getdate();
let dateFormat = new Date(strDate); let dateFormat = new Date(strDate);
dateFormat = dateFormat.setDate(dateFormat.getDate() - 1); dateFormat = dateFormat.setDate(dateFormat.getDate() - 1);
dateFormat = new Date(dateFormat); dateFormat = new Date(dateFormat);
let y = dateFormat.getFullYear() let y = dateFormat.getFullYear();
let m = (dateFormat.getMonth() + 1).toString().padStart(2, '0') let m = (dateFormat.getMonth() + 1).toString().padStart(2, "0");
let d = dateFormat.getDate().toString().padStart(2, '0') let d = dateFormat.getDate().toString().padStart(2, "0");
return `${y}-${m}-${d}` return `${y}-${m}-${d}`;
} };
const getMemberData = () => { const getMemberData = () => {
// $memberInfoCount({ // $memberInfoCount({
// queryDateRange: vdata.timeSelected // queryDateRange: vdata.timeSelected
// }).then(({ // }).then(({
@@ -195,14 +187,14 @@
// }) => { // }) => {
// Object.assign(memberData, bizData); // Object.assign(memberData, bizData);
// }); // });
}; };
defineExpose({ defineExpose({
refData refData,
}); });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.index-header { .index-header {
width: 680rpx; width: 680rpx;
margin: 0 auto; margin: 0 auto;
transform: translateY(30rpx); transform: translateY(30rpx);
@@ -298,5 +290,5 @@
border-radius: 20rpx; border-radius: 20rpx;
color: $J-color-t29; color: $J-color-t29;
} }
} }
</style> </style>

View File

@@ -6,23 +6,33 @@
<view class="close" @tap="close"> <view class="close" @tap="close">
<uni-icons type="closeempty" size="24"></uni-icons> <uni-icons type="closeempty" size="24"></uni-icons>
</view> </view>
</view> </view>
<!-- <view class="u-p-30 u-flex u-flex-wrap gap-20 fastTime"> <!-- <view class="u-p-30 u-flex u-flex-wrap gap-20 fastTime">
<view class="item" v-for="(item,index) in fastTime" :key="index" @tap="changeTime(item.key)"> <view class="item" v-for="(item,index) in fastTime" :key="index" @tap="changeTime(item.key)">
{{item.title}} {{item.title}}
</view> </view>
</view> --> </view> -->
<picker-view :immediate-change="true" @pickend="pickend" :value="value" @change="bindChange" <picker-view
class="picker-view"> :immediate-change="true"
@pickend="pickend"
:value="value"
@change="bindChange"
class="picker-view"
>
<picker-view-column> <picker-view-column>
<view class="item" v-for="(item,index) in years" :key="index">{{item}}</view> <view class="item" v-for="(item, index) in years" :key="index"
>{{ item }}</view
>
</picker-view-column> </picker-view-column>
<picker-view-column> <picker-view-column>
<view class="item" v-for="(item,index) in months" :key="index">{{item}}</view> <view class="item" v-for="(item, index) in months" :key="index"
>{{ item }}</view
>
</picker-view-column> </picker-view-column>
<picker-view-column> <picker-view-column>
<view class="item" v-for="(item,index) in days" :key="index">{{item}}</view> <view class="item" v-for="(item, index) in days" :key="index"
>{{ item }}</view
>
</picker-view-column> </picker-view-column>
<!-- <picker-view-column> <!-- <picker-view-column>
<view class="item" v-for="(item,index) in hours" :key="index">{{item}}</view> <view class="item" v-for="(item,index) in hours" :key="index">{{item}}</view>
@@ -35,18 +45,29 @@
</picker-view-column> --> </picker-view-column> -->
</picker-view> </picker-view>
<view class="u-text-center color-999"></view> <view class="u-text-center color-999"></view>
<picker-view :immediate-change="true" :value="value1" @pickend="pickend1" @change="bindChange1" <picker-view
class="picker-view"> :immediate-change="true"
:value="value1"
@pickend="pickend1"
@change="bindChange1"
class="picker-view"
>
<picker-view-column> <picker-view-column>
<view class="item" v-for="(item,index) in years" :key="index">{{item}}</view> <view class="item" v-for="(item, index) in years" :key="index"
>{{ item }}</view
>
</picker-view-column> </picker-view-column>
<picker-view-column> <picker-view-column>
<view class="item" v-for="(item,index) in months" :key="index">{{item}}</view> <view class="item" v-for="(item, index) in months" :key="index"
>{{ item }}</view
>
</picker-view-column> </picker-view-column>
<picker-view-column> <picker-view-column>
<view class="item" v-for="(item,index) in days1" :key="index">{{item}}</view> <view class="item" v-for="(item, index) in days1" :key="index"
>{{ item }}</view
>
</picker-view-column> </picker-view-column>
<!-- <picker-view-column> <!-- <picker-view-column>
<view class="item" v-for="(item,index) in hours" :key="index">{{item}}</view> <view class="item" v-for="(item,index) in hours" :key="index">{{item}}</view>
</picker-view-column> </picker-view-column>
<picker-view-column> <picker-view-column>
@@ -58,363 +79,372 @@
</picker-view> </picker-view>
<!-- 站位 --> <!-- 站位 -->
<view style="height: 80px;"></view> <view style="height: 80px"></view>
<view class="fixed_b"> <view class="fixed_b">
<my-button shape="circle" @tap="confirm">确定</my-button> <my-button shape="circle" @tap="confirm">确定</my-button>
</view> </view>
</view> </view>
</view> </view>
</template> </template>
<script setup> <script setup>
import myButton from "@/components/my-components/my-button.vue" import myButton from "@/components/my-components/my-button.vue";
import { import { reactive, ref } from "vue";
reactive, const $nowDate = new Date();
ref const nowDate = {
} from 'vue';
const $nowDate = new Date()
const nowDate = {
year: $nowDate.getFullYear(), year: $nowDate.getFullYear(),
month: $nowDate.getMonth() + 1, month: $nowDate.getMonth() + 1,
day: $nowDate.getDate(), day: $nowDate.getDate(),
hours: $nowDate.getHours(), hours: $nowDate.getHours(),
minutes: $nowDate.getMinutes(), minutes: $nowDate.getMinutes(),
seconds: $nowDate.getSeconds() seconds: $nowDate.getSeconds(),
} };
const yearsLen = 30 const yearsLen = 30;
const years = new Array(yearsLen).fill(1).map((v, index) => { const years = new Array(yearsLen)
return nowDate.year - index .fill(1)
}).reverse() .map((v, index) => {
const months = new Array(12).fill(1).map((v, index) => { return nowDate.year - index;
return index + 1
}) })
const days = ref(new Array(getMonthArea($nowDate, 'end').getDate()).fill(1).map((v, index) => { .reverse();
return index + 1 const months = new Array(12).fill(1).map((v, index) => {
})) return index + 1;
const days1 = ref(new Array(getMonthArea($nowDate, 'end').getDate()).fill(1).map((v, index) => { });
return index + 1 const days = ref(
})) new Array(getMonthArea($nowDate, "end").getDate()).fill(1).map((v, index) => {
const hours = new Array(24).fill(1).map((v, index) => { return index + 1;
return index
}) })
const minutes = new Array(60).fill(1).map((v, index) => { );
return index const days1 = ref(
new Array(getMonthArea($nowDate, "end").getDate()).fill(1).map((v, index) => {
return index + 1;
}) })
const seconds = new Array(60).fill(1).map((v, index) => { );
return index const hours = new Array(24).fill(1).map((v, index) => {
}) return index;
const fastTime = reactive([{ });
title: '今日', const minutes = new Array(60).fill(1).map((v, index) => {
key: 'now' return index;
});
const seconds = new Array(60).fill(1).map((v, index) => {
return index;
});
const fastTime = reactive([
{
title: "今日",
key: "now",
}, },
{ {
title: '昨日', title: "昨日",
key: 'prve' key: "prve",
}, },
{ {
title: '本月', title: "本月",
key: 'nowMonth' key: "nowMonth",
}, },
{ {
title: '上月', title: "上月",
key: 'prveMonth' key: "prveMonth",
} },
]) ]);
function setPrveDay() {}
function setNowMoneth() {}
function setPrveDay() { function setprveMoneth() {}
} function setDay(start, end) {
value.value = [start.year, start.month, start.day, 0, 0, 0];
value1.value = [end.year, end.month, end.day, 23, 59, 59];
}
function setNowMoneth() { function changeTime(key) {
const yearIndex = years.findIndex((v) => v == nowDate.year);
} const prveyearIndex = years.findIndex((v) => v == nowDate.year) - 1;
const nowMonthIndex = nowDate.month - 1;
function setprveMoneth() { const nowDayIndex = nowDate.day - 1;
}
function setDay(start, end) {
value.value = [
start.year,
start.month,
start.day,
0,
0,
0,
]
value1.value = [
end.year,
end.month,
end.day,
23,
59,
59,
]
}
function changeTime(key) {
const yearIndex = years.findIndex(v => v == nowDate.year)
const prveyearIndex = years.findIndex(v => v == nowDate.year) - 1
const nowMonthIndex = nowDate.month - 1
const nowDayIndex = nowDate.day - 1
const dataMap = { const dataMap = {
now: function() { now: function () {
return { return {
start: { start: {
year: yearIndex, year: yearIndex,
month: nowMonthIndex, month: nowMonthIndex,
day: nowDayIndex day: nowDayIndex,
}, },
end: { end: {
year: yearIndex, year: yearIndex,
month: nowMonthIndex, month: nowMonthIndex,
day: nowDayIndex day: nowDayIndex,
}
}
}, },
prve: function() { };
const oneDay=1000*60*60*24 },
const date=new Date(new Date(nowDate.year,nowDate.month,nowDate.day,0,0,0).getTime()-oneDay) prve: function () {
const oneDay = 1000 * 60 * 60 * 24;
const date = new Date(
new Date(nowDate.year, nowDate.month, nowDate.day, 0, 0, 0).getTime() -
oneDay
);
return { return {
start: { start: {
year:years.findIndex(v=>v==date.getFullYear()), year: years.findIndex((v) => v == date.getFullYear()),
month:date.getMonth()-1<0?11:date.getMonth()-1, month: date.getMonth() - 1 < 0 ? 11 : date.getMonth() - 1,
day: date.getDate()-1 day: date.getDate() - 1,
}, },
end: { end: {
year:years.findIndex(v=>v==date.getFullYear()), year: years.findIndex((v) => v == date.getFullYear()),
month:date.getMonth()-1<0?11:date.getMonth()-1, month: date.getMonth() - 1 < 0 ? 11 : date.getMonth() - 1,
day: date.getDate()-1 day: date.getDate() - 1,
}
}
}, },
nowMonth: function() { };
},
nowMonth: function () {
return { return {
start: { start: {
year:yearIndex, year: yearIndex,
month:nowMonthIndex, month: nowMonthIndex,
day: 0 day: 0,
}, },
end: { end: {
year:yearIndex, year: yearIndex,
month:nowMonthIndex, month: nowMonthIndex,
day:new Date(nowDate.year, nowDate.month , 0).getDate() - 1 day: new Date(nowDate.year, nowDate.month, 0).getDate() - 1,
}
}
}, },
prveMonth: function() { };
const oneDay=1000*60*60*24 },
const date=new Date(new Date(nowDate.year, nowDate.month-1,0,0,0).getTime()-oneDay) prveMonth: function () {
const oneDay = 1000 * 60 * 60 * 24;
const date = new Date(
new Date(nowDate.year, nowDate.month - 1, 0, 0, 0).getTime() - oneDay
);
console.log(date.getMonth()); console.log(date.getMonth());
return { return {
start: { start: {
year:years.findIndex(v=>v==date.getFullYear()), year: years.findIndex((v) => v == date.getFullYear()),
month:date.getMonth(), month: date.getMonth(),
day: 0 day: 0,
}, },
end: { end: {
year:years.findIndex(v=>v==date.getFullYear()), year: years.findIndex((v) => v == date.getFullYear()),
month:date.getMonth(), month: date.getMonth(),
day: date.getDate() day: date.getDate(),
} },
} };
} },
} };
const data = dataMap[key]() const data = dataMap[key]();
setDay(data.start, data.end) setDay(data.start, data.end);
changeDays(false,value.value) changeDays(false, value.value);
changeDays(true,value1.value) changeDays(true, value1.value);
console.log(value1.value); console.log(value1.value);
const start = returnDateString(value.value) const start = returnDateString(value.value);
const end = returnDateString(value1.value) const end = returnDateString(value1.value);
emits('confirm', { emits("confirm", {
text: `${start}——${end}`, text: `${start}——${end}`,
start, start,
end end,
}) });
close() close();
} }
let value = ref([ let value = ref([
years.length - 1, years.length - 1,
nowDate.month - 1, nowDate.month - 1,
nowDate.day - 1, nowDate.day - 1,
0, 0,
0, 0,
0, 0,
]) ]);
let value1 = ref([ let value1 = ref([
years.length - 1, years.length - 1,
nowDate.month - 1, nowDate.month - 1,
nowDate.day - 1, nowDate.day - 1,
23, 23,
59, 59,
59, 59,
]) ]);
let show = ref(false) let show = ref(false);
const emits = defineEmits('close', 'open', 'confirm') const emits = defineEmits("close", "open", "confirm");
function toggle() { function toggle() {
show.value = !show.value show.value = !show.value;
if (show.value) { if (show.value) {
emits('open', true) emits("open", true);
} else { } else {
emits('close', false) emits("close", false);
}
} }
}
function close() { function close() {
show.value = false show.value = false;
emits('close', false) emits("close", false);
} }
function open() { function open() {
show.value = true show.value = true;
emits('open', true) emits("open", true);
} }
function returnDateString(arr) { function returnDateString(arr) {
const year = years[arr[0]] const year = years[arr[0]];
const month = arr[1] + 1 const month = ("0" + (arr[1] + 1)).slice(-2);
const day = arr[2] + 1 const day = ("0" + (arr[2] + 1)).slice(-2);
const hour = ('0' + arr[3]).slice(-2) const hour = ("0" + arr[3]).slice(-2);
const min = ('0' + arr[4]).slice(-2) const min = ("0" + arr[4]).slice(-2);
const sen = ('0' + arr[5]).slice(-2) const sen = ("0" + arr[5]).slice(-2);
return `${year}-${month}-${day} ${hour}:${min}:${sen}`
}
return `${year}-${month}-${day} ${hour}:${min}:${sen}`;
}
function confirm(e) { function confirm(e) {
const start = returnDateString(value.value) const start = returnDateString(value.value);
const end = returnDateString(value1.value) const end = returnDateString(value1.value);
console.log(start); console.log(start);
console.log(end); console.log(end);
emits('confirm', { //如果结尾时间小于开始时间
if (new Date(start).getTime() > new Date(end).getTime()) {
return uni.showToast({
title: "结束时间不能小于开始时间",
icon: "none",
});
}
console.log(start);
console.log(end);
emits("confirm", {
text: `${start}——${end}`, text: `${start}——${end}`,
start, start,
end end,
}) });
close() close();
} }
function returnMonthStart(arr) { function returnMonthStart(arr) {
return new Date(years[arr[0]], months[arr[1]] - 1, 1).getDate(); return new Date(years[arr[0]], months[arr[1]] - 1, 1).getDate();
} }
function returnMonthEnd(arr) { function returnMonthEnd(arr) {
return new Date(years[arr[0]], months[arr[1]], 0).getDate(); return new Date(years[arr[0]], months[arr[1]], 0).getDate();
} }
function changeDays(isDays1,arr){ function changeDays(isDays1, arr) {
const end = returnMonthEnd(arr) const end = returnMonthEnd(arr);
if (end) { if (end) {
if(isDays1){ if (isDays1) {
days1.value= new Array(end).fill(1).map((v, days1.value = new Array(end).fill(1).map((v, index) => {
index) => { return index + 1;
return index + 1 });
}) } else {
}else{ days.value = new Array(end).fill(1).map((v, index) => {
days.value= new Array(end).fill(1).map((v, return index + 1;
index) => { });
return index + 1
})
} }
}
}
} function bindChange(e) {
} value.value = e.detail.value;
changeDays(false, e.detail.value);
}
function bindChange(e) { function bindChange1(e) {
value.value = e.detail.value value1.value = e.detail.value;
changeDays(false, e.detail.value) changeDays(true, e.detail.value);
} }
function bindChange1(e) { function getDayDate(date = new Date(), type) {
value1.value = e.detail.value const now = date;
changeDays(true, e.detail.value) if (type === "start") {
const startOfDay = new Date(
now.getFullYear(),
now.getMonth(),
now.getDate()
);
return startOfDay;
} }
if (type === "end") {
function getDayDate(date = new Date(), type) { const endOfDay = new Date(
const now = date now.getFullYear(),
if (type === 'start') { now.getMonth(),
const startOfDay = new Date(now.getFullYear(), now.getMonth(), now.getDate()); now.getDate(),
return startOfDay 23,
} 59,
if (type === 'end') { 59,
const endOfDay = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999); 999
);
return endOfDay; return endOfDay;
} }
} }
function getMonthArea(date = new Date(), type) { function getMonthArea(date = new Date(), type) {
let now = date let now = date;
let currentMonthStart = new Date(now.getFullYear(), now.getMonth(), 1); let currentMonthStart = new Date(now.getFullYear(), now.getMonth(), 1);
let currentMonthEnd = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59, 999); let currentMonthEnd = new Date(
if (type === 'start') { now.getFullYear(),
return currentMonthStart now.getMonth() + 1,
0,
23,
59,
59,
999
);
if (type === "start") {
return currentMonthStart;
} }
if (type === 'end') { if (type === "end") {
return currentMonthEnd; return currentMonthEnd;
} }
return { return {
start: currentMonthStart, start: currentMonthStart,
end: currentMonthEnd end: currentMonthEnd,
}; };
} }
function nullFunction() { function nullFunction() {}
} function pickend(e) {
function pickend(e) {
console.log(e); console.log(e);
} }
function pickend1(e) { function pickend1(e) {
console.log(e); console.log(e);
} }
defineExpose({ defineExpose({
close, close,
open, open,
confirm, confirm,
toggle toggle,
}) });
</script> </script>
<style lang="scss"> <style lang="scss">
.fastTime { .fastTime {
.item { .item {
background-color: rgb(247, 247, 247); background-color: rgb(247, 247, 247);
padding: 6rpx 40rpx; padding: 6rpx 40rpx;
border-radius: 6rpx; border-radius: 6rpx;
font-size: 32rpx; font-size: 32rpx;
} }
} }
.top { .top {
border-bottom: 1px solid #eee; border-bottom: 1px solid #eee;
} }
.close { .close {
position: absolute; position: absolute;
top: 50%; top: 50%;
transform: translateY(-50%); transform: translateY(-50%);
right: 30rpx; right: 30rpx;
} }
.mask { .mask {
position: fixed; position: fixed;
left: 0; left: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
top: 0; top: 0;
background-color: rgba(0, 0, 0, .7); background-color: rgba(0, 0, 0, 0.7);
z-index: 100; z-index: 100;
.box { .box {
position: absolute; position: absolute;
@@ -424,9 +454,9 @@
right: 0; right: 0;
border-radius: 16rpx 16rpx 0 0; border-radius: 16rpx 16rpx 0 0;
} }
} }
.fixed_b { .fixed_b {
position: absolute; position: absolute;
left: 0; left: 0;
right: 0; right: 0;
@@ -434,15 +464,15 @@
padding: 30rpx; padding: 30rpx;
z-index: 100; z-index: 100;
background-color: #fff; background-color: #fff;
} }
.picker-view { .picker-view {
width: 750rpx; width: 750rpx;
height: 300rpx; height: 300rpx;
} }
.item { .item {
line-height: 34px; line-height: 34px;
text-align: center; text-align: center;
} }
</style> </style>

View File

@@ -6,53 +6,76 @@
<view class="statisticsBox"> <view class="statisticsBox">
<view class="time-wrapper u-m-l-10 u-m-r-10"> <view class="time-wrapper u-m-l-10 u-m-r-10">
<view v-for="(v, i) in timeList" :key="i" class="timelistbox"> <view v-for="(v, i) in timeList" :key="i" class="timelistbox">
<view class="time-item" @tap="changeTime(v.value,i)" :class="{ 'time-selected':v.value==selected }"> <view
{{v.label}} class="time-item"
@tap="changeTime(v.value, i)"
:class="[v.value == selected ? 'time-selected' : '']"
>
{{ v.label }}
</view> </view>
<!-- <view class="xian" v-if="v.value==selected "> </view> --> <!-- <view class="xian" v-if="v.value==selected "> </view> -->
</view> </view>
</view> </view>
<view class="time_bootom_line"> <view class="time_bootom_line">
<view class="block" :style="{ <view
transform:'translateX('+comBlockX+'rpx) rotate(45deg) ' class="block"
}"></view> :style="{
transform: 'translateX(' + comBlockX + 'rpx) rotate(45deg) ',
}"
></view>
</view> </view>
<view class="bottom"></view> <view class="bottom"></view>
<div class="u-flex u-row-between u-font-28 color-333 "> <div class="u-flex u-row-between u-font-28 color-333">
<div class=" u-flex-1 "> <div class="u-flex-1">
<view class="u-m-t-32"> <view class="u-m-t-32">
<view class="">营业额</view> <view class="">营业额</view>
<view class="u-m-t-16"> <view class="u-m-t-16">
<up-text bold color="#318AFE" size="20" mode="price" :text="yingyeE"></up-text> <up-text
bold
color="#318AFE"
size="20"
mode="price"
:text="yingyeE"
></up-text>
</view> </view>
</view> </view>
<view class="u-m-t-20"> <view class="u-m-t-20">
<view class="">退款</view> <view class="">退款</view>
<view class="u-m-t-14"> <view class="u-m-t-14">
<up-text color="#333" size="14" bold mode="price" :text="refundCount"></up-text> <up-text
color="#333"
size="14"
bold
mode="price"
:text="refundCount"
></up-text>
</view> </view>
</view> </view>
</div> </div>
<view class="line"></view> <view class="line"></view>
<view class="payList u-flex-1 u-p-l-40"> <view class="payList u-flex-1 u-p-l-40">
<view class="li w-full u-flex u-row-between u-font-24 color-333" v-for="(item,index) in list" <view
:key="index"> class="li w-full u-flex u-row-between u-font-24 color-333"
v-for="(item, index) in list"
:key="index"
>
<view class="u-flex"> <view class="u-flex">
<view :style="returnColorStyle(item,index)" class="circle"></view> <view
:style="returnColorStyle(item, index)"
class="circle"
></view>
<view class="u-m-l-8"> <view class="u-m-l-8">
{{item.payType}} {{ item.payType }}
</view> </view>
</view> </view>
<view style="text-align: center;" class="u-m-t-6"> <view style="text-align: center" class="u-m-t-6">
{{item.payAmount}} {{ item.payAmount }}
</view> </view>
</view> </view>
</view> </view>
</div> </div>
<!-- <view class="u-m-t-8 u-flex u-row-center u-font-24 u-col-center color-666"> <!-- <view class="u-m-t-8 u-flex u-row-center u-font-24 u-col-center color-666">
<view class="u-flex" @click="toggleShowAll"> <view class="u-flex" @click="toggleShowAll">
<view>{{!showAll?'展开全部':'收起全部' }}</view> <view>{{!showAll?'展开全部':'收起全部' }}</view>
@@ -63,189 +86,151 @@
</view> --> </view> -->
</view> </view>
</view> </view>
<datePickerview @confirm="datePickerConfirm" ref="datePicker" style="z-index: 999;"></datePickerview> <datePickerview
@confirm="datePickerConfirm"
ref="datePicker"
style="z-index: 999"
></datePickerview>
</template> </template>
<script setup> <script setup>
import { import { ref, reactive, computed } from "vue";
ref, import { onShow } from "@dcloudio/uni-app";
reactive, import { timeList } from "@/data/index.js";
computed import dayjs from "dayjs"; //时间格式库
} from 'vue'; import datePickerview from "./my-date-pickerview.vue";
import {
onShow
} from '@dcloudio/uni-app';
import dayjs from 'dayjs' //时间格式库 import { getTrade } from "@/http/api/summary.js";
import datePickerview from './my-date-pickerview.vue'
import { let selected = ref("today");
getTrade let showAll = ref(false);
} from '@/http/api/summary.js' let list = ref();
const pageData = reactive({
let selected = ref('today') list: [
let showAll = ref(false); {
let list = ref() payType: "微信小程序",
const pageData = reactive({ key: "wechatPayAmount",
list: [{
payType: '微信小程序',
key: 'wechatPayAmount',
payAmount: 0, payAmount: 0,
bgcolor: '#5AA25F' bgcolor: "#5AA25F",
}, },
{ {
payType: '支付宝小程序', payType: "支付宝小程序",
key: 'aliPayAmount', key: "aliPayAmount",
payAmount: 0, payAmount: 0,
bgcolor: '#31ACFE' bgcolor: "#31ACFE",
}, },
{ {
payType: '主扫收款', payType: "主扫收款",
key: 'scanPayAmount', key: "scanPayAmount",
payAmount: 0, payAmount: 0,
bgcolor: '#FF5C6D' bgcolor: "#FF5C6D",
}, },
{ {
payType: '现金', payType: "现金",
key: 'cashPayAmount', key: "cashPayAmount",
payAmount: 0, payAmount: 0,
bgcolor: '#FC843F' bgcolor: "#FC843F",
}, },
{ {
payType: '充值', payType: "充值",
key: 'rechargeAmount', key: "rechargeAmount",
payAmount: 0, payAmount: 0,
bgcolor: '#9090FF' bgcolor: "#9090FF",
}, },
{ {
payType: '挂账', payType: "挂账",
key: 'creditPayAmount', key: "creditPayAmount",
payAmount: 0, payAmount: 0,
bgcolor: '#7BA7A4' bgcolor: "#7BA7A4",
}, },
// {payType: '收款码收款', key:'', payAmount: 0,bgcolor:'#5AA25F'}, // {payType: '收款码收款', key:'', payAmount: 0,bgcolor:'#5AA25F'},
], ],
}) });
function returnColorStyle(item) { function returnColorStyle(item) {
return { return {
backgroundColor: item.bgcolor backgroundColor: item.bgcolor,
} };
} }
function toggleShowAll() { function toggleShowAll() {
showAll.value = !showAll.value showAll.value = !showAll.value;
setList() setList();
} }
function setList() { function setList() {
// list.value = showAll.value ? pageData.list : pageData.list.slice(0, 4) // list.value = showAll.value ? pageData.list : pageData.list.slice(0, 4)
list.value = pageData.list list.value = pageData.list;
} }
const emit = defineEmits(["totalRevenue"]);
const emit = defineEmits(['totalRevenue']) const timeSleIndex = ref(0);
const timeList = [{
label: '今天', const datePicker = ref();
value: 'today' onShow((options) => {
}, let iToken = uni.getStorageSync("iToken").tokenValue;
{
label: '昨天',
value: 'yesterday'
},
{
label: '本周',
value: 'circumference'
}, {
label: '本月',
value: 'moon'
},
{
label: '自定义',
value: 'custom'
}
]
const datePicker = ref()
onShow((options) => {
let iToken = uni.getStorageSync('iToken').tokenValue
if (iToken) { if (iToken) {
getlist() getlist();
} else { } else {
uni.redirectTo({ uni.redirectTo({
url: '/pages/login/index' url: "/pages/login/index",
})
}
}); });
}
});
const yingyeE = ref(0) const yingyeE = ref(0);
const refundCount = ref(0) const refundCount = ref(0);
/** /**
* 获取统计数据 * 获取统计数据
* @param {Object} start * @param {Object} start
* @param {Object} end * @param {Object} end
*/ */
function getlist(start, end) { function getlist(start, end) {
let startTime, endTime; let beginDate, endDate;
if (selected.value == 'today') { const rangeType = timeList[timeSleIndex.value].value;
startTime = dayjs().format('YYYY-MM-DD') + ' 00:00:00' if(rangeType == "custom"){
endTime = dayjs().format('YYYY-MM-DD') + ' 23:59:59' beginDate = start.split(" ")[0];
} else if (selected.value == 'yesterday') { endDate = end.split(" ")[0];
startTime = formatTime() + ' 00:00:00' }else{
endTime = formatTime() + ' 23:59:59' beginDate = timeList[timeSleIndex.value].beginDate;
} else if (selected.value == 'circumference') { endDate = timeList[timeSleIndex.value].endDate;
var now = new Date();
var nowTime = now.getTime();
var day = now.getDay();
var oneDayTime = 24 * 60 * 60 * 1000;
//显示周一
var MondayTime = nowTime - (day - 1) * oneDayTime;
//显示周日
var SundayTime = nowTime + (7 - day) * oneDayTime;
startTime = dayjs(MondayTime).format('YYYY-MM-DD 00:00:00')
endTime = dayjs(SundayTime).format('YYYY-MM-DD 23:59:59')
} else if (selected.value == 'moon') {
startTime = dayjs().startOf('month').format('YYYY-MM-DD') + ' 00:00:00'
endTime = dayjs().endOf('month').format('YYYY-MM-DD') + ' 23:59:59'
} else if (selected.value == 'custom') {
let s = start.substring(0, start.indexOf(' '))
let e = end.substring(0, end.indexOf(' '))
startTime = s + ' 00:00:00'
endTime = e + ' 23:59:59'
} }
getTrade({ getTrade({
beginDate: startTime, beginDate: beginDate,
endDate: endTime, endDate: endDate,
shopId: uni.getStorageSync("shopId"),
rangeType: rangeType,
}).then((res) => { }).then((res) => {
refundCount.value = res.refundCount refundCount.value = res.refundCount;
for (var key in res) { for (var key in res) {
pageData.list.map(item => { pageData.list.map((item) => {
if (item.key == key) { if (item.key == key) {
item.payAmount = res[key] item.payAmount = res[key];
} }
}) });
} }
setList() setList();
let incomeAmountAll = 0; let incomeAmountAll = 0;
pageData.list.map(item => { pageData.list.map((item) => {
incomeAmountAll += (item.payAmount || 0) incomeAmountAll += item.payAmount || 0;
}) });
yingyeE.value = incomeAmountAll yingyeE.value = incomeAmountAll;
emit('totalRevenue', incomeAmountAll) emit("totalRevenue", incomeAmountAll);
}) });
} }
/**
/**
* 日期筛选确认 * 日期筛选确认
* @param {Object} e * @param {Object} e
*/ */
function datePickerConfirm(e) { function datePickerConfirm(e) {
getlist(e.start, e.end) getlist(e.start, e.end);
} }
// 获取当前时间 // 获取当前时间
function getdate() { function getdate() {
const dt = new Date(); const dt = new Date();
const y = dt.getFullYear(); const y = dt.getFullYear();
const m = (dt.getMonth() + 1 + "").padStart(2, "0"); const m = (dt.getMonth() + 1 + "").padStart(2, "0");
@@ -254,49 +239,47 @@
const mm = (dt.getMinutes() + "").padStart(2, "0"); const mm = (dt.getMinutes() + "").padStart(2, "0");
const ss = (dt.getSeconds() + "").padStart(2, "0"); const ss = (dt.getSeconds() + "").padStart(2, "0");
return `${y}-${m}-${d}`; return `${y}-${m}-${d}`;
} }
// 获取昨天时间 // 获取昨天时间
const formatTime = () => { const formatTime = () => {
let strDate = getdate() let strDate = getdate();
let dateFormat = new Date(strDate); let dateFormat = new Date(strDate);
dateFormat = dateFormat.setDate(dateFormat.getDate() - 1); dateFormat = dateFormat.setDate(dateFormat.getDate() - 1);
dateFormat = new Date(dateFormat); dateFormat = new Date(dateFormat);
let y = dateFormat.getFullYear() let y = dateFormat.getFullYear();
let m = (dateFormat.getMonth() + 1).toString().padStart(2, '0') let m = (dateFormat.getMonth() + 1).toString().padStart(2, "0");
let d = dateFormat.getDate().toString().padStart(2, '0') let d = dateFormat.getDate().toString().padStart(2, "0");
return `${y}-${m}-${d}` return `${y}-${m}-${d}`;
} };
const timeSleIndex = ref(0) function changeTime(e, index) {
selected.value = e;
function changeTime(e, index) { timeSleIndex.value = index;
selected.value = e if (e == "custom") {
timeSleIndex.value = index datePicker.value.toggle();
if (e == 'custom') {
datePicker.value.toggle()
} else { } else {
getlist() getlist();
}
} }
}
const xArr=[0,134,262,390,532] const xArr = [0, 134, 262, 390, 532];
const comBlockX = computed(() => { const comBlockX = computed(() => {
return xArr[ timeSleIndex.value] return xArr[timeSleIndex.value];
}) });
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
ul, ul,
li { li {
list-style: none; list-style: none;
padding: 0; padding: 0;
} }
.rotate { .rotate {
transform: rotate(180deg); transform: rotate(180deg);
} }
.statistics { .statistics {
padding: 0 28rpx; padding: 0 28rpx;
margin-top: 50rpx; margin-top: 50rpx;
position: relative; position: relative;
@@ -311,20 +294,21 @@
font-size: 26rpx; font-size: 26rpx;
color: #fff; color: #fff;
text-align: center; text-align: center;
background: linear-gradient(109deg, #70B9FF 0%, #629FFA 100%); background: linear-gradient(109deg, #70b9ff 0%, #629ffa 100%);
border-radius: 12rpx 12rpx 12rpx 0rpx; border-radius: 12rpx 12rpx 12rpx 0rpx;
top: -16px; top: -16px;
} }
.statisticsBox { .statisticsBox {
width: 694rpx; width: 694rpx;
background: #FFFFFF; background: #ffffff;
border-radius: 16rpx 16rpx 16rpx 16rpx; border-radius: 16rpx 16rpx 16rpx 16rpx;
padding: 48rpx 32rpx 32rpx; padding: 48rpx 32rpx 32rpx;
box-sizing: border-box; box-sizing: border-box;
margin-top: 54rpx; margin-top: 54rpx;
.bottom {} .bottom {
}
.time-wrapper { .time-wrapper {
display: flex; display: flex;
@@ -345,7 +329,7 @@
.xian { .xian {
width: 40rpx; width: 40rpx;
height: 3rpx; height: 3rpx;
background-color: #318AFE; background-color: #318afe;
// position: absolute; // position: absolute;
// left: 16rpx; // left: 16rpx;
// bottom: 0; // bottom: 0;
@@ -362,7 +346,7 @@
.line { .line {
width: 0rpx; width: 0rpx;
height: 170rpx; height: 170rpx;
border: 2rpx solid #EEE8E8; border: 2rpx solid #eee8e8;
} }
.payList { .payList {
@@ -378,24 +362,24 @@
white-space: nowrap; white-space: nowrap;
margin-top: 12rpx; margin-top: 12rpx;
>view { > view {
text-align: center; text-align: center;
} }
} }
} }
} }
} }
.circle { .circle {
width: 8rpx; width: 8rpx;
height: 8rpx; height: 8rpx;
border-radius: 8rpx; border-radius: 8rpx;
} }
.time_bootom_line { .time_bootom_line {
height: 16rpx; height: 16rpx;
position: relative; position: relative;
border-bottom: 1px solid #629FFA; border-bottom: 1px solid #629ffa;
.block { .block {
width: 18rpx; width: 18rpx;
@@ -403,13 +387,13 @@
box-sizing: border-box; box-sizing: border-box;
background: #fff; background: #fff;
position: absolute; position: absolute;
border-top: 0.5rpx solid #629FFA; border-top: 0.5rpx solid #629ffa;
border-left: 0.5rpx solid #629FFA; border-left: 0.5rpx solid #629ffa;
left: 30rpx; left: 30rpx;
top: 6rpx; top: 6rpx;
transform: rotate(45deg); transform: rotate(45deg);
transform-origin: center; transform-origin: center;
transition: all .2s linear; transition: all 0.2s linear;
}
} }
}
</style> </style>

View File

@@ -273,9 +273,11 @@
*/ */
async function loginFinishFunc(loginBizData) { async function loginFinishFunc(loginBizData) {
// 保存 token // 保存 token
console.log('loginBizData',loginBizData)
storageManage.setLogin(loginBizData) storageManage.setLogin(loginBizData)
storageManage.token(loginBizData.tokenInfo) storageManage.token(loginBizData.tokenInfo)
uni.setStorageSync("promission",loginBizData.promissionList) uni.setStorageSync("promission",loginBizData.promissionList)
uni.setStorageSync("shopId",loginBizData.shopInfo.id)
// var time1 = new Date(); // var time1 = new Date();
// var time2 = new Date(loginBizData.expireDate); // var time2 = new Date(loginBizData.expireDate);