Browse Source

服务器迁移,共享空调开发中

程志平 4 years ago
parent
commit
c2c92f9480

+ 21 - 0
pages.json

@@ -102,6 +102,27 @@
 				"navigationBarTitleText": "添加空调",
 				"enablePullDownRefresh": false
 			}
+		}, {
+			"path": "stdBookMgr/stdBookMgr",
+			"style": {
+				"navigationBarTitleText": "台账管理",
+				"enablePullDownRefresh": false
+			}
+
+		}, {
+			"path": "accountBalance/accountBalance",
+			"style": {
+				"navigationBarTitleText": "账户余额",
+				"enablePullDownRefresh": false
+			}
+
+		}, {
+			"path": "rechargeRecord/rechargeRecord",
+			"style": {
+				"navigationBarTitleText": "充值记录",
+				"enablePullDownRefresh": false
+			}
+
 		}]
 	}],
 	// "preloadRule": {

+ 2 - 2
pages/index/index.vue

@@ -13,10 +13,10 @@
 					<image src="../../static/images/recharge2x.png" mode=""></image>
 					<text>水电充值</text>
 				</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>
 					<text>共享空调</text>
-				</navigator>
+				</navigator> -->
 			</view>
 		</view>
 		<view class="qr_code" v-if="showQR_code">

+ 0 - 1
pages/reshui/reshui.vue

@@ -402,7 +402,6 @@
 				// 请求选定的月份消费记录
 				this.request_consumption_records()
 			},
-
 			/**
 			 * 使用说明组件取消
 			 */

+ 406 - 0
pagesAir/accountBalance/accountBalance.vue

