|
|
@@ -56,12 +56,14 @@
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
+ ceshi: 'dev',
|
|
|
+ id_card: '', // 身份证号
|
|
|
screenHeight: 0,
|
|
|
- ceshi: 'code',
|
|
|
- years: ['2021年', '2022年'], // 候选年份
|
|
|
- months: ['全部', '1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'], // 候选月份
|
|
|
- selYearIndex: 0, // 选择的年份
|
|
|
- selMonthindex: 0, // 选择的月份
|
|
|
+ years: this.$getDate('get_year'), // 候选年份
|
|
|
+ months: ['01月', '02月', '03月', '04月', '05月', '06月', '07月', '08月', '09月', '10月', '11月', '12月'], // 候选月份
|
|
|
+ selYearIndex: 0, // 选择的年份index
|
|
|
+ selMonthindex: this.$getDate('get_month'), // 选择的月份index
|
|
|
+ selYearMonth: '', // 选择的年份、月份
|
|
|
chartData: {
|
|
|
categories: [],
|
|
|
series: []
|
|
|
@@ -85,121 +87,138 @@
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- consumeRecords: [{
|
|
|
- loudong: '科技楼-5F-101',
|
|
|
- startTime: '2022-03-12 12:12:15',
|
|
|
- endTime: '2022-03-12 13:12:15',
|
|
|
- amount: -20.0
|
|
|
- },
|
|
|
- {
|
|
|
- loudong: '科技楼-5F-101',
|
|
|
- startTime: '2022-03-12 12:12:15',
|
|
|
- endTime: '2022-03-12 13:12:15',
|
|
|
- amount: -20.0
|
|
|
- },
|
|
|
- {
|
|
|
- loudong: '科技楼-5F-101',
|
|
|
- startTime: '2022-03-12 12:12:15',
|
|
|
- endTime: '2022-03-12 13:12:15',
|
|
|
- amount: -20.0
|
|
|
- },
|
|
|
- {
|
|
|
- loudong: '科技楼-5F-101',
|
|
|
- startTime: '2022-03-12 12:12:15',
|
|
|
- endTime: '2022-03-12 13:12:15',
|
|
|
- amount: -20.0
|
|
|
- },
|
|
|
- {
|
|
|
- loudong: '科技楼-5F-101',
|
|
|
- startTime: '2022-03-12 12:12:15',
|
|
|
- endTime: '2022-03-12 13:12:15',
|
|
|
- amount: -20.0
|
|
|
- }
|
|
|
- ]
|
|
|
+ consumeRecords: []
|
|
|
}
|
|
|
},
|
|
|
onLoad() {
|
|
|
- this.get_xiaofiezoushi()
|
|
|
+ // 获取年月格式
|
|
|
+ this.get_year_month()
|
|
|
+ // 获取基本信息
|
|
|
+ this.get_base_info()
|
|
|
},
|
|
|
onShow() {
|
|
|
// 从新计算高度
|
|
|
- // setTimeout(() => {
|
|
|
- this.calc_screen_height()
|
|
|
- // }, 1500)
|
|
|
+ setTimeout(() => {
|
|
|
+ this.calc_screen_height()
|
|
|
+ }, 1000)
|
|
|
},
|
|
|
methods: {
|
|
|
/**
|
|
|
- * 滚动到顶部提示
|
|
|
+ * 获取身份证号
|
|
|
*/
|
|
|
- scroll_to_upper() {
|
|
|
- uni.showToast({
|
|
|
- title: '到顶了!',
|
|
|
- icon: 'none',
|
|
|
- duration: 500
|
|
|
- })
|
|
|
+ get_base_info() {
|
|
|
+ try {
|
|
|
+ if (this.id_card == '' || typeof(this.id_card) == 'undefined') {
|
|
|
+ const userinfo = uni.getStorageSync('userinfo_storage_key')
|
|
|
+ if (userinfo) {
|
|
|
+ this.id_card = userinfo.id_card
|
|
|
+ } else {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '../index/index?from=' + options.from
|
|
|
+ })
|
|
|
+
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ title: '身份证号为空,请进行授权',
|
|
|
+ duration: 3000
|
|
|
+ });
|
|
|
+
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.log('获取基本信息:' + e.message);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 暂无走势图数据
|
|
|
+ this.getRechargeRecord()
|
|
|
},
|
|
|
/**
|
|
|
- * 滚动到底部提示
|
|
|
+ * 查询当月消费
|
|
|
*/
|
|
|
- scroll_to_lower() {
|
|
|
- uni.showToast({
|
|
|
- title: '到底了!',
|
|
|
- icon: 'none',
|
|
|
- duration: 500
|
|
|
+ async getRecord() {
|
|
|
+ let res = await this.$myRequest({
|
|
|
+ host: this.ceshi,
|
|
|
+ // url: '/HotWaters/elqueryDayPower.action',
|
|
|
+ url: '/airManage/consumequeryOwnPage.action',
|
|
|
+ method: 'POST',
|
|
|
+ header: {
|
|
|
+ 'content-type': 'application/x-www-form-urlencoded'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ page: 1,
|
|
|
+ rows: 90,
|
|
|
+ sfzh: this.id_card,
|
|
|
+ // sfzh: '360313110',
|
|
|
+ con_month: this.selYearMonth
|
|
|
+ }
|
|
|
})
|
|
|
+
|
|
|
+ // console.log(res.data);
|
|
|
+ let data = res.data
|
|
|
+ if (data.code === 200) {
|
|
|
+ if (typeof data.rows === 'undefined') {
|
|
|
+ uni.showToast({
|
|
|
+ title: '暂无消费数据',
|
|
|
+ duration: 1500
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let tmpRecord = []
|
|
|
+ for (var i = 0; i < data.rows.length; i++) {
|
|
|
+ tmpRecord.push({
|
|
|
+ loudong: data.rows[i].build + '-' + data.rows[i].floors + '-' + data.rows[i].dom
|
|
|
+ .split('-')[1],
|
|
|
+ startTime: data.rows[i].time,
|
|
|
+ endTime: data.rows[i].end_time,
|
|
|
+ amount: data.rows[i].account
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.consumeRecords = tmpRecord
|
|
|
+ } else if (typeof data.code === 'undefined') {
|
|
|
+ uni.showToast({
|
|
|
+ title: '无法识别code',
|
|
|
+ duration: 1500
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: '暂无数据',
|
|
|
+ duration: 1500
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
/**
|
|
|
- * 选择年份
|
|
|
- * @param {Object} e
|
|
|
- */
|
|
|
- bindYearPickerChange(e) {
|
|
|
- // console.log(e);
|
|
|
- this.selYearIndex = e.target.value
|
|
|
- console.log(this.years[this.selYearIndex]);
|
|
|
- },
|
|
|
- /**
|
|
|
- * 选择月份
|
|
|
- * @param {Object} e
|
|
|
- */
|
|
|
- bindMonthPickerChange(e) {
|
|
|
- // console.log(e);
|
|
|
- this.selMonthindex = e.target.value
|
|
|
- console.log(this.months[this.selMonthindex]);
|
|
|
- },
|
|
|
- /**
|
|
|
- * 按月、年获取消费记录
|
|
|
+ * 按获取消费走势图数据
|
|
|
*/
|
|
|
- async get_xiaofiezoushi() {
|
|
|
- // console.log(this.roomSelect);
|
|
|
- var reg = /[\u4e00-\u9fa5]/g;
|
|
|
- var str = '墨轩湖校区1-302';
|
|
|
- var dom = str.replace(reg, "");
|
|
|
- if (dom != '' && typeof(dom) != 'undefined') {
|
|
|
- let res = null;
|
|
|
- res = await this.$myRequest({
|
|
|
- host: this.ceshi,
|
|
|
- // url: '/HotWaters/elqueryDayPower.action',
|
|
|
- url: '/HotWaters/elMonthlist.action',
|
|
|
- method: 'POST',
|
|
|
- header: {
|
|
|
- 'content-type': 'application/x-www-form-urlencoded'
|
|
|
- },
|
|
|
- data: {
|
|
|
- 'dom': dom,
|
|
|
- 'page': 1,
|
|
|
- 'rows': 12
|
|
|
- }
|
|
|
- })
|
|
|
+ async getRechargeRecord() {
|
|
|
+ let res = await this.$myRequest({
|
|
|
+ host: this.ceshi,
|
|
|
+ // url: '/HotWaters/elqueryDayPower.action',
|
|
|
+ url: '/airManage/consumequeryOwnConTong.action',
|
|
|
+ method: 'POST',
|
|
|
+ header: {
|
|
|
+ 'content-type': 'application/x-www-form-urlencoded'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ sfzh: this.id_card
|
|
|
+ // sfzh: '360313110'
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
- // console.log(res.data.rows);
|
|
|
- // console.log(res.data);
|
|
|
- if (res.data.rows.length == 0) {
|
|
|
+ // console.log(res.data);
|
|
|
+ let tmpdata = res.data
|
|
|
+ if (tmpdata.code === 200) {
|
|
|
+ if (typeof res.data === 'undefined') {
|
|
|
+ uni.showToast({
|
|
|
+ title: '暂无走势图数据',
|
|
|
+ duration: 1500
|
|
|
+ })
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if (typeof res.data.rows === 'undefined') {
|
|
|
+ if (typeof tmpdata.data === 'undefined' || tmpdata.data.length === 0) {
|
|
|
uni.showToast({
|
|
|
- title: '加载数据异常',
|
|
|
+ title: '暂无走势图数据',
|
|
|
duration: 1500
|
|
|
})
|
|
|
return
|
|
|
@@ -207,16 +226,16 @@
|
|
|
|
|
|
let chrt_data = {
|
|
|
categories: [],
|
|
|
- series: [],
|
|
|
+ series: []
|
|
|
}
|
|
|
let elc_max = -1.0
|
|
|
let dt = ''
|
|
|
let temp = 0
|
|
|
let data = []
|
|
|
- for (var i = 0; i < res.data.rows.length; i++) {
|
|
|
- dt = res.data.rows[i].dataTime
|
|
|
+ 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 = res.data.rows[i].totalMoney
|
|
|
+ temp = tmpdata.data[i].num
|
|
|
temp = temp.toFixed(2)
|
|
|
data.push(temp)
|
|
|
if (parseFloat(temp) > parseFloat(elc_max)) {
|
|
|
@@ -243,12 +262,60 @@
|
|
|
}
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
- title: '宿舍号为空',
|
|
|
- icon: 'success'
|
|
|
- });
|
|
|
+ title: '数据异常',
|
|
|
+ duration: 1500
|
|
|
+ })
|
|
|
}
|
|
|
},
|
|
|
/**
|
|
|
+ * 转换年月格式
|
|
|
+ */
|
|
|
+ get_year_month() {
|
|
|
+ this.selYearMonth = this.years[this.selYearIndex].substring(0, 4) + '-' +
|
|
|
+ this.months[this.selMonthindex].substring(0, 2)
|
|
|
+
|
|
|
+ // 查询当月消费
|
|
|
+ this.getRecord()
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 选择年份
|
|
|
+ * @param {Object} e
|
|
|
+ */
|
|
|
+ bindYearPickerChange(e) {
|
|
|
+ // console.log(e);
|
|
|
+ this.selYearIndex = e.target.value
|
|
|
+ this.get_year_month()
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 选择月份
|
|
|
+ * @param {Object} e
|
|
|
+ */
|
|
|
+ bindMonthPickerChange(e) {
|
|
|
+ // console.log(e);
|
|
|
+ this.selMonthindex = e.target.value
|
|
|
+ this.get_year_month()
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 滚动到顶部提示
|
|
|
+ */
|
|
|
+ scroll_to_upper() {
|
|
|
+ uni.showToast({
|
|
|
+ title: '到顶了!',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 500
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 滚动到底部提示
|
|
|
+ */
|
|
|
+ scroll_to_lower() {
|
|
|
+ uni.showToast({
|
|
|
+ title: '到底了!',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 500
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /**
|
|
|
* 计算屏幕的高度
|
|
|
*/
|
|
|
calc_screen_height() {
|