Ver Fonte

Merge branch 'dev' into 'test'

h5支付调整

See merge request quanshu/mp-ui-user!73
世轩 há 2 anos atrás
pai
commit
fe5bbeb039

+ 5 - 1
src/components/pay-popup/pay-popup.vue

@@ -256,9 +256,13 @@
 									// #ifdef H5
 									let data = ele.data
 									_this.close()
+									sessionStorage.setItem('viewUrlData', JSON.stringify(data))
 									uni.navigateTo({
-										url: `/pages/index/payExternal?viewUrl=${ encodeURIComponent(JSON.stringify(data)) }&orderId=${ res.data.orderId }`
+										url: `/pages/index/payExternal?orderId=${ res.data.orderId }`
 									})
+									// uni.navigateTo({
+									// 	url: `/pages/index/payExternal?viewUrl=${ encodeURIComponent(JSON.stringify(data)) }&orderId=${ res.data.orderId }`
+									// })
 									// #endif
 
 								} else if (ele.code == 1005) {

+ 16 - 2
src/packageGoods/order/index.vue

@@ -193,13 +193,20 @@
 					appSource: appId 
 				}
 				// #endif
-				// #ifndef MP-ALIPAY
+				// #ifdef MP-WEIXIN
 				let data = {
 					orderId: item.orderId,
 					payType: 2,
 					appSource: appId
 				}
 				// #endif
+				// #ifdef H5
+				let data = {
+					orderId: item.orderId,
+					payType: 3,
+					appSource: appId
+				}
+				// #endif
 				$http.post('/api/v1/mp/user/deliver/order/pay', data).then(ele => {
 					uni.hideLoading();
 					payIng = true
@@ -224,7 +231,7 @@
 							}
 						})
 						// #endif
-						// #ifndef MP-ALIPAY
+						// #ifdef MP-WEIXIN
 						uni.requestPayment({
 							timeStamp: ele.data.timeStamp,
 							nonceStr: ele.data.nonceStr,
@@ -244,6 +251,13 @@
 							}
 						})
 						// #endif
+						// #ifdef H5
+						let data = ele.data
+						uni.redirectTo({
+							url: `/packageGoods/order/payOrder?viewUrl=${ encodeURIComponent(JSON.stringify(data)) }&orderId=${ item.orderId }`
+						})
+						// #endif
+						
 					} else if (ele.code == 1005) {
 						_this.authShow = true
 					} else if (ele.code == 1026) {

+ 137 - 0
src/packageGoods/order/payOrder.vue

@@ -0,0 +1,137 @@
+<template>
+	<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="支付中" /> -->
+			<u-navbar leftIconSize="0" :placeholder="true" bgColor="#fff" :border="true" title="支付中">
+				<view class="nav-left flex" slot="left" @click="toOrder()">
+					<u-icon name="arrow-left" size="20" color="#333"></u-icon>
+				</view>
+			</u-navbar>
+		</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" v-if="paystatus == 0">
+			<u-button class="btn1" @click="openPay(1)" text="前往第三方支付" shape="circle"></u-button>
+		</view>
+		<view class="btn" v-else>
+			<u-button class="btn1" @click="toPurchase" text="我已支付,前往订单列表查看" shape="circle"></u-button>
+			<u-button class="btn2" @click="openPay(2)" text="还未支付,前往第三方支付" shape="circle"></u-button>
+		</view>
+	</view>
+</template>
+
+<script>
+	import $http from '@/utils/request.js'
+	export default {
+		data() {
+			return {
+				info: 'https://openapi.ysepay.com/gateway.do?',
+				pagesNum: '',
+				orderId: '',
+				paystatus: 0,
+			}
+		},
+		onShow() {
+			this.pagesNum = getCurrentPages().length
+			this.paystatus = sessionStorage.getItem('paystatus') ? 1 : 0
+		},
+		onLoad(opthios) {
+			if(opthios.orderId){
+				this.orderId = opthios.orderId
+			}
+			
+			let data = sessionStorage.getItem('viewUrlData')
+			data = JSON.parse(data)
+			Object.keys(data).forEach(item=>{
+				this.info = this.info + item + '=' + encodeURIComponent(data[item]) + '&'
+			})
+			
+			// if(opthios.viewUrl){
+			// 	let data = JSON.parse(decodeURIComponent(opthios.viewUrl))
+			// 	Object.keys(data).forEach(item=>{
+			// 		this.info = this.info + item + '=' + encodeURIComponent(data[item]) + '&'
+			// 	})
+			// }
+			// location.href =  this.info
+			// window.open(this.info);
+		},
+		onUnload() {
+			sessionStorage.removeItem('paystatus');
+			sessionStorage.removeItem('viewUrlData');
+		},
+		methods: {
+			openPay(e) {
+				if(e == 1){
+					sessionStorage.setItem('paystatus', '1');
+					window.open(this.info);
+				}else{
+					window.open(this.info);
+				}
+			},
+			toOrder() {
+				uni.redirectTo({
+					url: `/packageGoods/order/index`
+				})
+			},
+			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.showToast({
+							title: '支付成功',
+							icon: 'success',
+							duration: 2000
+						})
+						setTimeout(() => {
+							uni.redirectTo({
+								url: `/packageGoods/order/index`
+							})
+						}, 500)
+					}else {
+						uni.$u.toast(res.msg);
+					}
+				}).catch(() => {
+					uni.hideLoading();
+				})
+			},
+			
+		}
+	}
+</script>
+
+<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>

