新增订单统计

This commit is contained in:
3321822538@qq.com 2024-10-08 17:58:03 +08:00
parent 4a06aa359e
commit c84e0d0e2a
9 changed files with 581 additions and 44 deletions

View File

@ -19,8 +19,8 @@ const install = (Vue, vm) => {
// },
// });
Vue.prototype.$u.http.setConfig({
baseUrl: 'http://192.168.2.81:10002',
// baseUrl: 'https://kg.chuangtewl.com/prod-api',
// baseUrl: 'http://192.168.2.81:10002',
baseUrl: 'https://kg.chuangtewl.com/prod-api',
// loadingText: '努力加载中~',
// loadingTime: 1000,
// 设置自定义头部content-type

View File

@ -56,6 +56,10 @@
<view class="tit"> 是否展示店铺</view>
<u-switch v-model="checked" active-color="#8883F0" disabled="false"></u-switch>
</view>
<view class="listval">
<view class="tit"> 是否允许在非营业时间使用</view>
<u-switch v-model="checkeds" active-color="#8883F0" disabled="false"></u-switch>
</view>
<!-- <view class="listval">
<view class="tit"> 详细地址</view>
<view class="but"> <input type="text" placeholder="请输入详细地址" v-model="xqdz" /> </view>
@ -114,6 +118,7 @@
hour: true,
minute: true,
},
checkeds:false,
show: false,
imglist: '',
token: '',
@ -237,6 +242,7 @@
this.area = this.listobj.county
this.storeId = this.listobj.storeId
this.checked = this.listobj.show
this.checkeds = this.listobj.useOutTime
if (this.selectorvalue == 1) {
this.selectortext = '商场'
this.updateTime = this.listobj.updateTime

View File

@ -50,6 +50,10 @@
<view class="tit"> 是否展示店铺</view>
<u-switch v-model="checked" active-color="#8883F0"></u-switch>
</view>
<view class="listval">
<view class="tit"> 是否允许在非营业时间使用</view>
<u-switch v-model="checkeds" active-color="#8883F0"></u-switch>
</view>
<!-- <view class="listval">
<view class="tit"> 详细地址</view>
<view class="but"> <input type="text" placeholder="请输入详细地址" v-model="xqdz" /> </view>
@ -105,6 +109,7 @@
minute: true,
},
show: false,
checkeds:false,
imglist: '',
token: '',
userImgs: '',
@ -175,6 +180,7 @@
this.area = this.listobj.county
this.storeId = this.listobj.storeId
this.checked = this.listobj.show
this.checkeds = this.listobj.useOutTime
if (this.selectorvalue == 1) {
this.selectortext = '商场'
this.updateTime = this.listobj.updateTime
@ -324,7 +330,8 @@
contactMobile: this.lxphone,
type: this.selectorvalue,
storeId: this.storeId,
show:this.checked
show:this.checked,
useOutTime:this.checkeds
}
this.$u.put("/app/store", data).then(res => {
if (res.code == 500) {

View File

@ -48,6 +48,10 @@
<view class="tit"> 是否展示店铺</view>
<u-switch v-model="checked" active-color="#8883F0"></u-switch>
</view>
<view class="listval">
<view class="tit"> 是否允许在非营业时间使用</view>
<u-switch v-model="checkeds" active-color="#8883F0"></u-switch>
</view>
<view class="icon">
<view class="list_box">
<view class="lt">
@ -102,6 +106,7 @@
minute: true,
},
show: false,
checkeds:true,
imglist: '',
token: '',
userImgs: '',
@ -294,7 +299,8 @@
contactName: this.shopname,
contactMobile: this.lxphone,
type: this.selectorvalue,
show:this.checked
show:this.checked,
useOutTime:this.checkeds
}
this.$u.post("/app/store", data).then(res => {
if (res.code == 200) {
@ -462,7 +468,7 @@
.list {
width: 680rpx;
height: 1000rpx;
height: 1060rpx;
background: #FFFFFF;
border-radius: 24rpx 24rpx 24rpx 24rpx;
margin: auto;

View File

@ -114,9 +114,7 @@
}
}
})
} else if (res.cancel) {
}
}
}
})
},
@ -139,8 +137,7 @@
})
} else {
uni.navigateTo({
url: '/page_user/mapditu/bdAlipay?accountId=' + this.infoList.OFFLINE_IMAGE[0]
.accountId
url: '/page_user/mapditu/bdAlipay?accountId=' + this.infoList.OFFLINE_IMAGE[0].accountId
})
}
}
@ -168,7 +165,6 @@
} else {
this.yhkflag = true
}
}
})
}

