Browse Source

空调控制前的提交

程志平 4 years ago
parent
commit
1d1fc678b9

+ 51 - 46
pagesAir/addAir/addAir.vue

@@ -59,7 +59,7 @@
 							<view class="item-jiaoshi" v-for="(item3, index3) in item2.children" :key="index3"
 							<view class="item-jiaoshi" v-for="(item3, index3) in item2.children" :key="index3"
 								:style="{display: item2.isShow ? '' : 'none'}">
 								:style="{display: item2.isShow ? '' : 'none'}">
 								<view class="jiaoshi" :id="item3.id"
 								<view class="jiaoshi" :id="item3.id"
-									@tap="get_air_in_the_room($event, item0.id + '|' + item1.id + '|' + item2.id + '|' + item3.id, item0.label + '|' + item1.label + '|'+ item2.label + '|' + item3.label)">
+									@tap="get_air_in_the_room($event, item0.id + '|' + item1.id + '|' + item2.id + '|' + item3.id, item0.label + '|' + item1.label + '|'+ item2.label + '|' + item3.label, item3.isShow)">
 									<view class="title-jiaoshi">
 									<view class="title-jiaoshi">
 										<uni-icons type="plus-filled" size="22" color="#2979ff"
 										<uni-icons type="plus-filled" size="22" color="#2979ff"
 											:style="{display: item3.isShow ? 'none' : ''}"></uni-icons>
 											:style="{display: item3.isShow ? 'none' : ''}"></uni-icons>
@@ -170,7 +170,7 @@
 			 * @param {Object} label
 			 * @param {Object} label
 			 * @param {Object} rooms
 			 * @param {Object} rooms
 			 */
 			 */
