程志平 vor 3 Jahren
Ursprung
Commit
5777195001
3 geänderte Dateien mit 127 neuen und 46 gelöschten Zeilen
  1. 33 9
      pagesAir/shareAir/shareAir.vue
  2. 93 36
      pagesAir/stdBookMgr/stdBookMgr.vue
  3. 1 1
      static/api.js

+ 33 - 9
pagesAir/shareAir/shareAir.vue

@@ -90,10 +90,11 @@
 							<view class="item-info">
 								<text class="item-info-left">{{item.info}}</text>
 								<image src="../static/images/power-off.png" mode="" class="item-info-icon"></image>
-								<text>未启动</text>
+								<text v-if="item.time !== ''">{{item.time}}</text>
+								<text v-else>未启动</text>
 							</view>
 						</view>
-						<view class="item-right"
+						<view class="item-right" v-if="item.abnormal == 1" 
 							@tap="btn_click(index, item.air_ip, item.name, item.info, item.order_num)" :ref="index">
 							<view class="item-btn">
 								<image src="../static/images/power-on.png" mode="aspectFit"></image>
@@ -102,6 +103,14 @@
 								</view>
 							</view>
 						</view>
+						<view class="item-right" v-else :ref="index">
+							<view class="item-btn">
+								<image src="../static/images/power-off.png" mode="aspectFit"></image>
+								<view class="item-txt-off">
+									禁用
+								</view>
+							</view>
+						</view>
 					</view>
 				</view>
 				<navigator url="../addAir/addAir" class="add-air-bottom">
@@ -179,6 +188,7 @@
 							name: tmpAirs[0] + ' ' + t[0],
 							info: t[1],
 							time: '',
+							abnormal: 1,
 							on: false, // true开启了,false关闭了
 							order_num: '' // 订单号
 						})
@@ -199,7 +209,7 @@
 			});
 
 			// 获取基本信息
-			this.get_base_info(this.options, 'onLoad')
+			this.get_base_info(this.options, 'onShow')
 
 			setTimeout(() => {
 				uni.hideLoading();
@@ -229,12 +239,22 @@
 						this.airs = []
 						let tmpAirs = []
 						for (var i = 0; i < data.length; i++) {
-							for (var j = 0; j < this.selectAirs.length; j++) {
-								if (this.selectAirs[j].air_ip == data[i].air_ip) {
-									tmpAirs.push(this.selectAirs[j])
-									break
-								}
-							}
+							tmpAirs.push({
+								air_ip: data[i].air_ip,
+								name: data[i].school + '-' + data[i].build + '-' + data[i].floors + '-' + data[i].dom +
+									'-' + data[i].air_name,
+								info: data[i].air_config,
+								time: '',
+								abnormal: data[i].is_normal,
+								on: data[i].is_on, // true开启了,false关闭了
+								order_num: '' // 订单号
+							})
+							// for (var j = 0; j < this.selectAirs.length; j++) {
+							// 	if (this.selectAirs[j].air_ip == data[i].air_ip) {
+							// 		tmpAirs.push(this.selectAirs[j])
+							// 		break
+							// 	}
+							// }
 						}
 						// 不为空
 						if (tmpAirs.length > 0) {
@@ -319,6 +339,10 @@
 					}
 					// 更新自己绑定的空调列表
 					this.airs.push(tmpAirs[index])
+				} else if (res.data.code !== 200) {
+					tmpAirs[index].time = res.data.message;
+					// 更新自己绑定的空调列表
+					this.airs.push(tmpAirs[index])
 				} else {
 					// uni.showToast({
 					// 	icon: 'none',

+ 93 - 36
pagesAir/stdBookMgr/stdBookMgr.vue

@@ -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('按月');
+				}
 			},
 			/**
 			 * 选择年份

+ 1 - 1
static/api.js

@@ -85,7 +85,7 @@ const getDate = function getDate(type) {
 		years.push((year - 3) + '年')
 		return years
 	} else if (type === 'get_month') {
-		return month - 1
+		return month
 	}
 
 	month = month > 9 ? month : '0' + month;