lilei 7 months ago
parent
commit
f5afa472aa
1 changed files with 28 additions and 25 deletions
  1. 28 25
      pagesB/shopiing/productDetail.vue

+ 28 - 25
pagesB/shopiing/productDetail.vue

@@ -557,19 +557,21 @@
 					if(res.status == 200){
 					if(res.status == 200){
 						res.data.detailList = []
 						res.data.detailList = []
 						this.$store.state.vuex_tempOrderData = res.data
 						this.$store.state.vuex_tempOrderData = res.data
-						// 打开确认付款弹框,这里判断是否开通支付,如果开通
+						// 这里判断是否开通支付,如果开通打开确认付款弹框
 						if(this.hasPay){
 						if(this.hasPay){
 							purchasePay({
 							purchasePay({
 								bizSn:res.data.purchaseSn,
 								bizSn:res.data.purchaseSn,
 								bizNo:res.data.purchaseNo,
 								bizNo:res.data.purchaseNo,
 								bizType:'PURCHASE',
 								bizType:'PURCHASE',
+								payUserOpenId: this.$store.state.vuex_openid || uni.getStorageSync('openid')
 							}).then(res=>{
 							}).then(res=>{
 								this.showPay = true
 								this.showPay = true
 								this.payData = res.data
 								this.payData = res.data
+								this.$store.state.vuex_tempOrderData.billStatus = 'WAIT_PAY'
 								uni.hideLoading()
 								uni.hideLoading()
 							})
 							})
 						}else{
 						}else{
-							// 创建成功,跳转到订单详情页
+							// 未开通支付,创建成功,跳转到订单详情页
 							this.showPopu = false
 							this.showPopu = false
 							this.submitOk = true
 							this.submitOk = true
 							uni.hideLoading()
 							uni.hideLoading()
@@ -587,8 +589,8 @@
 			beforeClosePopu(){
 			beforeClosePopu(){
 				console.log(this.showPay,this.submitOk,this.cacelOk)
 				console.log(this.showPay,this.submitOk,this.cacelOk)
 				// 正在支付
 				// 正在支付
-				if(this.cacelOk&&!this.submitOk){
-					this.cacelOk = false
+				if(this.showPay&&!this.submitOk&&!this.cacelOk){
+					this.showPay = false
 					this.cancelPay()
 					this.cancelPay()
 				}
 				}
 			},
 			},
@@ -634,33 +636,34 @@
 			// 确认付款
 			// 确认付款
 			confirmPay(){
 			confirmPay(){
 				const _this = this
 				const _this = this
-				// uni.showLoading({
-				// 	title: '正在支付...',
-				// 	mask: true
-				// })
 				// 确认付款
 				// 确认付款
 				const data = _this.payData
 				const data = _this.payData
-				uni.requestPayment({
-					provider: 'wxpay',
-					timeStamp: data.timeStamp,
-					nonceStr: data.nonceStr,
-					package: data.packageValue,
-					signType: data.signType,
-					paySign: data.paySign,
-					success: (res) =>{
-						console.log('success:', res);
-						_this.payComplete(1,data)
-					},
-					fail: (err)=> {
-						console.log('fail:',err);
-						_this.payComplete(err.errMsg.indexOf("cancel")>=0 ? 2 : 0,data)
-					}
-				});
+				if(data){
+					uni.requestPayment({
+						provider: 'wxpay',
+						timeStamp: data.timeStamp,
+						nonceStr: data.nonceStr,
+						package: data.packageValue,
+						signType: data.signType,
+						paySign: data.paySign,
+						success: (res) =>{
+							_this.payComplete(1,data)
+							_this.$store.state.vuex_tempOrderData.billStatus = 'WAIT_AUDIT'
+						},
+						fail: (err)=> {
+							console.log('fail:',err);
+							_this.payComplete(err.errMsg.indexOf("cancel")>=0 ? 2 : 0,data)
+							_this.$store.state.vuex_tempOrderData.billStatus = 'WAIT_PAY'
+						}
+					});
+				}else{
+					_this.payComplete(0,data)
+				}
 			},
 			},
 			payComplete(type,data){
 			payComplete(type,data){
 				uni.showToast({
 				uni.showToast({
 					mask: true,
 					mask: true,
-					title: data==1 ? '支付成功' : (type==2?'支付取消':'支付失败'),
+					title: type==1 ? '支付成功' : (type==2?'支付取消':'支付失败'),
 					icon: 'none'
 					icon: 'none'
 				})
 				})
 				this.showPopu = false
 				this.showPopu = false