Browse Source

【阶段性提交】

程志平 4 years ago
parent
commit
7b9f2acf0c

+ 6 - 5
pages/index/index.vue

@@ -13,14 +13,14 @@
 					<image src="../../static/images/recharge2x.png" mode=""></image>
 					<image src="../../static/images/recharge2x.png" mode=""></image>
 					<text>水电充值</text>
 					<text>水电充值</text>
 				</navigator>
 				</navigator>
-				<!-- <navigator :url="'/pagesAir/shareAir/shareAir'" open-type="navigate" class="menu_item">
+				<navigator :url="'/pagesAir/shareAir/shareAir'" open-type="navigate" class="menu_item">
 					<image src="../../static/images/air.png" mode=""></image>
 					<image src="../../static/images/air.png" mode=""></image>
 					<text>共享空调</text>
 					<text>共享空调</text>
-				</navigator> -->
+				</navigator>
 			</view>
 			</view>
 		</view>
 		</view>
 		<view class="qr_code" v-if="showQR_code">
 		<view class="qr_code" v-if="showQR_code">
-			<image src="https://jtishfw.ncjti.edu.cn/jxch-smartmp/HotWaters/image/1.jpg" mode="aspectFit"></image>
+			<image :src="qr_code_url" mode="aspectFit"></image>
 		</view>
 		</view>
 		<view v-if="showLogin">
 		<view v-if="showLogin">
 			<login :ocode="ocode" :appkey="appkey" scope="snsapi_userinfo" :visible="visible"
 			<login :ocode="ocode" :appkey="appkey" scope="snsapi_userinfo" :visible="visible"
@@ -46,7 +46,8 @@
 				validation_failed: false, // 验证失败
 				validation_failed: false, // 验证失败
 				validation_times: 0, // 授权次数
 				validation_times: 0, // 授权次数
 				from: 0, // 跳转参数
 				from: 0, // 跳转参数
-				execed_onload: false
+				execed_onload: false,
+				qr_code_url: this.$code_base_url + '/HotWaters/image/1.jpg'
 			}
 			}
 		},
 		},
 		onLoad(options) {
 		onLoad(options) {
@@ -177,7 +178,7 @@
 								});
 								});
 								// 出现二维码,用户扫描二维码添加校园卡、激活
 								// 出现二维码,用户扫描二维码添加校园卡、激活
 								// uni.downloadFile({
 								// uni.downloadFile({
-								// 	url: 'https://jtishfw.ncjti.edu.cn/jxch-smartmp/HotWaters/image/1.jpg',
+								// 	url: 'https://chtech.ncjti.edu.cn/shuidian/HotWaters/image/1.jpg',
 								// 	success: (res2) => {
 								// 	success: (res2) => {
 								// 		// console.log(res2);
 								// 		// console.log(res2);
 								// 		if (res2.statusCode == 200) {
 								// 		if (res2.statusCode == 200) {

+ 1 - 0
pages/reshui/reshui.vue

