Selaa lähdekoodia

完善活动作品现金投票功能

lyb 4 vuotta sitten
vanhempi
commit
5290fac44a
5 muutettua tiedostoa jossa 132 lisäystä ja 1 poistoa
  1. 3 0
      assets/http/api.js
  2. 41 0
      components/alert/payPopup.vue
  3. 9 0
      pages.json
  4. 17 1
      pages/activity/activityDetail.vue
  5. 62 0
      pages/webview/payOrder.vue

+ 3 - 0
assets/http/api.js

@@ -235,6 +235,9 @@ const order = {
 			'Content-Type': 'application/x-www-form-urlencoded'
 		}
 	}),
+	orderDetail: p => http.get('/sing_yeepay/yeepayorder/detail', {
+		params: p
+	}),
 }
 
 /**

+ 41 - 0
components/alert/payPopup.vue

@@ -0,0 +1,41 @@
+<template>
+	<view>
+		<u-popup v-model="show" mode="center" width="70%" border-radius="10" :mask-close-able="false">
+			<view class="pay-popup">
+				<view style="font-size: 34rpx; padding: 50rpx 0; text-align: center;">请确认微信支付是否已完成</view>
+				<button>已完成支付</button>
+				<button>支付遇到问题,重新支付</button>
+			</view>
+		</u-popup>
+	</view>
+</template>
+
+<script>
+	export default {
+		name:"voteSuccess",
+		data() {
+			return {
+				show: false,
+			};
+		},
+		created() {},
+
+		methods: {}
+	}
+</script>
+
+<style lang="scss" scoped>
+button {
+	border-top: 1rpx solid #ebebeb;
+	width: 100%;
+	font-size: 32rpx;
+	background-color: #FFFFFF;
+	color: #66656a;
+	&:nth-child(2){
+		color: var(--bgColor);
+	}
+	&::after {
+		border: none;
+	}
+}
+</style>

+ 9 - 0
pages.json

@@ -253,6 +253,15 @@
             }
             
         }
+        ,{
+            "path" : "pages/webview/payOrder",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "",
+                "enablePullDownRefresh": false
+            }
+            
+        }
     ],
 	"tabBar": {
 		"list": [{

+ 17 - 1
pages/activity/activityDetail.vue

@@ -72,6 +72,7 @@
 		<sms-alert ref="smsAlert" @exchange="cmccVote"></sms-alert>
 		<vote-success ref="voteSuccess" @support="skipShop"></vote-success>
 		<home-btn></home-btn>
+		<payPopup></payPopup>
 	</view>
 </template>
 
@@ -82,6 +83,7 @@
 	import votePopup from '@/components/alert/votePopup.vue'
 	import poster from "@/components/poster/poster.vue"
 	import smsAlert from "@/components/alert/smsAlert.vue"
+	import payPopup from "@/components/alert/payPopup.vue"
 	export default {
 		components: {
 			voteSuccess,
@@ -90,6 +92,7 @@
 			timelinePopup,
 			votePopup,
 			poster,
+			payPopup
 		},
 		async onLoad(props) {
 			// #ifdef MP-WEIXIN
@@ -124,6 +127,14 @@
 
 			this.getActivitySetting();
 		},
+		onShow() {
+			let that = this
+			uni.$on('updateData',function(payStatus){
+				that.payStatus = payStatus;
+				that.voteSuccess();
+				console.log('监听到事件来自 updateData ,携带参数为:' + payStatus);
+			})
+		},
 		computed: {
 			content() {
 				return decodeURIComponent(this.activity.content)
@@ -185,6 +196,8 @@
 				},
 				//活动设置
 				activitySetting: {},
+				//支付状态
+				payStatus: ''
 			}
 		},
 		onShareAppMessage(res) {
@@ -397,7 +410,10 @@
 				}
 				let res = await this.$api.order.cashExchange(params)
 				if (res.data.success) {
-					console.log("res", res);
+					this.payStatus = ''; //创建新订单,清空订单状态
+					uni.navigateTo({
+						url: `/pages/webview/payOrder?url=${res.data.data.qrCodeUrl}&orderId=${res.data.data.id}`
+					})
 				} else {
 					this.$refs.toast.error(res.data.msg)
 				}

+ 62 - 0
pages/webview/payOrder.vue

@@ -0,0 +1,62 @@
+<template>
+	<view class="">
+		<web-view :src="src"></web-view>
+	</view>
+</template>
+
+<script>
+	export default {
+		name: '',
+		data() {
+			return {
+				src: '',
+				orderId: '',
+				interval: ''
+			};
+		},
+		onLoad(options) {
+			this.src = options.url;
+			this.orderId = options.orderId;
+			if (options.title) {
+				uni.setNavigationBarTitle({
+					title:options.title
+				})
+			}
+		},
+		onShow(){
+			let that = this;
+			//轮询订单接口状态
+			that.interval = setInterval(function() {
+			  that.queryOrder();
+			}, 1000)
+		},
+		onHide: function() {
+		    clearInterval(this.interval)
+		},
+		onUnload: function() {
+		    clearInterval(this.interval)
+		},
+		methods: {
+			async queryOrder(){
+				let params = {
+					id: this.orderId
+				}
+				let res = await this.$api.order.orderDetail(params)
+				if(res.data.success){
+					if(res.data.data.payStatus === '付款成功'){
+						uni.$emit('updateData', res.data.data.payStatus)
+						uni.navigateBack({
+							delta: 1
+						})
+						return;
+					}
+				}
+			}
+		}
+	};
+</script>
+
+<style lang="scss" scoped>
+
+</style>
+