@@ -0,0 +1,406 @@
+<template>
+	<view class="container">
+		<view class="line"></view>
+		<view class="top">
+			<view class="it">
+				<view class="nv">
+					<image src="../static/images/ye.png" mode=""></image>
+					<view class="title">账户余额</view>
+					<view class="bal">¥{{balance.toFixed(2)}}</view>
+				</view>
+			</view>
+			<view class="it">
+				<navigator class="nv" url="/pagesAir/rechargeRecord/rechargeRecord">
+					<image src="../static/images/jl.png" mode=""></image>
+					<view class="title">充值记录</view>
+				</navigator>
+			</view>
+		</view>
+		<view class="line"></view>
+		<view class="middle-title">
+			<image src="../static/images/cz.png" mode=""></image>
+			<view class="txt">充值</view>
+		</view>
+		<view class="line"></view>
+		<view class="middle-balance">
+			<view class="balance" @tap="Recharge(10)" :class="{balanceborder: amount == 10}">10元</view>
+			<view class="balance" @tap="Recharge(20)" :class="{balanceborder: amount == 20}">20元</view>
+			<view class=" balance" @tap="Recharge(30)" :class="{balanceborder: amount == 30}">30元</view>
+			<view class=" balance" @tap="Recharge(40)" :class="{balanceborder: amount == 40}">40元</view>
+			<view class=" balance" @tap="Recharge(50)" :class="{balanceborder: amount == 50}">50元</view>
+			<view class=" balance" @tap="Recharge(60)" :class="{balanceborder: amount == 60}">60元</view>
+		</view>
+		<view class=" line"></view>
+		<input class="input-balance" type="text" v-model="amount" @input="onInput" @blur="onBlur" placeholder="请输入充值金额,金额大于10" placeholder-class="pc" />
+		<view class="line"></view>
+		<view class="btn-pay">
+			<button class="btn" url="/pagesAir/rechargeRecord/rechargeRecord" @tap="btn_click">
+				<text class="">立即付款</text>
+			</button>
+		</view>
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				balance: 18.88, // 余额
+				amount: '', // 充值金额
+				IP: '',
+				ceshi: 'code',
+				test: this.$store.state.test
+			}
+		},
+		onLoad() {
+			if (this.test) {
+				this.amount = 0.01
+			}
+		},
+		methods: {
+			/**
+			 * 选择了充值金额
+			 * @param {Object} param
+			 */
+			Recharge(param) {
+				this.amount = param
+			},
+			/**
+			 * 获取IP
+			 */
+			async getIP() {
+				const res = await this.$myRequest({
+					host: 'ip',
+					url: '?ie=utf-8',
+					method: 'POST'
+				})
+			
+				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])
+				}
+			},
+			/**
+			 * 获得code
+			 */
+			getCode(param_ip) {
+				uni.login({
+					success: (res) => {
+						// console.log('recharge', res);
+						if (res.code) {
+							// 组合地址,发起支付
+							this.jsapi(param_ip, res.code)
+						} else {
+							uni.showToast({
+								title: res.errMsg,
+								icon: 'none'
+							});
+						}
+					}
+				})
+			},
+			/**
+			 * 请求服务器,获取支付参数,并支付
+			 */
+			// 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);
+			// 			}
+			// 		});
+			// 	}
+			// },
+			/**
+			 * 输入充值金额
+			 */
+			onInput(e) {
+				if (this.test) { // 测试环境
+					return
+				}
+			
+				const v = e.detail.value
+			
+				const zero = /^(0{1,})|[^0-9]/g
+				let final = 0
+				if (!v) {
+					final = 0
+				} else {
+					final = v.toString().replace(zero, (v) => {
+						return 0
+					})
+			
+					if (final.split('')[0] * 1 === 0) {
+						final = final.slice(1) - 0 || 0
+					}
+			
+					if (final > 100) {
+						final = 100
+					}
+				}
+				this.$nextTick(() => {
+					if (final.toString() == '0') {
+						this.amount = ''
+					} else {
+						this.amount = final.toString() || '0'
+					}
+				})
+			},
+			/**
+			 * 输入框,失去焦点时
+			 */
+			onBlur() {
+				if (this.test) { // 测试环境
+					return
+				}
+				if (this.amount < 10) {
+					this.amount = 10
+				}
+			},
+			/**
+			 * 立即付款
+			 */
+			btn_click() {
+				// console.log(this.amount);
+				if (isNaN(this.amount)) {
+					uni.showToast({
+						title: '请输入正确金额',
+						duration: 2000
+					})
+					return
+				}
+				// 测试环境下执行
+				if (this.test) { // 测试环境
+					uni.showModal({
+						title: '提示',
+						content: '您选择了充值:¥' + this.amount + ' 元',
+						cancelText: '算了',
+						confirmText: '充值',
+						success: (res) => {
+							if (res.confirm) {
+								// 获取IP
+								this.getIP()
+							} else if (res.cancel) {
+								return
+							}
+						}
+					})
+					return
+				}
+				// 生产环境
+				if (this.amount < 10 || this.amount > 100) {
+					uni.showToast({
+						icon: 'none',
+						title: '最少充值10元,最多充值100元!',
+						mask: true,
+						duration: 3000
+					})
+					return
+				}
+				// 确认
+				uni.showModal({
+					title: '提示',
+					content: '您选择了充值:¥' + this.amount + ' 元',
+					cancelText: '算了',
+					confirmText: '充值',
+					success: (res) => {
+						if (res.confirm) {
+							// 获取IP
+							this.getIP()
+						} else if (res.cancel) {
+							return
+						}
+					}
+				})
+			}
+		}
+	}
+</script>
+
+<style lang="scss">
+	.container {
+		display: flex;
+		flex-direction: column;
+		font-size: 28rpx;
+		font-family: "Microsoft YaHei-3970(82674968)";
+		width: 730rpx;
+		padding: 10rpx;
+
+		.line {
+			height: 20rpx;
+		}
+
+		.top {
+			display: flex;
+			justify-content: space-around;
+			height: 220rpx;
+			border-radius: 10rpx;
+			padding-top: 30rpx;
+			background-color: #EFF2F9;
+
+			.it {
+				display: flex;
+				flex-direction: column;
+				align-items: center;
+
+				.nv {
+					display: flex;
+					flex-direction: column;
+					align-items: center;
+					padding: 18rpx;
+					border-radius: 10rpx;
+				}
+
+				image {
+					width: 60rpx;
+					height: 60rpx;
+					margin-bottom: 14rpx;
+				}
+
+				.title {
+					font-size: 36upx;
+				}
+
+				.bal {
+					font-size: 26upx;
+					color: #666666;
+				}
+			}
+		}
+
+		.middle-title {
+			display: flex;
+			align-items: center;
+
+			image {
+				width: 36rpx;
+				height: 36rpx;
+				margin-right: 10rpx;
+			}
+
+			.txt {
+				font-size: 32upx;
+			}
+		}
+
+		.middle-balance {
+			display: flex;
+			justify-content: space-around;
+			align-items: center;
+			flex-wrap: wrap;
+			height: 280rpx;
+
+			.balance {
+				display: flex;
+				justify-content: center;
+				align-items: center;
+				font-size: 36upx;
+				font-family: Microsoft YaHei-3970(82674968);
+				font-weight: bold;
+				color: #333333;
+				padding: 36rpx 0;
+				width: 220rpx;
+				background-color: #EFF2F9;
+				border-radius: 6rpx;
+			}
+
+			.balanceborder {
+				border: 1px solid #3869FC;
+				width: 218rpx;
+				padding: 34rpx 0;
+			}
+		}
+
+		.input-balance {
+			font-size: 40upx;
+			height: 80rpx;
+			background-color: #F2F2F2;
+			border-radius: 6rpx;
+			margin: 0 10rpx;
+			padding: 10rpx 20rpx;
+		}
+
+		.pc {
+			color: #B3B3B3;
+		}
+
+		.btn-pay {
+			display: flex;
+			justify-content: center;
+			align-items: center;
+
+			.btn {
+				display: flex;
+				justify-content: center;
+				align-items: center;
+				margin: 30rpx;
+				width: 280rpx;
+				height: 100rpx;
+				background: #3869FC;
+				border-radius: 6px;
+
+				font-size: 36upx;
+				font-family: Microsoft YaHei-3970(82674968);
+				font-weight: 400;
+				color: #FFFFFF;
+			}
+		}
+	}
+</style>