View File

@ -22,6 +22,16 @@
"navigationBarTextStyle": "#FFFFFF",
"navigationStyle": "custom"
}
},{
"path": "pages/tongji",
"style": {
"navigationBarTitleText": "我的",
// "enablePullDownRefresh": true,
"navigationBarBackgroundColor": "#3996FD",
"navigationBarTextStyle": "#FFFFFF",
"navigationStyle": "custom"
}
},
{

View File

@ -15,7 +15,11 @@
<view class="input_txt" style="width: 536rpx;font-size: 24rpx;line-height: 32rpx;">
您暂未授权共享开关小程序获取你的信息将无法正常使用小程序的功能如需要正常使用请点击授权按钮打开头像昵称等信息的授权
</view>
<button class="button" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber"
<!-- <button class="button" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber"
style="margin-left: -10rpx;">
授权登录
</button> -->
<button class="button" @click="getPhoneNumber"
style="margin-left: -10rpx;">
授权登录
</button>
@ -207,40 +211,62 @@
this.usertype = '00'
}
},
getPhoneNumber(e) {
let that = this;
console.log("eeeeeeee", e);
const wxLoginAsync = () => {
return new Promise((resolve, reject) => {
wx.login({
success(res) {
if (res.code) {
let data = {
loginCode: res.code,
mobileCode: e.detail.code,
}
resolve(data);
} else {
reject(res.errMsg)
}
},
fail(err) {
reject(err)
getPhoneNumber(){
let taht = this
wx.login({
success(res) {
if (res.code) {
let data = {
loginCode: res.code,
}
})
})
}
wxLoginAsync().then(async (data) => {
this.$u.post("/app/auth/wxLogin", data).then((res) => {
if (res.code == 200) {
wx.setStorageSync('token', res.token);
that.ceshi()
taht.$u.post('/app/auth/wxLogin', data).then(res => {
if (res.code == 10003) {
uni.navigateTo({
url: '/pages/login/login'
})
} else if (res.code == 200) {
uni.setStorageSync('token', res.token)
taht.ceshi()
}
})
}
})
}).catch((err) => {
console.error(err)
},
})
},
// getPhoneNumber(e) {
// let that = this;
// console.log("eeeeeeee", e);
// const wxLoginAsync = () => {
// return new Promise((resolve, reject) => {
// wx.login({
// success(res) {
// if (res.code) {
// let data = {
// loginCode: res.code,
// mobileCode: e.detail.code,
// }
// resolve(data);
// } else {
// reject(res.errMsg)
// }
// },
// fail(err) {
// reject(err)
// }
// })
// })
// }
// wxLoginAsync().then(async (data) => {
// this.$u.post("/app/auth/wxLogin", data).then((res) => {
// if (res.code == 200) {
// wx.setStorageSync('token', res.token);
// that.ceshi()
// }
// })
// }).catch((err) => {
// console.error(err)
// })
// },
async ceshi() {
this.$u.get("/app/user/userInfo").then((res) => {
if (this.id == 1) {

View File

@ -70,6 +70,10 @@
<image src="https://api.ccttiot.com/smartmeter/img/static/ujXfMLJmerXRSRGZfGFV" mode=""></image>
<view class="txt">订单管理</view>
</view>
<view class="botcard" @click="topage(10)">
<image src="https://api.ccttiot.com/smartmeter/img/static/uKewAY8xvJN04yFpGEjl" mode=""></image>
<view class="txt">订单统计</view>
</view>
<view class="botcard" @click="topage(4)">
<image src="https://api.ccttiot.com/smartmeter/img/static/uKewAY8xvJN04yFpGEjl" mode=""></image>
<view class="txt">设备故障</view>
@ -78,10 +82,10 @@
<image src="https://api.ccttiot.com/smartmeter/img/static/uYOquvGtfb1sm5F60NgJ" mode=""></image>
<view class="txt">商家合作</view>
</view> -->
<view class="botcard" @click="topage(2)">
<!-- <view class="botcard" @click="topage(2)">
<image src="https://api.ccttiot.com/smartmeter/img/static/u6qVTFXdkQKEqE1y0J4o" mode=""></image>
<view class="txt">帮助中心</view>
</view>
</view> -->
<!-- <view class="botcard" @click="topage(3)">
<image src="https://api.ccttiot.com/smartmeter/img/static/uGlrjkSOTDXMFuuRb03l" mode=""></image>
<view class="txt">意见反馈</view>
@ -237,6 +241,10 @@
uni.navigateTo({
url:'/page_fenbao/statulist/merchant/index'
})
}else if(num == 10){
uni.navigateTo({
url:'/pages/tongji'
})
}
},
topages(num){

478
pages/tongji.vue Normal file
View File

@ -0,0 +1,478 @@
<template>
<view class="pages">
<u-navbar title="订单统计" :border-bottom="false" :background="bgc" title-color='#fff' back-icon-color="#fff"
title-size='36' height='50'></u-navbar>
<view class="time">
<view class="timetit">
时间范围
</view>
<view class="timert">
<view style="margin-right: 10rpx;" class="xztime" @click="btnks(1)">{{endtime}}</view> <view
style="margin-left: 10rpx;" class="xztime" @click="btnks(2)">{{lasttime}}</view>
<view class="qinc" @click="btnqc">×</view>
</view>
</view>
<!-- 快捷选择 -->
<view class="ordertongji">
<view class="orderday">
<view class="sj">
<text @click="btnriq(1)" :class="dateindex == 1 ? 'dateactive' : ''">今日</text>
<text @click="btnriq(2)" :class="dateindex == 2 ? 'dateactive' : ''">昨日</text>
<text @click="btnriq(3)" :class="dateindex == 3 ? 'dateactive' : ''">近七日</text>
<text @click="btnriq(4)" :class="dateindex == 4 ? 'dateactive' : ''">本月</text>
</view>
</view>
</view>
<view class="serch">
<input type="text" v-model="type" placeholder="请输入店铺名称" />
<view class="" @click="btnsear">搜索</view>
</view>
<u-picker mode="time" v-model="show" :params="params" @confirm="confirm"></u-picker>
<view class="tab">
<view class="">店铺</view>
<view class="">设备</view>
<view class="">订单数</view>
<view class="">时长</view>
<view class="">电量</view>
<view class="">金额</view>
</view>
<view class="table-container">
<view
v-for="(row, index) in tableData"
:key="row.storeId"
class="table-row"
@click="toggleRow(index,row.storeId)">
<view class="row-header">
<text>{{ row.storeName }}</text>
<text class="">{{row.deviceCount}}</text>
<text class="">{{row.orderCount}}</text>
<text class="">{{row.formattedDuration}}</text>
<text class="">{{row.ele}}</text>
<text class="">{{row.arrivalAmount}}</text>
</view>
<view v-if="!row.folded" class="row-details" v-for="(val,index) in vallist" :key="index">
<view></view>
<view>{{ val.deviceName }}</view>
<view>{{ val.orderCount }}</view>
<view>{{ val.formattedDuration}}</view>
<view>{{ val.ele}}</view>
<view>{{ val.arrivalAmount }}</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
bgc: {
backgroundColor: "#8883F0",
},
statusList: '',
type: '',
endtime: '',
lasttime: '',
params: {
year: true,
month: true,
day: true,
hour: false,
minute: false,
second: false
},
show: false,
num: '',
tableData: [],
vallist:[],
previouslyExpandedIndex: null,
dateindex:1
}
},
onLoad() {
const todayStartTime = this.getTodayStartTime()
this.endtime = this.formatDate(todayStartTime)
this.lasttime = this.formatDate(todayStartTime)
this.getList()
},
onShow() {
},
//
onShareAppMessage: function() {
return {
title: '创想物联',
path: '/pages/shouye/index'
}
},
//
onShareTimeline: function() {
return {
title: '创想物联',
query: '',
path: '/pages/shouye/index'
}
},
methods: {
btnriq(num) {
this.dateindex = num
if (num == 1) {
let today = new Date();
this.endtime = this.formatDate(today)
this.lasttime = this.formatDate(today)
this.getList()
} else if (num == 2) {
let yesterday = new Date()
yesterday.setDate(yesterday.getDate() - 1)
this.endtime = this.formatDate(yesterday)
this.lasttime = this.formatDate(yesterday)
this.getList()
} else if (num == 3) {
let today = new Date()
let firstDayOfMonth = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 6)
this.endtime = this.formatDate(firstDayOfMonth)
this.lasttime = this.formatDate(new Date())
this.getList()
} else if (num == 4) {
let today = new Date()
let firstDayOfLastMonth = new Date(today.getFullYear(), today.getMonth(), 1)
let lastDayOfLastMonth = new Date(today.getFullYear(), today.getMonth(), today.getDate())
this.endtime = this.formatDate(firstDayOfLastMonth)
this.lasttime = this.formatDate(lastDayOfLastMonth)
this.getList()
}
},
formatDate(date) {
let year = date.getFullYear()
let month = String(date.getMonth() + 1).padStart(2, '0')
let day = String(date.getDate()).padStart(2, '0')
return `${year}-${month}-${day}`
},
//
getList(){
this.$u.get(`/mch/dashboard/businessStatisticsByStore?storeName=${this.type}&dateRange=${this.endtime+ ',' +this.lasttime}`).then((res) => {
if (res.code == 200) {
let arr = res.data
this.tableData = arr.map(item => ({
...item,
folded: true,
formattedDuration: this.formatDuration(item.seconds)
}))
}
})
},
formatDuration(seconds) {
const hours = Math.floor(seconds / 3600);
const minutes = Math.floor((seconds % 3600) / 60);
return `${hours.toString().padStart(2, '0')}小时${minutes.toString().padStart(2, '0')}分钟`;
},
//
btnsear(){
if(this.endtime == '' || this.endtime == ''){
uni.showToast({
title: '时间范围不能为空',
icon: 'none',
duration:2000
})
}else{
this.getList()
this.dateindex = ''
}
},
//
getTodayStartTime() {
const now = new Date();
const startOfDay = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0);
return startOfDay;
},
//
formatDate(date) {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // 01
const day = String(date.getDate()).padStart(2, '0'); //
const hours = String(date.getHours()).padStart(2, '0'); // 00
const minutes = String(date.getMinutes()).padStart(2, '0'); //
const seconds = String(date.getSeconds()).padStart(2, '0'); //
return `${year}-${month}-${day} `;
},
//
toggleRow(index,storeId) {
if(this.endtime == '' || this.endtime == ''){
uni.showToast({
title: '时间范围不能为空',
icon: 'none',
duration:2000
})
}else{
this.$u.get(`/mch/dashboard/businessStatisticsByDevice?storeId=${storeId == null ? '' : storeId}&dateRange=${this.endtime+ ',' +this.lasttime}`).then(res => {
if(res.code == 200){
let arr = res.data
this.vallist = arr.map(item => ({
...item,
formattedDuration: this.formatDuration(item.seconds)
}))
//
if (this.previouslyExpandedIndex !== null && this.previouslyExpandedIndex !== index) {
this.$set(this.tableData, this.previouslyExpandedIndex, {
...this.tableData[this.previouslyExpandedIndex],
folded: true
});
}
//
this.$set(this.tableData, index, {
...this.tableData[index],
folded: false
});
//
this.previouslyExpandedIndex = index;
}
})
}
},
//
btnks(num) {
this.show = true
if (num == 1) {
this.num = 1
} else {
this.num = 2
}
},
//
btnqc() {
this.endtime = ''
this.lasttime = ''
},
//
confirm(e) {
if (this.num == 1) {
this.endtime = e.year + '-' + e.month + '-' + e.day
} else {
this.lasttime = e.year + '-' + e.month + '-' + e.day
}
},
},
}
</script>
<style lang="scss">
/deep/ .u-title {
padding-bottom: 22rpx;
}
/deep/ .uicon-nav-back {
padding-bottom: 22rpx;
}
.dateactive {
background: #E3E3FF !important;
color: #3D3D3D !important;
}
.ordertongji {
width: 658rpx;
background: #FFFFFF;
border-radius: 24rpx 24rpx 24rpx 24rpx;
margin: auto;
margin-top: 20rpx;
.shuju {
display: flex;
justify-content: space-between;
box-sizing: border-box;
margin-top: 24rpx;
.sjone{
width: 170rpx;
margin: auto;
text-align: center;
.je{
font-size: 40rpx;
color: #3D3D3D;
font-weight: 600;
}
.shu{
font-size: 20rpx;
color: #3D3D3D;
margin-top: 20rpx;
}
}
}
.date {
padding-left: 80rpx;
padding-right: 80rpx;
box-sizing: border-box;
display: flex;
justify-content: space-between;
margin-top: 26rpx;
text {
padding: 6rpx 18rpx;
box-sizing: border-box;
background: #eee;
border-radius: 10rpx 10rpx 10rpx 10rpx;
font-size: 24rpx;
color: #808080;
}
}
.orderday {
display: flex;
justify-content: space-between;
width: 100%;
padding: 10rpx 12rpx;
box-sizing: border-box;
text {
margin-right: 10rpx;
border-radius: 20rpx;
text-align: center;
display: inline-block;
width: 148rpx;
height: 84rpx;
text-align: center;
line-height: 84rpx;
color: #979797;
background-color: #f5f5f5;
}
}
}
.table-container {
padding: 20rpx;
}
.table-row {
margin-bottom: 40rpx;
border-bottom: 1rpx solid #ddd;
}
.row-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10rpx;
background-color: #f5f5f5;
cursor: pointer;
height: 100rpx;
text{
width: 16%;
text-align: center;
overflow: scroll;
}
}
.row-details {
padding: 10rpx;
background-color: #fff;
display: flex;
justify-content: space-between;
align-items: center;
view{
width: 16%;
text-align: center;
overflow: scroll;
}
}
.folded-count {
margin-top: 20rpx;
font-size: 30rpx;
text-align: center;
}
.list{
padding: 0 30rpx;
box-sizing: border-box;
}
.tab {
display: flex;
justify-content: space-between;
padding: 0 30rpx;
box-sizing: border-box;
background-color: #fff;
height: 50rpx;
view{
width: 16%;
text-align: center;
overflow: scroll;
}
}
.serch {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 40rpx;
box-sizing: border-box;
height: 120rpx;
background-color: #fff;
input {
width: 100%;
height: 60rpx;
line-height: 60rpx;
padding-left: 30rpx;
border: 1px solid #ccc;
border-radius: 10rpx;
}
view {
width: 170rpx;
height: 60rpx;
line-height: 60rpx;
text-align: center;
color: #fff;
background-color: #8883F0;
border-radius: 10rpx;
margin-left: 30rpx;
}
}
.time {
height: 150rpx;
padding-top: 40rpx !important;
padding: 0 40rpx;
box-sizing: border-box;
background-color: #fff;
.timetit {
font-weight: 600;
font-size: 30rpx;
}
.timert {
display: flex;
line-height: 60rpx;
justify-content: space-between;
margin-top: 20rpx;
.xztime {
width: 300rpx;
height: 60rpx;
border: 1px solid #ccc;
border-radius: 10rpx;
text-align: center;
}
.qinc {
font-size: 50rpx;
color: #ccc;
width: 80rpx;
height: 60rpx;
text-align: center;
}
}
}
page {
background-color: #fff !important;
}
</style>