From 0cfe50c34659fc30b8e6cdc05d9e4198efa71be9 Mon Sep 17 00:00:00 2001
From: web <candymxq888@outlook.com>
Date: 星期五, 04 七月 2025 16:26:56 +0800
Subject: [PATCH] 支付模块

---
 pages/device/index.vue   |   15 ++++---
 pages/login/index.vue    |    2 
 config/index.js          |    2 
 api/index.js             |    4 +-
 App.vue                  |   10 ++--
 pages/index/index.vue    |    6 ++
 pages/recharge/index.vue |   32 ++++++++--------
 7 files changed, 39 insertions(+), 32 deletions(-)

diff --git a/App.vue b/App.vue
index 4f96dce..2208e81 100644
--- a/App.vue
+++ b/App.vue
@@ -2,11 +2,11 @@
 	export default {
 		onLaunch: function() {
 			console.log('App Launch')
-			// if(!uni.getStorageSync('openId') || !uni.getStorageSync('token')){
-			// 	uni.redirectTo({
-			// 		url:'/pages/login/index'
-			// 	}) 
-			// }
+			if(!uni.getStorageSync('openId') || !uni.getStorageSync('token')){
+				uni.redirectTo({
+					url:'/pages/login/index'
+				}) 
+			}
 		},
 		onShow: function() {
 			console.log('App Show')
diff --git a/api/index.js b/api/index.js
index 2273148..88c26e2 100644
--- a/api/index.js
+++ b/api/index.js
@@ -20,9 +20,9 @@
 	return request('/pay/service/wxPay',data,'POST')
 }
 
-//水卡充值*
+//生成订单
 export function rechargeApi(data){
-	return request('/rechargeRecords/fees',data,'POST')
+	return request('/api/user/fees',data,'POST')
 }
 
 // 设备列表
diff --git a/config/index.js b/config/index.js
index f69b0cf..d69268c 100644
--- a/config/index.js
+++ b/config/index.js
@@ -1 +1 @@
-export const BASE_URL = 'http://192.168.0.67:8041'
\ No newline at end of file
+export const BASE_URL = 'https://www.huiwuyuntong.com/water-ration-beta'
\ No newline at end of file
diff --git a/pages/device/index.vue b/pages/device/index.vue
index 52aab37..e54abd7 100644
--- a/pages/device/index.vue
+++ b/pages/device/index.vue
@@ -16,7 +16,7 @@
 							</view>
 							<view class="info-addr" @click="openMap(item.lat,item.lon)">
 								<text class="addr-text">地址:{{item.address}}</text>
-								<view>
+								<view class="addr-icon">
 									<image src="../../static/images/icon-point.svg" alt=''></image>
 									<text>{{item.distanceValue}}km</text>
 								</view>
@@ -198,21 +198,24 @@
 						align-items:center;
 						.addr-text{
 							width:340rpx;
+							flex-shrink: 0;
 							height:80rpx;
 							color: #6a6e75;
 							font-size:26rpx;
 						}
-						view{
+						.addr-icon{
+							width: 150rpx;
+							flex-shrink: 0;
 							display: flex;
-							justify-content: space-between;
 							align-items:center;
+							justify-content: flex-end;
 							image{
-								width:50rpx;
-								height:50rpx;
+								width: 40rpx;
+								height: 40rpx;
 							}
 							text{
 								color: #6a6e75;
-								font-size:26rpx;
+								font-size:22rpx;
 							}
 						}
 					}
diff --git a/pages/index/index.vue b/pages/index/index.vue
index c1abbf2..6d99bd1 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -51,6 +51,7 @@
     import { onMounted, ref } from "vue";
 	import { BASE_URL } from '../../config/index.js';
 	import { getUserInfo } from '@/api/index.js'
+	import { onShow } from "@dcloudio/uni-app"
 	
 	const topHeight = ref(0)
 	const userInfo = ref()
@@ -145,10 +146,13 @@
 	}
 	onMounted(() => {
 		getTopHeight()
-		getUserDatail()
 		// 获取位置信息
 		getUserLocation()
 	})
+	
+	onShow(() => {
+		getUserDatail()
+	})
 </script>
 
 <style lang="scss" scoped>
diff --git a/pages/login/index.vue b/pages/login/index.vue
index 2e29d3e..ec84e56 100644
--- a/pages/login/index.vue
+++ b/pages/login/index.vue
@@ -5,7 +5,7 @@
 				<image class="top-bg" src="../../static/images/login/top_bg.png" mode="widthFix"></image>
 				<view class="top--title">
 					<image class="logo" src="../../static/images/login/logo.png "></image>
-					<view class="text">慧物通直饮水</view>
+					<view class="text">定量取水小程序</view>
 				</view>
 			</view>
 			<view class="login-text">
diff --git a/pages/recharge/index.vue b/pages/recharge/index.vue
index f2c4e34..5c84c99 100644
--- a/pages/recharge/index.vue
+++ b/pages/recharge/index.vue
@@ -37,7 +37,7 @@
 					</view>
 				</view>
 			</view>
-			<button :style="{opacity:payStatus ? 1 : 0.7}" class="submit-btn" @click="submit()">立即充值</button>
+			<button :disabled="payStatus" class="submit-btn" @click="submit()">立即充值</button>
 		</view>
 	</view>
 </template>
@@ -71,7 +71,7 @@
 		{text:"微信支付",value:2,checked:true,img:'../../static/images/recharge/wx.png'},
 	])
 	let timerId 
-	let payStatus = ref(true)
+	let payStatus = ref(false)
 	
 	const chooseMoney = (index1) => {
 		moneyList.value.forEach((item,index) =>{
@@ -91,11 +91,8 @@
 	}
 
 	const submit = () => {
-		if(payStatus.value){
-			payStatus.value = false
-			timerId = setTimeout(()=>{
-				payStatus.value = true
-			},20000)
+		payStatus.value = true; //点击后禁用按钮
+		try{
 			let money = ''
 			if(disabled.value){
 				money = choosedMoney.value
@@ -103,25 +100,27 @@
 				money = Number(otherMoney.value)
 			}
 			let data = {
-			        cardNumber:userInfo.waterCardNumber,
-			        paymentMethod:1,
-			        rechargeAmount:money
-			    }
+				cardNumber:userInfo.waterCardNumber,
+				paymentMethod:1,
+				rechargeAmount:money
+			}
 			//生成订单
-			rechargeApi(data).then(async(res) =>{
+			rechargeApi(data).then(async (res) =>{
 				if(res.code == 200){
 					let data = {
 						businessType:1,
 						businessNo:res.data
-						}
+					}
 					//发起支付
 					await wxPay(data)
 					otherMoney.value = ''
+					payStatus.value = false;
 				}
 			})
-		}else{
+		}catch(err){
+			payStatus.value = false;
 			uni.showToast({
-				title:'充值间隔20秒,请稍后!',
+				title:'失败',
 				icon:'none'
 			})
 		}
@@ -132,9 +131,10 @@
 		wxPayApi(data).then((res) =>{
 			if(res.code == 200){
 				//调用微信官方支付接口弹出付款界面,输入密码扣款
-				wx.requestPayment({
+				uni.requestPayment({
 				  //预支付订单信息
 				  // appId: res.data.appId,
+				  provider: 'wxpay',
 				  timeStamp: res.data.timeStamp,     //时间戳 
 				  nonceStr: res.data.nonceStr,      //随机串     
 				  package: res.data.package,		//prepay_id

--
Gitblit v1.9.3