+ 375 - 0
pagesAir/rechargeRecord/rechargeRecord.vue

@@ -0,0 +1,375 @@
+<template>
+	<view class="container">
+		<view class="line"></view>
+		<view class="uni-list-cell-db">
+			<picker mode="date" :value="date" fields="month" :start="startDate" :end="endDate" @change="bindDateChange">
+				<view class="uni-input">
+					<text>{{date}}</text>
+					<text class="iconfont icon-arrow-down"></text>
+				</view>
+			</picker>
+		</view>
+		<view class="line"></view>
+		<scroll-view scroll-y="true" :style="{height: screenHeight}" @scrolltoupper="scroll_to_upper"
+			@scrolltolower="scroll_to_lower">
+			<view class="item-list" v-for="(item, i) in chongzhi_items" :key="i">
+				<view class="item-left">
+					<image src="../static/images/chongzhi-icon.png" mode=""></image>
+					<view class="left-desc">
+						<text class="item-list-title">{{item.desc}}</text>
+						<text class="item-list-time">{{item.begin_time}}</text>
+					</view>
+				</view>
+				<text class="item-right">{{numFilter(item.use_amount)}}</text>
+			</view>
+		</scroll-view>
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				screenHeight: 0,
+				stu_number: '', // 学号
+				date: this.$getDate({
+					format: true
+				}),
+				startDate: this.$getDate('start_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',
+			}
+		},
+		onLoad() {
+			if (this.stu_number && typeof(this.stu_number) != 'undefined') {
+				// 获取基本信息
+				this.get_base_info('options', 'onShow')
+			}
+		},
+		onShow() {
+			// 从新计算高度
+			// setTimeout(() => {
+			this.calc_screen_height()
+			// }, 1500)
+		},
+		methods: {
+			/**
+			 * 滚动到顶部提示
+			 */
+			scroll_to_upper() {
+				uni.showToast({
+					title: '到顶了!',
+					icon: 'none',
+					duration: 500
+				})
+			},
+			/**
+			 * 滚动到底部提示
+			 */
+			scroll_to_lower() {
+				uni.showToast({
+					title: '到底了!',
+					icon: 'none',
+					duration: 500
+				})
+			},
+			/**
+			 * 保留小数点数值后两位,尾数四舍五入
+			 * @param {Object} value
+			 */
+			numFilter(value) {
+				// 截取当前数据到小数点后两位
+				let realVal = parseFloat(value).toFixed(2)
+				return realVal
+			},
+			/**
+			 * 获取基本信息
+			 */
+			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
+						}
+					}
+				} catch (e) {
+					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)
+			},
+			/**
+			 * 获得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) {
+				const res = await this.$myRequest({
+					host: this.ceshi,
+					url: '/HotWaters/wpget_stu.action',
+					method: 'POST',
+					header: {
+						'content-type': 'application/x-www-form-urlencoded'
+					},
+					data: {
+						code: param_code
+					}
+				})
+
+				// 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()
+						}
+						// 请求选定的月份消费记录
+						this.request_consumption_records()
+					} else {
+						uni.showToast({
+							title: '未获取到学号!',
+							icon: 'success'
+						});
+
+						uni.navigateTo({
+							url: '../index/index?from=' + options.from
+						})
+					}
+				} else if (res.data.mess == '未查询到用户信息') {
+					// 数据库中 未查询到用户信息,就清除本地存储
+					uni.removeStorageSync('userinfo_storage_key');
+
+					uni.showToast({
+						title: '获取用户信息失败!'
+					})
+
+					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'
+						});
+					}
+				}
+			},
+			/**
+			 * 选择消费年月
+			 */
+			bindDateChange(e) {
+				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);
+				}
+			},
+			/**
+			 * 计算屏幕的高度
+			 */
+			calc_screen_height() {
+				uni.getSystemInfo({
+					success: res => {
+						let h = ((res.screenHeight * (750 / res.windowWidth)) - 280) //将px 转换rpx
+						this.screenHeight = Math.floor(h) + 'rpx'
+					}
+				});
+			}
+		}
+	}
+</script>
+
+<style lang="scss">
+	.container {
+		display: flex;
+		flex-direction: column;
+		font-size: 28rpx;
+		font-family: "Microsoft YaHei-3970(82674968)";
+		width: 730rpx;
+		padding: 10rpx;
+
+		.line {
+			height: 20rpx;
+		}
+
+		.uni-list-cell-db {
+
+			.uni-input {
+				display: flex;
+				justify-content: space-around;
+				align-items: center;
+				width: 200rpx;
+				height: 60rpx;
+				border: 2rpx solid #CCCCCC;
+				border-radius: 6rpx;
+				font-size: 32upx;
+			}
+		}
+
+		.item-list {
+			display: flex;
+			justify-content: space-between;
+			align-items: center;
+			padding: 20rpx 10rpx;
+			border-bottom: 1rpx solid #CCCCCC;
+
+			.item-left {
+				display: flex;
+				align-items: center;
+
+				image {
+					width: 80rpx;
+					height: 80rpx;
+				}
+
+				.left-desc {
+					display: flex;
+					flex-direction: column;
+					justify-content: space-around;
+					margin-left: 20rpx;
+
+					.item-list-title {
+						font-size: 32upx;
+						font-weight: bold;
+					}
+
+					.item-list-time {
+						color: #808080;
+					}
+				}
+			}
+
+			.item-right {
+				font-size: 36upx;
+				font-weight: bold;
+				color: #333333;
+			}
+		}
+	}
+</style>

