Browse Source

增加功能,和修复已知问题。

soft5566 3 years ago
parent
commit
86fc4de0a7

+ 7 - 0
pages.json

@@ -123,6 +123,13 @@
 					"enablePullDownRefresh": false
 					"enablePullDownRefresh": false
 				}
 				}
 
 
+			}, {
+				"path": "figure/figure",
+				"style": {
+					"navigationBarTitleText": "电流、电压、功率",
+					"enablePullDownRefresh": false
+				}
+
 			}]
 			}]
 		},
 		},
 		{
 		{

+ 5 - 2
pages/index/index.vue

@@ -75,10 +75,10 @@
 			if (typeof options.from != 'undefined') {
 			if (typeof options.from != 'undefined') {
 				this.from = options.from;
 				this.from = options.from;
 			}
 			}
-			// 是否是测试环境,查询数据接口中参数的值决定,方便以后测试
-			this.isTestEnvironment();
 			// 检查是否存在用户信息
 			// 检查是否存在用户信息
 			this.has_user_info();
 			this.has_user_info();
+			// 是否是测试环境,查询数据接口中参数的值决定,方便以后测试
+			this.isTestEnvironment();
 
 
 			this.execed_onload = true;
 			this.execed_onload = true;
 		},
 		},
@@ -364,6 +364,9 @@
 						duration: 800,
 						duration: 800,
 						success: res => {
 						success: res => {
 							if (_this.from != 0 || _this.from != '0') {
 							if (_this.from != 0 || _this.from != '0') {
+								// 页面跳转回去
+								uni.setStorageSync('navigateBack', 1);
+
 								uni.navigateBack({
 								uni.navigateBack({
 									delta: 1
 									delta: 1
 								});
 								});

+ 4 - 0
pages/reshui/reshui.vue

@@ -292,6 +292,10 @@
 			uni.$once('update_reshui_amount', (data) => {
 			uni.$once('update_reshui_amount', (data) => {
 				this.get_base_info('options', 'onShow');
 				this.get_base_info('options', 'onShow');
 			});
 			});
+			
+			let back = uni.getStorageSync('navigateBack');
+			if (back == 1)
+				this.get_base_info('options', 'navigateBack');
 
 
 			if (this.timer > -1) {
 			if (this.timer > -1) {
 				clearInterval(this.timer)
 				clearInterval(this.timer)

+ 12 - 13
pagesAir/addAir/addAir.vue

@@ -411,11 +411,8 @@
 												let obj4 = obj3[p].children
 												let obj4 = obj3[p].children
 												for (var u = 0; u < obj4.length; u++) {
 												for (var u = 0; u < obj4.length; u++) {
 													if (obj4[u].isChecked) {
 													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 + ','
+														airs_selected_ids += obj0[i].label + '-' + obj1[j].label + '-' +obj2[k]
+															.label + '-' + obj3[p].label + '|' + obj4[u].label + '|' +obj4[u].id + ','
 													}
 													}
 												}
 												}
 											}
 											}
@@ -426,7 +423,7 @@
 						}
 						}
 					}
 					}
 				}
 				}
