gcz 1 anno fa
parent
commit
ed312cdea3
1 ha cambiato i file con 36 aggiunte e 8 eliminazioni
  1. 36 8
      center/pay.vue

+ 36 - 8
center/pay.vue

@@ -11,14 +11,14 @@
 		<view class="page-wrap">
 			<view class="pay-way page-wrap">
 				  <u-radio-group  v-model="params.paymentMode" placement="column" @change="groupChange">
-				   <view class="pay-way-item u-flex u-row-between">
+				   <view class="pay-way-item u-flex u-row-between" @click="selectPayment('wx')">
 				    	<view class="left u-flex">
 				    		<image class="icon" :src="staticUrl+'/img/payway-wx.png'" mode="aspectFill"></image>
 				    		<view class="name">微信支付</view>
 				    	</view>
 				    	<u-radio name="wx" activeColor="#1677FF" size="36rpx"></u-radio>
 				    </view>
-					<view :class="{disabled:balanceInfo.balance<params.payAmount}" class="pay-way-item u-flex u-row-between">
+					<view :class="{disabled:balanceInfo.balance<params.payAmount}" @click="selectPayment('yue')" class="pay-way-item u-flex u-row-between">
 						<view class="left u-flex">
 							<image class="icon" :src="staticUrl+'/img/pyway-yue.png'" mode="aspectFill"></image>
 							<view class="name">账户余额</view>
@@ -26,7 +26,7 @@
 						</view>
 						<u-radio name="yue" :disabled="balanceInfo.balance<params.payAmount" activeColor="#1677FF" size="36rpx"></u-radio>
 					</view>
-					<view :class="{disabled:balanceInfo.grantSurplus<params.payAmount}" class="pay-way-item u-flex u-row-between">
+					<view :class="{disabled:balanceInfo.grantSurplus<params.payAmount}" @click="selectPayment('shouxin')" class="pay-way-item u-flex u-row-between">
 						<view class="left u-flex">
 							<image class="icon" :src="staticUrl+'/img/pyway-shouxin.png'" mode="aspectFill"></image>
 							<view class="name">授信余额</view>
@@ -36,7 +36,7 @@
 					</view>
 				  </u-radio-group>
 			</view>
-			<view class="full-btn" v-if="params.paymentMode" @click="payRoute">去支付<text>¥ {{params.payAmount}}</text></view>
+			<view class="full-btn" v-if="params.paymentMode&&cansubmit" @click="payRoute">去支付<text>¥ {{params.payAmount}}</text></view>
 			<view class="full-btn gray" v-else>去支付<text>¥ {{params.payAmount}}</text></view>
 			<u-popup :show="checkPassShow" @close="checkPassClose" mode="center">
 				<view class="check-pass">
@@ -98,10 +98,23 @@
 					grantSurplus:0,//剩余额度
 					isSetPayPassword:0,//是否设置支付密码 0-否 1-是
 				},
-				
+				cansubmit:true,
+				needPayQuery:0,
 			}
 		},
-		onShow() {	
+		onShow(page) {	
+			// console.log('onShow page',page);
+			let allPages = getCurrentPages(); //获取当前页面栈的实例;
+			// console.log(allPages);
+			let lastPages = allPages.length - 1; // 获得倒数第二个元素的索引;
+			console.log(lastPages);
+			let option = allPages[lastPages].options; // 获得上个页面传递的参数;
+			console.log(option);
+			if(option.needPayQuery){
+				this.cansubmit = false;
+				this.payQuery();
+			}
+			
 			this.getBalanceInfo();
 		},
 		onLoad(page) {
@@ -111,6 +124,11 @@
 			this.params.openid = this.vuex_wechatOpenid;
 			this.params.payAmount = page.payAmount;
 			this.params.paymentMode = page.paymentMode;
+			this.needPayQuery = page.needPayQuery;
+			if(page.needPayQuery){
+				this.cansubmit = false;
+				this.payQuery();
+			}
 		},
 		methods: {
 			leftClick(){
@@ -134,9 +152,10 @@
 				})
 			},
 			checkPassClose(){
-				this.checkPassShow = false
+				this.checkPassShow = false;
 			},
 			payRoute(){
+				this.cansubmit = false;
 				if(this.params.paymentMode!='wx'){
 					this.checkExistPayPassword();
 				}else{
@@ -204,6 +223,10 @@
 							id: this.params.orderId
 						});
 					}else {
+						window.location.href = res.data.payInfo;
+						
+						return
+						// 以下未微信原生支付
 						this.payResult = res.data.payInfo;
 						this.payResult.package = res.data.payInfo.packageValue;
 						
@@ -362,10 +385,12 @@
 							}else if(payStatus===0||payStatus===2){
 								this.payQuery()
 							}else if(payStatus===3){
+								that.cansubmit = true;
 								uni.toast('支付失败')
 							}
 							clearInterval(timer);
 						}).catch(err=>{
+							that.cansubmit = true;
 							console.log('payQuery',err);
 						}).finally(()=>{
 							uni.hideLoading()
@@ -375,7 +400,10 @@
 			},
 			groupChange(e){
 				console.log('groupChange',e);
-			}
+			},
+			selectPayment(paymentType) {
+			    this.params.paymentMode = paymentType;
+			},
 			
 		}
 	}