+ 3 - 3
pagesAir/shareAir/shareAir.vue

@@ -9,7 +9,7 @@
 		</uni-swiper-dot>
 		<view class="line"></view>
 		<view class="nav">
-			<navigator class="btn" url="" hover-class="navigator-hover">
+			<navigator class="btn" url="/pagesAir/stdBookMgr/stdBookMgr" hover-class="navigator-hover">
 				<view class="btn-icon-tzgl">
 					<image src="../static/images/tzgl.png" mode=""></image>
 					<text>台账管理</text>
@@ -19,10 +19,10 @@
 					<uni-icons type="forward" color="#c7c9ce" size="26"></uni-icons>
 				</view>
 			</navigator>
-			<navigator class="btn" url="" hover-class="navigator-hover">
+			<navigator class="btn" url="/pagesAir/accountBalance/accountBalance" hover-class="navigator-hover">
 				<view class="btn-icon">
 					<image src="../static/images/yhye.png" mode=""></image>
-					<text>户余额</text>
+					<text>户余额</text>
 				</view>
 				<view class="txt-right">
 					<text>{{balance}}</text>

BIN
pagesAir/static/images/chongzhi-icon.png


BIN
pagesAir/static/images/cz.png


BIN
pagesAir/static/images/dt.png


BIN
pagesAir/static/images/item-icon.png


BIN
pagesAir/static/images/jl.png


BIN
pagesAir/static/images/xfjl.png


BIN
pagesAir/static/images/ye.png


+ 389 - 0
pagesAir/stdBookMgr/stdBookMgr.vue

