| 
					
				 | 
			
			
				@@ -29,7 +29,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 </template> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 <script> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	import {payment} from '@/api/payment' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	import {payment,checkpayment} from '@/api/payment' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	export default { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		data() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			return { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -38,6 +38,9 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				desc:"", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				money:null, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				wxPay: true, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				checkTimer: null, // 轮询定时器 ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				maxRetryCount: 10, // 最大轮询次数(可选) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				retryCount: 0      // 当前轮询次数(可选) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		onLoad: function(options) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -53,6 +56,10 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 //   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			this.companyId=options.companyId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 	this.companyUserId=options.companyUserId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if (this.checkTimer) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			    clearInterval(this.checkTimer); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			    this.checkTimer = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		onShareAppMessage(res) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			return { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -98,7 +105,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				payment(data).then( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					res => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						if(res.code==200){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							 console.log(res); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							 console.log(1111,res); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 							 var result=res.result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				               wx.navigateToMiniProgram({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 appId: 'wx1b63de1096c46cde', // 收银台小程序 AppId 固定值 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -116,15 +123,35 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                   uni.showLoading({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     title:"查询支付结果中..." 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                   }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				  setTimeout(()=>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					 uni.navigateTo({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					 	url: 'pages_user/user/storeOrder' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					 }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				  },4000) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				 // 启动定时器并保存 ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				   that.checkTimer = setInterval(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							 const data = { orderId: result.payCode }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							 checkpayment(data).then(res => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							   if (res.code == 200) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								   console.log(res) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								 if (res.status == 3) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								   // 跳转前清除定时器 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								   clearInterval(that.checkTimer); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								   uni.navigateTo({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+									  url: './success' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								   }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								 }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+									 setTimeout(()=>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+										 clearInterval(that.checkTimer); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+										 	uni.showToast({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+										 		icon:'none', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+										 		title: "用户未支付", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+										 	}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+									 },500) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				   }, 4000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                   console.log(res) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // 接口调用成功的回调函数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 fail(res) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					if (that.checkTimer) clearInterval(that.checkTimer); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // 接口调用失败的回调函数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				               }) 
			 |