+ 20 - 2
src/packageGoods/order/settlement.vue

@@ -213,13 +213,20 @@
 								appSource: appId 
 							}
 							// #endif
-							// #ifndef MP-ALIPAY
+							// #ifdef MP-WEIXIN
 							let data = {
 								orderId: res.data.orderId,
 								payType: 2,
 								appSource: appId
 							}
 							// #endif
+							// #ifdef H5
+							let data = {
+								orderId: res.data.orderId,
+								payType: 3,
+								appSource: appId
+							}
+							// #endif
 							$http.post('/api/v1/mp/user/deliver/order/pay', data).then(ele => {
 								if (ele.code == 0) {
 									// #ifdef MP-ALIPAY
@@ -258,7 +265,7 @@
 									})
 									// #endif
 									
-									// #ifndef MP-ALIPAY
+									// #ifdef MP-WEIXIN
 									uni.requestPayment({
 										timeStamp: ele.data.timeStamp,
 										nonceStr: ele.data.nonceStr,
@@ -288,6 +295,17 @@
 									})
 									// #endif
 									
+									// #ifdef H5
+									let data = ele.data
+									sessionStorage.setItem('viewUrlData', JSON.stringify(data))
+									uni.navigateTo({
+										url: `/packageGoods/order/payOrder?orderId=${ res.data.orderId }`
+									})
+									// uni.redirectTo({
+									// 	url: `/packageGoods/order/payOrder?viewUrl=${ encodeURIComponent(JSON.stringify(data)) }&orderId=${ res.data.orderId }`
+									// })
+									// #endif
+									
 								} else if (ele.code == 1005) {
 									_this.authShow = true
 								} else if (ele.code == 1026) {

+ 7 - 5
src/packagePrize/choice/index.vue

@@ -96,11 +96,13 @@
 			</view>
 			<view class="choice-tip flex" @click="again" v-if="comfirmShow && type == 'online'">
 				<view class="txt">再买一个</view>
-			</view>
-			<view class="choice-download flex" @click="saveImg" v-if="comfirmShow">
-				<image src="../../packagePrize/static/download1.png" mode="aspectFit"></image>
-				<view>下载海报</view>
-			</view>
+			</view>
+			<!-- #ifdef MP-WEIXIN -->
+				<view class="choice-download flex" @click="saveImg" v-if="comfirmShow">
+					<image src="../../packagePrize/static/download1.png" mode="aspectFit"></image>
+					<view>下载海报</view>
+				</view>
+			<!-- #endif -->
 		</view>
 		<view v-else class="poster">
 		</view>

+ 3 - 0
src/pages.json

@@ -75,6 +75,9 @@
 				{
 					"path": "order/settlement"
 				},
+				{
+					"path": "order/payOrder"
+				},
 				{
 					"path": "ticket/index"
 				},

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

@@ -45,21 +45,27 @@
 			this.paystatus = sessionStorage.getItem('paystatus') ? 1 : 0
 		},
 		onLoad(opthios) {
-			
 			if(opthios.orderId){
 				this.orderId = opthios.orderId
-			}
-			if(opthios.viewUrl){
-				let data = JSON.parse(decodeURIComponent(opthios.viewUrl))
-				Object.keys(data).forEach(item=>{
-					this.info = this.info + item + '=' + encodeURIComponent(data[item]) + '&'
-				})
-			}
+			}
+			let data = sessionStorage.getItem('viewUrlData')
+			data = JSON.parse(data)
+			Object.keys(data).forEach(item=>{
+				this.info = this.info + item + '=' + encodeURIComponent(data[item]) + '&'
+			})
+			
+			// if(opthios.viewUrl){
+			// 	let data = JSON.parse(decodeURIComponent(opthios.viewUrl))
+			// 	Object.keys(data).forEach(item=>{
+			// 		this.info = this.info + item + '=' + encodeURIComponent(data[item]) + '&'
+			// 	})
+			// }
 			// location.href =  this.info
 			// window.open(this.info);
 		},
 		onUnload() {
 			sessionStorage.removeItem('paystatus');
+			sessionStorage.removeItem('viewUrlData');
 		},
 		methods: {
 			openPay(e) {
@@ -82,9 +88,16 @@
 				}).then(res => {
 					uni.hideLoading();
 					if (res.code == 0) {
-						uni.redirectTo({
-							url: `/packagePrize/purchase/index?boxId=${ res.data.boxId }&orderId=${ this.orderId }&isTry=0`
+						uni.showToast({
+							title: '支付成功',
+							icon: 'success',
+							duration: 2000
 						})
+						setTimeout(() => {
+							uni.redirectTo({
+								url: `/packagePrize/purchase/index?boxId=${ res.data.boxId }&orderId=${ this.orderId }&isTry=0`
+							})
+						}, 500)
 					}else {
 						uni.$u.toast(res.msg);
 					}