@@ -0,0 +1,389 @@
+<template>
+	<view class="container">
+		<view class="line"></view>
+		<view class="picker-box">
+			<picker @change="bindYearPickerChange" :value="selYearIndex" :range="years" class="picker-input">
+				<view class="txt-picker">
+					<view>{{years[selYearIndex]}}</view>
+					<uni-icons type="bottom" size="22"></uni-icons>
+				</view>
+			</picker>
+			<picker @change="bindMonthPickerChange" :value="selMonthindex" :range="months" class="picker-input">
+				<view class="txt-picker">
+					<view>{{months[selMonthindex]}}</view>
+					<uni-icons type="bottom" size="22"></uni-icons>
+				</view>
+			</picker>
+		</view>
+		<view class="line"></view>
+		<view class="show-charts">
+			<view class="show-label">
+				<image class="show-logo-left" src="../static/images/dt.png"></image>
+				<view class="show-txt-label">消费走势图</view>
+			</view>
+			<view class="charts-box">
+				<qiun-data-charts type="line" :chartData="chartData" :opts="chartOpts" :ontouch="true"
+					tooltipFormat="tooltipDemo1" />
+			</view>
+		</view>
+		<view class="line"></view>
+		<view class="xfjl">
+			<view class="xfjl-title">
+				<image class="show-logo-left" src="../static/images/xfjl.png"></image>
+				<view class="show-txt-label">消费记录</view>
+			</view>
+			<scroll-view scroll-y="true" :style="{height: screenHeight}" @scrolltoupper="scroll_to_upper"
+				@scrolltolower="scroll_to_lower">
+				<view class="items" v-for="(item, index) in consumeRecords" :key="index">
+					<view class="item">
+						<view class="item-left">
+							<image src="../static/images/item-icon.png" mode=""></image>
+							<view class="item-desc">
+								<view class="item-title">{{item.loudong}}</view>
+								<view class="item-time">开始时间:{{item.startTime}}</view>
+								<view class="item-time">结束时间:{{item.endTime}}</view>
+							</view>
+						</view>
+						<view class="item-right">{{item.amount.toFixed(2)}}</view>
+					</view>
+				</view>
+			</scroll-view>
+		</view>
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				screenHeight: 0,
+				ceshi: 'code',
+				years: ['2021年', '2022年'], // 候选年份
+				months: ['全部', '1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'], // 候选月份
+				selYearIndex: 0, // 选择的年份
+				selMonthindex: 0, // 选择的月份
+				chartData: {
+					categories: [],
+					series: []
+				},
+				chartOpts: {
+					color: ["#1890FF", "#91CB74", "#FAC858"],
+					padding: [15, 10, 0, 15],
+					legend: {},
+					xAxis: {
+						disableGrid: true
+					},
+					yAxis: {
+						data: [{
+							max: 0
+						}]
+					},
+					extra: {
+						line: {
+							type: "curve",
+							width: 2
+						}
+					}
+				},
+				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
+					}
+				]
+			}
+		},
+		onLoad() {
+			this.get_xiaofiezoushi()
+		},
+		onShow() {
+			// 从新计算高度
+			// setTimeout(() => {
+			this.calc_screen_height()
+			// }, 1500)
+		},
+		methods: {
+			/**
+			 * 滚动到顶部提示
+			 */
+			scroll_to_upper() {
+				uni.showToast({
+					title: '到顶了!',
+					icon: 'none',
+					duration: 500
+				})
+			},
+			/**
+			 * 滚动到底部提示
+			 */
+			scroll_to_lower() {
+				uni.showToast({
+					title: '到底了!',
+					icon: 'none',
+					duration: 500
+				})
+			},
+			/**
+			 * 选择年份
+			 * @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
+						}
+					})
+
+					// console.log(res.data.rows);
+					// console.log(res.data);
+					if (res.data.rows.length == 0) {
+						return
+					}
+
+					if (typeof res.data.rows === 'undefined') {
+						uni.showToast({
+							title: '加载数据异常',
+							duration: 1500
+						})
+						return
+					}
+
+					let chrt_data = {
+						categories: [],
+						series: [],
+					}
+					let elc_max = -1.0
+					let dt = ''
+					let temp = 0
+					let data = []
+					for (var i = 0; i < res.data.rows.length; i++) {
+						dt = res.data.rows[i].dataTime
+						chrt_data.categories.push(parseInt(dt.substr(dt.indexOf('-') + 1, dt.length)) + '月')
+						temp = res.data.rows[i].totalMoney
+						temp = temp.toFixed(2)
+						data.push(temp)
+						if (parseFloat(temp) > parseFloat(elc_max)) {
+							elc_max = temp
+						}
+					}
+					let items = {
+						name: '金额',
+						data: data
+					}
+					chrt_data.series.push(items)
+					let m = parseFloat(Math.abs(elc_max))
+					// console.log(chrt_data);
+					if (elc_max == 0.0) {
+						setTimeout(() => {
+							this.chartOpts.yAxis.data[0].max = parseInt(10)
+							this.chartData = chrt_data;
+						}, 1000);
+					} else {
+						setTimeout(() => {
+							this.chartOpts.yAxis.data[0].max = parseInt(m + 5)
+							this.chartData = chrt_data;
+						}, 1000);
+					}
+				} else {
+					uni.showToast({
+						title: '宿舍号为空',
+						icon: 'success'
+					});
+				}
+			},
+			/**
+			 * 计算屏幕的高度
+			 */
+			calc_screen_height() {
+				uni.getSystemInfo({
+					success: res => {
+						let h = ((res.screenHeight * (750 / res.windowWidth)) - 820) //将px 转换rpx
+						this.screenHeight = Math.floor(h) + 'rpx'
+					}
+				});
+			}
+		}
+	}
+</script>
+
+<style lang="scss">
+	.container {
+		display: flex;
+		flex-direction: column;
+		font-size: 28rpx;
+		font-family: "Microsoft YaHei-3970(82674968)";
+		width: 730rpx;
+		padding: 10rpx;
+
+		.line {
+			height: 20rpx;
+		}
+
+		.picker-box {
+			display: flex;
+			justify-content: space-between;
+			width: 375rpx;
+
+			.picker-input {
+				display: flex;
+				justify-content: space-around;
+				align-items: center;
+				border: 2rpx solid #CCCCCC;
+				border-radius: 6rpx;
+
+				.txt-picker {
+					display: flex;
+					justify-content: space-around;
+					align-items: center;
+					width: 175rpx;
+					height: 60rpx;
+				}
+			}
+		}
+
+		.show-charts {
+			display: flex;
+			flex-direction: column;
+
+			.show-label {
+				display: flex;
+				align-items: center;
+
+				image {
+					width: 30rpx;
+					height: 30rpx;
+					margin: 0 10rpx 0;
+				}
+
+				.show-txt-label {
+					font-size: 32upx;
+				}
+			}
+		}
+
+		.xfjl {
+			display: flex;
+			flex-direction: column;
+
+			.xfjl-title {
+				display: flex;
+				align-items: center;
+
+				image {
+					width: 30rpx;
+					height: 30rpx;
+					margin: 0 10rpx 0;
+				}
+
+				.show-txt-label {
+					font-size: 32upx;
+				}
+			}
+
+			.items {
+				display: flex;
+				flex-direction: column;
+
+				.item {
+					display: flex;
+					justify-content: space-between;
+					align-items: center;
+					height: 120rpx;
+					margin: 10rpx;
+					padding: 15rpx 0;
+					border-bottom: 1px solid #CCCCCC;
+
+					.item-left {
+						display: flex;
+						align-items: center;
+
+						image {
+							width: 90rpx;
+							height: 90rpx;
+							margin: 0 20rpx 0 0;
+						}
+
+						.item-desc {
+							display: flex;
+							flex-direction: column;
+							justify-content: space-between;
+
+							.item-title {
+								font-size: 32upx;
+								font-weight: bold;
+							}
+
+							.item-time {
+								font-size: 24upx;
+								color: #c8cdd8;
+							}
+						}
+					}
+
+					.item-right {
+						font-size: 36upx;
+						font-weight: bold;
+						color: #4456fb;
+					}
+				}
+			}
+		}
+	}
+</style>

+ 1 - 3
pagesElectric/show/show.vue

@@ -65,9 +65,7 @@
 					series: []
 				},
 				chartOpts: {
-					color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4",
-						"#ea7ccc"
-					],
+					color: ["#1890FF", "#91CB74", "#FAC858"],
 					padding: [15, 10, 0, 15],
 					legend: {},
 					xAxis: {

+ 2 - 1
static/api.js

@@ -1,6 +1,7 @@
 const WEXIN_BASE_URL = 'https://api.mch.weixin.qq.com' // wexin
 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://jtishfw.ncjti.edu.cn/jxch-smartmp' // code
+const CODE_BASE_URL = 'https://chtech.ncjti.edu.cn/shuidian' // code
 const IP_BASE_URL = 'https://pv.sohu.com/cityjson' // ip
 
 const myRequest = (options) => {