Quellcode durchsuchen

提升用户使用体验

程志平 vor 5 Jahren
Ursprung
Commit
068f79da5f
3 geänderte Dateien mit 85 neuen und 51 gelöschten Zeilen
  1. 8 1
      components/instructions.vue
  2. 76 50
      pages/reshui/reshui.vue
  3. 1 0
      uni.scss

+ 8 - 1
components/instructions.vue

@@ -21,7 +21,7 @@
 					<view class="img">
 						<image class="img_scan" src="../static/images/qr-code.png" mode=""></image>
 					</view>
-					<view class="bot_text" @click="child_cancel">
+					<view class="bot_text" @click="child_cancel" hover-class="bot_text_hover_color">
 						我知道了
 					</view>
 				</view>
@@ -90,10 +90,17 @@
 				}
 
 				.bot_text {
+					height: 65rpx;
+					line-height: 65rpx;
+					border-radius: 10rpx;
 					color: $my-color-primary;
 					font-size: 32rpx;
 					text-align: center;
 				}
+				
+				.bot_text_hover_color {
+					background-color: $my-color-btn-background;
+				}
 			}
 		}
 	}

+ 76 - 50
pages/reshui/reshui.vue

@@ -2,7 +2,7 @@
 	<view class="content">
 		<view class="container">
 			<view class="header">
-				<view class="scan" @tap="scan()">
+				<view class="scan" @tap="scan()" hover-class="scan_hover">
 					<text class="iconfont icon-saoma"></text>
 					<text>扫码连接</text>
 				</view>
@@ -123,6 +123,8 @@
 				// 获取存储的用户数据
 				const value = uni.getStorageSync('userinfo_storage_key')
 				let item = decodeURIComponent(options.item)
