学生消费报告

parent 389a02a3
...@@ -103,11 +103,11 @@ ...@@ -103,11 +103,11 @@
<view class="average-daily-consumption"> <view class="average-daily-consumption">
<view class="average-daily-consumption-item"> <view class="average-daily-consumption-item">
<text>¥</text> <text>¥</text>
<text class="average-daily-consumption-item-num">150.20</text> <text class="average-daily-consumption-item-num">{{dayConsumerTrend.userWeekAvgAmount}}</text>
</view> </view>
<view class="average-daily-consumption-item average-daily-consumption-item-orange"> <view class="average-daily-consumption-item average-daily-consumption-item-orange">
<text>¥</text> <text>¥</text>
<text class="average-daily-consumption-item-num">185.25</text> <text class="average-daily-consumption-item-num">{{dayConsumerTrend.classWeekAvgAmount}}</text>
</view> </view>
</view> </view>
<view class="average-daily-consumption-contrast"> <view class="average-daily-consumption-contrast">
...@@ -449,22 +449,38 @@ ...@@ -449,22 +449,38 @@
</template> </template>
<script> <script>
var gHost = "http://" + window.location.host; var gHost = "https://" + window.location.host;
if (window.location.protocol != "https:") { if (window.location.protocol != "https:") {
gHost = "http://dev-az-order-api.xiaopay.net"; gHost = "http://dev-az-order-api.xiaopay.net";
} }
//获取参数
function getQueryParams(params) {
let href = window.location.href
let query = href.substring(href.indexOf('?') + 1);
let vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
let pair = vars[i].split("=");
if (pair[0] == params) {
return pair[1];
}
}
return (false);
}
export default { export default {
name: 'ConsumptionReport', name: 'ConsumptionReport',
data() { data() {
return { return {
consumerNameIndex: 0, consumerNameIndex: 0,
dataRangeIndex: 0, dataRangeIndex: 0,
consumerNameArr: ['宁哲桂'], // 学生姓名列表 consumerNameArr: [], // 学生姓名列表
consumerInfo:[], //家长关联的学生信息
specifiedConsumerInfo:{}, //选择学生的信息
dayConsumerTrend:{}, //日消费趋势数据
// 日期范围列表 // 日期范围列表
dataRangeArr: ['12月06日~12月12日', '11月29日~12月05日', '11月22日~11月28日'], dataRangeArr: ['12月06日~12月12日', '11月29日~12月05日', '11月22日~11月28日'],
// 日消费趋势图表数据 // 日消费趋势图表数据
dailyConsumptionData: [83.67, 220.89, 66.02, 108.12, 70.30, 83.50, 315.45], dailyConsumptionData: [],
dailyConsumptionDate: ['12/06', '12/07', '12/08', '12/09', '12/10', '12/11', '12/12'], dailyConsumptionDate: [],
// 消费偏好数据 // 消费偏好数据
consumptionPreferencesData: [372.81, 145.05, 108.34], consumptionPreferencesData: [372.81, 145.05, 108.34],
} }
...@@ -487,17 +503,42 @@ ...@@ -487,17 +503,42 @@
} }
}, },
mounted() { mounted() {
this.queryPatriarchByStudent() this.queryPatriarchByStudent().then(()=>{
this.queryDayConsumerTrend()
})
this.getDataRangeArr()
}, },
methods: { methods: {
consumerChange(e) { consumerChange(e) {
this.consumerNameIndex = e.target.value this.consumerNameIndex = e.target.value
this.specifiedConsumerInfo=this.consumerInfo[this.consumerNameIndex]
this.queryDayConsumerTrend()
}, },
dataRangeChange(e) { dataRangeChange(e) {
this.dataRangeIndex = e.target.value this.dataRangeIndex = e.target.value
}, },
// 获取当前日期
getNowFormatDate(){
var date=new Date()
var seperator='-'
var year=date.getFullYear()
var month=date.getMonth()+1
var day=date.getDate()
if(month>=1&&month<=9){
month='0'+month
}
if(day>=1&&day<=9){
day='0'+day
}
var currentdate=year+seperator+month+seperator+day
return currentdate
},
// 获取日期范围列表
getDataRangeArr(){
console.log(this.getNowFormatDate())
},
// 查询家长关联的学生 // 查询家长关联的学生
async queryPatriarchByStudent() { queryPatriarchByStudent() {
let this_=this let this_=this
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
$.ajax({ $.ajax({
...@@ -506,20 +547,53 @@ ...@@ -506,20 +547,53 @@
dataType: 'json', dataType: 'json',
contentType: 'application/x-www-form-urlencoded', contentType: 'application/x-www-form-urlencoded',
data: { data: {
phone:'18942508364' phone:getQueryParams('phone')
}, },
success: function(res) { success: function(res) {
if(res.code==200){ if(res.code==200){
console.log(res) this_.consumerNameArr=res.obj.map(element=>element.name)
// this_.consumerNameArr=res.obj.name this_.consumerInfo=res.obj
this_.specifiedConsumerInfo=this_.consumerInfo[this_.consumerNameIndex]
} }
resolve()
}, },
error: function(error) { error: function(error) {
reject(error) reject(error)
} }
}) })
}).catch(e=>{}) })
},
// 查询周要点,消费金额
// 日消费趋势
queryDayConsumerTrend(){
let this_=this
return new Promise((resolve, reject) => {
$.ajax({
url: gHost + '/report-push/student-consumer-report/queryDayConsumerTrend',
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_.dayConsumerTrend=res.obj
this_.dailyConsumptionData=Object.values(this_.dayConsumerTrend.dayConsumerMap).reverse()
this_.dailyConsumptionDate=Object.keys(this_.dayConsumerTrend.dayConsumerMap).map(element=>element.substr(5).replace('-','/')).reverse()
} }
resolve()
},
error: function(error) {
reject(error)
}
})
})
},
} }
} }
</script> </script>
...@@ -531,7 +605,7 @@ ...@@ -531,7 +605,7 @@
} }
.consumption-report-container { .consumption-report-container {
width: 750rpx; width: 100%;
height: 2616rpx; height: 2616rpx;
background: #F6F6F6; background: #F6F6F6;
position: relative; position: relative;
......
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