Browse Source

对接台州银行支付接口

xdd 1 month ago
parent
commit
c4279a1f6a
2 changed files with 315 additions and 289 deletions
  1. 64 40
      pages/shopping/paymentOrder.vue
  2. 251 249
      pages_user/user/pay.vue

+ 64 - 40
pages/shopping/paymentOrder.vue

@@ -35,7 +35,7 @@
 						</label>
 					</view>
 				</radio-group>
-				 
+
 				<radio-group @change="payTypeChange" v-else-if="order.orderCreateType!=null&& order.orderCreateType==3">
 					<view class="item"  >
 						<view class="left" >
@@ -124,14 +124,14 @@
 					<text class="label">订单金额</text>
 					<text class="text" v-if="order!=null">{{order.payPrice.toFixed(2)}}</text>
 				</view>
-				 
+
 				<!-- <view class="item">
 					<text class="label">支付方式</text>
 					<text class="text">微信支付</text>
 				</view> -->
-				 
+
 			</view>
-			
+
 		</view>
 		<view class="btn-box">
 			<view class="btn" @click="payOrder()">去支付</view>
@@ -145,7 +145,7 @@
 
 <script>
 	import {getUserInfo} from '@/api/user'
-	
+
 	import {getStoreConfig} from '@/api/common'
 	import {editPayType,pay,getStoreOrderById} from '@/api/storeOrder'
 	export default {
@@ -179,7 +179,7 @@
 				path: '/pages_user/user/otherPaymentOrder?orderId='+this.orderId,
 				imageUrl: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20230106/6b459adfb1004c1a96219bcdf07e337c.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
 			}
-			
+
 		},
 		methods: {
 			getUserInfo(){
@@ -209,7 +209,7 @@
 					},
 					rej => {}
 				);
-				
+
 			},
 			payTypeChange(e){
 				this.editPayType(e.detail.value)
@@ -246,7 +246,7 @@
 								}
 							}
 							this.editPayType(this.order.payType)
-							
+
 						}else{
 							uni.showToast({
 								icon:'none',
@@ -256,7 +256,7 @@
 					},
 					rej => {}
 				);
-				
+
 			},
 			editPayType(payType){
 				var data = {orderId:this.orderId,payType:payType};
@@ -280,7 +280,7 @@
 					},
 					rej => {}
 				);
-				
+
 			},
 			otherPayOrder(){
 				uni.navigateTo({
@@ -296,30 +296,54 @@
 						if(res.code==200){
 							 console.log(res);
 							 if(res.payType==1||res.payType==2){
-								 var result=JSON.parse(res.result);
-								 uni.requestPayment({
-								 	provider: 'wxpay',
-								 	timeStamp: result.timeStamp,
-								 	nonceStr: result.nonceStr,
-								 	package: result.package,
-								 	signType: result.signType,
-								 	paySign: result.paySign,
-								 	success: function(res) {
-										uni.hideLoading();
-										uni.redirectTo({
-											url:"success?order="+JSON.stringify(that.order)
-										}) 
-								 	},
-								 	fail: function(err) {
-										uni.showToast({
-											icon:'none',
-											title:'fail:' + JSON.stringify(err),
-										});
-								 		console.log('fail:' + JSON.stringify(err));
-								 		uni.hideLoading();
-								 	}
-								 });
-								 
+                 var result = res.result;
+                 wx.navigateToMiniProgram({
+                   appId: 'wx1b63de1096c46cde', // 收银台小程序 AppId 固定值
+                   path: '/pages/pay/pay', // 收银台小程序 固定路径
+                   extraData: {
+                     orderNo: result.orderNo,
+                     orderAmt: result.orderAmt,
+                     platMerCstNo: result.platMerCstNo,
+                     platMerCstName: result.platMerCstName,
+                     businessCstNo: result.businessCstNo,
+                     licenseCode: result.licenseCode,
+                   },
+                   envVersion: 'release', // 开发版 develop,体验版 trial,正式环境传 release
+                   success(res) {
+                     uni.showLoading({
+                       title:"查询支付结果中..."
+                     })
+                     console.log(res)
+// 接口调用成功的回调函数
+                   },
+                   fail(res) {
+// 接口调用失败的回调函数
+                   }
+                 })
+								 // var result=JSON.parse(res.result);
+								 // uni.requestPayment({
+								 // 	provider: 'wxpay',
+								 // 	timeStamp: result.timeStamp,
+								 // 	nonceStr: result.nonceStr,
+								 // 	package: result.package,
+								 // 	signType: result.signType,
+								 // 	paySign: result.paySign,
+								 // 	success: function(res) {
+									// 	uni.hideLoading();
+									// 	uni.redirectTo({
+									// 		url:"success?order="+JSON.stringify(that.order)
+									// 	})
+								 // 	},
+								 // 	fail: function(err) {
+									// 	uni.showToast({
+									// 		icon:'none',
+									// 		title:'fail:' + JSON.stringify(err),
+									// 	});
+								 // 		console.log('fail:' + JSON.stringify(err));
+								 // 		uni.hideLoading();
+								 // 	}
+								 // });
+
 								 // uni.requestPayment({
 								 // 	provider: 'wxpay',
 								 // 	timeStamp: res.result.timeStamp,
@@ -331,7 +355,7 @@
 								 // 		 uni.hideLoading();
 									// 	  uni.redirectTo({
 									// 	  	url:"success?order="+JSON.stringify(that.order)
-									// 	  }) 
+									// 	  })
 								 // 	},
 								 // 	fail: function(err) {
 									// 	uni.showToast({
@@ -355,10 +379,10 @@
 									//如果是普通订单
 									uni.redirectTo({
 										url:"success?order="+JSON.stringify(that.order)
-									}) 
+									})
 								 }
 							 }
-							 
+
 						}else{
 							uni.showToast({
 								icon:'none',
@@ -368,7 +392,7 @@
 					},
 					rej => {}
 				);
-				
+
 			}
 		}
 	}
