lilei 7 months ago
parent
commit
5476012bc4

+ 24 - 7
pagesB/components/payModal.vue

@@ -143,19 +143,36 @@
 			// 确认付款
 			confirmPay(){
 				const _this = this
-				// uni.showLoading({
-				// 	title: '正在支付...',
-				// 	mask: true
-				// })
 				// 确认付款
 				const data = _this.payData
+				console.log(data)
+				if(data){
+					uni.requestPayment({
+						provider: 'wxpay',
+						timeStamp: data.timeStamp,
+						nonceStr: data.nonceStr,
+						package: data.package,
+						signType: data.signType,
+						paySign: data.paySign,
+						success: (res) =>{
+							_this.payComplete(1,true)
+						},
+						fail: (err)=> {
+							_this.payComplete(err.errMsg.indexOf("cancel")>=0 ? 2 : 0,false)
+						}
+					});
+				}else{
+					_this.payComplete(0,false)
+				}
+			},
+			payComplete(type,data){
 				uni.showToast({
 					mask: true,
-					title: data ? '支付成功' : '支付失败',
+					title: type==1 ? '支付成功' : (type==2?'支付取消':'支付失败'),
 					icon: 'none'
 				})
-				_this.showModal = false
-				_this.submitOk = data
+				this.showModal = false
+				this.submitOk = data
 			},
 		}
 	}

+ 17 - 4
pagesB/procureOrder/creatOrder.vue

@@ -214,7 +214,7 @@
 								productSn:item.productSn,
 								productCode: item.productCode,
 								qty: item.qty,
-								price:item.price,
+								price:0.02,
 								promoSn: item.promoSn
 							}
 						})
@@ -264,6 +264,10 @@
 						// 删除已提交产品
 						uni.$emit('removeCatGood',cartSn,true,false)
 						res.data.detailList = []
+						// 倒计时
+						let now = new Date(res.data.purchaseDate)
+						now.setMilliseconds(now.getMilliseconds() + 30 * 60 * 1000)
+						res.data.timestamp = now.getTime()
 						this.$store.state.vuex_tempOrderData = res.data
 						// 这里判断是否开通支付,如果开通打开确认付款弹框
 						if(this.hasPay){
@@ -273,11 +277,12 @@
 								bizType:'PURCHASE',
 							}).then(res=>{
 								this.showPopu = true
-								this.payData = res.data
+								this.payData = res.data?res.data.payRequestRest:null
+								this.$store.state.vuex_tempOrderData.billStatus = 'WAIT_PAY'
 							})
 						}else{
 							// 创建成功,跳转到订单详情页
-							this.toOrderDetial()
+							this.toOrderDetial(null,true)
 						}
 					}else{
 						uni.showToast({
@@ -288,8 +293,16 @@
 				})
 			},
 			// 订单详情页