@@ -138,6 +138,7 @@
 		},
 		},
 		onLoad(options) {
 		onLoad(options) {
 			// console.log(options);
 			// console.log(options);
+			// 向用户发起授权请求
 			uni.authorize({
 			uni.authorize({
 				scope: 'scope.userLocation',
 				scope: 'scope.userLocation',
 				success(res) {
 				success(res) {

+ 35 - 162
pagesAir/rechargeRecord/rechargeRecord.vue

@@ -31,33 +31,19 @@
 		data() {
 		data() {
 			return {
 			return {
 				screenHeight: 0,
 				screenHeight: 0,
-				stu_number: '', // 学
+				id_card: '', // 身份证
 				date: this.$getDate({
 				date: this.$getDate({
 					format: true
 					format: true
 				}),
 				}),
 				startDate: this.$getDate('start_date'),
 				startDate: this.$getDate('start_date'),
 				endDate: this.$getDate('end_date'),
 				endDate: this.$getDate('end_date'),
-				chongzhi_items: [{
-					desc: '手机充值',
-					begin_time: '10-12 11:15:15',
-					use_amount: '-20.00'
-				}, {
-					desc: '手机充值',
-					begin_time: '10-12 11:15:15',
-					use_amount: '-20.00'
-				}, {
-					desc: '手机充值',
-					begin_time: '10-12 11:15:15',
-					use_amount: '-20.00'
-				}], // 消费记录
-				ceshi: 'code',
+				chongzhi_items: [], // 消费记录
+				ceshi: 'dev',
 			}
 			}
 		},
 		},
-		onLoad() {
-			if (this.stu_number && typeof(this.stu_number) != 'undefined') {
-				// 获取基本信息
-				this.get_base_info('options', 'onShow')
-			}
+		onLoad(options) {
+			// 获取身份证号
+			this.get_base_info()
 		},
 		},
 		onShow() {
 		onShow() {
 			// 从新计算高度
 			// 从新计算高度
@@ -96,18 +82,15 @@
 				return realVal
 				return realVal
 			},
 			},
 			/**
 			/**
-			 * 获取基本信息
+			 * 获取身份证号
 			 */
 			 */
-			get_base_info(options, param) {
+			get_base_info() {
 				// console.log(options);
 				// console.log(options);
 				try {
 				try {
-					// 获取学号
-					this.stu_number = this.$store.state.userInfo.card_number
-
-					if (this.stu_number == '' || typeof(this.stu_number) == 'undefined') {
+					if (this.id_card == '' || typeof(this.id_card) == '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.id_card = userinfo.id_card
 						} else {
 						} else {
 							uni.navigateTo({
 							uni.navigateTo({
 								url: '../index/index?from=' + options.from
 								url: '../index/index?from=' + options.from
@@ -115,7 +98,7 @@
 
 
 							uni.showToast({
 							uni.showToast({
 								icon: 'none',
 								icon: 'none',
-								title: '号为空,请进行授权',
+								title: '身份证号为空,请进行授权',
 								duration: 3000
 								duration: 3000
 							});
 							});
 
 
@@ -126,107 +109,50 @@
 					console.log('获取基本信息:' + e.message);
 					console.log('获取基本信息:' + e.message);
 				}
 				}
 
 
-				if (param == 'onShow') {
-					if (this.$store.state.payInfo.from == 'reshui_pay') {
-						uni.showToast({
-							title: this.$store.state.payInfo.resultMsg,
-							icon: 'success',
-							success: () => {
-								this.$store.state.payInfo.resultMsg = ''
-								this.$store.state.payInfo.from = ''
-							}
-						})
-					}
-				}
-
-				// 获取code
-				this.getCode(options, param)
+				this.getRechargeRecord()
 			},
 			},
 			/**
 			/**
-			 * 获得code
+			 * 请求服务器,获得充值记录
 			 */
 			 */
-			getCode(options, param) {
-				uni.login({
-					success: (res) => {
-						// console.log('getCode', res);
-						if (res.code) {
-							// 请求服务器,获得openid
-							this.getOpenId(options, res.code, param)
-						} else {
-							uni.showToast({
-								title: res.errMsg,
-								icon: 'none'
-							});
-						}
-					}
-				})
-			},
-			/**
-			 * 请求服务器,获得openid
-			 */
-			async getOpenId(options, param_code, param) {
+			async getRechargeRecord() {
 				const res = await this.$myRequest({
 				const res = await this.$myRequest({
 					host: this.ceshi,
 					host: this.ceshi,
-					url: '/HotWaters/wpget_stu.action',
+					url: '/airManage/rechargequeryOwn.action',
 					method: 'POST',
 					method: 'POST',
 					header: {
 					header: {
 						'content-type': 'application/x-www-form-urlencoded'
 						'content-type': 'application/x-www-form-urlencoded'
 					},
 					},
 					data: {
 					data: {
-						code: param_code
+						sfzh: this.id_card,
+						// sfzh: '36012325455222',
+						month: this.date
 					}
 					}
 				})
 				})
 
 
-				// console.log(res);
-				if (res.data.mess == '返回成功') {
-					// stu_number是否存在
-					let cardNumber = res.data.info[0].card_number
-					if (typeof(cardNumber) != 'undefined' && cardNumber != '' && JSON.stringify(cardNumber) != '{}') {
-						// 学号 和 姓名
-						this.stu_number = res.data.info[0].stu_number
-						this.user_name = res.data.info[0].user_name
-						// 剩余金额
-						this.amount = res.data.info[0].balance.toFixed(2)
-						// if (this.amount > 0)
-						this.$store.state.reshui_amount = this.amount
-						// 组合楼栋宿舍号
-						this.dorm_number = res.data.info[0].build + res.data.info[0].dom
-						// 校区
-						// this.compus = res.data.info[0].campus
-
-						if (param == 'onLoad' && typeof(options.from) != 'undefined' && options.from != 0) {
-							// 初始化蓝牙
-							this.openBluetoothAdapter()
+				// console.log(res.data);
+				let data = res.data
+				if (data.code == 200) {
+					this.chongzhi_items = []
+					if (typeof data.data != 'undefined' && data.data != '' && JSON.stringify(data.data) != '{}') {
+						let tmp_items = []
+						for (var i = 0; i < data.data.length; i++) {
+							tmp_items.push({
+								begin_time: data.data[i].time,
+								desc: data.data[i].order_num,
+								use_amount: data.data[i].account
+							})
 						}
 						}
-						// 请求选定的月份消费记录
-						this.request_consumption_records()
+						this.chongzhi_items = tmp_items
 					} else {
 					} else {
 						uni.showToast({
 						uni.showToast({
-							title: '未获取到学号!',
+							title: '无充值记录!',
 							icon: 'success'
 							icon: 'success'
 						});
 						});
-
-						uni.navigateTo({
-							url: '../index/index?from=' + options.from
-						})
 					}
 					}
-				} else if (res.data.mess == '未查询到用户信息') {
-					// 数据库中 未查询到用户信息,就清除本地存储
-					uni.removeStorageSync('userinfo_storage_key');
-
+				} else {
 					uni.showToast({
 					uni.showToast({
-						title: '获取用户信息失败!'
+						title: data.data.message
 					})
 					})
-
-					if (options && typeof(options.from) != 'undefined' && typeof(options.from) != '') {
-						uni.navigateTo({
-							url: '../index/index?from=' + options.from
-						})
-					} else {
-						uni.redirectTo({
-							url: '../index/index?from=0'
-						});
-					}
 				}
 				}
 			},
 			},
 			/**
 			/**
@@ -234,61 +160,8 @@
 			 */
 			 */
 			bindDateChange(e) {
 			bindDateChange(e) {
 				this.date = e.detail.value
 				this.date = e.detail.value
-				this.changeDate = true
 				// 请求选定的月份消费记录
 				// 请求选定的月份消费记录
-				this.request_consumption_records()
-			},
-			/**
-			 * 请求选定的月份消费记录
-			 */
-			async request_consumption_records() {
-				try {
-					if (this.stu_number != '' && typeof(this.stu_number) != 'undefined') {
-						const res = await this.$myRequest({
-							host: this.ceshi,
-							url: '/HotWaters/wpqueryConsume.action',
-							method: 'POST',
-							header: {
-								'content-type': 'application/x-www-form-urlencoded'
-							},
-							data: {
-								stu_number: this.stu_number,
-								begin_time: this.date
-							}
-						});
-
-						// console.log(res);
-						if (res.data.mess == '返回成功') {
-							this.chongzhi_items = []
-							// 消费记录
-							let items = res.data.data
-							for (var i = 0; i < items.length; i++) {
-								this.chongzhi_items.push(items[i])
-							}
-						} else {
-							if (this.changeDate) {
-								uni.showToast({
-									icon: 'success',
-									title: res.data.mess,
-									success: () => {
-										this.changeDate = false
-									}
-								})
-
-								if (res.data.mess == '本月无消费记录') {
-									this.chongzhi_items = []
-								}
-							}
-						}
-					} else {
-						uni.showToast({
-							icon: 'success',
-							title: '未获得学号'
-						})
-					}
-				} catch (e) {
-					console.log('请求选定的月份消费记录:' + e.message);
-				}
+				this.getRechargeRecord()
 			},
 			},
 			/**
 			/**
 			 * 计算屏幕的高度
 			 * 计算屏幕的高度

+ 161 - 12
pagesAir/shareAir/shareAir.vue

@@ -1,8 +1,8 @@
 <template>
 <template>
 	<view class="container">
 	<view class="container">
-		<uni-swiper-dot :info="info" :current="current" field="content" :mode="dotMode">
+		<uni-swiper-dot :info="imgUrl" :current="current" field="content" :mode="dotMode">
 			<swiper class="swiper-box" @change="swiper_change" autoplay :interval="3000" :duration="500">
 			<swiper class="swiper-box" @change="swiper_change" autoplay :interval="3000" :duration="500">
-				<swiper-item v-for="(item ,index) in info" :key="index">
+				<swiper-item v-for="(item ,index) in imgUrl" :key="index">
 					<image :src="item.url" mode="aspectFill"></image>
 					<image :src="item.url" mode="aspectFill"></image>
 				</swiper-item>
 				</swiper-item>
 			</swiper>
 			</swiper>
@@ -115,26 +115,30 @@
 	export default {
 	export default {
 		data() {
 		data() {
 			return {
 			return {
+				ceshi: 'dev',
+				stu_number: '',
+				userinfo: {},
 				// 滚动横幅的数据
 				// 滚动横幅的数据
-				info: [{
-						url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg'
+				imgUrl: [{
+						url: this.$code_base_url + '/image/1.png'
 					},
 					},
 					{
 					{
-						url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg'
+						url: this.$code_base_url + '/image/2.png'
 					},
 					},
 					{
 					{
-						url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg'
+						url: this.$code_base_url + '/image/3.png'
 					}
 					}
 				],
 				],
-				current: 0, // 开始显示第几个
+				balance: 0.0.toFixed(2), // 余额
+				airs: [], // 已经添加的空调列表数据
 				dotMode: 'round', // 显示控制点样式
 				dotMode: 'round', // 显示控制点样式
-				balance: 18.88, // 余额
+				current: 0, // 开始显示第几个
 				isList: false, // 是否显示添加的空调列表
 				isList: false, // 是否显示添加的空调列表
-				airs: [], // 已经添加的空调列表数据
 				screenHeight: '' // 屏幕的高度
 				screenHeight: '' // 屏幕的高度
 			};
 			};
 		},
 		},
-		onLoad() {
+		onLoad(options) {
+			// 选择绑定了的空调
 			let airs_selected = uni.getStorageSync('airs_selected')
 			let airs_selected = uni.getStorageSync('airs_selected')
 			if (airs_selected.length > 0) {
 			if (airs_selected.length > 0) {
 				// 使用存储的列表
 				// 使用存储的列表
@@ -142,11 +146,15 @@
 				// 显示添加的空调列表
 				// 显示添加的空调列表
 				this.isList = true
 				this.isList = true
 			}
 			}
+
+			// 获取基本信息
+			this.get_base_info(options, 'onLoad')
 		},
 		},
 		onShow() {
 		onShow() {
 			// 从新计算高度
 			// 从新计算高度
 			this.calc_screen_height()
 			this.calc_screen_height()
 			// 监听全局的自定义事件,事件由 uni.$emit 触发,但仅触发一次,在第一次触发之后移除该监听器。
 			// 监听全局的自定义事件,事件由 uni.$emit 触发,但仅触发一次,在第一次触发之后移除该监听器。
+			// 绑定空调
 			uni.$once('selectAirs', data => {
 			uni.$once('selectAirs', data => {
 				// console.log('监听到事件来自 selectAirs ,携带参数 airs 为:' + data.airs);
 				// console.log('监听到事件来自 selectAirs ,携带参数 airs 为:' + data.airs);
 				// this.airs = []
 				// this.airs = []
@@ -191,7 +199,146 @@
 			})
 			})
 		},
 		},
 		methods: {
 		methods: {
-			// 长按事件
+			/**
+			 * 获取基本信息
+			 */
+			get_base_info(options, param) {
+				// console.log(options);
+				try {
+					// 获取学号
+					this.stu_number = this.$store.state.userInfo.card_number
+
+					if (this.stu_number == '' || typeof(this.stu_number) == 'undefined') { // 学号不存在,可以从存储中拿用户信息
+						const userinfo = uni.getStorageSync('userinfo_storage_key')
+						if (userinfo) { // 拿学号
+							this.stu_number = userinfo.card_number
+						} else { // 还没有需要跳转到首页进行获取
+							uni.navigateTo({
+								url: '../index/index?from=' + options.from
+							})
+
+							uni.showToast({
+								icon: 'none',
+								title: '学号为空,请进行授权',
+								duration: 3000
+							});
+
+							return
+						}
+					} else { // 学号已经存在,可以从存储中拿用户信息
+						this.userinfo = JSON.stringify(uni.getStorageSync('userinfo_storage_key'))
+					}
+				} catch (e) {
+					console.log('获取基本信息:' + e.message);
+				}
+
+				// 获取code
+				this.getCode(options, param)
+			},
+			/**
+			 * 获得code
+			 */
+			getCode(options, param) {
+				uni.login({
+					success: (res) => {
+						// console.log('getCode', res);
+						if (res.code) {
+							if (param == 'get_user_info') {
+								this.getUserInfo(res.code)
+							} else {
+								// 请求服务器,获得openid
+								this.getOpenId(options, res.code)
+							}
+						} else {
+							uni.showToast({
+								title: res.errMsg,
+								icon: 'none'
+							});
+						}
+					}
+				})
+			},
+			/**
+			 * 请求服务器,获得openid
+			 */
+			async getOpenId(options, param_code) {
+				const res = await this.$myRequest({
+					host: this.ceshi,
+					url: '/airManage/usersopenid.action',
+					method: 'POST',
+					header: {
+						'content-type': 'application/x-www-form-urlencoded'
+					},
+					data: {
+						code: param_code,
+						userinfo: this.userinfo
+					}
+				})
+
+				// console.log(res.data);
+				if (res.data.code == 200) {
+					// 查询用户基本信息
+					this.getCode(options, 'get_user_info')
+					// 绑定成功,提示返回信息,但没必要提示
+					// uni.showToast({
+					// 	title: res.data.message
+					// })
+				} else if (res.data.code == 205) {
+					// 查询用户基本信息
+					this.getCode(options, 'get_user_info')
+					// 用户已经存在,但没必要提示
+					// uni.showToast({
+					// 	title: res.data.message
+					// })
+				} else {
+					// 提示返回信息
+					uni.showToast({
+						title: res.data.message
+					})
+
+					if (options && typeof(options.from) != 'undefined' && typeof(options.from) != '') {
+						uni.navigateTo({
+							url: '../index/index?from=' + options.from
+						})
+					} else {
+						uni.redirectTo({
+							url: '../index/index?from=0'
+						});
+					}
+				}
+			},
+			/**
+			 * 获取用户基本信息
+			 * @param {Object} code
+			 */
+			async getUserInfo(code) {
+				const res = await this.$myRequest({
+					host: this.ceshi,
+					url: '/airManage/usersget_user.action',
+					method: 'POST',
+					header: {
+						'content-type': 'application/x-www-form-urlencoded'
+					},
+					data: {
+						code: code
+					}
+				})
+
+				// console.log(res.data);
+				if (res.data.code == 200) {
+					// 余额
+					this.balance = res.data.data.balance.toFixed(2)
+				} else {
+					uni.showToast({
+						title: res.data.message
+					})
+				}
+			},
+			/**
+			 * 长按可删除
+			 * @param {Object} e
+			 * @param {Object} val
+			 */
 			itemLongPress(e, val) {
 			itemLongPress(e, val) {
 				// console.log(e, val);
 				// console.log(e, val);
 				if (val == 0) {
 				if (val == 0) {
@@ -218,6 +365,7 @@
 			},
 			},
 			/**
 			/**
 			 * 单击了启动或关闭按钮
 			 * 单击了启动或关闭按钮
+			 * @param {Object} e
 			 */
 			 */
 			btn_click(e) {
 			btn_click(e) {
 				// console.log(e.currentTarget.dataset.ref);
 				// console.log(e.currentTarget.dataset.ref);
@@ -278,10 +426,11 @@
 			 * @param {Object} e
 			 * @param {Object} e
 			 */
 			 */
 			swiper_change(e) {
 			swiper_change(e) {
+				// console.log(e.detail.current);
 				this.current = e.detail.current;
 				this.current = e.detail.current;
 			},
 			},
 			/**
 			/**
-			 * 计算屏幕的高度
+			 * 计算屏幕的高度, 适配屏幕的高度
 			 */
 			 */
 			calc_screen_height() {
 			calc_screen_height() {
 				uni.getSystemInfo({
 				uni.getSystemInfo({

+ 172 - 105
pagesAir/stdBookMgr/stdBookMgr.vue

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

+ 14 - 1
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://jtishfw.ncjti.edu.cn/jxch-smartmp' // code
 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 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,6 +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 == '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') {
@@ -75,9 +77,20 @@ const getDate = function getDate(type) {
 		year = year - 4;
 		year = year - 4;
 	} else if (type === 'end_date') {
 	} else if (type === 'end_date') {
 		year = year;
 		year = year;
+	} else if (type === 'get_year') {
+		let years = []
+		years.push(year + '年')
+		years.push((year - 1) + '年')
+		years.push((year - 2) + '年')
+		years.push((year - 3) + '年')
+		return years
+	} else if (type === 'get_month') {
+		return month - 1
 	}
 	}
 
 
 	month = month > 9 ? month : '0' + month;
 	month = month > 9 ? month : '0' + month;
+
+
 	// day = day > 9 ? day : '0' + day;
 	// day = day > 9 ? day : '0' + day;
 
 
 	return `${year}-${month}`;
 	return `${year}-${month}`;