@@ -527,7 +551,7 @@
 							margin-left: 24upx;
 						}
 					}
-					 
+
 				}
 				.line{
 					width: 100%;
@@ -583,5 +607,5 @@
 			}
 		}
 	}
-	
+
 </style>

+ 251 - 249
pages_user/user/pay.vue

@@ -1,266 +1,268 @@
 <template>
-	<view class="content">
-		<view class="top">
-			<view class="inner">
-				<view class="pay">
-					<view class="title">
-						<text class="name">付款给 御君方</text>
-						<text class="desc">微信收款</text>
-					</view>
-					<view class="pay-money">
-					 	<view class="pay-money-title">支付金额</view>
-					 	<view class="money">
-					 		<text class="fh">¥</text>
-					 		<input v-model="money"  class="uni-input"  @input="testMoney" type="digit" focus   />
-					 	</view>
-						<textarea class="desc" placeholder="请填写备注说明" maxlength="20" v-model="desc" />
-					</view>
-				</view>
-			</view>
-			<view class="btn-box">
-				<view class="btn" @click="pay()">确认支付</view>
-			</view>
+	<view class="content">
+		<view class="top">
+			<view class="inner">
+				<view class="pay">
+					<view class="title">
+						<text class="name">付款给 御君方</text>
+						<text class="desc">微信收款</text>
+					</view>
+					<view class="pay-money">
+					 	<view class="pay-money-title">支付金额</view>
+					 	<view class="money">
+					 		<text class="fh">¥</text>
+					 		<input v-model="money"  class="uni-input"  @input="testMoney" type="digit" focus   />
+					 	</view>
+						<textarea class="desc" placeholder="请填写备注说明" maxlength="20" v-model="desc" />
+					</view>
+				</view>
+			</view>
+			<view class="btn-box">
+				<view class="btn" @click="pay()">确认支付</view>
+			</view>
 		</view>
-		<view class="ad">
-			<ad unit-id="adunit-a018415a6deb69e8"></ad>
-		</view>
-		
+		<view class="ad">
+			<ad unit-id="adunit-a018415a6deb69e8"></ad>
+		</view>
+
 	</view>
 </template>
 