-			toOrderDetial(){
+			toOrderDetial(data, result){
+				console.log(result)
+				// 创建成功,跳转到订单详情页
 				this.showPopu = false
+				// 取消支付,或失败
+				if(!result){
+					this.$store.state.vuex_tempOrderData.billStatus = 'WAIT_PAY'
+				}else{
+					this.$store.state.vuex_tempOrderData.billStatus = 'WAIT_AUDIT'
+				}
 				uni.navigateTo({
 					url: "/pagesB/procureOrder/orderDetail"
 				})

+ 19 - 6
pagesB/procureOrder/orderDetail.vue

@@ -1,6 +1,6 @@
 <template>
 	<view class="orderDetail-digitalShel flex flex_column">
-		<view class="contHead" :style="{background:state!= 'error'&&state!= 'AUDIT_REJECT'&&state!='CANCEL' ? '#066cff':'#e61100',color:'#fff'}">
+		<view class="contHead" :style="{background:state!= 'error'&&state!= 'AUDIT_REJECT'&&state!='CANCEL'&&state!='WAIT_PAY' ? '#066cff':'#e61100',color:'#fff'}">
 			<view class="statusH">
 				<view class="flex flex_column align_center">
 					<view class="status-row">
@@ -9,6 +9,11 @@
 						<text>{{statusText}}</text>
 					</view>
 					<view class="messageText" v-if="statusMessage"><text>{{statusMessage}}</text></view>
+					<view v-if="info.billStatus=='WAIT_PAY'" class="messageText">
+						请尽快支付,
+						<u-count-down separator="zh" :separator-size="24" bg-color="none" color="#ffff7f" separator-color="#ffff7f" :timestamp="info.timestamp" :show-days="false" :show-hours="false"></u-count-down>
+						后订单将自动取消。
+					</view>
 				</view>
 			</view>
 		</view>
@@ -167,13 +172,13 @@
 			<view :style="{height:safeAreaBottom+'px'}"></view>
 		</view>
 		<!-- 付款弹框 -->
-		<payModal :showPopu="showPopu" :payInfo="payInfo" @close="showPopu=false" @payComplete="payComplete"></payModal> 
+		<payModal :showPopu="showPopu" :payInfo="payInfo" :payData="payData" @close="showPopu=false" @payComplete="payComplete"></payModal> 
 	</view>
 </template>
 
 <script>
 	import payModal from '../components/payModal.vue'
-	import { purchaseQueryDetailPage,purchaseCancel,purchaseReceive } from '@/api/purchase.js'
+	import { purchaseQueryDetailPage,purchaseCancel,purchaseReceive,purchasePay } from '@/api/purchase.js'
 	export default {
 	   name: 'procureDetailOrder',
 	   components:{
@@ -194,6 +199,7 @@
 			   purchaseSn: null,
 			   showPopu: false,
 			   safeAreaBottom: 0, // 底部安全区域高度
+			   payData: null
 		   }
 	   },
 	   onLoad(option) { 
@@ -215,7 +221,7 @@
 			  // 更改标题栏背景色
 			  uni.setNavigationBarColor({
 			  	frontColor: '#ffffff',
-			  	backgroundColor: this.state!= 'error'&&this.state!= 'AUDIT_REJECT'&&this.state!= 'CANCEL' ? '#066cff':'#e61100',
+			  	backgroundColor: this.state!= 'error'&&this.state!= 'AUDIT_REJECT'&&this.state!= 'CANCEL'&&this.state!= 'WAIT_PAY' ? '#066cff':'#e61100',
 			  })
 		  }
 	   },
@@ -293,13 +299,20 @@
 		 },
 		 // 立即支付
 		 payOrder(item){
-		 	this.showPopu = true
+			purchasePay({
+				bizSn:item.purchaseSn,
+				bizNo:item.purchaseNo,
+				bizType:'PURCHASE',
+			}).then(res=>{
+				this.showPopu = true
+				this.payData = res.data?res.data.payRequestRest:null
+			})
 		 },
 		 // 付款成功,isOk: false 取消支付或支付失败,true 支付完成
 		 payComplete(item,isOk){
 		 	this.showPopu = false
 		 	if(isOk){
-		 		uni.$emit('refreshPurcaOrder',item,'payOk')
+		 		uni.$emit('refreshPurcaOrder',item,'WAIT_AUDIT')
 				uni.navigateBack()
 		 	}
 		 },

+ 15 - 4
pagesB/procureOrder/orderList.vue

@@ -20,7 +20,9 @@
 										<span v-if="item.billStatus == 'WAIT_AUDIT'&&item.payOnlineFlag==0">待审核</span>
 										<view v-if="item.billStatus == 'WAIT_PAY'" class="waitPay">
 											<text>待付款</text>
