Commit 6bebf5dd authored by 李智书's avatar 李智书

1.新增-校园消费数据H5

parent 7b9ea81f
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -573,6 +573,22 @@ ...@@ -573,6 +573,22 @@
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
},
{
"path": "pages/ApplyConsumption/businessRecord/consumeRecord/consumeRecord",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": "校园消费数据",
"enablePullDownRefresh": false
}
},
{
"path": "pages/ApplyConsumption/businessRecord/transactionDetails/transactionDetails",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": "设备交易明细",
"enablePullDownRefresh": false
}
} }
], ],
"globalStyle": { "globalStyle": {
......
<template>
<view class="consumeRecord">
<van-tabs v-model="active" animated sticky color="#01CB88" title-active-color="#1B1B1B"
title-inactive-color="rgba(0,0,0,0.5)" @change="changeTabs">
<van-tab title="门店">
<!-- 标题 -->
<template #title>
<view :class="active!=1?'custstyle':'default'">门店</view>
</template>
<!-- 内容 -->
<template #default>
<Store v-if="active!=1" :isperiod="isperiod" :StoreInfo_="StoreInfo_" :flowsList="flowsList"
:storeInfo="storeInfo" @selectTime="selectTime" @selectStore="selectStore"
:starttime="starttime" :endtime="endtime" :calendar="calendar" :ImgUrl="ImgUrl"
:ImgUrl2="ImgUrl2"></Store>
</template>
</van-tab>
<van-tab title="设备">
<!-- 标题 -->
<template #title>
<view :class="active==1?'custstyle':'default'">设备</view>
</template>
<!-- 内容 -->
<template #default>
<Device v-if="active==1" :isperiod="isperiod" :StoreInfo_="StoreInfo_" :deviceList_="deviceList_"
:storeInfo="storeInfo" @transactionDetails="transactionDetails" @selectStore="selectStore"
@selectTime="selectTime" :showPicker="showPicker" :calendar="calendar" :ImgUrl="ImgUrl"
:ImgUrl2="ImgUrl2"></Device>
</template>
</van-tab>
</van-tabs>
<!-- 选择日期组件 -->
<van-calendar v-model="calendar" :min-date="minDate" :max-range="93" :show-confirm="true" position="bottom"
color="#01CB88" type="range" @confirm="onConfirm" />
<!-- 门店选择 -->
<van-popup v-model="showPicker" round position="bottom">
<view class="" style="height: 600rpx;">
<van-picker title="门店选择" show-toolbar :columns="stores" @confirm="onConfirmStore"
@cancel="onCancelStore" @change="onChangeStore">
<template #option="option">
<view class="">
{{option.storeName}}
</view>
</template>
</van-picker>
</view>
</van-popup>
</view>
</template>
<script>
import Store from "../components/store/store.vue"
import Device from "../components/device/device.vue"
import dayjs from "dayjs"
import isBetween from "dayjs/plugin/isBetween"
dayjs.extend(isBetween)
// const starttime = dayjs().subtract(1, 'day').format('YYYY/MM/DD')
const starttime = dayjs().format('YYYY/MM/DD')
const endtime = dayjs().format('YYYY/MM/DD')
import login from "../mixin/login.js"
// 高峰期限制
// "上午" 06:00:00-08:30:00
// "中午" 11:00:00-13:00:00
// "晚上" 17:00:00-19:00:00
const s1 = dayjs().format('YYYY-MM-DD 06:00:00')
const s2 = dayjs().format('YYYY-MM-DD 08:30:00')
const z1 = dayjs().format('YYYY-MM-DD 11:00:00')
const z2 = dayjs().format('YYYY-MM-DD 13:00:00')
const x1 = dayjs().format('YYYY-MM-DD 17:00:00')
const x2 = dayjs().format('YYYY-MM-DD 19:00:00')
const isperiod = dayjs().isBetween(s1, s2) || dayjs().isBetween(z1, z2) || dayjs().isBetween(x1,
x2)
console.warn("高峰期====>>>", isperiod)
import {
Dialog,
Toast
} from 'vant';
import config from '../../common/config.js'
import {
requestGet,
requestPost
} from '../../common/request.js'
export default {
name: "consumeRecord",
mixins: [login],
components: {
Store,
Device
},
data() {
return {
// 是否高峰期
isperiod,
// 默认时间
starttime,
endtime,
ImgUrl: this.$ImgUrl,
ImgUrl2: this.$ImgUrl + 'xzfalipay/',
active: 0,
// 日历选择弹框
calendar: false,
// 门店选择弹框
showPicker: false,
minDate: new Date(2021, 0, 1),
// 门店列表
stores: [],
// 选择的门店
StoreInfo_: {},
// 门店流水列表数据
flowsList: [],
// 门店流水列表数据
deviceList_: [],
pageIndex: 1,
pageSize: 20,
}
},
onLoad: function(options) {
},
methods: {
//门店设备
async DeviceList(storeId) {
// 高峰期禁止请求接口
if (this.isperiod) {
return
}
const loading = Toast.loading('数据加载中...');
let data = await requestPost('/cgi-xpay/app/busi/DeviceList', {
"businessId": 0,
"storeId": storeId || 0
})
loading.clear();
if (data['code'] != 200) {
await Dialog({
title: '温馨提示',
message: "门店设备查询失败",
confirmButtonText: "知道了"
})
return
}
let jsonData = JSON.parse(JSON.stringify(data || {}))
const backData = jsonData.data.backData || []
this.deviceList_ = backData
},
//门店流水
async StoreFlows(storeId) {
// 高峰期禁止请求接口
if (this.isperiod) {
return
}
const loading = Toast.loading('数据加载中...');
let data = await requestPost('/cgi-xpay/app/busi/StoreFlows', {
"businessId": 0,
"startDate": this.starttime.replaceAll("/", "-"),
"endDate": this.endtime.replaceAll("/", "-"),
"pageIndex": this.pageIndex,
"pageSize": this.pageSize,
"storeId": storeId || 0
})
loading.clear();
if (data['code'] != 200) {
await Dialog({
title: '温馨提示',
message: "门店流水查询失败",
confirmButtonText: "知道了"
})
return
}
let jsonData = JSON.parse(JSON.stringify(data || {}))
const backData = jsonData.data.backData || []
const totalCnt = jsonData.data.totalCnt || 0
this.flowsList = backData.map((v, index) => {
v['amount'] = parseFloat(v.amount / 100).toFixed(2)
return v
})
},
// 设备查看明细
async transactionDetails(item, index) {
const loading = Toast.loading('数据加载中...');
console.warn(item, index)
uni.setStorageSync("details", item)
uni.navigateTo({
url: "../transactionDetails/transactionDetails",
success: () => {
loading.clear();
}
})
},
onConfirmStore(value, index) {
this.selectStore()
const StoreInfo_ = this.stores[index]
this.StoreInfo_ = StoreInfo_
// 查询门店交易数据
if (this.active === 0) {
this.StoreFlows(StoreInfo_['id'])
} else {
this.DeviceList(StoreInfo_['id'])
}
},
onChangeStore(picker, value, index) {
},
onCancelStore() {
this.selectStore()
},
// 选择门店
selectStore() {
this.showPicker = !this.showPicker
},
// 组件提交时间
onConfirm(date) {
const [start, end] = date;
// this.calendar = false;
this.starttime = dayjs(start).format('YYYY/MM/DD')
this.endtime = dayjs(end).format('YYYY/MM/DD')
this.calendar = false
// 查询门店交易数据
if (this.active === 0) {
this.StoreFlows(this.StoreInfo_['id'])
} else {
this.DeviceList(this.StoreInfo_['id'])
}
},
// 选择时间
selectTime(status) {
this.calendar = status
},
// tab切换
async changeTabs(e) {
// 清空选择的门店信息
this.StoreInfo_ = {}
if (e === 0) {
this.StoreFlows()
} else {
this.DeviceList()
}
}
}
}
</script>
<style>
page {
height: 100vh;
background: #F3F3F3;
}
.consumeRecord {
.default {
font-size: 32rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: rgba(0, 0, 0, 0.5);
}
.van-tabs__line {
background: #01CB88 !important;
border-radius: 8rpx !important;
width: 68rpx;
height: 6rpx;
}
.custstyle {
font-size: 34rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #1B1B1B;
}
}
</style>
\ No newline at end of file
/**
* 支付宝商家端查询门店/设备交易数据
*/
import {
Dialog
} from 'vant';
import config from '../../common/config.js'
import {
requestGet,
requestPost
} from '../../common/request.js'
export default {
data() {
return {
path: "",
// 门店初始化数据
storeInfo: {}
};
},
onLoad: function(options) {
if (!options['token']) {
Dialog({
title: '系统提示',
message: 'token为空!',
confirmButtonText: "知道了"
}).then(res => {
window.close()
})
return;
}
this.UserLogin(options['token'])
if (options['path']) {
this.path = options['path'] || ""
}
},
onShow: function() {
},
onunload: function() {
},
methods: {
//登录获取用户信息
async UserLogin(token) {
let data = await requestPost('/cgi-xpay/app/Login', {
grantType: 'GT_azCloud_business',
code: token,
})
if (data['code'] != 200) {
await Dialog({
title: '温馨提示',
message: data['message'],
confirmButtonText: "知道了"
})
return
}
uni.setStorageSync('token', data.data['token'])
// 门店初始化数据
this.StoreData()
// 门店商家列表
this.StoreList()
},
//门店初始化数据
async StoreData(token) {
let data = await requestPost('/cgi-xpay/app/busi/StoreData', {})
if (data['code'] != 200) {
await Dialog({
title: '温馨提示',
message: "门店初始化数据",
confirmButtonText: "知道了"
})
return
}
let jsonData = JSON.parse(JSON.stringify(data.data))
jsonData['offlineDeviceCnt'] = jsonData['offlineDeviceCnt'] || 0
jsonData['onlineDeviceCnt'] = jsonData['onlineDeviceCnt'] || 0
jsonData['totalAmount'] = ((jsonData['totalAmount'] || 0) / 100).toFixed(2)
jsonData['totalCnt'] = jsonData['totalCnt'] || 0
jsonData["cateringData"] = jsonData["cateringData"].map((v, index) => {
if (v['mealType'] == "早餐") {
v['mealTypePng'] = "xzf/h5/zao.png"
}
if (v['mealType'] == "中餐") {
v['mealTypePng'] = "xzf/h5/wu.png"
}
if (v['mealType'] == "晚餐") {
v['mealTypePng'] = "xzf/h5/wan.png"
}
if (v['mealType'] == "夜宵") {
v['mealTypePng'] = "xzf/h5/ye.png"
}
if (v['mealType'] == "夜夜宵") {
v['mealTypePng'] = "xzf/h5/yeye.png"
}
if (parseInt(jsonData['totalAmount']) === 0) {
v['perc'] = 0
} else {
v['perc'] = parseFloat(v.dealAmount / jsonData['totalAmount'])
}
v['dealAmount'] = (v['dealAmount'] / 100).toFixed(2)
return v
})
this.storeInfo = jsonData
},
//门商家列表
async StoreList(token) {
let data = await requestPost('/cgi-xpay/app/busi/StoreList', {})
if (data['code'] != 200) {
await Dialog({
title: '温馨提示',
message: "门商家列表查询失败",
confirmButtonText: "知道了"
})
return
}
let jsonData = JSON.parse(JSON.stringify(data.data || []))
this.stores = [{
id: 0,
storeName: "全部门店"
}, ...jsonData]
// 查询门店交易数据
if (this.active === 0) {
this.StoreFlows()
}
}
}
}
\ No newline at end of file
...@@ -278,7 +278,7 @@ ...@@ -278,7 +278,7 @@
:key="index" class="consumer-details-body" :key="index" class="consumer-details-body"
:style="{background:Number.isInteger(index/2)?'#FFFFFF':'#F8F8F7'}"> :style="{background:Number.isInteger(index/2)?'#FFFFFF':'#F8F8F7'}">
<view class="consumer-details-body-item" v-for="(e,i) in item.consumerDetailsArr" <view class="consumer-details-body-item" v-for="(e,i) in item.consumerDetailsArr"
:class="i?'':'consumer-details-body-data'"> :class="i?'':'consumer-details-body-data'" :key="i">
<text>{{e}}</text> <text>{{e}}</text>
</view> </view>
</view> </view>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment