hmp 4 лет назад
Родитель
Сommit
b324fc377e
1 измененных файлов с 49 добавлено и 15 удалено
  1. 49 15
      pages/activityList/goods/detail.vue

+ 49 - 15
pages/activityList/goods/detail.vue

@@ -104,6 +104,25 @@
 					style="width: 180upx;height: 80upx;z-index: 99;">取消</button>
 			</view>
 		</view>
+		
+		<u-popup v-model="payShow" mode="center" width="500rpx" height="320rpx" border-radius="30">
+			<view class="text-center text-lg padding">请确定支付是否已完成</view>
+			<u-line color="#c2c2c2"></u-line>
+			<view class="text-red text-center text-lg padding" @click="checkPayInterval">已完成支付</view>
+			<u-line color="#c2c2c2"></u-line>
+			<view class="text-gray text-center text-lg padding" @click="confirm">支付遇到问题,重新支付</view>
+		</u-popup>
+		
+		<u-popup v-model="errorShow" mode="center" width="500rpx" height="600rpx" border-radius="30">
+			<view class="bg-img text-center" style="background-image: url('https://upload-file-data.obs.cn-south-1.myhuaweicloud.com/e914f556be414767aca011a30961560a-dialogBgImg.png');height: 600rpx;">
+				<view style="height: 120upx;"></view>
+				<u-avatar :src="detail.image" size="160"></u-avatar>
+				<view class="text-center margin-top text-lg text-bold">支付失败</view>
+				<view class="padding">
+					<u-button class="custom-style" shape="circle" @click="errorShow = false">确定</u-button>
+				</view>
+			</view>
+		</u-popup>
 	</view>
 </template>
 
@@ -147,6 +166,11 @@
 				cashPositive: true,
 				otherStep: 10,
 				otherPositive: true,
+				
+				orderId:"",
+				payShow:false,
+				errorShow:false,
+				
 			}
 		},
 		onLoad(options) {
@@ -264,6 +288,9 @@
 				this.changeCash.pointsCash = this.numberMul(item.value, this.proportion.pointsProportion)
 			},
 			async confirm() {
+				this.payShow = false;
+				let _this = this;
+				
 				if (this.$u.test.isEmpty(this.address) || this.$u.test.isEmpty(this.address.id)) {
 					this.$u.toast('请选择地址')
 					return;
@@ -280,7 +307,7 @@
 				}
 				
 				if (!this.$u.test.isEmpty(parseFloat(this.data.cashValue))) {
-					let orderId = new Date().getTime()
+					this.orderId = this.$u.guid(16);
 					//去支付,支付成功后
 					let orderInfo = (await this.$u.api.yeePay.initOrder({
 						"appId": appId,
@@ -299,16 +326,17 @@
 						"redirectUrl": "",
 						"scene": "OFFLINE",
 						"uniqueOrderNo": "",
-						"userId": uni.getStorageSync("openid"),
+						"userId": uni.getStorageSync("userId"),
 						"userIp": "127.0.0.1"
 					}));
 					this.$u.api.boost.billRecord({
-						orderId: orderId,
+						orderId: this.orderId,
 						payPath: encodeURIComponent(window.location.href),
 						userId: this.userId,
-						openId: uni.getStorageSync("openid"),
 						activityId: this.activityId,
 						price: this.data.cashValue,
+						pointsValue:this.data.pointsValue,
+						hotValue:this.data.hotValue,
 						presentId: '',
 						presentCount: '',
 						relationId: this.id,
@@ -317,7 +345,7 @@
 					}).then(res => {
 						if (typeof orderInfo.prePayTn != 'undefined') {
 							//调起支付
-							this.toPay(JSON.parse(orderInfo.prePayTn));
+							this.toPay(orderInfo.prePayTn);
 						}
 					})
 				} else {
@@ -326,16 +354,19 @@
 
 			},
 			toPay(info) {
-				WeixinJSBridge.invoke('getBrandWCPayRequest', info, (res) => {
-					if (res.err_msg == "get_brand_wcpay_request:ok") {
-						this.doConfirm();
-						this.getUsableHotAndPoints()
-					} else if (res.err_msg == "get_brand_wcpay_request:cancel") {
-						console.log("取消支付");
-					} else {
-						console.log(res.err_msg);
-					}
-				});
+				location.href = `alipays://platformapi/startapp?saId=10000007&clientVersion=3.7.0.0718&qrcode=${info}`;
+				setTimeout(() => {
+					this.payShow = true;
+				}, 4000)
+			},
+			async checkPayInterval() {
+				this.payShow = false;
+				let res = await this.$u.api.boost.billRecordDetail({orderId: this.orderId})
+				if (res && res.payStatus == 1) {
+					this.exchangeSuccess()
+				} else {
+					this.errorShow = true;
+				}
 			},
 			async doConfirm() {
 				this.data.pointsGoodsId = this.id
@@ -349,6 +380,9 @@
 					})
 					return;
 				}
+				this.exchangeSuccess()
+			},
+			exchangeSuccess(){
 				uni.showModal({
 					title: "提示",
 					content: "兑换成功,可到个人中心查看!",