-											<u-count-down :timestamp="item.timestamp" :show-days="false" :show-hours="false"></u-count-down>
+											<view style="padding:0 5px;">
+												<u-count-down separator="zh" :separator-size="24" bg-color="none" :timestamp="item.timestamp" :show-days="false" :show-hours="false"></u-count-down>
+											</view>
 										</view>
 										<span v-if="item.billStatus == 'AUDIT_REJECT'">审核不通过</span>
 										<span v-if="item.billStatus == 'WAIT_OUT_WAREHOUSE' || item.billStatus == 'WAIT_RECEIVE'">待收货</span>
@@ -72,12 +74,12 @@
 				</swiper>
 		</view>
 		<!-- 付款弹框 -->
-		<payModal :showPopu="showPopu" :payInfo="payInfo" @close="showPopu=false" @payComplete="payComplete"></payModal> 
+		<payModal :showPopu="showPopu" :payInfo="payInfo" :payData="payData" @close="showPopu=false" @payComplete="payComplete"></payModal> 
 	</view>
 </template>
 
 <script>
-	import { purchaseQueryPage,purchaseCancel,purchaseReceive } from '@/api/purchase.js'
+	import { purchaseQueryPage,purchaseCancel,purchaseReceive,purchasePay } from '@/api/purchase.js'
 	import payModal from '../components/payModal.vue'
 	export default {
 		components:{
@@ -127,6 +129,7 @@
 				pageSize: 10,
 				list: [],
 				total: 0,
+				payData: null
 			}
 		},
 		computed: {
@@ -233,13 +236,21 @@
 			// 立即支付
 			payOrder(item){
 				this.$store.state.vuex_tempOrderData = item
-				this.showPopu = true
+				purchasePay({
+					bizSn:item.purchaseSn,
+					bizNo:item.purchaseNo,
+					bizType:'PURCHASE',
+				}).then(res=>{
+					this.showPopu = true
+					this.payData = res.data?res.data.payRequestRest:null
+				})
 			},
 			// 付款成功,isOk: false 取消支付或支付失败,true 支付完成
 			payComplete(item,isOk){
 				this.showPopu = false
 				if(isOk){
 					item.payOnlineFlag = 0
+					item.billStatus = 'WAIT_AUDIT'
 					this.viewRow(item)
 					setTimeout(()=>{
 						this.resetList(item,'WAIT_AUDIT')

+ 10 - 5
pagesB/shopiing/productDetail.vue

@@ -556,6 +556,10 @@
 				}).then(res => {
 					if(res.status == 200){
 						res.data.detailList = []
+						// 倒计时
+						let now = new Date(res.data.purchaseDate)
+						now.setMilliseconds(now.getMilliseconds() + 30 * 60 * 1000)
+						res.data.timestamp = now.getTime()
 						this.$store.state.vuex_tempOrderData = res.data
 						// 这里判断是否开通支付,如果开通打开确认付款弹框
 						if(this.hasPay){
@@ -566,7 +570,7 @@
 								payUserOpenId: this.$store.state.vuex_openid || uni.getStorageSync('openid')
 							}).then(res=>{
 								this.showPay = true
-								this.payData = res.data
+								this.payData = res.data?res.data.payRequestRest:null
 								this.$store.state.vuex_tempOrderData.billStatus = 'WAIT_PAY'
 								uni.hideLoading()
 							})
@@ -638,26 +642,27 @@
 				const _this = this
 				// 确认付款
 				const data = _this.payData
+				console.log(data)
 				if(data){
 					uni.requestPayment({
 						provider: 'wxpay',
 						timeStamp: data.timeStamp,
 						nonceStr: data.nonceStr,
-						package: data.packageValue,
+						package: data.package,
 						signType: data.signType,
 						paySign: data.paySign,
 						success: (res) =>{
-							_this.payComplete(1,data)
+							_this.payComplete(1,true)
 							_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.payComplete(err.errMsg.indexOf("cancel")>=0 ? 2 : 0,false)
 							_this.$store.state.vuex_tempOrderData.billStatus = 'WAIT_PAY'
 						}
 					});
 				}else{
-					_this.payComplete(0,data)
+					_this.payComplete(0,false)
 				}
 			},
 			payComplete(type,data){