-				this.return_selected_airs = airs_selected_ids.substring(0, airs_selected_ids.length - 1)
+				this.return_selected_airs = airs_selected_ids.substring(0, airs_selected_ids.length - 1);
 			},
 			},
 			/**
 			/**
 			 * 更新airs_selected中的数据
 			 * 更新airs_selected中的数据
@@ -579,13 +576,15 @@
 
 
 					uni.$emit('selectAirs', {
 					uni.$emit('selectAirs', {
 						sel_airs: this.return_selected_airs
 						sel_airs: this.return_selected_airs
-					})
+					});
 				}
 				}
 
 
-				// 返回空调列表页面
-				uni.navigateBack({
-					delta: -1
-				})
+				setTimeout(()=>{
+					// 返回空调列表页面
+					uni.navigateTo({
+						url: '/pagesAir/shareAir/shareAir'
+					});
+				}, 1000);
 			},
 			},
 			/**
 			/**
 			 * 绑定空调
 			 * 绑定空调
@@ -611,13 +610,13 @@
 					uni.showToast({
 					uni.showToast({
 						icon: 'none',
 						icon: 'none',
 						title: res.data.message,
 						title: res.data.message,
-						duration: 1500
+						duration: 3000
 					})
 					})
 				} else {
 				} else {
 					uni.showToast({
 					uni.showToast({
 						icon: 'none',
 						icon: 'none',
 						title: res.data.message,
 						title: res.data.message,
-						duration: 1500
+						duration: 3000
 					})
 					})
 				}
 				}
 			},
 			},

+ 25 - 0
pagesAir/figure/figure.vue

@@ -0,0 +1,25 @@
+<template>
+	<view>
+		
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				
+			}
+		},
+		onLoad(options) {
+			console.log(options.airip);
+		},
+		methods: {
+			
+		}
+	}
+</script>
+
+<style>
+
+</style>

+ 76 - 108
pagesAir/shareAir/shareAir.vue

@@ -34,7 +34,7 @@
 		<view class="add-air" v-if="isList === false" :style="{height: screenHeight}">
 		<view class="add-air" v-if="isList === false" :style="{height: screenHeight}">
 			<view class="add-content">
 			<view class="add-content">
 				<view class="add-left">
 				<view class="add-left">
-					<navigator url="../addAir/addAir" class="add-btn">
+					<navigator open-type="redirect" url="../addAir/addAir" class="add-btn">
 						<uni-icons type="plus" color="white" size="30"></uni-icons>
 						<uni-icons type="plus" color="white" size="30"></uni-icons>
 						<view>添加</view>
 						<view>添加</view>
 					</navigator>
 					</navigator>
@@ -52,8 +52,7 @@
 		<view class="list-air" v-else>
 		<view class="list-air" v-else>
 			<scroll-view scroll-y="true" :style="{height: screenHeight}">
 			<scroll-view scroll-y="true" :style="{height: screenHeight}">
 				<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 === true" class="item-air"
-						@longpress="itemLongPress($event, item.time, item.air_ip)">
+					<view v-if="item.on === true" class="item-air" @tap="tapHandler(item.air_ip)" @longpress="itemLongPress($event, item.time, 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>
@@ -66,8 +65,7 @@
 								<text>{{item.status}}</text><text>{{item.time}}</text>
 								<text>{{item.status}}</text><text>{{item.time}}</text>
 							</view>
 							</view>
 						</view>
 						</view>
-						<view class="item-right"
-							@tap="btn_click(index, item.air_ip, item.name, item.info, item.order_num, item.time)">
+						<view class="item-right" @tap="btn_click(index, item.air_ip, item.name, item.info, item.order_num, item.time)">
 							<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">
@@ -76,8 +74,7 @@
 							</view>
 							</view>
 						</view>
 						</view>
 					</view>
 					</view>
-					<view v-else class="item-air" @longpress="itemLongPress($event, item.time, item.air_ip)"
-						:ref="index">
+					<view v-else class="item-air" @tap="tapHandler(item.air_ip)" @longpress="itemLongPress($event, item.time, 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>
@@ -87,14 +84,12 @@
 							<view class="item-title">{{item.name_show}}</view>
 							<view class="item-title">{{item.name_show}}</view>
 							<view class="item-info">
 							<view class="item-info">
 								<text class="item-info-left">{{item.info}}</text>
 								<text class="item-info-left">{{item.info}}</text>
-								<!-- <image src="../static/images/power-off.png" mode="" class="item-info-icon"></image> -->
 								<text>{{item.status}}</text>
 								<text>{{item.status}}</text>
 								<text v-if="item.time !== ''">{{item.time}}</text>
 								<text v-if="item.time !== ''">{{item.time}}</text>
 								<text v-else>未启动</text>
 								<text v-else>未启动</text>
 							</view>
 							</view>
 						</view>
 						</view>
-						<view class="item-right" v-if="item.abnormal == 1"
-							@tap="btn_click(index, item.air_ip, item.name, item.info, item.order_num, item.time)"
+						<view class="item-right" v-if="item.abnormal == 1" @tap="btn_click(index, item.air_ip, item.name, item.info, item.order_num, item.time)"
 							:ref="index">
 							: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>
@@ -113,7 +108,7 @@
 						</view>
 						</view>
 					</view>
 					</view>
 				</view>
 				</view>
-				<navigator url="../addAir/addAir" class="add-air-bottom">
+				<navigator open-type="redirect" url="../addAir/addAir" class="add-air-bottom">
 					<uni-icons type="plus" size="30" color="#4B8DFB"></uni-icons>
 					<uni-icons type="plus" size="30" color="#4B8DFB"></uni-icons>
 					<view class="add-btn-bottom">添加</view>
 					<view class="add-btn-bottom">添加</view>
 				</navigator>
 				</navigator>
@@ -154,9 +149,8 @@
 			};
 			};
 		},
 		},
 		onLoad(options) {
 		onLoad(options) {
-			var _this = this;
 			// 系统正在维护...
 			// 系统正在维护...
-			if (_this.test == 'weihuzhong') {
+			if (this.test == 'weihuzhong') {
 				uni.redirectTo({
 				uni.redirectTo({
 					url: '../../pages/index/index'
 					url: '../../pages/index/index'
 				})
 				})
@@ -164,27 +158,25 @@
 				return;
 				return;
 			}
 			}
 
 
-			_this.options = options
+			this.options = options
 			try {
 			try {
 				// 选择绑定了的空调
 				// 选择绑定了的空调
 				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.selectAirs = airs_selected
+					this.selectAirs = airs_selected
 				}
 				}
 			} catch (e) {
 			} catch (e) {
 				console.log('读取空调相关信息:' + e.message);
 				console.log('读取空调相关信息:' + e.message);
 			}
 			}
-
-			// _this._freshing = false;
-			// setTimeout(() => {
-			// 	_this.triggered = true;
-			// }, 500);
 		},
 		},
 		onShow() {
 		onShow() {
-			var _this = this;
-			// 从新计算高度
-			_this.calc_screen_height();
+			uni.showLoading({
+				title: '加载中...',
+				mask: true
+			});
+
+			// var _this = this;
 			// 监听全局的自定义事件,事件由 uni.$emit 触发,但仅触发一次,在第一次触发之后移除该监听器。
 			// 监听全局的自定义事件,事件由 uni.$emit 触发,但仅触发一次,在第一次触发之后移除该监听器。
 			// 绑定空调
 			// 绑定空调
 			uni.$once('selectAirs', data => {
 			uni.$once('selectAirs', data => {
@@ -196,14 +188,14 @@
 					let tmpAirs = arrAirs[i].split('|');
 					let tmpAirs = arrAirs[i].split('|');
 					let t = tmpAirs[1].split('-');
 					let t = tmpAirs[1].split('-');
 					tf = true;
 					tf = true;
-					for (var j = 0; j < _this.selectAirs.length; j++) {
-						if (_this.selectAirs[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.selectAirs.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],
@@ -215,45 +207,48 @@
 					}
 					}
 				}
 				}
 				// 如果选的空调不为空,则显示添加的空调列表
 				// 如果选的空调不为空,则显示添加的空调列表
-				if (_this.selectAirs.length > 0) {
+				if (this.selectAirs.length > 0) {
 					// 去重
 					// 去重
-					var newArr = [...new Set(_this.selectAirs.map(e => JSON.stringify(e)))].map(e => JSON.parse(
-						e));
+					const newArr = Array.from(new Set(this.selectAirs.map(JSON.stringify))).map(JSON.parse);
 
 
-					_this.selectAirs = newArr;
+					this.selectAirs = newArr;
 				}
 				}
 				// 存储空调列表
 				// 存储空调列表
-				uni.setStorageSync('airs_selected', _this.selectAirs);
+				uni.setStorageSync('airs_selected', this.selectAirs);
 				// 移除全局自定义事件监听器。
 				// 移除全局自定义事件监听器。
-				// uni.$off('selectAirs')
+				uni.$off('selectAirs');
 			});
 			});
 
 
 			// 获取基本信息
 			// 获取基本信息
-			_this.get_base_info(_this.options, 'onShow');
-
-			setTimeout(() => {
-				uni.hideLoading();
-			}, 3000);
+			this.get_base_info('onShow');
+			
+			// 从新计算高度
+			this.calc_screen_height();
+			// setTimeout(() => {
+			// 	uni.hideLoading();
+			// }, 3000);
 		},
 		},
 		// 下拉刷新
 		// 下拉刷新
 		onPullDownRefresh() {
 		onPullDownRefresh() {
-			var _this = this;
 			// 获取基本信息
 			// 获取基本信息
-			_this.get_base_info(_this.options, 'onShow');
+			this.get_base_info(this.options, 'onShow');
 			// 查询绑定的空调(更新列表)
 			// 查询绑定的空调(更新列表)
-			_this.select_banding_airs();
+			this.select_banding_airs();
 			// 停止刷新
 			// 停止刷新
 			uni.stopPullDownRefresh();
 			uni.stopPullDownRefresh();
 		},
 		},
 		methods: {
 		methods: {
+			// 跳转到电流、电压、功率页面
+			tapHandler(air_ip) {
+				// console.log(air_ip);
+				uni.navigateTo({
+					url: '/pagesAir/figure/figure?airip=' + air_ip
+				});
+			},
 			/**
 			/**
 			 * 查询绑定的空调
 			 * 查询绑定的空调
 			 */
 			 */
 			async select_banding_airs() {
 			async select_banding_airs() {
-				uni.showLoading({
-					title: '加载绑定的空调'
-				});
-
 				var _this = this;
 				var _this = this;
 				const res = await this.$myRequest({
 				const res = await this.$myRequest({
 					host: _this.ceshi,
 					host: _this.ceshi,
@@ -265,32 +260,25 @@
 					data: {
 					data: {
 						sfzh: _this.id_card
 						sfzh: _this.id_card
 					}
 					}
-				})
+				});
 
 
 				// 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;
 					if (data.length > 0) {
 					if (data.length > 0) {
-						_this.airs = []
-						let tmpAirs = []
+						_this.airs = [];
+						let tmpAirs = [];
 						for (var i = 0; i < data.length; i++) {
 						for (var i = 0; i < data.length; i++) {
 							tmpAirs.push({
 							tmpAirs.push({
 								air_ip: data[i].air_ip,
 								air_ip: data[i].air_ip,
-								name: data[i].school + '-' + data[i].build + '-' + data[i].floors + '-' + data[
-									i].dom + '-' + data[i].air_name,
+								name: data[i].school + '-' + data[i].build + '-' + data[i].floors + '-' + data[i].dom + '-' + data[i].air_name,
 								name_show: data[i].school + '-' + data[i].dom + '-' + data[i].air_name,
 								name_show: data[i].school + '-' + data[i].dom + '-' + data[i].air_name,
 								info: data[i].air_config,
 								info: data[i].air_config,
 								time: '',
 								time: '',
 								abnormal: data[i].is_normal,
 								abnormal: data[i].is_normal,
 								on: data[i].is_on, // true开启了,false关闭了
 								on: data[i].is_on, // true开启了,false关闭了
 								order_num: '' // 订单号
 								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) {
 						if (tmpAirs.length > 0) {
@@ -300,32 +288,32 @@
 								(function(t, tmpAirs) { // 注意这里是形参
 								(function(t, tmpAirs) { // 注意这里是形参
 									setTimeout(function() {
 									setTimeout(function() {
 										_this.readAirsStatus(tmpAirs, t);
 										_this.readAirsStatus(tmpAirs, t);
-									}, 100 * t); // 还是0.1秒执行一次,不是累加的
-								})(i, tmpAirs) // 注意这里是实参,这里把要用的参数传进去
+									}, 10 * t); // 还是0.01秒执行一次,不是累加的
+								})(i, tmpAirs); // 注意这里是实参,这里把要用的参数传进去
 							}
 							}
 
 
 							setTimeout(() => {
 							setTimeout(() => {
 								if (_this.airs.length > 0) {
 								if (_this.airs.length > 0) {
 									// 显示添加的空调列表
 									// 显示添加的空调列表
 									_this.isList = true;
 									_this.isList = true;
-									uni.hideLoading();
+									// uni.hideLoading();
 								}
 								}
-							}, 500);
+							}, 300);
 						}
 						}
 					} else {
 					} else {
 						// 隐藏添加的空调列表
 						// 隐藏添加的空调列表
-						_this.isList = false
+						_this.isList = false;
 					}
 					}
 				} else if (res.data.code == 205) {
 				} else if (res.data.code == 205) {
 					// 隐藏添加的空调列表
 					// 隐藏添加的空调列表
-					_this.isList = false
+					_this.isList = false;
 				} else {
 				} else {
 					// 隐藏添加的空调列表
 					// 隐藏添加的空调列表
-					_this.isList = false
+					_this.isList = false;
 					// 提示返回信息
 					// 提示返回信息
 					uni.showToast({
 					uni.showToast({
 						title: res.data.message
 						title: res.data.message
-					})
+					});
 				}
 				}
 				// 隐藏加载
 				// 隐藏加载
 				uni.hideLoading();
 				uni.hideLoading();
@@ -348,7 +336,7 @@
 						air_ip: tmpAirs[index].air_ip,
 						air_ip: tmpAirs[index].air_ip,
 						sfzh: _this.id_card
 						sfzh: _this.id_card
 					}
 					}
-				})
+				});
 
 
 				// console.log(res.data, tmpAirs[index].air_ip);
 				// console.log(res.data, tmpAirs[index].air_ip);
 				if (res.data.code == 200) {
 				if (res.data.code == 200) {
@@ -383,27 +371,23 @@
 			/**
 			/**
 			 * 获取基本信息
 			 * 获取基本信息
 			 */
 			 */
-			get_base_info(options, param) {
+			get_base_info(param) {
 				// console.log(options);
 				// console.log(options);
-				uni.showLoading({
-					title: '加载中',
-					mask: true
-				})
-
+				var _this = this;
 				// 获取学号
 				// 获取学号
-				this.stu_number = this.$store.state.userInfo.card_number
+				_this.stu_number = _this.$store.state.userInfo.card_number;
 
 
 				try {
 				try {
-					if (this.stu_number == '' || typeof(this.stu_number) == 'undefined') { // 学号不存在,可以从存储中拿用户信息
+					if (_this.stu_number == '' || typeof(_this.stu_number) == 'undefined') { // 学号不存在,可以从存储中拿用户信息
 						const userinfo = uni.getStorageSync('userinfo_storage_key')
 						const userinfo = uni.getStorageSync('userinfo_storage_key')
 						if (userinfo) { // 拿学号
 						if (userinfo) { // 拿学号
-							this.userinfo = userinfo
-							this.stu_number = userinfo.card_number
-							this.id_card = userinfo.id_card
+							_this.userinfo = userinfo;
+							_this.stu_number = userinfo.card_number;
+							_this.id_card = userinfo.id_card;
 						} else { // 还没有需要跳转到首页进行获取
 						} else { // 还没有需要跳转到首页进行获取
 							uni.navigateTo({
 							uni.navigateTo({
-								url: '../../pages/index/index?from=' + options.from
-							})
+								url: '../../pages/index/index?from=' + _this.options.from
+							});
 
 
 							uni.showToast({
 							uni.showToast({
 								icon: 'none',
 								icon: 'none',
@@ -411,36 +395,31 @@
 								duration: 3000
 								duration: 3000
 							});
 							});
 
 
-							return
+							return;
 						}
 						}
 					} else { // 学号已经存在,可以从存储中拿用户信息
 					} else { // 学号已经存在,可以从存储中拿用户信息
-						this.userinfo = JSON.stringify(uni.getStorageSync('userinfo_storage_key'))
+						_this.userinfo = JSON.stringify(uni.getStorageSync('userinfo_storage_key'));
 					}
 					}
 				} catch (e) {
 				} catch (e) {
 					console.log('获取基本信息:' + e.message);
 					console.log('获取基本信息:' + e.message);
 				}
 				}
 				// 获取code
 				// 获取code
-				this.getCode(options, param)
-
-				// if (this.id_card !== '') {
-				// 	// 查询绑定的空调
-				// 	this.select_banding_airs()
-				// }
+				_this.getCode(param);
 			},
 			},
 			/**
 			/**
 			 * 获得code
 			 * 获得code
 			 */
 			 */
-			getCode(options, param) {
+			getCode(param) {
 				var _this = this;
 				var _this = this;
 				uni.login({
 				uni.login({
 					success: (res) => {
 					success: (res) => {
 						// console.log('getCode', res);
 						// console.log('getCode', res);
 						if (res.code) {
 						if (res.code) {
 							if (param == 'get_user_info') {
 							if (param == 'get_user_info') {
-								_this.getUserInfo(res.code)
+								_this.getUserInfo(res.code);
 							} else {
 							} else {
 								// 请求服务器,获得openid
 								// 请求服务器,获得openid
-								_this.getOpenId(options, res.code)
+								_this.getOpenId(res.code);
 							}
 							}
 						} else {
 						} else {
 							uni.showToast({
 							uni.showToast({
@@ -449,12 +428,12 @@
 							});
 							});
 						}
 						}
 					}
 					}
-				})
+				});
 			},
 			},
 			/**
 			/**
 			 * 请求服务器,获得openid
 			 * 请求服务器,获得openid
 			 */
 			 */
-			async getOpenId(options, param_code) {
+			async getOpenId(param_code) {
 				var _this = this;
 				var _this = this;
 				if (typeof _this.userinfo === 'object') {
 				if (typeof _this.userinfo === 'object') {
 					_this.userinfo = JSON.stringify(_this.userinfo)
 					_this.userinfo = JSON.stringify(_this.userinfo)
@@ -475,27 +454,19 @@
 				// console.log(res.data);
 				// console.log(res.data);
 				if (res.data.code == 200) {
 				if (res.data.code == 200) {
 					// 查询用户基本信息
 					// 查询用户基本信息
-					_this.getCode(options, 'get_user_info')
-					// 绑定成功,提示返回信息,但没必要提示
-					// uni.showToast({
-					// 	title: res.data.message
-					// })
+					_this.getCode('get_user_info')
 				} else if (res.data.code == 205) {
 				} else if (res.data.code == 205) {
 					// 查询用户基本信息
 					// 查询用户基本信息
-					_this.getCode(options, 'get_user_info')
-					// 用户已经存在,但没必要提示
-					// uni.showToast({
-					// title: res.data.message
-					// })
+					_this.getCode('get_user_info')
 				} else {
 				} else {
 					// 提示返回信息
 					// 提示返回信息
 					uni.showToast({
 					uni.showToast({
 						title: res.data.message
 						title: res.data.message
 					})
 					})
 
 
-					if (options && typeof(options.from) != 'undefined' && typeof(options.from) != '') {
+					if (_this.options && typeof _this.options.from != 'undefined' && typeof _this.options.from != '') {
 						uni.navigateTo({
 						uni.navigateTo({
-							url: '../../pages/index/index?from=' + options.from
+							url: '../../pages/index/index?from=' + _this.options.from
 						})
 						})
 					} else {
 					} else {
 						uni.redirectTo({
 						uni.redirectTo({
@@ -865,9 +836,6 @@
 					}
 					}
 				}
 				}
 			},
 			},
-			onRestore() {
-				this.triggered = true; // 需要重置
-			},
 			/**
 			/**
 			 * 轮播图发生改变
 			 * 轮播图发生改变
 			 * @param {Object} e
 			 * @param {Object} e
@@ -1165,4 +1133,4 @@
 			}
 			}
 		}
 		}
 	}
 	}
-</style>
+</style>

+ 67 - 71
pagesElectric/jiaofei/jiaofei.vue

@@ -152,7 +152,7 @@
 			 */
 			 */
 			loadImgError(e) {
 			loadImgError(e) {
 				// console.log(e);
 				// console.log(e);
-				this.img_url = ''
+				this.img_url = '';
 			},
 			},
 			/**
 			/**
 			 * 获取广告缩略图
 			 * 获取广告缩略图
@@ -169,11 +169,11 @@
 					data: {
 					data: {
 						'url_name': '水电广告'
 						'url_name': '水电广告'
 					}
 					}
-				})
+				});
 
 
 				// console.log(res.data)
 				// console.log(res.data)
 				if (typeof res.data.data == 'undefined' || res.data.data.length == 0) {
 				if (typeof res.data.data == 'undefined' || res.data.data.length == 0) {
-					return
+					return;
 				}
 				}
 
 
 				if (res.data.code == 200) {
 				if (res.data.code == 200) {
@@ -197,9 +197,9 @@
 					uni.showToast({
 					uni.showToast({
 						title: '加载数据异常',
 						title: '加载数据异常',
 						duration: 1500
 						duration: 1500
-					})
+					});
 
 
-					return
+					return;
 				}
 				}
 			},
 			},
 			/**
 			/**
@@ -214,7 +214,7 @@
 					uni.showToast({
 					uni.showToast({
 						title: '请再次选择宿舍',
 						title: '请再次选择宿舍',
 						icon: 'success'
 						icon: 'success'
-					})
+					});
 				} else {
 				} else {
 					uni.navigateTo({
 					uni.navigateTo({
 						url: '../dfxq/dfxq?roomSelect=' + this.roomSelect + '&stu_number=' + this.stu_number,
 						url: '../dfxq/dfxq?roomSelect=' + this.roomSelect + '&stu_number=' + this.stu_number,
@@ -235,7 +235,7 @@
 					uni.showToast({
 					uni.showToast({
 						title: '请再次选择宿舍',
 						title: '请再次选择宿舍',
 						icon: 'success'
 						icon: 'success'
-					})
+					});
 				} else {
 				} else {
 					uni.navigateTo({
 					uni.navigateTo({
 						url: '../sfxq/sfxq?roomSelect=' + this.roomSelect + '&stu_number=' + this.stu_number,
 						url: '../sfxq/sfxq?roomSelect=' + this.roomSelect + '&stu_number=' + this.stu_number,
@@ -249,7 +249,7 @@
 			ad_redirect() {
 			ad_redirect() {
 				uni.navigateTo({
 				uni.navigateTo({
 					url: 'ad_dianfei'
 					url: 'ad_dianfei'
-				})
+				});
 			},
 			},
 			/**
 			/**
 			 * 获取基本信息
 			 * 获取基本信息
@@ -258,17 +258,17 @@
 				try {
 				try {
 					if (this.stu_number == '' || typeof this.stu_number == 'undefined') {
 					if (this.stu_number == '' || typeof this.stu_number == 'undefined') {
 						// 获取学号
 						// 获取学号
-						this.stu_number = this.$store.state.userInfo.card_number
+						this.stu_number = this.$store.state.userInfo.card_number;
 					}
 					}
 
 
 					if (this.stu_number == '' || typeof this.stu_number == 'undefined') {
 					if (this.stu_number == '' || typeof this.stu_number == 'undefined') {
 						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;
 						} else {
 						} else {
 							uni.navigateTo({
 							uni.navigateTo({
 								url: '../../pages/index/index?from=' + options.from
 								url: '../../pages/index/index?from=' + options.from
-							})
+							});
 
 
 							uni.showToast({
 							uni.showToast({
 								icon: 'none',
 								icon: 'none',
@@ -276,7 +276,7 @@
 								duration: 3000
 								duration: 3000
 							});
 							});
 
 
-							return
+							return;
 						}
 						}
 					}
 					}
 				} catch (e) {
 				} catch (e) {
@@ -287,7 +287,7 @@
 				this.$store.state.building.add_class = 0;
 				this.$store.state.building.add_class = 0;
 
 
 				// 获取code
 				// 获取code
-				this.getCode(options, param)
+				this.getCode(options, param);
 			},
 			},
 			/**
 			/**
 			 * 获取code
 			 * 获取code
@@ -300,10 +300,10 @@
 						if (res.code) {
 						if (res.code) {
 							if (param == 'comfirm') {
 							if (param == 'comfirm') {
 								// 组合地址,发起支付
 								// 组合地址,发起支付
-								_this.jsapi(res.code)
+								_this.jsapi(res.code);
 							} else {
 							} else {
 								// 请求服务器,获得openid
 								// 请求服务器,获得openid
-								_this.getOpenId(options, res.code)
+								_this.getOpenId(options, res.code);
 							}
 							}
 						} else {
 						} else {
 							uni.showToast({
 							uni.showToast({
@@ -317,7 +317,7 @@
 							});
 							});
 						}
 						}
 					}
 					}
-				})
+				});
 			},
 			},
 			/**
 			/**
 			 * 请求服务器,获得openid
 			 * 请求服务器,获得openid
@@ -337,42 +337,42 @@
 							code: param_code,
 							code: param_code,
 							card_number: _this.stu_number
 							card_number: _this.stu_number
 						}
 						}
-					})
+					});
 
 
 					// console.log('获得openid', res);
 					// console.log('获得openid', res);
 					if (res.data.mess == '返回成功') {
 					if (res.data.mess == '返回成功') {
 						if (!(_this.$store.state.building.roomSelect && typeof _this.$store.state.building.roomSelect != 'undefined')) {
 						if (!(_this.$store.state.building.roomSelect && typeof _this.$store.state.building.roomSelect != 'undefined')) {
 							// 栋宿舍号
 							// 栋宿舍号
-							_this.dorm_number = res.data.info[0].build + res.data.info[0].dom
+							_this.dorm_number = res.data.info[0].build + res.data.info[0].dom;
 							// 校区
 							// 校区
-							_this.compus = res.data.info[0].campus
+							_this.compus = res.data.info[0].campus;
 							// 填充校区宿舍号
 							// 填充校区宿舍号
 							if (typeof _this.dorm_number.split('栋')[1] == 'undefined') {
 							if (typeof _this.dorm_number.split('栋')[1] == 'undefined') {
-								_this.roomSelect = _this.compus + ''
+								_this.roomSelect = _this.compus + '';
 							} else {
 							} else {
-								_this.roomSelect = _this.compus + _this.dorm_number.split('栋')[1]
+								_this.roomSelect = _this.compus + _this.dorm_number.split('栋')[1];
 							}
 							}
 							// 存储选择
 							// 存储选择
-							_this.$store.state.building.roomSelect = _this.roomSelect
+							_this.$store.state.building.roomSelect = _this.roomSelect;
 							// 样式
 							// 样式
-							_this.add_class = 1
+							_this.add_class = 1;
 						}
 						}
 
 
 						// 请求选定的月份消费记录
 						// 请求选定的月份消费记录
-						_this.getDianLiang()
+						_this.getDianLiang();
 					} else if (res.data.mess == '未查询到用户信息') {
 					} else if (res.data.mess == '未查询到用户信息') {
 						// 数据库中 未查询到用户信息,就清除本地存储
 						// 数据库中 未查询到用户信息,就清除本地存储
 						// uni.removeStorageSync('userinfo_storage_key');
 						// uni.removeStorageSync('userinfo_storage_key');
 
 
 						uni.showToast({
 						uni.showToast({
 							title: '获取用户信息失败!'
 							title: '获取用户信息失败!'
-						})
+						});
 
 
 						// 跳转到首页
 						// 跳转到首页
 						if (options && typeof(options.from) != 'undefined' && typeof(options.from) != '') {
 						if (options && typeof(options.from) != 'undefined' && typeof(options.from) != '') {
 							uni.navigateTo({
 							uni.navigateTo({
 								url: '../../pages/index/index?from=' + options.from
 								url: '../../pages/index/index?from=' + options.from
-							})
+							});
 						} else {
 						} else {
 							uni.redirectTo({
 							uni.redirectTo({
 								url: '../../pages/index/index/index?from=0'
 								url: '../../pages/index/index/index?from=0'
@@ -385,9 +385,9 @@
 						if (userinfo && typeof(userinfo) != 'undefined' && typeof(userinfo.campus) != 'undefined' &&
 						if (userinfo && typeof(userinfo) != 'undefined' && typeof(userinfo.campus) != 'undefined' &&
 							typeof(userinfo.dorm_number) != 'undefined' && userinfo.campus != '' && userinfo
 							typeof(userinfo.dorm_number) != 'undefined' && userinfo.campus != '' && userinfo
 							.dorm_number != '') {
 							.dorm_number != '') {
-							_this.roomSelect = userinfo.campus + userinfo.dorm_number
+							_this.roomSelect = userinfo.campus + userinfo.dorm_number;
 						} else {
 						} else {
-							_this.roomSelect = '请选择宿舍号'
+							_this.roomSelect = '请选择宿舍号';
 						}
 						}
 					}
 					}
 				} else {
 				} else {
@@ -413,7 +413,7 @@
 						data: {
 						data: {
 							'roomSelect': _this.roomSelect
 							'roomSelect': _this.roomSelect
 						}
 						}
-					})
+					});
 
 
 					// console.log('取得电费额度', res);
 					// console.log('取得电费额度', res);
 					if (res.data.mess == '0') {
 					if (res.data.mess == '0') {
@@ -421,7 +421,7 @@
 							_this.remainElec = res.data.amount.toFixed(2)
 							_this.remainElec = res.data.amount.toFixed(2)
 						}, 30);
 						}, 30);
 					} else {
 					} else {
-						this.remainElec = 0.00.toFixed(2)
+						this.remainElec = 0.00.toFixed(2);
 					}
 					}
 				} else {
 				} else {
 					uni.showToast({
 					uni.showToast({
@@ -440,31 +440,31 @@
 			},
 			},
 			// 是否选择了宿舍号
 			// 是否选择了宿舍号
 			haveSelectRoom() {
 			haveSelectRoom() {
-				if (this.roomSelect == '请选择宿舍') {
+				if (typeof this.roomSelect == 'undefined' || this.roomSelect == '' || this.roomSelect == '请选择宿舍') {
 					uni.showToast({
 					uni.showToast({
-						title: '请选择宿舍',
-						icon: 'success'
-					})
-					return true
+						title: '请选择宿舍',
+						icon: 'error'
+					});
+					return true;
 				}
 				}
 
 
 				uni.setStorageSync('roomSelect', this.roomSelect);
 				uni.setStorageSync('roomSelect', this.roomSelect);
 				uni.setStorageSync('stu_number', this.stu_number);
 				uni.setStorageSync('stu_number', this.stu_number);
 
 
-				return false
+				return false;
 			},
 			},
 
 
 			//跳转到台账页面
 			//跳转到台账页面
 			navigateToShow(e) {
 			navigateToShow(e) {
 				if (this.haveSelectRoom()) {
 				if (this.haveSelectRoom()) {
-					return
+					return;
 				}
 				}
 
 
 				if (this.roomSelect == '' || typeof this.roomSelect == 'undefined') {
 				if (this.roomSelect == '' || typeof this.roomSelect == 'undefined') {
 					uni.showToast({
 					uni.showToast({
 						title: '请再次选择宿舍号',
 						title: '请再次选择宿舍号',
 						icon: 'success'
 						icon: 'success'
-					})
+					});
 				} else {
 				} else {
 					uni.navigateTo({
 					uni.navigateTo({
 						url: '../show/show?roomSelect=' + this.roomSelect + '&stu_number=' + this.stu_number,
 						url: '../show/show?roomSelect=' + this.roomSelect + '&stu_number=' + this.stu_number,
@@ -477,19 +477,15 @@
 			 * 增加固定金额
 			 * 增加固定金额
 			 */
 			 */
 			add_money(e) {
 			add_money(e) {
-				this.amount = e.currentTarget.dataset.item
+				this.amount = e.currentTarget.dataset.item;
 			},
 			},
 			/**
 			/**
 			 * 确认宿舍号
 			 * 确认宿舍号
 			 */
 			 */
 			confirm_room(op) {
 			confirm_room(op) {
 				// 检查房间号
 				// 检查房间号
-				if (this.roomSelect == '' || this.roomSelect == '请选择宿舍号') {
-					uni.showToast({
-						title: '请选择宿舍号',
-						icon: 'success'
-					})
-					return
+				if (this.haveSelectRoom()) {
+					return;
 				}
 				}
 				// 输入金额进行充值
 				// 输入金额进行充值
 				if (op == 'input_money') {
 				if (op == 'input_money') {
@@ -498,16 +494,16 @@
 						uni.showToast({
 						uni.showToast({
 							title: '请输入充值金额',
 							title: '请输入充值金额',
 							duration: 2000
 							duration: 2000
-						})
-						return
+						});
+						return;
 					}
 					}
 
 
 					if (isNaN(this.amount)) {
 					if (isNaN(this.amount)) {
 						uni.showToast({
 						uni.showToast({
 							title: '请输入正确金额',
 							title: '请输入正确金额',
 							duration: 2000
 							duration: 2000
-						})
-						return
+						});
+						return;
 					}
 					}
 
 
 					if (!this.test) { // 非测试环境
 					if (!this.test) { // 非测试环境
@@ -515,13 +511,13 @@
 							uni.showToast({
 							uni.showToast({
 								title: '限额10~200元',
 								title: '限额10~200元',
 								duration: 2000
 								duration: 2000
-							})
-							return
+							});
+							return;
 						}
 						}
 					}
 					}
 				}
 				}
 				// 确认充值对话框
 				// 确认充值对话框
-				this.confirm_dialog()
+				this.confirm_dialog();
 			},
 			},
 			/**
 			/**
 			 * 确认充值对话框
 			 * 确认充值对话框
@@ -534,18 +530,18 @@
 					success: (res) => {
 					success: (res) => {
 						if (res.confirm) {
 						if (res.confirm) {
 							// 获取code
 							// 获取code
-							_this.getCode('options', 'comfirm')
+							_this.getCode('options', 'comfirm');
 						} else if (res.cancel) {
 						} else if (res.cancel) {
 							// console.log('用户点击取消');
 							// console.log('用户点击取消');
 						}
 						}
 					}
 					}
-				})
+				});
 			},
 			},
 			//增加可变金额
 			//增加可变金额
 			input_money(e) {
 			input_money(e) {
 				// console.log(this.test);
 				// console.log(this.test);
 				// console.log(e)
 				// console.log(e)
-				this.confirm_room('input_money')
+				this.confirm_room('input_money');
 			},
 			},
 			/**
 			/**
 			 * 请求服务器,获取支付参数,并支付
 			 * 请求服务器,获取支付参数,并支付
@@ -555,7 +551,7 @@
 					uni.showToast({
 					uni.showToast({
 						title: 'code、充值金额、宿舍号或IP为空'
 						title: 'code、充值金额、宿舍号或IP为空'
 					});
 					});
-					return
+					return;
 				}
 				}
 				var _this = this;
 				var _this = this;
 				// console.log(_this.roomSelect);
 				// console.log(_this.roomSelect);
@@ -572,7 +568,7 @@
 						stu_number: _this.stu_number,
 						stu_number: _this.stu_number,
 						roomSelect: _this.roomSelect
 						roomSelect: _this.roomSelect
 					}
 					}
-				})
+				});
 
 
 				// console.log(res);
 				// console.log(res);
 				if (res.data.code == 200 && res.data.sub_openid && res.data.sub_openid != '') {
 				if (res.data.code == 200 && res.data.sub_openid && res.data.sub_openid != '') {
@@ -618,49 +614,49 @@
 			onInput(e) {
 			onInput(e) {
 				var _this = this;
 				var _this = this;
 				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
-				let final = 0
+				const zero = /^(0{1,})|[^0-9]/g;
+				let final = 0;
 				if (!v) {
 				if (!v) {
-					final = 0
+					final = 0;
 				} else {
 				} else {
 					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 > 200) {
 					if (final > 200) {
-						final = 200
+						final = 200;
 					}
 					}
 				}
 				}
 				_this.$nextTick(() => {
 				_this.$nextTick(() => {
 					if (final.toString() == '0') {
 					if (final.toString() == '0') {
-						_this.amount = ''
+						_this.amount = '';
 					} else {
 					} else {
-						_this.amount = final.toString() || '0'
+						_this.amount = final.toString() || '0';
 					}
 					}
-				})
+				});
 			},
 			},
 			/**
 			/**
 			 * 失去焦点时
 			 * 失去焦点时
 			 */
 			 */
 			onBlur() {
 			onBlur() {
 				if (this.test) { // 测试环境
 				if (this.test) { // 测试环境
-					return
+					return;
 				}
 				}
 
 
 				if (this.amount < 10) {
 				if (this.amount < 10) {
-					this.amount = 10
+					this.amount = 10;
 				}
 				}
 			}
 			}
-		},
+		}
 	}
 	}
 </script>
 </script>