|
|
@@ -22,8 +22,8 @@
|
|
|
<view class="show-txt-label">消费走势图</view>
|
|
|
</view>
|
|
|
<view class="charts-box">
|
|
|
- <qiun-data-charts canvasId="canvasAirId" type="line" :chartData="chartData" :opts="chartOpts" :ontouch="true" :canvas2d="false"
|
|
|
- id="chartsAir"/>
|
|
|
+ <qiun-data-charts canvasId="canvasAirId" type="line" :chartData="chartData" :opts="chartOpts"
|
|
|
+ :ontouch="true" :canvas2d="false" id="chartsAir" />
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="line"></view>
|
|
|
@@ -60,7 +60,7 @@
|
|
|
id_card: '', // 身份证号
|
|
|
screenHeight: 0,
|
|
|
years: this.$getDate('get_year'), // 候选年份
|
|
|
- months: ['01月', '02月', '03月', '04月', '05月', '06月', '07月', '08月', '09月', '10月', '11月', '12月'], // 候选月份
|
|
|
+ months: ['全部', '01月', '02月', '03月', '04月', '05月', '06月', '07月', '08月', '09月', '10月', '11月', '12月'], // 候选月份
|
|
|
selYearIndex: 0, // 选择的年份index
|
|
|
selMonthindex: this.$getDate('get_month'), // 选择的月份index
|
|
|
selYearMonth: '', // 选择的年份、月份
|
|
|
@@ -69,10 +69,10 @@
|
|
|
series: []
|
|
|
},
|
|
|
chartDataInit: { // 如果 chartData 没有数据,解决一直打转的问题
|
|
|
- "categories": ["无数据", "无数据", "无数据", "无数据", "无数据"],
|
|
|
+ "categories": ["无数据"],
|
|
|
"series": [{
|
|
|
"name": "金额",
|
|
|
- "data": ["0.00", "0.00", "0.00", "0.00", "0.00"]
|
|
|
+ "data": ["0.00"]
|
|
|
}]
|
|
|
},
|
|
|
chartOpts: {
|
|
|
@@ -144,7 +144,7 @@
|
|
|
/**
|
|
|
* 查询当月消费
|
|
|
*/
|
|
|
- async getRecord() {
|
|
|
+ async getRecord(param) {
|
|
|
if (this.id_card == '') {
|
|
|
uni.showToast({
|
|
|
icon: 'none',
|
|
|
@@ -153,6 +153,26 @@
|
|
|
});
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ let pYear = this.years[this.selYearIndex].substring(0, 4);
|
|
|
+ let pData = '';
|
|
|
+ if (param === '全部') {
|
|
|
+ pData = {
|
|
|
+ page: 1,
|
|
|
+ rows: 90,
|
|
|
+ sfzh: this.id_card,
|
|
|
+ con_year: pYear
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ pData = {
|
|
|
+ page: 1,
|
|
|
+ rows: 90,
|
|
|
+ sfzh: this.id_card,
|
|
|
+ con_year: pYear,
|
|
|
+ con_month: this.selYearMonth
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
let res = await this.$myRequest({
|
|
|
host: this.ceshi,
|
|
|
url: '/airManage/consumequeryOwnPage.action',
|
|
|
@@ -160,12 +180,7 @@
|
|
|
header: {
|
|
|
'content-type': 'application/x-www-form-urlencoded'
|
|
|
},
|
|
|
- data: {
|
|
|
- page: 1,
|
|
|
- rows: 90,
|
|
|
- sfzh: this.id_card,
|
|
|
- con_month: this.selYearMonth
|
|
|
- }
|
|
|
+ data: pData
|
|
|
})
|
|
|
|
|
|
// console.log(res.data);
|
|
|
@@ -216,6 +231,13 @@
|
|
|
* 获取消费走势图数据
|
|
|
*/
|
|
|
async getRechargeRecord() {
|
|
|
+ let pYear = this.years[this.selYearIndex].substring(0, 4);
|
|
|
+ let pMonth = '';
|
|
|
+ if (this.selMonthindex == 0) {
|
|
|
+ pMonth = this.months[this.selMonthindex].substring(0, 2);
|
|
|
+ } else {
|
|
|
+ pMonth = pYear + '-' + this.months[this.selMonthindex].substring(0, 2);
|
|
|
+ }
|
|
|
let res = await this.$myRequest({
|
|
|
host: this.ceshi,
|
|
|
url: '/airManage/consumequeryOwnConTong.action',
|
|
|
@@ -224,8 +246,10 @@
|
|
|
'content-type': 'application/x-www-form-urlencoded'
|
|
|
},
|
|
|
data: {
|
|
|
- // sfzh: '360313110'
|
|
|
- sfzh: this.id_card
|
|
|
+ // sfzh: '421182199112100031'
|
|
|
+ sfzh: this.id_card,
|
|
|
+ con_year: pYear,
|
|
|
+ con_month: pMonth
|
|
|
}
|
|
|
})
|
|
|
|
|
|
@@ -255,45 +279,70 @@
|
|
|
_this.chartData = _this.chartDataInit
|
|
|
}, 1000);
|
|
|
|
|
|
- return
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
let chrt_data = {
|
|
|
categories: [],
|
|
|
series: []
|
|
|
- }
|
|
|
- let elc_max = -1.0
|
|
|
- let dt = ''
|
|
|
- let temp = 0
|
|
|
- let data = []
|
|
|
- for (var i = 0; i < tmpdata.data.length; i++) {
|
|
|
- dt = tmpdata.data[i].month
|
|
|
- chrt_data.categories.push(parseInt(dt.substr(dt.indexOf('-') + 1, dt.length)) + '月')
|
|
|
- temp = tmpdata.data[i].num
|
|
|
- temp = temp.toFixed(2)
|
|
|
- data.push(temp)
|
|
|
- if (parseFloat(temp) > parseFloat(elc_max)) {
|
|
|
- elc_max = temp
|
|
|
+ };
|
|
|
+ let elc_max = -1.0;
|
|
|
+ let dt = '';
|
|
|
+ let temp = 0;
|
|
|
+ let data = [];
|
|
|
+ if (this.selMonthindex == 0) {
|
|
|
+ let echartData = tmpdata.data.sort((a, b) => a.month.localeCompare(b.month));
|
|
|
+ for (var i = 0; i < echartData.length; i++) {
|
|
|
+ dt = echartData[i].month;
|
|
|
+ chrt_data.categories.push(parseInt(dt.substr(dt.lastIndexOf('-') + 1, dt.length)) + '月');
|
|
|
+ temp = echartData[i].num;
|
|
|
+ temp = temp.toFixed(2);
|
|
|
+ data.push(temp);
|
|
|
+ if (parseFloat(temp) > parseFloat(elc_max)) {
|
|
|
+ elc_max = temp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ let echartData = tmpdata.data.sort((a, b) => a.day.localeCompare(b.day));
|
|
|
+ for (var i = 0; i < echartData.length; i++) {
|
|
|
+ dt = echartData[i].day;
|
|
|
+ chrt_data.categories.push(parseInt(dt.substr(dt.lastIndexOf('-') + 1, dt.length)) + '日');
|
|
|
+ temp = echartData[i].num;
|
|
|
+ temp = temp.toFixed(2);
|
|
|
+ data.push(temp);
|
|
|
+ if (parseFloat(temp) > parseFloat(elc_max)) {
|
|
|
+ elc_max = temp;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
let items = {
|
|
|
name: '金额',
|
|
|
data: data
|
|
|
- }
|
|
|
- chrt_data.series.push(items)
|
|
|
- let m = parseFloat(Math.abs(elc_max))
|
|
|
+ };
|
|
|
+ chrt_data.series.push(items);
|
|
|
+ let m = parseFloat(Math.abs(elc_max));
|
|
|
// console.log(chrt_data);
|
|
|
if (elc_max == 0.0) {
|
|
|
setTimeout(() => {
|
|
|
- this.chartOpts.yAxis.data[0].max = parseInt(10)
|
|
|
+ this.chartOpts.yAxis.data[0].max = parseInt(10);
|
|
|
this.chartData = chrt_data;
|
|
|
}, 1000);
|
|
|
} else {
|
|
|
setTimeout(() => {
|
|
|
- this.chartOpts.yAxis.data[0].max = parseInt(m + 5)
|
|
|
+ this.chartOpts.yAxis.data[0].max = parseInt(m + 5);
|
|
|
this.chartData = chrt_data;
|
|
|
}, 1000);
|
|
|
}
|
|
|
+ } else if (tmpdata.code === 205) {
|
|
|
+ setTimeout(() => {
|
|
|
+ _this.chartData = _this.chartDataInit
|
|
|
+ }, 1000);
|
|
|
+
|
|
|
+ uni.showToast({
|
|
|
+ title: tmpdata.message,
|
|
|
+ duration: 1500
|
|
|
+ })
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
title: '数据异常',
|
|
|
@@ -305,11 +354,19 @@
|
|
|
* 转换年月格式
|
|
|
*/
|
|
|
get_year_month() {
|
|
|
+ // 走势图数据
|
|
|
+ this.getRechargeRecord();
|
|
|
+
|
|
|
this.selYearMonth = this.years[this.selYearIndex].substring(0, 4) + '-' +
|
|
|
- this.months[this.selMonthindex].substring(0, 2)
|
|
|
+ this.months[this.selMonthindex].substring(0, 2);
|
|
|
|
|
|
- // 查询当月消费
|
|
|
- this.getRecord()
|
|
|
+ if (this.selMonthindex == 0) {
|
|
|
+ // 全部,显示1-12月的数据
|
|
|
+ this.getRecord('全部');
|
|
|
+ } else {
|
|
|
+ // 查询当月消费
|
|
|
+ this.getRecord('按月');
|
|
|
+ }
|
|
|
},
|
|
|
/**
|
|
|
* 选择年份
|