Commit 94b4e340 authored by aifen@azjy1.onexmail.com's avatar aifen@azjy1.onexmail.com

Merge branch 'V1.5.24_feature' of...

Merge branch 'V1.5.24_feature' of https://git.xiaopay.net/lizhishu/xzf_uniapp-wechat-web into V1.5.24_feature

# Conflicts:
#	src/pages/ConsumptionReport/ConsumptionReport.vue
parents f601ac3a a0507f62
...@@ -20,8 +20,9 @@ ...@@ -20,8 +20,9 @@
<view class="consumption-report-info"> <view class="consumption-report-info">
<view class="consumption-report-data"> <view class="consumption-report-data">
<view class="consumer-list"> <view class="consumer-list">
<picker @change="dataRangeChange" :value="dataRangeIndex" :range="dataRangeArr"> <picker @change="dataRangeChange" :value="dataRangeIndex" :range="dataRangeArr"
<view class="uni-input">{{dataRangeArr[dataRangeIndex]}}</view> range-key="week">
<view class="uni-input">{{dataRangeArr[dataRangeIndex].week||""}}</view>
</picker> </picker>
</view> </view>
</view> </view>
...@@ -468,6 +469,8 @@ ...@@ -468,6 +469,8 @@
} }
return (false); return (false);
} }
// 时间处理模块
import dayjs from 'dayjs'
export default { export default {
name: 'ConsumptionReport', name: 'ConsumptionReport',
data() { data() {
...@@ -512,6 +515,21 @@ ...@@ -512,6 +515,21 @@
this.queryStudentConsumerPreference() this.queryStudentConsumerPreference()
}) })
this.getDataRangeArr() this.getDataRangeArr()
let tmpArr = []
// 获取时间
for (let i = 1; i <= 4; i++) {
let startWeek = dayjs().subtract(i, 'week').startOf('week').add(1, 'day');
let endWeek = dayjs().subtract(i, 'week').endOf('week').add(1, 'day');
// console.warn("一周开始-----", dayjs().subtract(i, 'week').startOf('week').add(1, 'day').format("YYYY年MM月DD日"))
// console.warn("一周结束-----", dayjs().subtract(i, 'week').endOf('week').add(1, 'day').format("YYYY年MM月DD日"))
tmpArr.push({
week: (startWeek.format("YYYY年MM月DD日")) + '~' + (endWeek.format("YYYY年MM月DD日")),
startDate: startWeek.format("YYYY-MM-DD"),
endDate: endWeek.format("YYYY-MM-DD")
})
}
this.dataRangeArr = tmpArr
}, },
methods: { methods: {
consumerChange(e) { consumerChange(e) {
...@@ -521,6 +539,7 @@ ...@@ -521,6 +539,7 @@
}, },
dataRangeChange(e) { dataRangeChange(e) {
this.dataRangeIndex = e.target.value this.dataRangeIndex = e.target.value
this.queryDayConsumerTrend()
}, },
// 获取当前日期 // 获取当前日期
getNowFormatDate() { getNowFormatDate() {
...@@ -570,108 +589,53 @@ ...@@ -570,108 +589,53 @@
}) })
}, },
// 查询周要点,消费金额 // 查询周要点,消费金额
queryWeekConsumerAmout() {
let this_ = this
return new Promise((resolve, reject) => {
$.ajax({
url: gHost + '/report-push/student-consumer-report/queryWeekConsumerAmout',
type: 'get',
dataType: 'json',
contentType: 'application/x-www-form-urlencoded',
data: {
userId: this_.specifiedConsumerInfo.id,
schoolId: this_.specifiedConsumerInfo.schoolid,
startDate: '2021-12-06',
endDate: '2021-12-12'
},
success: function(res) {
if (res.code == 200) {
this_.weekConsumerAmout = res.obj
this_.weekConsumerTrend(this_.weekConsumerAmout.compareStatus)
}
resolve()
},
error: function(error) {
reject(error)
}
})
})
},
// 周消费趋势箭头
weekConsumerTrend(compareStatus) {
switch (compareStatus) {
case 0:
this.condition = ''
this.trendimg = '../../static/images/trend0.png'
return
case 1:
this.condition = '+'
this.trendimg = '../../static/images/trend.png'
return
case 2:
this.condition = '-'
this.trendimg = '../../static/images/trend2.png'
return
}
},
// 日消费趋势 // 日消费趋势
queryDayConsumerTrend() { async queryDayConsumerTrend() {
let this_ = this let this_ = this
return new Promise((resolve, reject) => { try {
$.ajax({ await new Promise((resolve, reject) => {
url: gHost + '/report-push/student-consumer-report/queryDayConsumerTrend', $.ajax({
type: 'get', url: gHost + '/report-push/student-consumer-report/queryDayConsumerTrend',
dataType: 'json', type: 'get',
contentType: 'application/x-www-form-urlencoded', dataType: 'json',
data: { contentType: 'application/x-www-form-urlencoded',
userId: this_.specifiedConsumerInfo.id, data: {
schoolId: this_.specifiedConsumerInfo.schoolid, userId: this_.specifiedConsumerInfo.id || "",
startDate: '2021-12-06', schoolId: this_.specifiedConsumerInfo.schoolid || "",
endDate: '2021-12-12' startDate: this_.dataRangeArr[this_.dataRangeIndex] ? this_
}, .dataRangeArr[this_.dataRangeIndex].startDate : "",
success: function(res) { endDate: this_.dataRangeArr[this_.dataRangeIndex] ? this_.dataRangeArr[
if (res.code == 200) { this_.dataRangeIndex].endDate : "",
this_.dayConsumerTrend = res.obj },
this_.dailyConsumptionData = Object.values(this_.dayConsumerTrend success: function(res) {
.dayConsumerMap).reverse() if (res.code == 200) {
this_.dailyConsumptionDate = Object.keys(this_.dayConsumerTrend this_.dayConsumerTrend = res.obj
.dayConsumerMap).map(element => element.substr(5).replace('-', this_.dailyConsumptionData = Object.values(this_
'/')).reverse() .dayConsumerTrend
.dayConsumerMap).reverse()
this_.dailyConsumptionDate = Object.keys(this_.dayConsumerTrend
.dayConsumerMap).map(element => element.substr(5)
.replace(
'-',
'/')).reverse()
resolve()
return
}
reject(res.message)
},
error: function(error) {
reject(error)
} }
resolve() })
},
error: function(error) {
reject(error)
}
}) })
}) } catch (e) {
}, console.warn(e)
// 查询学生消费偏好类型 //TODO handle the exception
queryStudentConsumerPreference() { uni.showModal({
let this_ = this content: e.message
return new Promise((resolve, reject) => {
$.ajax({
url: gHost + '/report-push/student-consumer-report/queryStudentConsumerPreference',
type: 'get',
dataType: 'json',
contentType: 'application/x-www-form-urlencoded',
data: {
userId: this_.specifiedConsumerInfo.id,
schoolId: this_.specifiedConsumerInfo.schoolid,
startDate: '2021-12-06',
endDate: '2021-12-12'
},
success: function(res) {
if (res.code == 200) {
this_.consumptionPreferencesData=res.obj
}
resolve()
},
error: function(error) {
reject(error)
}
}) })
}) }
}, },
// 消费偏好百分比 // 消费偏好百分比
consumerPreferencePercent(num){ consumerPreferencePercent(num){
......
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