+				// console.log(value)
+				// console.log(item)
 				if (item === '{}' && value == '') { // 如果没有用户信息,返回首页
 					uni.redirectTo({
 						url: '../index/index'
@@ -143,6 +145,8 @@
 				console.log(e)
 			}
 
+			this.card_number = this.userinfo.card_number; // 卡号
+			
 			// 查询用户信息
 			this.select_user_info()
 		},
@@ -168,37 +172,44 @@
 			 * 请求选定的月份消费记录
 			 */
 			async request_consumption_records() {
-				this.xiaofei_items = []
-				const res = await this.$myRequest({
-					host: 'code',
-					url: '/HotWater/wxpayqueryConsume.action',
-					method: 'POST',
-					header: {
-						'content-type': 'application/x-www-form-urlencoded'
-					},
-					data: {
-						card_number: this.card_number,
-						begin_time: this.date
-					}
-				});
+				if (this.card_number != '') {
+					this.xiaofei_items = []
+					const res = await this.$myRequest({
+						host: 'code',
+						url: '/HotWater/wxpayqueryConsume.action',
+						method: 'POST',
+						header: {
+							'content-type': 'application/x-www-form-urlencoded'
+						},
+						data: {
+							card_number: this.card_number,
+							begin_time: this.date
+						}
+					});
 
-				// console.log(res.data.mess, 'request_consumption_records');
-				if (typeof(res.data.mess) != 'undefined') {
-					let items = res.data.mess
-					// 按时间倒序排列
-					// items.sort((a, b) => {
-					// 	return a.begin_time < b.begin_time ? 1 : -1;
-					// })
-					for (var i = 0; i < items.length; i++) {
-						// 过滤掉为0的记录,只显示消费大于0的记录
-						// if (items[i].use_amount > 0.00) {
+					// console.log(res.data.mess, 'request_consumption_records');
+					if (typeof(res.data.mess) != 'undefined') {
+						let items = res.data.mess
+						// 按时间倒序排列
+						// items.sort((a, b) => {
+						// 	return a.begin_time < b.begin_time ? 1 : -1;
+						// })
+						for (var i = 0; i < items.length; i++) {
+							// 过滤掉为0的记录,只显示消费大于0的记录
+							// if (items[i].use_amount > 0.00) {
 							this.xiaofei_items.push(items[i])
-						// }
+							// }
+						}
+					} else {
+						uni.showToast({
+							icon: 'success',
+							title: '该月无消费记录'
+						})
 					}
 				} else {
 					uni.showToast({
 						icon: 'success',
-						title: '该月无消费记录'
+						title: '用户卡号为空'
 					})
 				}
 			},
@@ -220,24 +231,30 @@
 				});
 
 				// console.log(res, 'select_user_info');
-				// 将JSON字符串转化为JSON对象,取余额
-				let userinfo = res.data.info[0];
-				let amount = userinfo.balance; // 余额
-				let cnumber = userinfo.card_number; // 卡号
-				this.user_name = userinfo.user_name;
-				this.card_number = cnumber; // 卡号
-				this.dorm_number = userinfo.dom; // 宿舍号
-				if (amount != 0) {
-					this.amount = amount.toFixed(2)
-				}
-
-				if (cnumber == null || cnumber == undefined || cnumber == '') {
-					// 之前未绑定用户信息,现在去绑定用户信息
-					this.send_save_user_info()
+				if (res.statusCode == 502) {
+					uni.showToast({
+						icon: 'success',
+						title: '服务器网关错误'
+					})
+				} else {
+					// 将JSON字符串转化为JSON对象,取余额
+					let userinfo = res.data.info[0]
+					let amount = userinfo.balance // 余额
+					let cnumber = this.userinfo.card_number
+					this.user_name = userinfo.user_name;
+					this.dorm_number = userinfo.dom // 宿舍号
+					if (amount != 0) {
+						this.amount = amount.toFixed(2)
+					}
+					
+					if (cnumber == null || cnumber == undefined || cnumber == '') {
+						// 之前未绑定用户信息,现在去绑定用户信息
+						this.send_save_user_info()
+					}
+					
+					// 请求选定的月份消费记录
+					this.request_consumption_records()
 				}
-
-				// 请求选定的月份消费记录
-				this.request_consumption_records()
 			},
 
 			/**
@@ -516,7 +533,7 @@
 							title: err.errMsg,
 							duration: 2000
 						})
-						
+
 						this.isScan = false
 					}
 				})
@@ -558,7 +575,7 @@
 						if (!device.name && !device.localName) {
 							return
 						}
-						
+
 						if (device.name == this.device_code) {
 							//data里面建立一个deviceId、device_code,存储起来
 							// this.device_code = device.name;
@@ -1137,15 +1154,18 @@
 			box-sizing: border-box;
 
 			.header {
+				display: flex;
+				justify-content: center;
 				position: relative;
 				height: 200rpx;
 
 				.scan {
 					display: flex;
-					height: 200rpx;
 					flex-direction: column;
-					align-items: center;
 					justify-content: center;
+					align-items: center;
+					height: 200rpx;
+					width: 30%;
 
 					.iconfont {
 						margin-bottom: 10rpx;
@@ -1153,6 +1173,11 @@
 						color: $my-color-primary;
 					}
 				}
+				
+				.scan_hover {
+					border-radius: 15rpx;
+					background-color: $my-color-btn-background;
+				}
 
 				.qinshihao {
 					position: fixed;
@@ -1169,6 +1194,7 @@
 			}
 
 			.start_text {
+
 				.start_top,
 				.start_mid {
 					display: flex;
@@ -1176,7 +1202,7 @@
 					height: 100rpx;
 					align-items: center;
 					border-bottom: 2rpx #ccc solid;
-					
+
 					.item_left {
 						display: flex;
 						align-items: center;
@@ -1245,11 +1271,11 @@
 					height: 100rpx;
 					line-height: 100rpx;
 					font-weight: bold;
-					
+
 					.uni-input {
 						display: flex;
 						align-items: center;
-						
+
 						text:nth-child(1) {
 							margin-right: 10rpx;
 						}

+ 1 - 0
uni.scss

@@ -14,6 +14,7 @@
 
 /* 颜色变量 */
 $my-color-primary: #1296db;
+$my-color-btn-background: #E5E5E5;
 
 /* 行为相关颜色 */
 $uni-color-primary: #007aff;