From b29d7b6bbe8256d5e95fb878adf06ffa9abb449a Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期一, 09 二月 2026 10:29:00 +0800
Subject: [PATCH] 新增退款

---
 web/pages/index/index.vue |   84 ++++++++++++++++++++++++++++++++---------
 1 files changed, 65 insertions(+), 19 deletions(-)

diff --git a/web/pages/index/index.vue b/web/pages/index/index.vue
index fefe54d..b71fd03 100644
--- a/web/pages/index/index.vue
+++ b/web/pages/index/index.vue
@@ -1,5 +1,5 @@
 <template>
-	<view class="content">
+	<view class="content" v-if="validPath">
 		<view class="banner">
 			<image src="/static/banner.png" mode="widthFix"></image>
 		</view>
@@ -38,6 +38,10 @@
 		</view>
 		<view class="btn" @click="sendSave">鍘绘敮浠�</view>
 	</view>
+	<view class="box" v-else>
+		<image src="/static/ic_payfail.png" mode="widthFix" class="icon"></image> 
+		<view class="title" >璇蜂娇鐢ㄥ井淇℃垨鑰呮敮浠樺疂搴旂敤鎵爜鎵撳紑</view> 
+	</view>
 </template>
 
 <script>
@@ -46,6 +50,7 @@
 		data() {
 			return {
 				flag:'name',
+				validPath : true,
 				form: {
 					type: 0,
 					name: '',
@@ -53,13 +58,32 @@
 					money: '',
 					remark: '',
 					userId:''
-				}
+				},
+				loading:false
 			}
 		},
 		mounted() {
+			this.loading=false
+			this.validPath = this.isWeChatBrowser() || this.isAlipayBrowser()
 			this.form.userId = this.fetchParams("userId",window.location.href)
 		},
 		methods: {
+			// 鍒ゆ柇鏄惁鍦ㄥ井淇℃祻瑙堝櫒涓墦寮�
+			isWeChatBrowser() {
+			  // #ifdef H5
+			  const userAgent = navigator.userAgent.toLowerCase();
+			  return userAgent.indexOf('micromessenger') !== -1;
+			  // #endif
+			  return false;
+			},
+			// 鍒ゆ柇鏄惁鍦ㄦ敮浠樺疂娴忚鍣ㄤ腑鎵撳紑
+			isAlipayBrowser() {
+			  // #ifdef H5
+			  const userAgent = navigator.userAgent.toLowerCase();
+			  return userAgent.indexOf('alipayclient') !== -1;
+			  // #endif
+			  return false;
+			},
 			toSuccess() {
 				uni.navigateTo({
 					url: '/pages/success/success'
@@ -75,17 +99,30 @@
 				return decodeURIComponent(results[2].replace(/\+/g, ' '));
 			},
 			async sendSave() {
+				if(this.loading){
+					// return
+				}
+				this.loading=true
 				var that = this
 				if(!this.form.name){
 					uni.showToast({
 						'title': '璇疯緭鍏ュ鍚�',icon:'none'
 					})
+					this.loading=false
 					return
 				}
 				if(!this.form.phone){
 					uni.showToast({
 						'title': '璇疯緭鍏ユ墜鏈哄彿',icon:'none'
 					})
+					this.loading=false
+					return
+				}
+				if(this.form.phone.length != 11){
+					uni.showToast({
+						'title': '璇疯緭鍏ユ纭殑11浣嶆墜鏈哄彿',icon:'none'
+					})
+					this.loading=false
 					return
 				}
 				if(!this.form.money || this.form.money < 0.01){
@@ -95,21 +132,15 @@
 					return
 				}
 				let res = await this.$u.api.orderCreate(this.form)
-				if (res.code === 200) {
+				if (res && res.code === 200) {
 					 const url = res.data.url
-					 // axios.post('https://third-party-website.com/api/submit', this.formData, {
-					 //   headers: { 'Content-Type': 'application/json' } // 鏍规嵁闇�瑕佹坊鍔犲叾浠栧ご閮ㄤ俊鎭紝濡傝璇佷护鐗岀瓑銆�
-					 // })
-					 // axios.post(res.data.url, res.data.params);
-					// const resolve = this.$router.push(url,params);
-					// window.open(resolve.href, "_blank")
-					 console.log(res)
 					 const elements = document.querySelectorAll('form');
 					 if(elements&& elements.length){
 						 elements.forEach(element => {
 						     element.remove();
 						 })
 					 }
+					 uni.showToast({title:'鍙戣捣鏀粯涓�'})
 					 var demo_form = document.createElement("form");
 					   demo_form.action = url;
 					   demo_form.id = "tempFromId";
@@ -128,28 +159,42 @@
 						   }
 					   }
 					   document.body.appendChild(demo_form)
-					   uni.showToast({
-					   	'title': '鐗规寫鍓�',icon:'none'
-					   })
 					   demo_form.submit() 
 					   
 					// this.toSuccess()
-				}
+				} 
+				this.loading=false
 			},
 		}
 	}
 </script>
 
 <style lang="scss" scoped>
+	.box {
+		width: 100%;
+		padding: 0 40rpx;
+		box-sizing: border-box;
+		display: flex;
+		align-items: center;
+		justify-content: center;
+		flex-direction: column;
+		.icon {
+			width: 180rpx;
+			height: 180rpx;
+			margin-top: 54rpx;
+		}
+		.title { 
+			font-size: 32rpx;
+			color: #222222;
+			margin-top: 32rpx;
+		}
+	}
 	.content {
 		width: 100%;
 		padding: 20rpx 30rpx;
 		box-sizing: border-box;
 		.btn {
-			position: fixed;
-			left: 30rpx;
-			bottom: calc(30rpx + env(safe-area-inset-bottom));
-			width: calc(100vw - 60rpx);
+			width: 100%;
 			height: 88rpx;
 			line-height: 88rpx;
 			text-align: center;
@@ -158,6 +203,7 @@
 			font-weight: 500;
 			font-size: 32rpx;
 			color: #FFFFFF;
+			margin-top: 150rpx;
 		}
 		.banner {
 			width: 100%;
@@ -225,7 +271,7 @@
 						width: 100%;
 						font-weight: 400;
 						font-size: 28rpx;
-						color: #999999;
+						//color: #999999;
 						text-align: right;
 					}
 				}

--
Gitblit v1.9.3