Browse Source

Merge branch 'dev' into 'test'

h5支付

See merge request quanshu/mp-ui-user!70
世轩 2 years ago
parent
commit
15ff6ef3a8
2 changed files with 85 additions and 32 deletions
  1. 3 22
      src/components/pay-popup/pay-popup.vue
  2. 82 10
      src/pages/index/payExternal.vue

+ 3 - 22
src/components/pay-popup/pay-popup.vue

@@ -253,31 +253,12 @@
 										}
 									})
 									// #endif
-									// #ifdef H5
-									// localStorage.removeItem('callbackHTML');
-									// localStorage.setItem('callbackHTML',ele.data.payUrl);
+									// #ifdef H5
 									let data = ele.data
+									_this.close()
 									uni.navigateTo({
-										url: `/pages/index/payExternal?viewUrl=${ encodeURIComponent(JSON.stringify(data)) }`
+										url: `/pages/index/payExternal?viewUrl=${ encodeURIComponent(JSON.stringify(data)) }&orderId=${ res.data.orderId }`
 									})
-									// let formData = new FormData()
-									// Object.keys(ele.data).forEach(key => {
-									// 	formData.append(key,ele.data[key])
-									// })
-									// uni.request({
-									// 	url: 'https://openapi.ysepay.com/gateway.do',
-									// 	header: {
-									// 		'Content-Type': 'application/x-www-form-urlencoded',
-									// 	},
-									// 	data: ele.data,
-									// 	method: 'GET',
-									// 	success: (_res) => {
-									// 		console.log(_res);
-									// 	},
-									// 	fail: (err) => {
-									// 		console.log(err);
-									// 	}
-									// 	})
 									// #endif
 
 								} else if (ele.code == 1005) {

+ 82 - 10
src/pages/index/payExternal.vue

@@ -1,29 +1,101 @@
 <template>
-	<view class="">
-		<!-- <web-view :src='info'></web-view> -->
+	<view class="">
+		<!-- #ifdef MP-ALIPAY -->
+		<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="支付中" leftIconSize="0"></u-navbar>
+		<!-- #endif -->
+		<!-- #ifdef MP-WEIXIN -->
+		<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="支付中"></u-navbar>
+		<!-- #endif -->
+		<!-- #ifndef MP-WEIXIN || MP-ALIPAY -->
+		<view v-if="pagesNum > 1">
+			<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="支付中" />
+		</view>
+		<view v-else>
+			<u-navbar leftIconSize="0" :placeholder="true" bgColor="#fff" :border="true" title="支付中">
+				<view class="nav-left flex" slot="left" @click="$toIndex()">
+					<u-icon name="arrow-left" size="20" color="#333"></u-icon>
+				</view>
+			</u-navbar>
+		</view>
+		<!-- #endif -->
+		<!-- <web-view :src='info'></web-view> -->
+		
+		<view class="btn">
+			<u-button class="btn1" @click="toPurchase" text="我已支付" shape="circle"></u-button>
+			<u-button class="btn2" @click="openPay" text="还未支付" shape="circle"></u-button>
+		</view>
 	</view>
 </template>
 
-<script>
+<script>
+	import $http from '@/utils/request.js'
 	export default {
 		data() {
 			return {
-				info: 'https://openapi.ysepay.com/gateway.do?',
+				info: 'https://openapi.ysepay.com/gateway.do?',
+				pagesNum: '',
+				orderId: '',
 			}
+		},
+		onShow() {
+			this.pagesNum = getCurrentPages().length
 		},
-		onLoad(opthios) {
+		onLoad(opthios) {
+			if(opthios.orderId){
+				this.orderId = opthios.orderId
+			}
 			if(opthios.viewUrl){
 				let data = JSON.parse(decodeURIComponent(opthios.viewUrl))
-				// this.info = 'https://openapi.ysepay.com/gateway.do?'
 				Object.keys(data).forEach(item=>{
 					this.info = this.info + item + '=' + encodeURIComponent(data[item]) + '&'
 				})
 			}
-			location.href =  this.info
-		},
+			// location.href =  this.info
+			window.open(this.info);
+		},
+		methods: {
+			openPay() {
+				window.open(this.info);
+			},
+			
+			toPurchase() {
+				let _this = this
+				uni.showLoading({
+					title: '加载中'
+				});
+				$http.post('/api/v1/mp/user/ticket/query', {
+					orderId: this.orderId,
+				}).then(res => {
+					uni.hideLoading();
+					if (res.code == 0) {
+						uni.redirectTo({
+							url: `/packagePrize/purchase/index?boxId=${ res.data.boxId }&orderId=${ this.orderId }&isTry=0`
+						})
+					}else {
+						uni.$u.toast(res.msg);
+					}
+				}).catch(() => {
+					uni.hideLoading();
+				})
+			},
+			
+		}
 	}
 </script>
 
-<style>
-
+<style lang="scss" scoped>
+.btn {
+	 margin: 156rpx 41rpx 0 41rpx;
+	 .btn1 {
+		 background: linear-gradient(180deg, #FEA052 0%, #FF8D2F 100%);
+		 border-radius: 2px;
+		 color: #FFFFFF;
+	 }
+	 .btn2 {
+		 margin-top: 51rpx;
+		 border-radius: 2px;
+		 background-color: #EFEFEF;
+		 color: #666666;
+	 }
+}
 </style>