-<script>
+<script>
 	import {payment} from '@/api/payment'
 	export default {
 		data() {
-			return {
-				companyUserId:null,
-				companyId:null,
-				desc:"",
-				money:null,
+			return {
+				companyUserId:null,
+				companyId:null,
+				desc:"",
+				money:null,
 				wxPay: true,
 			}
-		},
-		onLoad: function(options) {
-		 //   if (options.hasOwnProperty('q') && options.q) {
-		 //   	// 通过下面这步解码,可以拿到url的值
-		 //   	const url = decodeURIComponent(options.q)
-		 //   	this.url=url;
-		 //   	// // 对url中携带的参数提取处理
-		 //   	const obj = this.utils.urlToObj(url)
-			// console.log(obj)
-		 //   	this.companyId=obj.companyId;
-			// this.companyUserId=obj.companyUserId;
-		 //   }
-			this.companyId=options.companyId;
		 	this.companyUserId=options.companyUserId;
-		},
-		onShareAppMessage(res) {
-			return {
-				title: '御君方-收款',
-				path: `/pages_user/user/pay?companyId=`+this.companyId+"&companyUserId="+this.companyUserId
-			}
-		},
-		methods: {
-			testMoney(e){
-				let that = this;
-				let price = e.detail.value
-				if (price.indexOf(".") == 0) {
-					//'首位小数点情况'
-					price = price.replace(/[^$#$]/g, "0.");
-					price = price.replace(/\.{2,}/g, ".");
-				} 
-				price = price.match(/^\d*(\.?\d{0,2})/g)[0] || null;
-				  //重新赋值给input
-				this.$nextTick(() => {
-					this.money = price;
-				});
-			 
-			},
-			pay(){
-				if(this.money==null){
-					uni.showToast({
-						icon:'none',
-						title: "请输入支付金额"
-					});
-					return;
-				}
-				uni.login({
-					success: res => {
-						console.log(res)
-						this.payment(res.code);
-					}
-				});
-			},
-			payment(code){
-				var data = {payMoney:this.money,remark:this.desc,code:code,companyId:this.companyId,companyUserId:this.companyUserId};
-				var that=this;
-				uni.showLoading();
-				payment(data).then(
-					res => {
-						if(res.code==200){
-							 console.log(res);
-							 var result=JSON.parse(res.result);
-							 uni.requestPayment({
-							 	provider: 'wxpay',
-							 	timeStamp: result.timeStamp,
-							 	nonceStr: result.nonceStr,
-							 	package: result.package,
-							 	signType: result.signType,
-							 	paySign: result.paySign,
-							 	success: function(res) {
-							 			uni.hideLoading();
-							 			uni.redirectTo({
-							 				url:"./success"
-							 			})
-							 	},
-							 	fail: function(err) {
-							 		uni.showToast({
-							 			icon:'none',
-							 			title:'fail:' + JSON.stringify(err),
-							 		});
-							 		console.log('fail:' + JSON.stringify(err));
-							 		uni.hideLoading();
-							 	}
-							 });
-							 // uni.requestPayment({
-							 // 	provider: 'wxpay',
-							 // 	timeStamp: res.result.timeStamp,
-							 // 	nonceStr: res.result.nonceStr,
-							 // 	package: res.result.packageValue,
-							 // 	signType: res.result.signType,
-							 // 	paySign: res.result.paySign,
-							 // 	success: function(res) {
-							 // 		uni.hideLoading();
-								// 	uni.showToast({
-								// 		icon:'success',
-								// 		title: "支付成功",
-								// 	});
-								// 	uni.navigateTo({
-								// 		url:'./success'
-								// 	})
-							 // 	},
-							 // 	fail: function(err) {
-							 // 		console.log('fail:' + JSON.stringify(err));
-							 // 		uni.hideLoading();
-							 // 	}
-							 // });
-						}else{
-							uni.showToast({
-								icon:'none',
-								title: res.msg,
-							});
-						}
-					},
-					rej => {}
-				);
-				
+		},
+		onLoad: function(options) {
+		 //   if (options.hasOwnProperty('q') && options.q) {
+		 //   	// 通过下面这步解码,可以拿到url的值
+		 //   	const url = decodeURIComponent(options.q)
+		 //   	this.url=url;
+		 //   	// // 对url中携带的参数提取处理
+		 //   	const obj = this.utils.urlToObj(url)
+			// console.log(obj)
+		 //   	this.companyId=obj.companyId;
+			// this.companyUserId=obj.companyUserId;
+		 //   }
+			this.companyId=options.companyId;
+		 	this.companyUserId=options.companyUserId;
+		},
+		onShareAppMessage(res) {
+			return {
+				title: '御君方-收款',
+				path: `/pages_user/user/pay?companyId=`+this.companyId+"&companyUserId="+this.companyUserId
+			}
+		},
+		methods: {
+			testMoney(e){
+				let that = this;
+				let price = e.detail.value
+				if (price.indexOf(".") == 0) {
+					//'首位小数点情况'
+					price = price.replace(/[^$#$]/g, "0.");
+					price = price.replace(/\.{2,}/g, ".");
+				}
+				price = price.match(/^\d*(\.?\d{0,2})/g)[0] || null;
+				  //重新赋值给input
+				this.$nextTick(() => {
+					this.money = price;
+				});
+
+			},
+			pay(){
+				if(this.money==null){
+					uni.showToast({
+						icon:'none',
+						title: "请输入支付金额"
+					});
+					return;
+				}
+				uni.login({
+					success: res => {
+						console.log(res)
+						this.payment(res.code);
+					}
+				});
+			},
+			payment(code){
+				var data = {payMoney:this.money,remark:this.desc,code:code,companyId:this.companyId,companyUserId:this.companyUserId};
+				var that=this;
+				uni.showLoading();
+				payment(data).then(
+					res => {
+						if(res.code==200){
+							 console.log(res);
+							 var result=res.result;
+              wx.navigateToMiniProgram({
+                appId: 'wx1b63de1096c46cde', // 收银台小程序 AppId 固定值
+                path: '/pages/pay/pay', // 收银台小程序 固定路径
+                extraData: {
+                  orderNo: result.orderNo,
+                  orderAmt: result.orderAmt,
+                  platMerCstNo: result.platMerCstNo,
+                  platMerCstName: result.platMerCstName,
+                  businessCstNo: result.businessCstNo,
+                  licenseCode: result.licenseCode,
+                },
+                envVersion: 'release', // 开发版 develop,体验版 trial,正式环境传 release
+                success(res) {
+                  uni.showLoading({
+                    title:"查询支付结果中..."
+                  })
+                  console.log(res)
+// 接口调用成功的回调函数
+                },
+                fail(res) {
+// 接口调用失败的回调函数
+                }
+              })
+							 // uni.requestPayment({
+							 // 	provider: 'wxpay',
+							 // 	timeStamp: res.result.timeStamp,
+							 // 	nonceStr: res.result.nonceStr,
+							 // 	package: res.result.packageValue,
+							 // 	signType: res.result.signType,
+							 // 	paySign: res.result.paySign,
+							 // 	success: function(res) {
+							 // 		uni.hideLoading();
+								// 	uni.showToast({
+								// 		icon:'success',
+								// 		title: "支付成功",
+								// 	});
+								// 	uni.navigateTo({
+								// 		url:'./success'
+								// 	})
+							 // 	},
+							 // 	fail: function(err) {
+							 // 		console.log('fail:' + JSON.stringify(err));
+							 // 		uni.hideLoading();
+							 // 	}
+							 // });
+						}else{
+							uni.showToast({
+								icon:'none',
+								title: res.msg,
+							});
+						}
+					},
+					rej => {}
+				);
+
 			}
 		}
 	}
 </script>
 
 <style lang="scss">
-	page{
-		height: 100%;
-		background-color: #f0eff4;
-	}
-	.content{
-		height: 100%;
-		display: flex;
-		flex-direction: column;
-		.top{
-			flex:1;
-			padding: 20rpx;
-			.inner{
-				width: 100%;
-				display: flex;
-				flex-direction: column;
-				align-items: flex-start;
-				justify-content: center;
-				.pay{
-					width: 100%;
-					box-shadow: 1px 1px 5px #e6e6e6;
-					background: #FFFFFF;
-					border-radius: 5upx;
-					display: flex;
-					flex-direction: column;
-					align-items: flex-start;
-					.title{
-						display: flex;
-						flex-direction: column;
-						align-items: flex-start;
-						width: 100%;
-						background-color: #f7f7f7;
-						padding: 30rpx 0rpx;
-						.name{
-							padding: 15rpx 30rpx;
-							font-size: 32rpx;
-						}
-						.desc{
-							color: #989898;
-							padding: 15rpx 30rpx;
-							font-size: 25rpx;
-						}
-					}
-					.pay-money
-					{
-						padding: 30rpx 0rpx;
-						 width: 100%;
-						 background: #FFFFFF;
-						 border-radius: 5upx;
-						 display: flex;
-						 flex-direction: column;
-						 align-items: flex-start;
-						 .pay-money-title{
-						 	padding: 15rpx 30rpx;
-						 	font-size: 32rpx;
-						 }
-						 .money{
-							 font-size: 42rpx;
-							 padding: 15rpx 30rpx;
-							 display: flex;
-							 flex-direction: row;
-							 align-items: flex-start;
-							 input{
-								 margin-left: 15rpx;
-							 }
-						 }
-						 .desc{
-							 width: 100%;
-							 padding: 30rpx 30rpx;
-							 border-top: 1rpx solid #e6e6e6;
-						 }
-						 textarea {
-							 height:50rpx;
-							 line-height: 50rpx;
-						 }
-					}
-				}
-				
-				 
-			}
-			.btn-box{
-				padding: 30rpx 0rpx;
-				height: 121upx;
-				display: flex;
-				align-items: center;
-				justify-content: center;
-				.btn{
-					width: 91.73%;
-					height: 88upx;
-					line-height: 88upx;
-					font-size: 30upx;
-					font-family: PingFang SC;
-					font-weight: bold;
-					color: #FFFFFF;
-					text-align: center;
-					background: #2BC7B9;
-					border-radius: 44upx;
-				}
-			}
-		}
-		.ad{
-			margin: 0rpx 0rpx 60rpx;
-		}
-	}
-	
+	page{
+		height: 100%;
+		background-color: #f0eff4;
+	}
+	.content{
+		height: 100%;
+		display: flex;
+		flex-direction: column;
+		.top{
+			flex:1;
+			padding: 20rpx;
+			.inner{
+				width: 100%;
+				display: flex;
+				flex-direction: column;
+				align-items: flex-start;
+				justify-content: center;
+				.pay{
+					width: 100%;
+					box-shadow: 1px 1px 5px #e6e6e6;
+					background: #FFFFFF;
+					border-radius: 5upx;
+					display: flex;
+					flex-direction: column;
+					align-items: flex-start;
+					.title{
+						display: flex;
+						flex-direction: column;
+						align-items: flex-start;
+						width: 100%;
+						background-color: #f7f7f7;
+						padding: 30rpx 0rpx;
+						.name{
+							padding: 15rpx 30rpx;
+							font-size: 32rpx;
+						}
+						.desc{
+							color: #989898;
+							padding: 15rpx 30rpx;
+							font-size: 25rpx;
+						}
+					}
+					.pay-money
+					{
+						padding: 30rpx 0rpx;
+						 width: 100%;
+						 background: #FFFFFF;
+						 border-radius: 5upx;
+						 display: flex;
+						 flex-direction: column;
+						 align-items: flex-start;
+						 .pay-money-title{
+						 	padding: 15rpx 30rpx;
+						 	font-size: 32rpx;
+						 }
+						 .money{
+							 font-size: 42rpx;
+							 padding: 15rpx 30rpx;
+							 display: flex;
+							 flex-direction: row;
+							 align-items: flex-start;
+							 input{
+								 margin-left: 15rpx;
+							 }
+						 }
+						 .desc{
+							 width: 100%;
+							 padding: 30rpx 30rpx;
+							 border-top: 1rpx solid #e6e6e6;
+						 }
+						 textarea {
+							 height:50rpx;
+							 line-height: 50rpx;
+						 }
+					}
+				}
+
+
+			}
+			.btn-box{
+				padding: 30rpx 0rpx;
+				height: 121upx;
+				display: flex;
+				align-items: center;
+				justify-content: center;
+				.btn{
+					width: 91.73%;
+					height: 88upx;
+					line-height: 88upx;
+					font-size: 30upx;
+					font-family: PingFang SC;
+					font-weight: bold;
+					color: #FFFFFF;
+					text-align: center;
+					background: #2BC7B9;
+					border-radius: 44upx;
+				}
+			}
+		}
+		.ad{
+			margin: 0rpx 0rpx 60rpx;
+		}
+	}
+
 </style>