From 16c98154ca67d48665ed3a83874d43fdc626ac60 Mon Sep 17 00:00:00 2001
From: Liuyi <candymxq888@outlook.com>
Date: 星期三, 09 十月 2024 17:42:24 +0800
Subject: [PATCH] 添加获取用户位置

---
 pages/index/index.vue |  173 +++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 119 insertions(+), 54 deletions(-)

diff --git a/pages/index/index.vue b/pages/index/index.vue
index 004c816..56bf6c4 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -24,14 +24,15 @@
 	})
 	const isVip = ref(false)
 	//获取会员卡信息
-	async function getVipInfo(){
+	async function getInfo(){
 		let res = await getUserInfo()
+		console.log('res',res.data)
 		cardInfo.value.userName = res.data.userInfo.userName
 		cardInfo.value.headImg = res.data.userInfo.headImg
 		cardInfo.value.userPhone = res.data.userInfo.userPhone
 		if(res.data.userInfo.waterCardNumber){
 			let res1 = await getVipInfoApi()
-			cardInfo.value.waterCardNumber = res1.data.userInfo.waterCardNumber
+			cardInfo.value.waterCardNumber = res1.data.cardNumber
 			if(res1.data.cardType == 1){
 				cardInfo.value.balance = res1.data.balance
 			}else if(res1.data.cardType == 2){
@@ -41,14 +42,23 @@
 		}else{
 			isVip.value = false
 		}
+		uni.setStorageSync('userInfo',JSON.stringify(cardInfo.value))
 	}
 	/**
 	 * 扫码取水相关
 	 */
 	function toScan(){
-		uni.navigateTo({
-			url:'/pages/scanWater/index'
-		})
+		// 调用二维码扫描接口
+		uni.scanCode({
+			scanType: ['qrCode'],
+			success: function (res) {
+				console.log('条码类型:' + res.scanType);
+				console.log('条码内容:' + res.result);
+				uni.navigateTo({
+					url:'/pages/scanWater/index'
+				})
+			}
+		});
 	}
 	/**
 	 * 功能列表相关
@@ -88,11 +98,11 @@
 	}
 	onMounted( async() =>{
 		getTopHeight()
-		await getVipInfo()
+		// await getInfo()
 		// await getUserLocation()
 	})
 	onShow(async() =>{
-	await getVipInfo()
+		await getInfo()
 	})
 </script>
 
@@ -100,12 +110,12 @@
 	<view class="container">
 		<view class="content">
 			<view class="card-box" :style="{paddingTop:topHeight + 'rpx'}">
-				<view class="user-info">
+				<view class="user-info" @click="navTo('/pages/userInfo/index')">
 					<image class="user-img" src='../../static/images/index/hend1.png' alt=''></image>
 					<text>{{cardInfo.userName}}</text>
-					<image class="uesr-more"src="../../static/images/index/back.png"></image>
+					<image class="user-more"src="../../static/images/index/back.png"></image>
 				</view>
-				<view class="card" @click="navTo('/pages/userInfo/index')">
+				<view class="card">
 					<view class="card-content">
 						<view class="card-left">
 							<view class="left-top">
@@ -115,11 +125,21 @@
 								</view>
 								<view>ID:{{cardInfo.waterCardNumber}}</view>
 							</view>
-							<view></view>
+							<view class="left-bottom">电话:{{cardInfo.userPhone}}</view>
 						</view>
 						<view class="card-right">
-							<view></view>
-							<view></view>
+							<view class="card-right-top">
+								<view @click="navTo('/pages/addCard/index')">
+									<image src='../../static/images/index/vip-add.png' alt=''></image>
+									<span>添加会员卡</span>
+								</view>
+								<span>金额卡</span>
+							</view>
+							<view @click="navTo('/pages/recharge/index')">
+								<span>余额:</span>
+								<span class="card-balance">{{cardInfo.balance}}</span>
+								<span>元</span>
+							</view>
 						</view>
 					</view>
 				</view>
@@ -129,15 +149,17 @@
 					<image src="../../static/images/index/home21.png" alt=""></image>
 					<view>送水到家</view>
 				</view>
-				<view class="box1-bg box1-two">
-					<view>账户余额(元)</view>
+				<view @click="navTo('/pages/facilityList/index')" class="box1-bg box1-two">
+					<image src="../../static/images/index/icon22.png" alt=""></image>
+					<view>附近设备</view>
+					<!-- <view>账户余额(元)</view>
 					<view class="recharge">
 						<text>¥</text>
 						<text>120.00</text>
 					</view>
 					<view @click="navTo('/pages/recharge/index')">
 						充值
-					</view>
+					</view> -->
 				</view>
 				<view class="box1-bg box1-three" @click="toScan()">
 					<image src="../../static/images/index/icon23.png" alt=""></image>
@@ -237,9 +259,9 @@
 						margin-right:20rpx;
 						color: #fff;
 					}
-					.uesr-more{
+					.user-more{
 						width: 12rpx;
-						height: 28rpx;;
+						height: 28rpx;
 					}
 				}
 				.card{
@@ -252,9 +274,12 @@
 						width: 100%;
 						height: 100%;
 						box-sizing: border-box;
-						padding:15rpx;
+						padding:20rpx 15rpx;
 						display: flex;
 						justify-content:space-between;
+						font-weight: 300;
+						font-size: 30rpx;
+						color: #FFFFFF;
 						.card-left{
 							height:100%;
 							display: flex;
@@ -277,6 +302,40 @@
 										color: #FFFFFF;
 									}
 								}
+								view:last-child{
+									margin-left:10rpx;
+								}
+							}
+						}
+						.card-right{
+							display: flex;
+							justify-content: space-between;
+							align-items:flex-end;
+							flex-direction: column;
+							height:100%;
+							.card-right-top{
+								align-items: center;
+								display: flex;
+								justify-content: space-between;
+								view{
+									background-color: #fff;
+									color: #5EA1FA;
+									border-radius:20rpx;
+									padding: 5rpx 8rpx;
+									align-items: center;
+									display: flex;
+									justify-content: space-around;
+									font-size:24rpx;
+									margin-right:10rpx;
+									image{
+											width:28rpx;
+											height:28rpx;
+											margin-right:10rpx;
+									}
+								}
+							}
+							.card-balance{
+								font-weight:600;
 							}
 						}
 					}
@@ -314,45 +373,51 @@
 					}
 				}
 				.box1-two{
-					box-sizing: border-box;
-					padding:25rpx 0 10rpx;
+					font-weight: 300;
+					font-size: 32rpx;
+					color: #000000;
 					display: flex;
 					flex-direction:column;
 					align-items:center;
-					justify-content:space-around;
-					view:first-child{
-						font-weight: 300;
-						font-size: 24rpx;
-						color: #464646;
-						text-align: center;
-						margin-bottom:10rpx;
+					justify-content:space-evenly;
+					image{
+						width:96rpx;
+						height: 96rpx;
+						// margin-bottom:20rpx;
 					}
-					.recharge{
-						text:first-child{
-							font-weight: 500;
-							font-size: 32rpx;
-							color: #000;
-						}
-						text:last-child{
-							font-weight: 300;
-							font-size: 32rpx;
-							color: #2269E5;
-						}
-					}
-					view:last-child{
-						width: 140rpx;
-						height: 80rpx;
-						font-weight:300;
-						font-size: 24rpx;
-						color: #000141;
-						background-image: url('../../static/images/index/icon22.png');
-						background-repeat: no-repeat;
-						background-position: center;
-						background-size: 100% 100%;
-						text-align:center;
-						line-height:80rpx;
-						margin-top:10rpx;
-					}
+					// view:first-child{
+					// 	font-weight: 300;
+					// 	font-size: 24rpx;
+					// 	color: #464646;
+					// 	text-align: center;
+					// 	margin-bottom:10rpx;
+					// }
+					// .recharge{
+					// 	text:first-child{
+					// 		font-weight: 500;
+					// 		font-size: 32rpx;
+					// 		color: #000;
+					// 	}
+					// 	text:last-child{
+					// 		font-weight: 300;
+					// 		font-size: 32rpx;
+					// 		color: #2269E5;
+					// 	}
+					// }
+					// view:last-child{
+					// 	width: 140rpx;
+					// 	height: 70rpx;
+					// 	font-weight:300;
+					// 	font-size: 24rpx;
+					// 	color: #000141;
+					// 	background-image: url('../../static/images/index/icon22.png');
+					// 	background-repeat: no-repeat;
+					// 	background-position: center;
+					// 	background-size: 100% 100%;
+					// 	text-align:center;
+					// 	line-height:70rpx;
+					// 	margin-top:10rpx;
+					// }
 				}
 				.box1-three{
 					font-weight: 300;

--
Gitblit v1.9.3