-			async get_air_in_the_room(e, id, label) {
+			async get_air_in_the_room(e, id, label, isShow) {
 				let ids = id.split('|')
 				let ids = id.split('|')
 				let labels = label.split('|')
 				let labels = label.split('|')
 				// console.log(ids);
 				// console.log(ids);
@@ -178,52 +178,56 @@
 				// 展开或收起
 				// 展开或收起
 				this.handle_toggle_items(e)
 				this.handle_toggle_items(e)
 
 
-				const res = await this.$myRequest({
-					host: this.ceshi,
-					url: '/airManage/buildairqueryAirMes.action',
-					method: 'POST',
-					header: {
-						'content-type': 'application/x-www-form-urlencoded'
-					},
-					data: {
-						school: labels[0],
-						build: labels[1],
-						floors: labels[2],
-						dom: labels[3]
-					}
-				})
-
-				// console.log(res.data);
-				let data = res.data
-				if (typeof data.code === 'undefined') {
-					uni.showToast({
-						title: '未找到code!',
-						icon: 'success'
-					});
-					return
-				}
+				// 展开时获取接口空调信息
+				if (false === isShow) {
+					const res = await this.$myRequest({
+						host: this.ceshi,
+						url: '/airManage/buildairqueryAirMes.action',
+						method: 'POST',
+						header: {
+							'content-type': 'application/x-www-form-urlencoded'
+						},
+						data: {
+							school: labels[0],
+							build: labels[1],
+							floors: labels[2],
+							dom: labels[3]
+						}
+					})
 
 
-				if (data.code === 200 && typeof data.data !== 'undefined') {
-					// 清空
-					this.airsData = []
-					for (var i = 0; i < data.data.length; i++) {
-						this.airsData.push({
-							isUsering: data.data[i].is_on == 1 ? true : false,
-							label: data.data[i].air_name + '-' + data.data[i].air_config,
-							isChecked: false,
-							id: data.data[i].air_ip
-						})
+					// console.log(res.data);
+					let data = res.data
+					if (typeof data.code === 'undefined') {
+						uni.showToast({
+							title: '未找到code!',
+							icon: 'success'
+						});
+						return
 					}
 					}
-					if (this.airsData.length > 0) {
-						// 填充数据
-						this.insert_into_treeData_rooms(this.treeData, ids[3])
+
+					if (data.code === 200 && typeof data.data !== 'undefined') {
+						// 清空
+						this.airsData = []
+						for (var i = 0; i < data.data.length; i++) {
+							this.airsData.push({
+								isUsering: data.data[i].is_on == 1 ? true : false,
+								label: data.data[i].air_name + '-' + data.data[i].air_config,
+								isChecked: false,
+								id: data.data[i].air_ip
+							})
+						}
+						// 排序
+						this.airsData.sort((a, b) => a.label.localeCompare(b.label))
+						if (this.airsData.length > 0) {
+							// 填充数据
+							this.insert_into_treeData_rooms(this.treeData, ids[3])
+						}
+					} else {
+						uni.showToast({
+							title: '该房间未配空调'
+						});
 					}
 					}
-				} else {
-					uni.showToast({
-						title: '该房间未配空调'
-					});
 				}
 				}
-
 			},
 			},
 			/**
 			/**
 			 * 填充空调到教室下面,供选择
 			 * 填充空调到教室下面,供选择
@@ -271,7 +275,7 @@
 					});
 					});
 					return
 					return
 				}
 				}
-				
+
 				if (res.data.code === 200) {
 				if (res.data.code === 200) {
 					let data = res.data.data
 					let data = res.data.data
 					// 校区
 					// 校区
@@ -613,7 +617,8 @@
 			 */
 			 */
 			show_selected_airs() {
 			show_selected_airs() {
 				// 显示到上方
 				// 显示到上方
-				this.show_airs = this.airs_selected.split('').reverse().join('')
+				this.show_airs = this.airs_selected.split('').reverse().join('').replaceAll('(', '>').replaceAll(')', '<')
+					.replaceAll('>', ')').replaceAll('<', '(')
 			},
 			},
 			/**
 			/**
 			 * 计算屏幕的高度
 			 * 计算屏幕的高度

+ 71 - 43
pagesAir/shareAir/shareAir.vue

@@ -134,7 +134,8 @@
 				],
 				],
 				current: 0, // 开始显示第几个
 				current: 0, // 开始显示第几个
 				balance: 0.0.toFixed(2), // 余额
 				balance: 0.0.toFixed(2), // 余额
-				airs: [], // 已经添加的空调列表数据
+				airs: [], // 已经添加成功的空调列表数据
+				selectAirs: [], // 已经选择的空调列表数据
 				dotMode: 'round', // 显示控制点样式
 				dotMode: 'round', // 显示控制点样式
 				isList: false, // 是否显示添加的空调列表
 				isList: false, // 是否显示添加的空调列表
 				screenHeight: '' // 屏幕的高度
 				screenHeight: '' // 屏幕的高度
@@ -145,12 +146,8 @@
 			let airs_selected = uni.getStorageSync('airs_selected')
 			let airs_selected = uni.getStorageSync('airs_selected')
 			if (airs_selected.length > 0) {
 			if (airs_selected.length > 0) {
 				// 使用存储的列表
 				// 使用存储的列表
-				this.airs = airs_selected
-				// 显示添加的空调列表
-				this.isList = true
+				this.selectAirs = airs_selected
 			}
 			}
-			// 获取基本信息
-			this.get_base_info(options, 'onLoad')
 		},
 		},
 		onShow() {
 		onShow() {
 			// 从新计算高度
 			// 从新计算高度
@@ -164,14 +161,14 @@
 					let tmpAirs = arrAirs[i].split('|')
 					let tmpAirs = arrAirs[i].split('|')
 					let t = tmpAirs[1].split('-')
 					let t = tmpAirs[1].split('-')
 					let tf = true
 					let tf = true
-					for (var j = 0; j < this.airs.length; j++) {
-						if (this.airs[j].air_ip == tmpAirs[2]) {
+					for (var j = 0; j < this.selectAirs.length; j++) {
+						if (this.selectAirs[j].air_ip == tmpAirs[2]) {
 							tf = false
 							tf = false
 						}
 						}
 					}
 					}
 					// 存在则不添加到数组和缓存
 					// 存在则不添加到数组和缓存
 					if (true === tf) {
 					if (true === tf) {
-						this.airs.push({
+						this.selectAirs.push({
 							air_ip: tmpAirs[2],
 							air_ip: tmpAirs[2],
 							name: tmpAirs[0] + ' ' + t[0],
 							name: tmpAirs[0] + ' ' + t[0],
 							info: t[1],
 							info: t[1],
@@ -181,16 +178,25 @@
 					}
 					}
 				}
 				}
 				// 如果选的空调不为空,则显示添加的空调列表
 				// 如果选的空调不为空,则显示添加的空调列表
-				if (this.airs.length > 0) {
-					this.airs.sort((a, b)=> a.name.localeCompare(b.name))
-					// 显示添加的空调列表
-					this.isList = true
+				if (this.selectAirs.length > 0) {
+					// 去重
+					const newArr = [...new Set(this.selectAirs.map(e => JSON.stringify(e)))].map(e => JSON.parse(
+						e));
+
+					this.selectAirs = newArr
 				}
 				}
 				// 存储空调列表
 				// 存储空调列表
-				uni.setStorageSync('airs_selected', this.airs)
+				uni.setStorageSync('airs_selected', this.selectAirs)
 				// 移除全局自定义事件监听器。
 				// 移除全局自定义事件监听器。
 				uni.$off('selectAirs')
 				uni.$off('selectAirs')
-			})
+			});
+
+			// 获取基本信息
+			this.get_base_info('options', 'onLoad')
+
+			setTimeout(() => {
+				uni.hideLoading();
+			}, 3000)
 		},
 		},
 		methods: {
 		methods: {
 			/**
 			/**
@@ -212,36 +218,48 @@
 				// console.log(res.data);
 				// console.log(res.data);
 				if (res.data.code == 200) {
 				if (res.data.code == 200) {
 					let data = res.data.data
 					let data = res.data.data
-					// console.log(this.airs);
-					// console.log(data);
-					let len = this.airs
-					for (var i = 0; i < this.airs.length; i++) {
-						let tf = false
-						for (var j = 0; j < data.length; j++) {
-							if (this.airs[i].air_ip == data[j].air_ip) {
-								tf = true
+					if (data.length > 0) {
+						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
+								}
 							}
 							}
 						}
 						}
-						if (tf !== true) {
-							this.airs.slice(i, 1)
-						}
-					}
-					if (len > this.airs.length) {
-						// 存储空调列表
-						uni.setStorageSync('airs_selected', this.airs)
+						// 按名称排序
+						tmpAirs.sort((a, b) => a.name.localeCompare(b.name))
+						this.airs = tmpAirs
+						// 显示添加的空调列表
+						this.isList = true
+					} else {
+						// 隐藏添加的空调列表
+						this.isList = false
 					}
 					}
+				} else if (res.data.code == 205) {
+					// 隐藏添加的空调列表
+					this.isList = false
 				} else {
 				} else {
+					// 隐藏添加的空调列表
+					this.isList = false
 					// 提示返回信息
 					// 提示返回信息
 					uni.showToast({
 					uni.showToast({
 						title: res.data.message
 						title: res.data.message
 					})
 					})
 				}
 				}
+				// 隐藏加载
+				uni.hideLoading();
 			},
 			},
 			/**
 			/**
 			 * 获取基本信息
 			 * 获取基本信息
 			 */
 			 */
 			get_base_info(options, param) {
 			get_base_info(options, param) {
 				// console.log(options);
 				// console.log(options);
+				uni.showLoading({
+					title: '加载中'
+				})
 				try {
 				try {
 					// 获取学号
 					// 获取学号
 					this.stu_number = this.$store.state.userInfo.card_number
 					this.stu_number = this.$store.state.userInfo.card_number
@@ -301,6 +319,9 @@
 			 * 请求服务器,获得openid
 			 * 请求服务器,获得openid
 			 */
 			 */
 			async getOpenId(options, param_code) {
 			async getOpenId(options, param_code) {
+				if (JSON.stringify(this.userinfo) === "{}") {
+					return
+				}
 				const res = await this.$myRequest({
 				const res = await this.$myRequest({
 					host: this.ceshi,
 					host: this.ceshi,
 					url: '/airManage/usersopenid.action',
 					url: '/airManage/usersopenid.action',
@@ -368,7 +389,7 @@
 					// 余额
 					// 余额
 					this.balance = res.data.data.balance.toFixed(2)
 					this.balance = res.data.data.balance.toFixed(2)
 					this.id_card = res.data.data.sfzh
 					this.id_card = res.data.data.sfzh
-
+					// 查询绑定的空调
 					this.select_banding_airs()
 					this.select_banding_airs()
 				} else {
 				} else {
 					uni.showToast({
 					uni.showToast({
@@ -390,12 +411,8 @@
 						content: '是否删除该空调?',
 						content: '是否删除该空调?',
 						success: (res) => {
 						success: (res) => {
 							if (res.confirm) {
 							if (res.confirm) {
-								// 删除指定下标的元素
-								this.airs.splice(index, 1)
-								// 更新存储
-								uni.setStorageSync('airs_selected', this.airs)
 								// 解绑空调
 								// 解绑空调
-								this.unbangding_airs(air_ip)
+								this.unbangding_airs(air_ip, index)
 							}
 							}
 						}
 						}
 					})
 					})
@@ -410,8 +427,9 @@
 			/**
 			/**
 			 * 解绑空调
 			 * 解绑空调
 			 * @param {Object} air_ip
 			 * @param {Object} air_ip
+			 * @param {Object} index
 			 */
 			 */
-			async unbangding_airs(air_ip) {
+			async unbangding_airs(air_ip, index) {
 				const res = await this.$myRequest({
 				const res = await this.$myRequest({
 					host: this.ceshi,
 					host: this.ceshi,
 					url: '/airManage/usersdelAir.action',
 					url: '/airManage/usersdelAir.action',
@@ -427,6 +445,13 @@
 
 
 				// console.log(res.data);
 				// console.log(res.data);
 				if (res.data.code == 200) {
 				if (res.data.code == 200) {
+					// 删除指定下标的元素
+					this.airs.splice(index, 1)
+
+					if (this.airs.length == 0) {
+						this.isList = false
+					}
+
 					uni.showToast({
 					uni.showToast({
 						title: res.data.message
 						title: res.data.message
 					})
 					})
@@ -446,6 +471,7 @@
 				let build = tmp[1],
 				let build = tmp[1],
 					floors = tmp[2],
 					floors = tmp[2],
 					dom = tmp[3] + '-' + tmp[4].split(' ')[0];
 					dom = tmp[3] + '-' + tmp[4].split(' ')[0];
+				let air_name = name.split(' ')[1]
 				// 未获取到索引
 				// 未获取到索引
 				if (typeof index === 'undefined') {
 				if (typeof index === 'undefined') {
 					return
 					return
@@ -475,8 +501,7 @@
 										if (res.code) {
 										if (res.code) {
 											// 调用接口,开启空调
 											// 调用接口,开启空调
 											this.open_airs(res.code, index, air_ip, build, floors,
 											this.open_airs(res.code, index, air_ip, build, floors,
-												dom,
-												info)
+												dom, info, air_name)
 										} else {
 										} else {
 											uni.showToast({
 											uni.showToast({
 												title: res.errMsg,
 												title: res.errMsg,
@@ -503,7 +528,7 @@
 					return
 					return
 				}
 				}
 
 
-				if (this.this.id_card == '') {
+				if (this.id_card == '') {
 					uni.showToast({
 					uni.showToast({
 						title: '未获得身份证号'
 						title: '未获得身份证号'
 					})
 					})
@@ -547,7 +572,7 @@
 			 * @param {Object} dom
 			 * @param {Object} dom
 			 * @param {Object} air_config
 			 * @param {Object} air_config
 			 */
 			 */
-			async open_airs(code, index, air_ip, build, floors, dom, air_config) {
+			async open_airs(code, index, air_ip, build, floors, dom, air_config, air_name) {
 				const res = await this.$myRequest({
 				const res = await this.$myRequest({
 					host: this.ceshi,
 					host: this.ceshi,
 					url: '/airManage/consumestart.action',
 					url: '/airManage/consumestart.action',
@@ -561,20 +586,23 @@
 						build: build,
 						build: build,
 						floors: floors,
 						floors: floors,
 						dom: dom,
 						dom: dom,
-						air_config: air_config
+						air_config: air_config,
+						air_name: air_name
 					}
 					}
 				})
 				})
 
 
 				console.log(res.data);
 				console.log(res.data);
 				if (res.data.code == 200) {
 				if (res.data.code == 200) {
 					uni.showToast({
 					uni.showToast({
+						icon: 'none',
 						title: res.data.message
 						title: res.data.message
 					})
 					})
 					// 显示已经开启图标
 					// 显示已经开启图标
 					this.airs[index].on = true
 					this.airs[index].on = true
-					this.order_num = res.data.data.order_num
+					this.order_num = res.data.order_num
 				} else {
 				} else {
 					uni.showToast({
 					uni.showToast({
+						icon: 'none',
 						title: res.data.message
 						title: res.data.message
 					})
 					})
 				}
 				}

+ 12 - 11
pagesAir/stdBookMgr/stdBookMgr.vue

@@ -22,8 +22,8 @@
 				<view class="show-txt-label">消费走势图</view>
 				<view class="show-txt-label">消费走势图</view>
 			</view>
 			</view>
 			<view class="charts-box">
 			<view class="charts-box">
-				<qiun-data-charts type="line" :chartData="chartData" :opts="chartOpts" :ontouch="true"
-					tooltipFormat="tooltipDemo1" />
+				<qiun-data-charts canvasId="canvasAirId" type="line" :chartData="chartData" :opts="chartOpts" :ontouch="true" :canvas2d="false"
+          id="chartsAir"/>
 			</view>
 			</view>
 		</view>
 		</view>
 		<view class="line"></view>
 		<view class="line"></view>
@@ -69,10 +69,10 @@
 					series: []
 					series: []
 				},
 				},
 				chartDataInit: { // 如果 chartData 没有数据,解决一直打转的问题
 				chartDataInit: { // 如果 chartData 没有数据,解决一直打转的问题
-					"categories": ["无数据","无数据","无数据","无数据","无数据"],
+					"categories": ["无数据", "无数据", "无数据", "无数据", "无数据"],
 					"series": [{
 					"series": [{
 						"name": "金额",
 						"name": "金额",
-						"data": ["0.00","0.00","0.00","0.00","0.00"]
+						"data": ["0.00", "0.00", "0.00", "0.00", "0.00"]
 					}]
 					}]
 				},
 				},
 				chartOpts: {
 				chartOpts: {
@@ -109,6 +109,10 @@
 				this.calc_screen_height()
 				this.calc_screen_height()
 			}, 1000)
 			}, 1000)
 		},
 		},
+		mounted() {
+			// 暂无走势图数据
+			this.getRechargeRecord()
+		},
 		methods: {
 		methods: {
 			/**
 			/**
 			 * 获取身份证号
 			 * 获取身份证号
@@ -136,9 +140,6 @@
 				} catch (e) {
 				} catch (e) {
 					console.log('获取基本信息:' + e.message);
 					console.log('获取基本信息:' + e.message);
 				}
 				}
-
-				// 暂无走势图数据
-				this.getRechargeRecord()
 			},
 			},
 			/**
 			/**
 			 * 查询当月消费
 			 * 查询当月消费
@@ -224,11 +225,11 @@
 						title: '暂无走势图数据',
 						title: '暂无走势图数据',
 						duration: 1500
 						duration: 1500
 					});
 					});
-					
+
 					setTimeout(() => {
 					setTimeout(() => {
 						_this.chartData = _this.chartDataInit
 						_this.chartData = _this.chartDataInit
 					}, 1000);
 					}, 1000);
-					
+
 					return
 					return
 				}
 				}
 				let tmpdata = res.data
 				let tmpdata = res.data
@@ -238,11 +239,11 @@
 							title: '暂无走势图数据',
 							title: '暂无走势图数据',
 							duration: 1500
 							duration: 1500
 						});
 						});
-						
+
 						setTimeout(() => {
 						setTimeout(() => {
 							_this.chartData = _this.chartDataInit
 							_this.chartData = _this.chartDataInit
 						}, 1000);
 						}, 1000);
-						
+
 						return
 						return
 					}
 					}
 
 

+ 4 - 3
pagesElectric/show/show.vue

@@ -8,8 +8,8 @@
 				<view class="show-item-label">消费走势图</view>
 				<view class="show-item-label">消费走势图</view>
 			</view>
 			</view>
 			<view class="charts-box">
 			<view class="charts-box">
-				<qiun-data-charts type="line" :chartData="chartData" :opts="chartOpts" :ontouch="true"
-					tooltipFormat="tooltipDemo1" />
+				<qiun-data-charts :canvasId="canvas_Electric_id" type="line" :chartData="chartData" :opts="chartOpts"
+					:ontouch="true" :canvas2d="false" id="chartsElectric" />
 			</view>
 			</view>
 			<view class="select-show">
 			<view class="select-show">
 				<button :class="[btn ? 'first-button-bg' : 'first-button']"
 				<button :class="[btn ? 'first-button-bg' : 'first-button']"
@@ -60,6 +60,7 @@
 		data() {
 		data() {
 			return {
 			return {
 				btn: false,
 				btn: false,
+				canvasId: 'canvas_Electric_id',
 				chartData: {
 				chartData: {
 					categories: [],
 					categories: [],
 					series: []
 					series: []
@@ -131,7 +132,7 @@
 				console.log(e);
 				console.log(e);
 			}
 			}
 		},
 		},
-		onReady() {
+		mounted() {
 			// 消费走势
 			// 消费走势
 			this.getEnergyConsumption('month')
 			this.getEnergyConsumption('month')
 		},
 		},