Selaa lähdekoodia

完善现金支付IOS问题

lyb 4 vuotta sitten
vanhempi
commit
b7834c108e
5 muutettua tiedostoa jossa 49 lisäystä ja 15 poistoa
  1. 13 0
      assets/http/api.js
  2. 7 3
      pages/activity/activityDetail.vue
  3. 20 6
      pages/payResult/payResult.vue
  4. 8 4
      pages/shop/detail.vue
  5. 1 2
      store/index.js

+ 13 - 0
assets/http/api.js

@@ -305,6 +305,18 @@ const poster={
 	})
 }
 
+//易宝支付
+const yeepay={
+	saveOrderUrlAndColor: p => http.post('app/yeepay/saveOrderUrlAndColor', p ,{
+		header: {
+			'Content-Type': 'application/x-www-form-urlencoded'
+		}
+	}),
+	getOrderUrlAndColor: p => http.get('app/yeepay/getOrderUrlAndColor', {
+		params: p
+	})
+}
+
 export const api = {
 	uploadFileUrl,
 	sms,
@@ -327,4 +339,5 @@ export const api = {
 	census,
 	activerecord,
 	poster,
+	yeepay,
 }

+ 7 - 3
pages/activity/activityDetail.vue

@@ -436,9 +436,13 @@
 				}
 				let res = await this.$api.order.cashExchange(params)
 				if (res.data.success) {
-					let url = encodeURIComponent(window.location.href);
-					this.$u.vuex('vuex_redirect_url', url);
-					console.log("支付订单",JSON.parse(res.data.data.prePayTn))
+					let url = encodeURIComponent(location.href);
+					let params = {
+						orderId: res.data.data.bankOrderId,
+						orderUrl: url,
+						color: this.vuex_theme.bgColor
+					}
+					this.$api.yeepay.saveOrderUrlAndColor(params)
 					this.$shareConfig.H5Pay(JSON.parse(res.data.data.prePayTn)).then((res) => {
 						console.log("作品投票页面res", res)
 						this.voteSuccess();

+ 20 - 6
pages/payResult/payResult.vue

@@ -1,13 +1,14 @@
 <template>
 	<view class="payResult">
-		<u-icon name="checkmark-circle-fill" :color="vuex_theme.bgColor" style="margin-top: 50rpx;" size="100"></u-icon>
+		<u-icon name="checkmark-circle-fill" :color="bgColor" style="margin-top: 50rpx;" size="100"></u-icon>
 		<view>支付成功</view>
-		<u-button  shape="circle" :custom-style="customStyle" style="margin-top: 50rpx;" @click="goback">返回</u-button>
+		<u-button  shape="circle" :custom-style="customStyle" style="margin-top: 50rpx;" @click="goback">返回详情页</u-button>
 	</view>
 </template>
 
 <script>
 	let goldPlan = require('@/utils/jgoldplan-1.0.0.js');
+	import VConsole from 'vconsole';
 	export default {
 		data() {
 			return {
@@ -18,12 +19,25 @@
 					margin: '10rpx',
 					height:"60rpx",
 					fontSize:"26rpx"
-				}
+				},
+				redirect_url: '',
+				bgColor: ''
 			}
 		},
-		onLoad(options) {
+		async onLoad(options) {
+			// const vConsole = new VConsole();
 			console.log("商品小票",options)
-			this.customStyle.background = this.vuex_theme.bgColor;
+			this.customStyle.background = this.bgColor;
+			let params = {
+				orderId: options.out_trade_no
+			}
+			let res = await this.$api.yeepay.getOrderUrlAndColor(params)
+			if(res.data.success){
+				this.redirect_url = res.data.data.url;
+				this.bgColor = res.data.data.color;
+				this.customStyle.background = this.bgColor;
+			}
+			
 		},
 		onReady() {
 			let mchData = {
@@ -38,7 +52,7 @@
 			goback() {
 				let mchData = {
 					action: 'jumpOut',
-					jumpOutUrl: decodeURIComponent(this.vuex_redirect_url) //跳转的页面
+					jumpOutUrl: decodeURIComponent(this.redirect_url) //跳转的页面
 				}				
 				var postData = JSON.stringify(mchData);
 				parent.postMessage(postData, 'https://payapp.weixin.qq.com')

+ 8 - 4
pages/shop/detail.vue

@@ -275,7 +275,7 @@
 			 */
 			async confirm() {
 				// #ifdef H5
-				if(this.$isEmpty(this.vuex_gzh_userOpenid)){
+				if(this.$isEmpty(this.vuex_gzh_userOpenid) && this.exchangeType != 1){
 					let code = this.$util.getUrlParam("code");
 					if(this.$isEmpty(code)){
 						this.$refs.webAuthAlert.show = true;
@@ -338,9 +338,13 @@
 							// #endif
 							
 							// #ifdef H5
-							let url = encodeURIComponent(window.location.href);
-							this.$u.vuex('vuex_redirect_url', url);
-							console.log("支付订单",res.data.data)
+							let url = encodeURIComponent(location.href);
+							let params = {
+								orderId: res.data.data.orderId,
+								orderUrl: url,
+								color: this.vuex_theme.bgColor
+							}
+							this.$api.yeepay.saveOrderUrlAndColor(params)
 							this.$shareConfig.H5Pay(res.data.data).then((res) => {
 								console.log("商品兑换页面res", res)
 								this.$refs.exchangeSuccess.showSuccess(this.detail.imgUrl)

+ 1 - 2
store/index.js

@@ -17,7 +17,7 @@ try {
 
 // 需要永久存储,且下次APP启动需要取出的,在state中的变量名
 let saveStateKeys = ['vuex_audit', 'vuex_userId', 'vuex_phone', 'vuex_skin',
-	'vuex_theme', 'vuex_active_setting', 'vuex_isCMCC', 'vuex_gzh_userOpenid', 'vuex_redirect_url'
+	'vuex_theme', 'vuex_active_setting', 'vuex_isCMCC', 'vuex_gzh_userOpenid',
 ];
 
 // 保存变量到本地存储中
@@ -47,7 +47,6 @@ const store = new Vuex.Store({
 		vuex_active_setting: lifeData.vuex_active_setting ? lifeData.vuex_active_setting : {},
 		vuex_isCMCC: lifeData.vuex_isCMCC ? lifeData.vuex_isCMCC : false,
 		vuex_gzh_userOpenid: lifeData.vuex_gzh_userOpenid ? lifeData.vuex_gzh_userOpenid : null,
-		vuex_redirect_url: lifeData.vuex_redirect_url ? lifeData.vuex_redirect_url : null
 	},
 
 	mutations: {