Ver código fonte

差空调控制,其他已经完成

程志平 4 anos atrás
pai
commit
d06fd864d0

+ 155 - 94
pagesAir/accountBalance/accountBalance.vue

@@ -31,7 +31,8 @@
 			<view class=" balance" @tap="Recharge(60)" :class="{balanceborder: amount == 60}">60元</view>
 			<view class=" balance" @tap="Recharge(60)" :class="{balanceborder: amount == 60}">60元</view>
 		</view>
 		</view>
 		<view class=" line"></view>
 		<view class=" line"></view>
-		<input class="input-balance" type="text" v-model="amount" @input="onInput" @blur="onBlur" placeholder="请输入充值金额,金额大于10" placeholder-class="pc" />
+		<input class="input-balance" type="text" v-model="amount" @input="onInput" @blur="onBlur"
+			placeholder="请输入充值金额,金额大于10" placeholder-class="pc" />
 		<view class="line"></view>
 		<view class="line"></view>
 		<view class="btn-pay">
 		<view class="btn-pay">
 			<button class="btn" url="/pagesAir/rechargeRecord/rechargeRecord" @tap="btn_click">
 			<button class="btn" url="/pagesAir/rechargeRecord/rechargeRecord" @tap="btn_click">
@@ -45,55 +46,106 @@
 	export default {
 	export default {
 		data() {
 		data() {
 			return {
 			return {
-				balance: 18.88, // 余额
+				ceshi: 'air',
+				id_card: '',
+				appkey: '3183DC96A6DABA8D', // 商户appkey
+				ocode: '1015730314', // 获取用户信息
+				app_secret: '05742955578EC5BD29B7BC4CAC5AFACA', // 获取用户信息
+				balance: 0.00, // 余额
 				amount: '', // 充值金额
 				amount: '', // 充值金额
 				IP: '',
 				IP: '',
-				ceshi: 'code',
 				test: this.$store.state.test
 				test: this.$store.state.test
 			}
 			}
 		},
 		},
-		onLoad() {
+		onLoad(options) {
 			if (this.test) {
 			if (this.test) {
 				this.amount = 0.01
 				this.amount = 0.01
 			}
 			}
+			// 获取身份证号
+			this.get_base_info(options)
 		},
 		},
 		methods: {
 		methods: {
 			/**
 			/**
-			 * 选择了充值金额
-			 * @param {Object} param
+			 * 获取身份证号
 			 */
 			 */
-			Recharge(param) {
-				this.amount = param
+			get_base_info(options) {
+				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.getBalance()
 			},
 			},
 			/**
 			/**
-			 * 获取IP
+			 * 请求服务器,获得余额
 			 */
 			 */
-			async getIP() {
+			async getBalance() {
 				const res = await this.$myRequest({
 				const res = await this.$myRequest({
-					host: 'ip',
-					url: '?ie=utf-8',
-					method: 'POST'
+					host: this.ceshi,
+					url: '/airManage/usersqueryYu.action',
+					method: 'POST',
+					header: {
+						'content-type': 'application/x-www-form-urlencoded'
+					},
+					data: {
+						// sfzh: '3602123654'
+						sfzh: this.id_card
+					}
 				})
 				})
-			
-				if (res) {
-					// console.log(res);
-					const reg = /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/;
-					let ip = reg.exec(res.data);
-					
-					// 获取code
-					this.getCode(ip[0])
+
+				// console.log(res.data);
+				let data = res.data
+				if (data.code === 200) {
+					if (typeof data.data != 'undefined' && data.data != '' && JSON.stringify(data.data) != '{}') {
+						this.balance = data.data.balance
+					} else {
+						uni.showToast({
+							title: '未查询到余额!',
+							icon: 'success'
+						});
+					}
+				} else {
+					uni.showToast({
+						title: data.data.message
+					})
 				}
 				}
 			},
 			},
 			/**
 			/**
+			 * 选择了充值金额
+			 * @param {Object} param
+			 */
+			Recharge(param) {
+				this.amount = param
+			},
+			/**
 			 * 获得code
 			 * 获得code
 			 */
 			 */
-			getCode(param_ip) {
+			getCode() {
 				uni.login({
 				uni.login({
 					success: (res) => {
 					success: (res) => {
 						// console.log('recharge', res);
 						// console.log('recharge', res);
 						if (res.code) {
 						if (res.code) {
-							// 组合地址,发起支付
-							this.jsapi(param_ip, res.code)
+							// 发起支付
+							this.jsapi(res.code)
 						} else {
 						} else {
 							uni.showToast({
 							uni.showToast({
 								title: res.errMsg,
 								title: res.errMsg,
@@ -106,68 +158,76 @@
 			/**
 			/**
 			 * 请求服务器,获取支付参数,并支付
 			 * 请求服务器,获取支付参数,并支付
 			 */
 			 */
-			// async jsapi(param_ip, param_code) {
-			// 	if (param_code == '' || this.amount == '' || param_ip == '') {
-			// 		uni.showToast({
-			// 			icon: 'none',
-			// 			title: 'code、充值金额或IP为空'
-			// 		});
-			// 		return
-			// 	}
-				
-			// 	const res = await this.$myRequest({
-			// 		host: this.ceshi,
-			// 		url: '/HotWaters/wpPay.action',
-			// 		method: 'POST',
-			// 		header: {
-			// 			'content-type': 'application/x-www-form-urlencoded'
-			// 		},
-			// 		data: {
-			// 			code: param_code,
-			// 			num: this.amount,
-			// 			ip: param_ip
-			// 		}
-			// 	})
-				
-			// 	// console.log(res);
-			// 	if (res.data.pay == 'error') {
-			// 		uni.showToast({
-			// 			title: '未获得支付参数',
-			// 			icon: 'success',
-			// 			duration: 3000
-			// 		});
-			// 	} else {
-			// 		wx.requestPayment({
-			// 			timeStamp: res.data.pay.timeStamp,
-			// 			nonceStr: res.data.pay.nonceStr,
-			// 			package: 'prepay_id=' + res.data.pay.prepay_id,
-			// 			signType: res.data.pay.signType,
-			// 			paySign: res.data.pay.paySign,
-			// 			success: (res) => {
-			// 				if (res.errMsg == 'requestPayment:ok') {
-			// 					this.$store.state.payInfo.from = 'reshui_pay'
-			// 					this.$store.state.payInfo.resultMsg = '支付成功'
-			// 					this.$store.state.reshui_amount = this.amount
-			// 					uni.navigateBack({
-			// 						delta: 1
-			// 					})
-			// 				}
-			// 			},
-			// 			fail: (res) => {
-			// 				if (res.errMsg == 'requestPayment:fail cancel') {
-			// 					uni.showToast({
-			// 						title: '支付已取消',
-			// 						icon: 'success',
-			// 						duration: 2000
-			// 					});
-			// 				}
-			// 			},
-			// 			complete: (res) => {
-			// 				// console.log(res);
-			// 			}
-			// 		});
-			// 	}
-			// },
+			async jsapi(param_code) {
+				if (param_code == '' || this.amount == '' || this.id_card == '') {
+					uni.showToast({
+						icon: 'none',
+						title: 'code、充值金额或身份证号为空',
+						duration: 3000
+					});
+					return
+				}
+
+				const res = await this.$myRequest({
+					host: this.ceshi,
+					url: '/airManage/rechargepay_ns.action',
+					method: 'POST',
+					header: {
+						'content-type': 'application/x-www-form-urlencoded'
+					},
+					data: {
+						sfzh: this.id_card,
+						code: param_code,
+						num: this.amount
+					}
+				})
+
+				// console.log(res);
+				if (res.statusCode !== 200) {
+					uni.showToast({
+						title: '未获得支付参数',
+						icon: 'success',
+						duration: 3000
+					});
+				} else {
+					// 调起微信支付
+					wx.requestPayment({
+						timeStamp: res.data.timeStamp,
+						nonceStr: res.data.nonceStr,
+						package: res.data.package,
+						signType: res.data.signType,
+						paySign: res.data.paySign,
+						success: (res) => {
+							if (res.errMsg == 'requestPayment:ok') {
+								let _this = this;
+								// 提示用户支付成功
+								uni.showToast({
+									title: '支付成功',
+									icon: 'success',
+									duration: 2000,
+									success() {
+										// 请求服务器,获得余额
+										_this.getBalance()
+									}
+								});
+							}
+						},
+						fail: (res) => {
+							if (res.errMsg == 'requestPayment:fail cancel') {
+								// 提示用户已经取消支付了
+								uni.showToast({
+									title: '支付已取消',
+									icon: 'success',
+									duration: 2000
+								});
+							}
+						},
+						complete: (res) => {
+							// console.log(res);
+						}
+					});
+				}
+			},
 			/**
 			/**
 			 * 输入充值金额
 			 * 输入充值金额
 			 */
 			 */
@@ -175,9 +235,9 @@
 				if (this.test) { // 测试环境
 				if (this.test) { // 测试环境
 					return
 					return
 				}
 				}
-			
+
 				const v = e.detail.value
 				const v = e.detail.value
-			
+
 				const zero = /^(0{1,})|[^0-9]/g
 				const zero = /^(0{1,})|[^0-9]/g
 				let final = 0
 				let final = 0
 				if (!v) {
 				if (!v) {
@@ -186,11 +246,11 @@
 					final = v.toString().replace(zero, (v) => {
 					final = v.toString().replace(zero, (v) => {
 						return 0
 						return 0
 					})
 					})
-			
+
 					if (final.split('')[0] * 1 === 0) {
 					if (final.split('')[0] * 1 === 0) {
 						final = final.slice(1) - 0 || 0
 						final = final.slice(1) - 0 || 0
 					}
 					}
-			
+
 					if (final > 100) {
 					if (final > 100) {
 						final = 100
 						final = 100
 					}
 					}
@@ -235,8 +295,8 @@
 						confirmText: '充值',
 						confirmText: '充值',
 						success: (res) => {
 						success: (res) => {
 							if (res.confirm) {
 							if (res.confirm) {
-								// 获取IP
-								this.getIP()
+								// 获取code
+								this.getCode()
 							} else if (res.cancel) {
 							} else if (res.cancel) {
 								return
 								return
 							}
 							}
@@ -244,6 +304,7 @@
 					})
 					})
 					return
 					return
 				}
 				}
+
 				// 生产环境
 				// 生产环境
 				if (this.amount < 10 || this.amount > 100) {
 				if (this.amount < 10 || this.amount > 100) {
 					uni.showToast({
 					uni.showToast({
@@ -262,8 +323,8 @@
 					confirmText: '充值',
 					confirmText: '充值',
 					success: (res) => {
 					success: (res) => {
 						if (res.confirm) {
 						if (res.confirm) {
-							// 获取IP
-							this.getIP()
+							// 获取code
+							this.getCode()
 						} else if (res.cancel) {
 						} else if (res.cancel) {
 							return
 							return
 						}
 						}

+ 435 - 174
pagesAir/addAir/addAir.vue

@@ -13,64 +13,81 @@
 		<view class="line"></view>
 		<view class="line"></view>
 		<view class="tree-box">
 		<view class="tree-box">
 			<scroll-view scroll-y="true" class="tree-scroll" :style="{height: screenHeight}">
 			<scroll-view scroll-y="true" class="tree-scroll" :style="{height: screenHeight}">
-				<view class="item-loudong" v-for="(item1, index1) in treeData" :key="index1">
-					<view class="loudong" :id="item1.id" @tap="handle_toggle_items">
-						<view class="title-loudong">
-							<uni-icons type="plus-filled" size="22" color="#2979ff"
-								:style="{display: item1.isShow ? 'none' : ''}"></uni-icons>
-							<uni-icons type="minus-filled" size="22" color="#2979ff"
-								:style="{display: item1.isShow ? '' : 'none'}"></uni-icons>
-							<view class="txt-loudong">{{item1.label}}</view>
-						</view>
-						<uni-icons type="bottom" size="22" color="#2979ff"
-							:style="{display: item1.isShow ? '' : 'none'}"></uni-icons>
-						<uni-icons type="top" size="22" color="#2979ff" :style="{display: item1.isShow ? 'none' : ''}">
+				<!-- 校区 -->
+				<view class="item-school" v-for="(item0, index0) in treeData" :key="index0">
+					<view class="school" :id="item0.id" @tap="handle_toggle_items">
+						<view>{{item0.label}}</view>
+						<uni-icons type="bottom" size="22" color="#ffffff"
+							:style="{display: item0.isShow ? '' : 'none'}"></uni-icons>
+						<uni-icons type="top" size="22" color="#ffffff" :style="{display: item0.isShow ? 'none' : ''}">
 						</uni-icons>
 						</uni-icons>
 					</view>
 					</view>
-					<view class="item-loucheng" v-for="(item2, index2) in item1.children" :key="index2"
-						:style="{display: item1.isShow ? '' : 'none'}">
-						<view class="loucheng" :id="item2.id" @tap="handle_toggle_items">
-							<view class="title-loucheng">
+					<!-- 楼栋 -->
+					<view class="item-loudong" v-for="(item1, index1) in item0.children" :key="index1"
+						:style="{display: item0.isShow ? '' : 'none'}">
+						<view class="loudong" :id="item1.id" @tap="handle_toggle_items">
+							<view class="title-loudong">
 								<uni-icons type="plus-filled" size="22" color="#2979ff"
 								<uni-icons type="plus-filled" size="22" color="#2979ff"
-									:style="{display: item2.isShow ? 'none' : ''}"></uni-icons>
+									:style="{display: item1.isShow ? 'none' : ''}"></uni-icons>
 								<uni-icons type="minus-filled" size="22" color="#2979ff"
 								<uni-icons type="minus-filled" size="22" color="#2979ff"
-									:style="{display: item2.isShow ? '' : 'none'}"></uni-icons>
-								<view class="txt-loucheng">{{item2.label}}</view>
+									:style="{display: item1.isShow ? '' : 'none'}"></uni-icons>
+								<view class="txt-loudong">{{item1.label}}</view>
 							</view>
 							</view>
 							<uni-icons type="bottom" size="22" color="#2979ff"
 							<uni-icons type="bottom" size="22" color="#2979ff"
-								:style="{display: item2.isShow ? '' : 'none'}"></uni-icons>
+								:style="{display: item1.isShow ? '' : 'none'}"></uni-icons>
 							<uni-icons type="top" size="22" color="#2979ff"
 							<uni-icons type="top" size="22" color="#2979ff"
-								:style="{display: item2.isShow ? 'none' : ''}"></uni-icons>
+								:style="{display: item1.isShow ? 'none' : ''}">
+							</uni-icons>
 						</view>
 						</view>
-						<view class="item-jiaoshi" v-for="(item3, index3) in item2.children" :key="index3"
-							:style="{display: item2.isShow ? '' : 'none'}">
-							<view class="jiaoshi" :id="item3.id" @tap="handle_toggle_items">
-								<view class="title-jiaoshi">
+						<!-- 楼层 -->
+						<view class="item-loucheng" v-for="(item2, index2) in item1.children" :key="index2"
+							:style="{display: item1.isShow ? '' : 'none'}">
+							<view class="loucheng" :id="item2.id" @tap="handle_toggle_items">
+								<view class="title-loucheng">
 									<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: item2.isShow ? 'none' : ''}"></uni-icons>
 									<uni-icons type="minus-filled" size="22" color="#2979ff"
 									<uni-icons type="minus-filled" size="22" color="#2979ff"
-										:style="{display: item3.isShow ? '' : 'none'}"></uni-icons>
-									<view class="txt-jiaoshi">{{item3.label}}</view>
+										:style="{display: item2.isShow ? '' : 'none'}"></uni-icons>
+									<view class="txt-loucheng">{{item2.label}}</view>
 								</view>
 								</view>
 								<uni-icons type="bottom" size="22" color="#2979ff"
 								<uni-icons type="bottom" size="22" color="#2979ff"
-									:style="{display: item3.isShow ? '' : 'none'}"></uni-icons>
+									:style="{display: item2.isShow ? '' : 'none'}"></uni-icons>
 								<uni-icons type="top" size="22" color="#2979ff"
 								<uni-icons type="top" size="22" color="#2979ff"
-									:style="{display: item3.isShow ? 'none' : ''}"></uni-icons>
+									:style="{display: item2.isShow ? 'none' : ''}"></uni-icons>
 							</view>
 							</view>
-							<view v-for="(item4, index4) in item3.children" :key="index4"
-								:style="{display: item3.isShow ? '' : 'none'}">
-								<view class="item-kongtiao" v-if="item4.isUsering">
-									<view :style="{color: item4.isUsering ? '#747578' : '#2979ff'}">
-										{{item4.label}}(使用中)
+							<!-- 教室、房间 -->
+							<view class="item-jiaoshi" v-for="(item3, index3) in item2.children" :key="index3"
+								:style="{display: item2.isShow ? '' : 'none'}">
+								<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)">
+									<view class="title-jiaoshi">
+										<uni-icons type="plus-filled" size="22" color="#2979ff"
+											:style="{display: item3.isShow ? 'none' : ''}"></uni-icons>
+										<uni-icons type="minus-filled" size="22" color="#2979ff"
+											:style="{display: item3.isShow ? '' : 'none'}"></uni-icons>
+										<view class="txt-jiaoshi">{{item3.label}}</view>
 									</view>
 									</view>
-									<checkbox :id="item4.id" :checked="true" :disabled="true" />
+									<uni-icons type="bottom" size="22" color="#2979ff"
+										:style="{display: item3.isShow ? '' : 'none'}"></uni-icons>
+									<uni-icons type="top" size="22" color="#2979ff"
+										:style="{display: item3.isShow ? 'none' : ''}"></uni-icons>
 								</view>
 								</view>
-								<view class="item-kongtiao" v-else>
-									<view :style="{color: item4.isUsering ? '#747578' : '#2979ff'}">
-										{{item4.label}}
+								<!-- 空调 -->
+								<view v-for="(item4, index4) in item3.children" :key="index4"
+									:style="{display: item3.isShow ? '' : 'none'}">
+									<view class="item-kongtiao" v-if="item4.isUsering">
+										<view :style="{color: item4.isUsering ? '#747578' : '#2979ff'}">
+											{{item4.label}}(使用中)
+										</view>
+										<checkbox :id="item4.id" :checked="true" :disabled="true" />
+									</view>
+									<view class="item-kongtiao" v-else>
+										<view :style="{color: item4.isUsering ? '#747578' : '#2979ff'}">
+											{{item4.label}}
+										</view>
+										<checkbox :value="index4" :id="item4.id" :checked="item4.isChecked"
+											@tap="handle_kongtiao" />
 									</view>
 									</view>
-									<checkbox :value="index4" :id="item4.id" :checked="item4.isChecked"
-										@tap="handle_kongtiao" />
 								</view>
 								</view>
 							</view>
 							</view>
 						</view>
 						</view>
@@ -85,109 +102,245 @@
 	export default {
 	export default {
 		data() {
 		data() {
 			return {
 			return {
-				// 用于返回到上一页面的结果变量
-				airs_selected: '',
+				ceshi: 'air',
+				id_card: '', // 身份证号
+				user_name: '', // 姓名
+				airs_selected: '', //
+				return_selected_airs: '', // 用于返回到上一页面的结果变量
 				show_airs: '', // 用于显示已经选择的空调
 				show_airs: '', // 用于显示已经选择的空调
-				screenHeight: '', // 屏幕的高度
-				// tree
-				treeData: [] // 树形选择器的数据
+				treeData: [], // 树形选择器的数据,目录树treeData
+				airsData: [], // 点击教室的时候,获取该教室的空调数据
+				screenHeight: '' // 屏幕的高度
 			};
 			};
 		},
 		},
-		onLoad() {
+		onLoad(options) {
 			uni.showLoading({
 			uni.showLoading({
 				title: '加载中'
 				title: '加载中'
 			})
 			})
 
 
-			// 模拟异步请求
+			// 获取表格数据
+			this.getTableData()
+
 			setTimeout(() => {
 			setTimeout(() => {
-				this.treeData = [{
-					id: 1,
-					label: '科技楼',
-					isShow: false,
-					children: [{
-						id: 11,
-						label: '5F',
-						isShow: false,
-						children: [{
-							id: 111,
-							label: '501',
-							isShow: false,
-							children: [{
-								id: 1111,
-								label: '空调-01',
-								isChecked: false,
-								isUsering: false
-							}, {
-								id: 1112,
-								label: '空调-02',
-								isChecked: true,
-								isUsering: true
-							}]
-						}, {
-							id: 112,
-							label: '502',
-							isShow: false,
-							children: [{
-								id: 1121,
-								label: '空调-01',
-								isChecked: false,
-								isUsering: false
-							}]
-						}]
-					}]
-				}, {
-					id: 2,
-					label: '志胜楼',
-					isShow: false,
-					children: [{
-						id: 21,
-						label: '1F',
-						isShow: false,
-						children: [{
-							id: 211,
-							label: '101',
-							isShow: false,
-							children: [{
-								id: 2111,
-								label: '空调-01',
-								isChecked: false,
-								isUsering: false
-							}, {
-								id: 2112,
-								label: '空调-02',
-								isChecked: false,
-								isUsering: false
-							}]
-						}, {
-							id: 212,
-							label: '102',
-							isShow: false,
-							children: [{
-								id: 2121,
-								label: '空调-01',
-								isChecked: false,
-								isUsering: false
-							}, {
-								id: 2122,
-								label: '空调-02',
-								isChecked: false,
-								isUsering: false
-							}]
-						}]
-					}]
-				}];
-
-				setTimeout(() => {
-					uni.hideLoading();
-				}, 500);
+				uni.hideLoading();
 			}, 500);
 			}, 500);
+
+			// 获取身份证号
+			this.get_base_info(options)
 		},
 		},
 		onShow() {
 		onShow() {
 			// 从新计算高度
 			// 从新计算高度
-			this.calc_screen_height()
+			setTimeout(() => {
+				this.calc_screen_height()
+			}, 1500)
 		},
 		},
 		methods: {
 		methods: {
 			/**
 			/**
+			 * 获取身份证号
+			 */
+			get_base_info(options) {
+				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
+							this.user_name = userinfo.name
+						} else {
+							uni.navigateTo({
+								url: '../index/index?from=' + options.from
+							})
+
+							uni.showToast({
+								icon: 'none',
+								title: '身份证号为空,请进行授权',
+								duration: 3000
+							});
+
+							return
+						}
+					}
+				} catch (e) {
+					console.log('获取基本信息:' + e.message);
+				}
+			},
+			/**
+			 * 点击房间,显示空调
+			 * @param {Object} e
+			 * @param {Object} id
+			 * @param {Object} label
+			 * @param {Object} rooms
+			 */
+			async get_air_in_the_room(e, id, label) {
+				let ids = id.split('|')
+				let labels = label.split('|')
+				// console.log(ids);
+				// console.log(labels);
+				// 展开或收起
+				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 (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
+						})
+					}
+					if (this.airsData.length > 0) {
+						// 填充数据
+						this.insert_into_treeData_rooms(this.treeData, ids[3])
+					}
+				} else {
+					uni.showToast({
+						title: '该房间未配空调'
+					});
+				}
+
+			},
+			/**
+			 * 填充空调到教室下面,供选择
+			 * @param {Object} obj
+			 * @param {Object} id
+			 */
+			insert_into_treeData_rooms(obj, id) {
+				for (var i = 0; i < obj.length; i++) {
+					if (obj[i].id == id) {
+						obj[i].children = this.airsData
+						return
+					}
+
+					if (typeof obj[i].children != 'undefined' && obj[i].children.length > 0) {
+						this.insert_into_treeData_rooms(obj[i].children, id)
+					}
+				}
+			},
+			/**
+			 * 树形选择器的数据
+			 */
+			async getTableData() {
+				const res = await this.$myRequest({
+					host: this.ceshi,
+					url: '/airManage/buildqueryDom.action',
+					method: 'POST',
+					header: {
+						'content-type': 'application/x-www-form-urlencoded'
+					}
+				})
+
+				// console.log(res.data);
+				if (typeof res.data.code === 'undefined') {
+					uni.showToast({
+						title: '未找到code!',
+						icon: 'success'
+					});
+					return
+				}
+
+				if (typeof res.data.data === 'undefined') {
+					uni.showToast({
+						title: '未返回数据data!',
+						icon: 'success'
+					});
+					return
+				}
+				
+				if (res.data.code === 200) {
+					let data = res.data.data
+					// 校区
+					let school = JSON.parse(data)
+					// console.log('school', school);
+					if (typeof school !== 'undefined' && school !== '') {
+						this.treeData = []
+						let tmpSchool = []
+						for (var i = 0; i < school.length; i++) {
+							let nData = []
+							let builds = school[i]["builds"]
+							for (var j = 0; j < builds.length; j++) {
+								let tmpBuilds = {}
+								let tmpFloors = []
+								let floors = builds[j]['floors']
+								for (var k = 0; k < floors.length; k++) {
+									let room = []
+									let tmpRooms = []
+									let rooms = floors[k].rooms
+									for (var p = 0; p < rooms.length; p++) {
+										room.push({
+											id: school[i].id + '' + builds[j].id + '' + floors[k].id + '' + i +
+												'' + j + '' + k + '' + p,
+											isShow: false,
+											label: rooms[p],
+											children: []
+										})
+									}
+									let floor = {
+										id: floors[k].id,
+										label: floors[k].floor,
+										isShow: false,
+										children: room
+									}
+									tmpFloors.push(floor)
+								}
+								tmpFloors.sort((a, b) => a.label.localeCompare(b.label))
+								tmpBuilds.id = builds[j].id
+								tmpBuilds.label = builds[j].building
+								tmpBuilds.isShow = false
+								tmpBuilds.children = []
+								tmpBuilds.children = tmpFloors
+								nData.push(tmpBuilds)
+							}
+							nData.sort((a, b) => a.label.localeCompare(b.label))
+							tmpSchool.push({
+								id: school[i].id,
+								label: school[i].school,
+								isShow: true,
+								children: nData
+							})
+						}
+						tmpSchool.sort((a, b) => b.label.localeCompare(a.label))
+						this.treeData = tmpSchool
+						// console.log(JSON.stringify(this.treeData));
+					} else {
+						this.treeData = []
+						uni.showToast({
+							title: '无符合的数据!'
+						});
+					}
+				} else {
+					uni.showToast({
+						title: res.data.message,
+						icon: 'success'
+					});
+				}
+			},
+			/**
 			 * 获取空调的全称,勾选返回空调全称,不勾返回-空调全称,递归调用
 			 * 获取空调的全称,勾选返回空调全称,不勾返回-空调全称,递归调用
 			 * @param {Object} obj
 			 * @param {Object} obj
 			 * @param {Object} id
 			 * @param {Object} id
@@ -202,7 +355,7 @@
 
 
 						if (obj[i].isChecked) {
 						if (obj[i].isChecked) {
 							obj[i].isChecked = false
 							obj[i].isChecked = false
-							return '-' + parentName + ' ' + obj[i].label
+							return '+' + parentName + ' ' + obj[i].label
 						} else {
 						} else {
 							obj[i].isChecked = true
 							obj[i].isChecked = true
 							return parentName + ' ' + obj[i].label
 							return parentName + ' ' + obj[i].label
@@ -210,31 +363,70 @@
 					}
 					}
 
 
 					let selfName = ''
 					let selfName = ''
-					if (typeof obj[i].children != 'undefined' && obj[i].children.length > 0) {
+					if (typeof obj[i].children !== 'undefined' && obj[i].children.length > 0) {
 						if (parentName == '') {
 						if (parentName == '') {
 							selfName = this.get_airs_full_name(obj[i].children, id, obj[i].label)
 							selfName = this.get_airs_full_name(obj[i].children, id, obj[i].label)
 						} else {
 						} else {
-							selfName = this.get_airs_full_name(obj[i].children, id, parentName + '-' + obj[i].label)
+							selfName = this.get_airs_full_name(obj[i].children, id, parentName + '+' + obj[i].label)
 						}
 						}
 
 
-						if (typeof selfName != 'undefined') {
+						if (typeof selfName !== 'undefined') {
 							return selfName
 							return selfName
 						}
 						}
 					}
 					}
 				}
 				}
 			},
 			},
 			/**
 			/**
+			 * 获取空调的ids
+			 * @param {Object} obj
+			 * @param {Object} id
+			 */
+			get_airs_ids() {
+				let airs_selected_ids = ''
+				let obj0 = this.treeData
+				for (var i = 0; i < obj0.length; i++) {
+					if (typeof obj0[i].children !== 'undefined' && obj0[i].children.length > 0) {
+						let obj1 = obj0[i].children
+						for (var j = 0; j < obj1.length; j++) {
+							if (typeof obj1[j].children !== 'undefined' && obj1[j].children.length > 0) {
+								let obj2 = obj1[j].children
+								for (var k = 0; k < obj2.length; k++) {
+									if (typeof obj2[k].children !== 'undefined' && obj2[k].children.length > 0) {
+										let obj3 = obj2[k].children
+										for (var p = 0; p < obj3.length; p++) {
+											if (typeof obj3[p].children !== 'undefined' && obj3[p].children.length > 0) {
+												let obj4 = obj3[p].children
+												for (var u = 0; u < obj4.length; u++) {
+													if (obj4[u].isChecked) {
+														airs_selected_ids += obj0[i].label + '-' + obj1[j].label + '-' +
+															obj2[k]
+															.label + '-' + obj3[p].label + '|' + obj4[u].label + '|' +
+															obj4[u]
+															.id + ','
+													}
+												}
+											}
+										}
+									}
+								}
+							}
+						}
+					}
+				}
+				this.return_selected_airs = airs_selected_ids.substring(0, airs_selected_ids.length - 1)
+			},
+			/**
 			 * 更新airs_selected中的数据
 			 * 更新airs_selected中的数据
 			 * @param {Object} param
 			 * @param {Object} param
 			 */
 			 */
 			update_airs_selected(param) {
 			update_airs_selected(param) {
 				let tmp_airs_selected = ''
 				let tmp_airs_selected = ''
-				if (param.indexOf('-') == 0) { // 删除airs_selected中的数据
-					// 把前面的'-'去除
+				if (param.indexOf('+') == 0) { // 删除airs_selected中的数据
+					// 把前面的'+'去除
 					let del_val = param.substring(1)
 					let del_val = param.substring(1)
-					// 需要删除的值进行拆分成:【楼栋-楼层-房间,空调】
+					// 需要删除的值进行拆分成:【楼栋+楼层+房间, 空调】
 					let room = del_val.split(' ')
 					let room = del_val.split(' ')
-					if (this.airs_selected.trim() != '') {
+					if (this.airs_selected.trim() !== '') {
 						let arrAirs = this.airs_selected.trim().split(',')
 						let arrAirs = this.airs_selected.trim().split(',')
 						let airs = ''
 						let airs = ''
 						for (var i = 0; i < arrAirs.length; i++) {
 						for (var i = 0; i < arrAirs.length; i++) {
@@ -249,7 +441,7 @@
 								}
 								}
 							}
 							}
 
 
-							if (airs != '') {
+							if (airs !== '') {
 								// 保存到临时变量tmp_airs_selected中
 								// 保存到临时变量tmp_airs_selected中
 								tmp_airs_selected += airs + ','
 								tmp_airs_selected += airs + ','
 							}
 							}
@@ -310,7 +502,9 @@
 				let id = e.currentTarget.id
 				let id = e.currentTarget.id
 				// 获取勾选的值
 				// 获取勾选的值
 				let airsFullName = this.get_airs_full_name(this.treeData, id, '')
 				let airsFullName = this.get_airs_full_name(this.treeData, id, '')
-				if (typeof airsFullName != 'undefined') {
+				// 获取所有选中的id
+				this.get_airs_ids()
+				if (typeof airsFullName !== 'undefined') {
 					// 更新airs_selected中的数据
 					// 更新airs_selected中的数据
 					this.update_airs_selected(airsFullName)
 					this.update_airs_selected(airsFullName)
 				} else {
 				} else {
@@ -356,9 +550,22 @@
 			 */
 			 */
 			confirm_selection() {
 			confirm_selection() {
 				// 触发全局的自定义事件,附加参数都会传给监听器回调函数。
 				// 触发全局的自定义事件,附加参数都会传给监听器回调函数。
-				if (this.airs_selected != '') {
+				if (this.return_selected_airs !== '') {
+					// 保存到数据库
+					let arrAirs = this.return_selected_airs.trim().split(',').sort()
+					for (var i = 0; i < arrAirs.length; i++) {
+						let tmpAirs = arrAirs[i].split('|');
+						let _this = this;
+						// 绑定空调
+						(function(t, air_ip) {
+							setTimeout(function() {
+								_this.bangding_airs(air_ip);
+							}, 300 * t);
+						})(i, tmpAirs[2])
+					}
+
 					uni.$emit('selectAirs', {
 					uni.$emit('selectAirs', {
-						airs: this.airs_selected
+						airs: this.return_selected_airs
 					})
 					})
 				}
 				}
 
 
@@ -368,7 +575,41 @@
 				})
 				})
 			},
 			},
 			/**
 			/**
-			 * 超出左边显示...
+			 * 绑定空调
+			 * @param {Object} air_id
+			 */
+			async bangding_airs(air_id) {
+				const res = await this.$myRequest({
+					host: this.ceshi,
+					url: '/airManage/usersbdair.action',
+					method: 'POST',
+					header: {
+						'content-type': 'application/json'
+					},
+					data: {
+						user_name: this.user_name,
+						sfzh: this.id_card,
+						air_ip: air_id
+					}
+				})
+
+				// console.log(res.data);
+				if (res.data.code == 200) {
+					uni.showToast({
+						icon: 'none',
+						title: res.data.message,
+						duration: 1500
+					})
+				} else {
+					uni.showToast({
+						icon: 'none',
+						title: res.data.message,
+						duration: 1500
+					})
+				}
+			},
+			/**
+			 * 超出左边显示"..."
 			 */
 			 */
 			show_selected_airs() {
 			show_selected_airs() {
 				// 显示到上方
 				// 显示到上方
@@ -453,88 +694,108 @@
 				overflow: scroll;
 				overflow: scroll;
 			}
 			}
 
 
-			.item-loudong {
+			.item-school {
 				display: flex;
 				display: flex;
 				flex-direction: column;
 				flex-direction: column;
 				padding: 10rpx 0 0 10rpx;
 				padding: 10rpx 0 0 10rpx;
 
 
-				.loudong {
+				.school {
 					display: flex;
 					display: flex;
 					align-items: center;
 					align-items: center;
 					justify-content: space-between;
 					justify-content: space-between;
-					border: 1rpx solid #c7c9ce;
-					padding: 10rpx;
+					background-color: #2979ff;
+					color: #ffffff;
+					padding: 10rpx 10rpx 10rpx 20rpx;
 					height: 60rpx;
 					height: 60rpx;
-					width: 636rpx;
+					width: 668rpx;
 					font-size: 30rpx;
 					font-size: 30rpx;
-
-					.title-loudong {
-						display: flex;
-					}
-
-					.txt-loudong {
-						padding-left: 5rpx;
-					}
 				}
 				}
 
 
-				.item-loucheng {
+				.item-loudong {
 					display: flex;
 					display: flex;
 					flex-direction: column;
 					flex-direction: column;
-					margin-left: 60rpx;
+					padding: 10rpx 0 0 10rpx;
+					margin-left: 30rpx;
 
 
-					.loucheng {
+
+					.loudong {
 						display: flex;
 						display: flex;
 						align-items: center;
 						align-items: center;
 						justify-content: space-between;
 						justify-content: space-between;
 						border: 1rpx solid #c7c9ce;
 						border: 1rpx solid #c7c9ce;
 						padding: 10rpx;
 						padding: 10rpx;
 						height: 60rpx;
 						height: 60rpx;
-						width: 578rpx;
+						width: 636rpx;
 						font-size: 30rpx;
 						font-size: 30rpx;
 
 
-						.title-loucheng {
+						.title-loudong {
 							display: flex;
 							display: flex;
 						}
 						}
 
 
-						.txt-loucheng {
+						.txt-loudong {
 							padding-left: 5rpx;
 							padding-left: 5rpx;
 						}
 						}
 					}
 					}
 
 
-					.item-jiaoshi {
+					.item-loucheng {
 						display: flex;
 						display: flex;
 						flex-direction: column;
 						flex-direction: column;
 						margin-left: 60rpx;
 						margin-left: 60rpx;
 
 
-						.jiaoshi {
+						.loucheng {
 							display: flex;
 							display: flex;
 							align-items: center;
 							align-items: center;
 							justify-content: space-between;
 							justify-content: space-between;
 							border: 1rpx solid #c7c9ce;
 							border: 1rpx solid #c7c9ce;
 							padding: 10rpx;
 							padding: 10rpx;
 							height: 60rpx;
 							height: 60rpx;
-							width: 520rpx;
+							width: 578rpx;
 							font-size: 30rpx;
 							font-size: 30rpx;
 
 
-							.title-jiaoshi {
+							.title-loucheng {
 								display: flex;
 								display: flex;
 							}
 							}
 
 
-							.txt-jiaoshi {
+							.txt-loucheng {
 								padding-left: 5rpx;
 								padding-left: 5rpx;
 							}
 							}
 						}
 						}
 
 
-						.item-kongtiao {
+						.item-jiaoshi {
 							display: flex;
 							display: flex;
-							justify-content: space-between;
-							align-items: center;
-							border: 1rpx solid #c7c9ce;
+							flex-direction: column;
 							margin-left: 60rpx;
 							margin-left: 60rpx;
-							padding: 10rpx 10rpx 10rpx 30rpx;
-							height: 60rpx;
-							width: 442rpx;
-							font-size: 32rpx;
+
+							.jiaoshi {
+								display: flex;
+								align-items: center;
+								justify-content: space-between;
+								border: 1rpx solid #c7c9ce;
+								padding: 10rpx;
+								height: 60rpx;
+								width: 520rpx;
+								font-size: 30rpx;
+
+								.title-jiaoshi {
+									display: flex;
+								}
+
+								.txt-jiaoshi {
+									padding-left: 5rpx;
+								}
+							}
+
+							.item-kongtiao {
+								display: flex;
+								justify-content: space-between;
+								align-items: center;
+								border: 1rpx solid #c7c9ce;
+								margin-left: 60rpx;
+								padding: 10rpx 10rpx 10rpx 30rpx;
+								height: 60rpx;
+								width: 442rpx;
+								font-size: 32rpx;
+							}
 						}
 						}
 					}
 					}
 				}
 				}

+ 8 - 8
pagesAir/rechargeRecord/rechargeRecord.vue

@@ -30,7 +30,7 @@
 	export default {
 	export default {
 		data() {
 		data() {
 			return {
 			return {
-				screenHeight: 0,
+				ceshi: 'air',
 				id_card: '', // 身份证号
 				id_card: '', // 身份证号
 				date: this.$getDate({
 				date: this.$getDate({
 					format: true
 					format: true
@@ -38,7 +38,7 @@
 				startDate: this.$getDate('start_date'),
 				startDate: this.$getDate('start_date'),
 				endDate: this.$getDate('end_date'),
 				endDate: this.$getDate('end_date'),
 				chongzhi_items: [], // 消费记录
 				chongzhi_items: [], // 消费记录
-				ceshi: 'dev',
+				screenHeight: 0,
 			}
 			}
 		},
 		},
 		onLoad(options) {
 		onLoad(options) {
@@ -47,9 +47,9 @@
 		},
 		},
 		onShow() {
 		onShow() {
 			// 从新计算高度
 			// 从新计算高度
-			// setTimeout(() => {
-			this.calc_screen_height()
-			// }, 1500)
+			setTimeout(() => {
+				this.calc_screen_height()
+			}, 1500)
 		},
 		},
 		methods: {
 		methods: {
 			/**
 			/**
@@ -85,7 +85,6 @@
 			 * 获取身份证号
 			 * 获取身份证号
 			 */
 			 */
 			get_base_info() {
 			get_base_info() {
-				// console.log(options);
 				try {
 				try {
 					if (this.id_card == '' || typeof(this.id_card) == 'undefined') {
 					if (this.id_card == '' || typeof(this.id_card) == 'undefined') {
 						const userinfo = uni.getStorageSync('userinfo_storage_key')
 						const userinfo = uni.getStorageSync('userinfo_storage_key')
@@ -123,8 +122,8 @@
 						'content-type': 'application/x-www-form-urlencoded'
 						'content-type': 'application/x-www-form-urlencoded'
 					},
 					},
 					data: {
 					data: {
-						sfzh: this.id_card,
 						// sfzh: '36012325455222',
 						// sfzh: '36012325455222',
+						sfzh: this.id_card,
 						month: this.date
 						month: this.date
 					}
 					}
 				})
 				})
@@ -138,7 +137,8 @@
 						for (var i = 0; i < data.data.length; i++) {
 						for (var i = 0; i < data.data.length; i++) {
 							tmp_items.push({
 							tmp_items.push({
 								begin_time: data.data[i].time,
 								begin_time: data.data[i].time,
-								desc: data.data[i].order_num,
+								// desc: data.data[i].order_num,
+								desc: '空调充值',
 								use_amount: data.data[i].account
 								use_amount: data.data[i].account
 							})
 							})
 						}
 						}

+ 229 - 50
pagesAir/shareAir/shareAir.vue

@@ -56,7 +56,7 @@
 			<scroll-view scroll-y="true" :style="{height: screenHeight}" @scrolltoupper="scroll_to_upper"
 			<scroll-view scroll-y="true" :style="{height: screenHeight}" @scrolltoupper="scroll_to_upper"
 				@scrolltolower="scroll_to_lower">
 				@scrolltolower="scroll_to_lower">
 				<view class="list-items" v-for="(item, index) in airs" :key="index">
 				<view class="list-items" v-for="(item, index) in airs" :key="index">
-					<view v-if="item.on" class="item-air" @longpress="itemLongPress($event, 1)">
+					<view v-if="item.on" class="item-air" @longpress="itemLongPress($event, 1, item.air_ip)">
 						<view class="item-left">
 						<view class="item-left">
 							<view class="item-icon">
 							<view class="item-icon">
 								<view class="circle1"></view>
 								<view class="circle1"></view>
@@ -69,7 +69,7 @@
 								<text>启用时长:</text><text>{{item.time}}</text>
 								<text>启用时长:</text><text>{{item.time}}</text>
 							</view>
 							</view>
 						</view>
 						</view>
-						<view class="item-right" @tap="btn_click" :ref="index">
+						<view class="item-right" @tap="btn_click(index, item.air_ip, item.name, item.info)">
 							<view class="item-btn">
 							<view class="item-btn">
 								<image src="../static/images/power-off.png" mode="aspectFit"></image>
 								<image src="../static/images/power-off.png" mode="aspectFit"></image>
 								<view class="item-txt-off">
 								<view class="item-txt-off">
@@ -78,7 +78,7 @@
 							</view>
 							</view>
 						</view>
 						</view>
 					</view>
 					</view>
-					<view v-else class="item-air" @longpress="itemLongPress($event, 0)" :ref="index">
+					<view v-else class="item-air" @longpress="itemLongPress($event, 0, item.air_ip)" :ref="index">
 						<view class="item-left">
 						<view class="item-left">
 							<view class="item-icon">
 							<view class="item-icon">
 								<view class="circle1"></view>
 								<view class="circle1"></view>
@@ -92,7 +92,8 @@
 								<text>未启用</text>
 								<text>未启用</text>
 							</view>
 							</view>
 						</view>
 						</view>
-						<view class="item-right" @tap="btn_click" :ref="index">
+						<view class="item-right" @tap="btn_click(index, item.air_ip, item.name, item.info)"
+							:ref="index">
 							<view class="item-btn">
 							<view class="item-btn">
 								<image src="../static/images/power-on.png" mode="aspectFit"></image>
 								<image src="../static/images/power-on.png" mode="aspectFit"></image>
 								<view class="item-txt-on">
 								<view class="item-txt-on">
@@ -115,9 +116,11 @@
 	export default {
 	export default {
 		data() {
 		data() {
 			return {
 			return {
-				ceshi: 'dev',
-				stu_number: '',
-				userinfo: {},
+				ceshi: 'air',
+				userinfo: {}, // 用户信息
+				stu_number: '', // 学号
+				id_card: '', // 身份证号
+				order_num: '', // 订单号
 				// 滚动横幅的数据
 				// 滚动横幅的数据
 				imgUrl: [{
 				imgUrl: [{
 						url: this.$code_base_url + '/image/1.png'
 						url: this.$code_base_url + '/image/1.png'
@@ -129,10 +132,10 @@
 						url: this.$code_base_url + '/image/3.png'
 						url: this.$code_base_url + '/image/3.png'
 					}
 					}
 				],
 				],
+				current: 0, // 开始显示第几个
 				balance: 0.0.toFixed(2), // 余额
 				balance: 0.0.toFixed(2), // 余额
 				airs: [], // 已经添加的空调列表数据
 				airs: [], // 已经添加的空调列表数据
 				dotMode: 'round', // 显示控制点样式
 				dotMode: 'round', // 显示控制点样式
-				current: 0, // 开始显示第几个
 				isList: false, // 是否显示添加的空调列表
 				isList: false, // 是否显示添加的空调列表
 				screenHeight: '' // 屏幕的高度
 				screenHeight: '' // 屏幕的高度
 			};
 			};
@@ -146,7 +149,6 @@
 				// 显示添加的空调列表
 				// 显示添加的空调列表
 				this.isList = true
 				this.isList = true
 			}
 			}
-
 			// 获取基本信息
 			// 获取基本信息
 			this.get_base_info(options, 'onLoad')
 			this.get_base_info(options, 'onLoad')
 		},
 		},
@@ -156,39 +158,31 @@
 			// 监听全局的自定义事件,事件由 uni.$emit 触发,但仅触发一次,在第一次触发之后移除该监听器。
 			// 监听全局的自定义事件,事件由 uni.$emit 触发,但仅触发一次,在第一次触发之后移除该监听器。
 			// 绑定空调
 			// 绑定空调
 			uni.$once('selectAirs', data => {
 			uni.$once('selectAirs', data => {
-				// console.log('监听到事件来自 selectAirs ,携带参数 airs 为:' + data.airs);
-				// this.airs = []
-				let arrAirs = data.airs.trim().split(',').sort()
-				let airs = []
-				let room = '' // 房间名
-				let temp = true // 没有同名的空调
+				// console.log(data.airs);
+				let arrAirs = data.airs.trim().split(',')
 				for (var i = 0; i < arrAirs.length; i++) {
 				for (var i = 0; i < arrAirs.length; i++) {
-					airs = arrAirs[i].trim().split(' ')
-					// room = airs[0].replaceAll('-', '')
-					room = airs[0]
-					for (var j = 1; j < airs.length; j++) {
-						if (airs[j].trim().length > 0) {
-							temp = true
-							for (var k = 0; k < this.airs.length; k++) {
-								if (this.airs[k].name == room + ' ' + airs[j]) {
-									temp = false
-									break
-								}
-							}
-							// 没有同名的
-							if (temp) {
-								this.airs.push({
-									name: room + ' ' + airs[j],
-									info: '2P空调',
-									time: '01:25:21',
-									on: false
-								})
-							}
+					let tmpAirs = arrAirs[i].split('|')
+					let t = tmpAirs[1].split('-')
+					let tf = true
+					for (var j = 0; j < this.airs.length; j++) {
+						if (this.airs[j].air_ip == tmpAirs[2]) {
+							tf = false
 						}
 						}
 					}
 					}
+					// 存在则不添加到数组和缓存
+					if (true === tf) {
+						this.airs.push({
+							air_ip: tmpAirs[2],
+							name: tmpAirs[0] + ' ' + t[0],
+							info: t[1],
+							time: '',
+							on: false
+						})
+					}
 				}
 				}
 				// 如果选的空调不为空,则显示添加的空调列表
 				// 如果选的空调不为空,则显示添加的空调列表
 				if (this.airs.length > 0) {
 				if (this.airs.length > 0) {
+					this.airs.sort((a, b)=> a.name.localeCompare(b.name))
 					// 显示添加的空调列表
 					// 显示添加的空调列表
 					this.isList = true
 					this.isList = true
 				}
 				}
@@ -200,6 +194,50 @@
 		},
 		},
 		methods: {
 		methods: {
 			/**
 			/**
+			 * 查询绑定的空调
+			 */
+			async select_banding_airs() {
+				const res = await this.$myRequest({
+					host: this.ceshi,
+					url: '/airManage/usersqueryAir.action',
+					method: 'POST',
+					header: {
+						'content-type': 'application/x-www-form-urlencoded'
+					},
+					data: {
+						sfzh: this.id_card
+					}
+				})
+
+				// console.log(res.data);
+				if (res.data.code == 200) {
+					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 (tf !== true) {
+							this.airs.slice(i, 1)
+						}
+					}
+					if (len > this.airs.length) {
+						// 存储空调列表
+						uni.setStorageSync('airs_selected', this.airs)
+					}
+				} else {
+					// 提示返回信息
+					uni.showToast({
+						title: res.data.message
+					})
+				}
+			},
+			/**
 			 * 获取基本信息
 			 * 获取基本信息
 			 */
 			 */
 			get_base_info(options, param) {
 			get_base_info(options, param) {
@@ -212,6 +250,7 @@
 						const userinfo = uni.getStorageSync('userinfo_storage_key')
 						const userinfo = uni.getStorageSync('userinfo_storage_key')
 						if (userinfo) { // 拿学号
 						if (userinfo) { // 拿学号
 							this.stu_number = userinfo.card_number
 							this.stu_number = userinfo.card_number
+							this.id_card = userinfo.id_card
 						} else { // 还没有需要跳转到首页进行获取
 						} else { // 还没有需要跳转到首页进行获取
 							uni.navigateTo({
 							uni.navigateTo({
 								url: '../index/index?from=' + options.from
 								url: '../index/index?from=' + options.from
@@ -288,7 +327,7 @@
 					this.getCode(options, 'get_user_info')
 					this.getCode(options, 'get_user_info')
 					// 用户已经存在,但没必要提示
 					// 用户已经存在,但没必要提示
 					// uni.showToast({
 					// uni.showToast({
-					// 	title: res.data.message
+					// title: res.data.message
 					// })
 					// })
 				} else {
 				} else {
 					// 提示返回信息
 					// 提示返回信息
@@ -328,6 +367,9 @@
 				if (res.data.code == 200) {
 				if (res.data.code == 200) {
 					// 余额
 					// 余额
 					this.balance = res.data.data.balance.toFixed(2)
 					this.balance = res.data.data.balance.toFixed(2)
+					this.id_card = res.data.data.sfzh
+
+					this.select_banding_airs()
 				} else {
 				} else {
 					uni.showToast({
 					uni.showToast({
 						title: res.data.message
 						title: res.data.message
@@ -339,8 +381,8 @@
 			 * @param {Object} e
 			 * @param {Object} e
 			 * @param {Object} val
 			 * @param {Object} val
 			 */
 			 */
-			itemLongPress(e, val) {
-				// console.log(e, val);
+			itemLongPress(e, val, air_ip) {
+				// console.log(e, val, air_ip);
 				if (val == 0) {
 				if (val == 0) {
 					let index = e.currentTarget.dataset.ref
 					let index = e.currentTarget.dataset.ref
 					uni.showModal({
 					uni.showModal({
@@ -352,6 +394,8 @@
 								this.airs.splice(index, 1)
 								this.airs.splice(index, 1)
 								// 更新存储
 								// 更新存储
 								uni.setStorageSync('airs_selected', this.airs)
 								uni.setStorageSync('airs_selected', this.airs)
+								// 解绑空调
+								this.unbangding_airs(air_ip)
 							}
 							}
 						}
 						}
 					})
 					})
@@ -364,26 +408,57 @@
 				}
 				}
 			},
 			},
 			/**
 			/**
+			 * 解绑空调
+			 * @param {Object} air_ip
+			 */
+			async unbangding_airs(air_ip) {
+				const res = await this.$myRequest({
+					host: this.ceshi,
+					url: '/airManage/usersdelAir.action',
+					method: 'POST',
+					header: {
+						'content-type': 'application/x-www-form-urlencoded'
+					},
+					data: {
+						sfzh: this.id_card,
+						air_ip: air_ip
+					}
+				})
+
+				// console.log(res.data);
+				if (res.data.code == 200) {
+					uni.showToast({
+						title: res.data.message
+					})
+				} else {
+					uni.showToast({
+						title: res.data.message
+					})
+				}
+			},
+			/**
 			 * 单击了启动或关闭按钮
 			 * 单击了启动或关闭按钮
 			 * @param {Object} e
 			 * @param {Object} e
 			 */
 			 */
-			btn_click(e) {
-				// console.log(e.currentTarget.dataset.ref);
-				let index_btn = e.currentTarget.dataset.ref
+			btn_click(index, air_ip, name, info) {
+				// console.log(index, air_ip, name, info);
+				let tmp = name.split('-');
+				let build = tmp[1],
+					floors = tmp[2],
+					dom = tmp[3] + '-' + tmp[4].split(' ')[0];
 				// 未获取到索引
 				// 未获取到索引
-				if (typeof index_btn === 'undefined') {
+				if (typeof index === 'undefined') {
 					return
 					return
 				}
 				}
 
 
-				if (this.airs[index_btn].on) {
+				if (this.airs[index].on) {
 					uni.showModal({
 					uni.showModal({
 						title: '提示',
 						title: '提示',
 						content: '确认【关闭】空调吗?',
 						content: '确认【关闭】空调吗?',
 						success: (res) => {
 						success: (res) => {
 							if (res.confirm) {
 							if (res.confirm) {
-								// 操作【关闭】空调
-
-								this.airs[index_btn].on = false
+								// 【关闭】空调
+								this.close_airs(index, air_ip)
 							}
 							}
 						}
 						}
 					});
 					});
@@ -393,15 +468,118 @@
 						content: '确认【启动】空调吗?',
 						content: '确认【启动】空调吗?',
 						success: (res) => {
 						success: (res) => {
 							if (res.confirm) {
 							if (res.confirm) {
-								// 操作【启动】空调
-
-								this.airs[index_btn].on = true
+								// 【启动】空调
+								uni.login({
+									success: (res) => {
+										// console.log('getCode', res);
+										if (res.code) {
+											// 调用接口,开启空调
+											this.open_airs(res.code, index, air_ip, build, floors,
+												dom,
+												info)
+										} else {
+											uni.showToast({
+												title: res.errMsg,
+												icon: 'none'
+											});
+										}
+									}
+								})
 							}
 							}
 						}
 						}
 					});
 					});
 				}
 				}
 			},
 			},
 			/**
 			/**
+			 * 关闭空调
+			 * @param {Object} index
+			 * @param {Object} air_ip
+			 */
+			async close_airs(index, air_ip) {
+				if (this.order_num == '') {
+					uni.showToast({
+						title: '未获得单号'
+					})
+					return
+				}
+
+				if (this.this.id_card == '') {
+					uni.showToast({
+						title: '未获得身份证号'
+					})
+					return
+				}
+
+				const res = await this.$myRequest({
+					host: this.ceshi,
+					url: '/airManage/consumeend.action',
+					method: 'POST',
+					header: {
+						'content-type': 'application/x-www-form-urlencoded'
+					},
+					data: {
+						sfzh: this.id_card,
+						order_num: this.order_num,
+						clientId: air_ip
+					}
+				})
+
+				console.log(res.data);
+				if (res.data.code == 200) {
+					uni.showToast({
+						title: res.data.message
+					})
+					// 显示已经关闭图标
+					this.airs[index].on = false
+				} else {
+					uni.showToast({
+						title: res.data.message
+					})
+				}
+			},
+			/**
+			 * 启动空调
+			 * @param {Object} code
+			 * @param {Object} index
+			 * @param {Object} air_ip
+			 * @param {Object} build
+			 * @param {Object} floors
+			 * @param {Object} dom
+			 * @param {Object} air_config
+			 */
+			async open_airs(code, index, air_ip, build, floors, dom, air_config) {
+				const res = await this.$myRequest({
+					host: this.ceshi,
+					url: '/airManage/consumestart.action',
+					method: 'POST',
+					header: {
+						'content-type': 'application/x-www-form-urlencoded'
+					},
+					data: {
+						code: code,
+						air_ip: air_ip,
+						build: build,
+						floors: floors,
+						dom: dom,
+						air_config: air_config
+					}
+				})
+
+				console.log(res.data);
+				if (res.data.code == 200) {
+					uni.showToast({
+						title: res.data.message
+					})
+					// 显示已经开启图标
+					this.airs[index].on = true
+					this.order_num = res.data.data.order_num
+				} else {
+					uni.showToast({
+						title: res.data.message
+					})
+				}
+			},
+			/**
 			 * 滚动到顶部提示
 			 * 滚动到顶部提示
 			 */
 			 */
 			scroll_to_upper() {
 			scroll_to_upper() {
@@ -673,6 +851,7 @@
 							flex-direction: column;
 							flex-direction: column;
 							justify-content: center;
 							justify-content: center;
 							align-items: center;
 							align-items: center;
+							margin-left: 20rpx;
 							width: 100rpx;
 							width: 100rpx;
 							height: 100rpx;
 							height: 100rpx;
 							border: 1px solid #d9deeb;
 							border: 1px solid #d9deeb;

+ 3 - 5
pagesAir/stdBookMgr/stdBookMgr.vue

@@ -56,7 +56,7 @@
 	export default {
 	export default {
 		data() {
 		data() {
 			return {
 			return {
-				ceshi: 'dev',
+				ceshi: 'air',
 				id_card: '', // 身份证号
 				id_card: '', // 身份证号
 				screenHeight: 0,
 				screenHeight: 0,
 				years: this.$getDate('get_year'), // 候选年份
 				years: this.$getDate('get_year'), // 候选年份
@@ -139,7 +139,6 @@
 			async getRecord() {
 			async getRecord() {
 				let res = await this.$myRequest({
 				let res = await this.$myRequest({
 					host: this.ceshi,
 					host: this.ceshi,
-					// url: '/HotWaters/elqueryDayPower.action',
 					url: '/airManage/consumequeryOwnPage.action',
 					url: '/airManage/consumequeryOwnPage.action',
 					method: 'POST',
 					method: 'POST',
 					header: {
 					header: {
@@ -177,7 +176,7 @@
 					this.consumeRecords = tmpRecord
 					this.consumeRecords = tmpRecord
 				} else if (typeof data.code === 'undefined') {
 				} else if (typeof data.code === 'undefined') {
 					uni.showToast({
 					uni.showToast({
-						title: '无法识别code',
+						title: data.message,
 						duration: 1500
 						duration: 1500
 					})
 					})
 				} else {
 				} else {
@@ -193,15 +192,14 @@
 			async getRechargeRecord() {
 			async getRechargeRecord() {
 				let res = await this.$myRequest({
 				let res = await this.$myRequest({
 					host: this.ceshi,
 					host: this.ceshi,
-					// url: '/HotWaters/elqueryDayPower.action',
 					url: '/airManage/consumequeryOwnConTong.action',
 					url: '/airManage/consumequeryOwnConTong.action',
 					method: 'POST',
 					method: 'POST',
 					header: {
 					header: {
 						'content-type': 'application/x-www-form-urlencoded'
 						'content-type': 'application/x-www-form-urlencoded'
 					},
 					},
 					data: {
 					data: {
-						sfzh: this.id_card
 						// sfzh: '360313110'
 						// sfzh: '360313110'
+						sfzh: this.id_card
 					}
 					}
 				})
 				})
 
 

+ 3 - 3
static/api.js

@@ -1,7 +1,7 @@
 const WEXIN_BASE_URL = 'https://api.mch.weixin.qq.com' // wexin
 const WEXIN_BASE_URL = 'https://api.mch.weixin.qq.com' // wexin
 const WECARD_BASE_URL = 'https://open.wecard.qq.com' // wecard
 const WECARD_BASE_URL = 'https://open.wecard.qq.com' // wecard
 const CODE_BASE_URL = 'https://chtech.ncjti.edu.cn/shuidian' // code
 const CODE_BASE_URL = 'https://chtech.ncjti.edu.cn/shuidian' // code
-const CODE_DEV_URL = 'http://demo.xwsyjjy.com' // dev 开发域名
+const AIR_BASE_URL = 'https://chtech.ncjti.edu.cn/air-conditioner-control' // air
 const IP_BASE_URL = 'https://pv.sohu.com/cityjson' // ip
 const IP_BASE_URL = 'https://pv.sohu.com/cityjson' // ip
 
 
 const myRequest = (options) => {
 const myRequest = (options) => {
@@ -17,8 +17,8 @@ const myRequest = (options) => {
 			BASE_URL = WEXIN_BASE_URL;
 			BASE_URL = WEXIN_BASE_URL;
 		} else if (options.host == 'wecard') {
 		} else if (options.host == 'wecard') {
 			BASE_URL = WECARD_BASE_URL;
 			BASE_URL = WECARD_BASE_URL;
-		} else if (options.host == 'dev') { // 开发域名,上线后删除
-			BASE_URL = CODE_DEV_URL; // 开发测试,上线后删除
+		} else if (options.host == 'air') {
+			BASE_URL = AIR_BASE_URL;
 		} else if (options.host == 'code') {
 		} else if (options.host == 'code') {
 			BASE_URL = CODE_BASE_URL;
 			BASE_URL = CODE_BASE_URL;
 		} else if (options.host == 'ip') {
 		} else if (options.host == 'ip') {