浏览代码

合利宝微信支付

zhengjinyi 3 年之前
父节点
当前提交
e51ef9ed5b
共有 3 个文件被更改,包括 45 次插入13 次删除
  1. 5 1
      pages/user/order/order-payhlb.vue
  2. 30 9
      pages/user/order/order-success.vue
  3. 10 3
      utils/mixins/wechatPay.js

+ 5 - 1
pages/user/order/order-payhlb.vue

@@ -89,10 +89,12 @@
 			return{
 				orderId:0,
 				shopOrderId:0,
+				shopOrderInfo:0,
 				payType:'',
 				payWay:'',
 				isRepuest:false,
 				realPay:0,//应付金额
+				payableAmount:0,// 应付总额
 				receiptAmount:0,// 已付金额
 				obligation:0,//待付金额
 				balanceAmount:0,
@@ -171,10 +173,12 @@
 				this.PayService.PayOrderCheckoutShoporders({shopOrderId:this.shopOrderId}).then(response =>{
 					let data = response.data
 					this.discernReceipt = data.discernReceipt 	// 支付记录
+					this.shopOrderInfo = data.shopOrder  	// 子订单
 					this.obligation = data.shopOrder.obligation  	// 待付金额
+					this.orderId = data.shopOrder.orderId  	// 主订单Id
 					this.receiptAmount = data.shopOrder.receiptAmount  	// 已付金额
 					this.payableAmount = data.shopOrder.realPay // 应付金额
-					this.payAmount = this.toFixedFn(this.payableAmount)			// 自定义金额
+					this.payAmount = this.toFixedFn(this.obligation)		// 自定义金额
 					this.balanceAmount = this.obligation - this.payAmount	// 计算剩余支付金额
 					this.isRepuest = true
 				}).catch(error =>{

+ 30 - 9
pages/user/order/order-success.vue

@@ -15,8 +15,8 @@
 				<view class="amount-money">¥{{ amuntMoney | NumFormat }}</view>
 			</view>
 			<view class="container-button">
-				<view class="btn btn-home" v-if="payStatus" @click="this.$api.switchTabTo('/pages/tabBar/home/index')">回到首页</view>
-				<view class="btn btn-home" v-else @click="toAgainPay">重新支付</view>
+				<view class="btn btn-home" v-if="payBtnStatus" @click="toAgainPay">继续下一笔支付</view>
+				<view class="btn btn-home" v-else @click="this.$api.switchTabTo('/pages/tabBar/home/index')">回到首页</view>
 				<view class="btn btn-open" @click="details">查看订单</view>
 			</view>
 		</view>
@@ -37,11 +37,13 @@
 					textLeft:this.$store.state.isIphone
 				},
 				payType:'',
-				payStatus:false,
+				payStatus:true,
+				payBtnStatus:false,
 				amuntMoney:0,
-				successText:'本次支付失败',
+				successText:'订单支付失败',
 				isIphoneX:this.$store.state.isIphoneX,
 				CustomBar:this.CustomBar,// 顶部导航栏高度
+				mapStateArr:[11,12,13,21,22,23,111]
 				
 			}
 		},
@@ -59,22 +61,41 @@
 			this.initData(option)
 		},
 		methods:{
+			initOrderInfo() {
+			    this.orderInfo = uni.getStorageSync('orderInfo')
+			    uni.removeStorageSync('orderInfo')
+			},
 			initData(option){
-				const data = JSON.parse(option.data);
+				const data = JSON.parse(option.data)
+				console.log('==========>',data)
 				this.orderId = data.data.orderId
 				this.payType = data.data.type
 				this.amuntMoney = data.data.payAmount
 				if(this.payType == 'success'){
 					this.payStatus = true
-					this.successText = '本次支付成功'
+					this.successText = '订单支付成功'
 				}else{
 					this.payStatus = false
-					this.successText = '本次支付失败'
+					this.successText = '订单支付失败'
 				}
-				console.log(this.orderId)
+				console.log('主订单Id======>',this.orderId)
+				this.PayOrderCheckoutCounter(this.orderId)
+			},
+			PayOrderCheckoutCounter(orderId){//初始化支付信息
+				this.PayService.PayOrderCheckoutCounter({ orderId : orderId }).then(response =>{
+					this.isRepuest = true
+					const status = response.data.order.status //主订单状态
+					this.mapStateArr.forEach(value => {
+						if(status === value){
+							this.payBtnStatus = true
+						}
+					})
+				}).catch(error =>{
+					this.$util.msg(error.msg,2000)
+				})
 			},
 			toAgainPay(){
-				this.$api.navigateBack(2)
+				this.$api.navigateTo(`/pages/user/order/order-pay-list?orderId=${this.orderId}`)
 			},
 			details(){
 				this.$api.redirectTo('/pages/user/order/order-details?type=share&orderId='+this.orderId)

+ 10 - 3
utils/mixins/wechatPay.js

@@ -34,11 +34,18 @@ const wechatPay = {
 			    const payment = JSON.parse(response.data.rt10_payInfo)
                 console.log('payment',payment)
 			    const payFlag = await wxRequestPayment(payment)
-			    console.log('payFlag',this.payFlag)
+			    console.log('payFlag',payFlag)
+                uni.setStorageSync('shopOrderInfo', this.shopOrderInfo)
 			    if (payFlag) {
-			        // 微信支付成功回调
-			        uni.reLaunch({url: '/pages/tabBar/user/user'})
+			       // 微信支付成功回调
+			       let linkData =  {
+                        payAmount:this.payAmount,
+                        orderId:this.shopOrderInfo.orderId,
+                        type:'success'
+                    }
+			        uni.redirectTo({ url: `/pages/user/order/order-success?data=${JSON.stringify({ data: linkData })}`})
 			    } else {
+                    // 微信支付失败
 			        this.$util.msg('支付失败~',2000)
 			    }
 			 } catch (error) {