فهرست منبع

第三方支付

zhengjinyi 5 سال پیش
والد
کامیت
206b50c74e
6فایلهای تغییر یافته به همراه133 افزوده شده و 45 حذف شده
  1. 2 2
      common/config/config.js
  2. 31 26
      pages/user/order/order-pay.vue
  3. 63 15
      pages/user/order/order-payment.vue
  4. 2 2
      services/ajax.env.js
  5. 3 0
      services/index.js
  6. 32 0
      services/pay.service.js

+ 2 - 2
common/config/config.js

@@ -3,8 +3,8 @@ if(process.env.NODE_ENV === 'development'){
     // 开发环境
 	// URL_CONFIG = 'http://192.168.1.24:8008'	 //俊俊联调地址
 	// URL_CONFIG = 'http://192.168.1.22:8008'	 //裴裴联调地址
-	URL_CONFIG = 'http://192.168.1.20:8008'	 //超超联调地址
-    // URL_CONFIG = 'https://spi-b.caimei365.com'	 //采美测试地址
+	// URL_CONFIG = 'http://192.168.1.20:8008'	 //超超联调地址
+    URL_CONFIG = 'https://spi-b.caimei365.com'	 //采美测试地址
 	// URL_CONFIG = 'https://spi.caimei365.com'
 }else{
     // 生产环境

+ 31 - 26
pages/user/order/order-pay.vue

@@ -90,7 +90,6 @@
 	import authorize from '@/common/config/authorize.js'
 	// import keyboard from "@/components/keyboard/keyboard.vue"
 	import thorui from "@/components/clipboard/clipboard.thorui.js"
-	import { PayOrderCheckoutCounter,WeChatMiniWxPay,PayOrderPayLink } from "@/api/order.js"
 	export default{
 		components: {
 			// keyboard
@@ -145,7 +144,7 @@
 				this.GetPayOrderInfo()
 			},
 			GetPayOrderInfo(){
-				PayOrderCheckoutCounter({orderId:this.orderID}).then(response =>{
+				this.PayService.PayOrderCheckoutCounter({orderId:this.orderID}).then(response =>{
 					this.isRepuest = true
 					this.discernReceipt = response.data.discernReceipt 		//支付记录
 					this.payTotalFee = response.data.order.payTotalFee  //已付金额
@@ -163,14 +162,18 @@
 						this.MiniWxPayFor()
 						break;
 					case '1':
-						this.isShowTip = true
 						this.BuildCatenate()
 						break;
 				}
 			},
 			BuildCatenate(){
-				PayOrderPayLink({unpaidAmount:this.payAmount,orderId:this.orderID}).then(response =>{
+				if(this.payAmount <=10){
+					this.$util.msg("企业网银支付的金额必须大于¥10.00",2000)
+					return
+				}
+				this.PayService.PayOrderPayLink({unpaidAmount:this.payAmount,orderId:this.orderID}).then(response =>{
 					this.payHttpUrl = response.data
+					this.isShowTip = true
 				})
 			},
 			MiniWxPayFor(){
@@ -180,41 +183,43 @@
 						this.$util.msg("请输入本次支付的金额",2000)
 						return
 					}
+					if(this.payAmount*100 < 2){
+						this.$util.msg("本次支付的金额必须大于¥0.02",2000)
+						return
+					}
 					let params ={
 							payAmount:this.payAmount*100,
 							payWay:"WEIXIN",
-							payType:"MINIAPP_WEIXIN",
 							code:wechatcode,
 							orderId:this.orderID
 						}
-					WeChatMiniWxPay(params).then(response =>{
+					this.PayService.WeChatMiniWxPay(params).then(response =>{
 						let PayInfo = JSON.parse(response.data.data.payInfo);
-						uni.setStorageSync('payInfo',PayInfo)
-						console.log(PayInfo)
-						wx.requestPayment({
-							'timeStamp': PayInfo.timeStamp,
-							'nonceStr': PayInfo.nonceStr,
-							'package': PayInfo.package,
-							'signType': PayInfo.signType,
-							'paySign': PayInfo.paySign,
-							'success':function(res){
-								console.log('支付成功');
-								wx.reLaunch({url: '/pages/tabBar/user/user'});
-							},
-							'fail':function(res){
-								self.$util.msg('订单支付已取消')
-							},
-							'complete':function(res){
-								
-							}
-						})
+						this.WxRequestPayment(PayInfo)
 					}).catch(error =>{
 						this.$util.msg(error.msg,2000)
 					})
 				})
 			},
+			WxRequestPayment(data){
+				wx.requestPayment({
+					'timeStamp': data.timeStamp,
+					'nonceStr': data.nonceStr,
+					'package': data.package,
+					'signType': data.signType,
+					'paySign': data.paySign,
+					'success':function(res){
+						wx.reLaunch({url: '/pages/tabBar/user/user'});
+					},
+					'fail':function(res){
+						self.$util.msg('订单支付已取消')
+					},
+					'complete':function(res){
+						
+					}
+				})
+			},
 			confirmEvent(value){//点击自定义键盘完成的回调函数
-				console.log(value)
 				this.chechValue(value)
 				this.showDigitKeyboard = false
 			},

+ 63 - 15
pages/user/order/order-payment.vue

@@ -1,7 +1,7 @@
 <template>
-	<view class="container cashier">
+	<view class="container cashier" :style="{paddingTop:CustomBar+'px'}">
 		<cu-custom :navbar-data='nvabarData' @navigateBack="hanldNavigateBack"></cu-custom>
-		<view class="container-cash clearfix" :style="{marginTop:CustomBar+'px'}">
+		<view class="container-cash clearfix">
 			<view class="container-wrapper">
 				<view class="pay-title" v-show="isConfirm"><text>订单提交成功,请支付订单</text></view>
 				<view class="pay-content">
@@ -41,7 +41,17 @@
 			<view class="pay-button">
 				<view class="btn" @click.stop="goOrderCash" :style="{'background':btnColor}">{{buttonText}}</view>
 			</view>
-			<view class="pay-bring clearfix" :style="{bottom:isIphoneX ? '68rpx' : '24rpx'}" @click.stop="showTips">
+			<view class="pay-statustext">
+				<view class="pay-statustext-inner">
+					<view class="pay-icon">
+						<text class="iconfont icon-gantanhao-yuankuang"></text>
+					</view>
+					<view class="pay-text">
+						<text>{{payStatusText}}</text>
+					</view>
+				</view>
+			</view>
+			<view class="pay-bring clearfix" :style="{bottom:isIphoneX ? '68rpx' : '24rpx'}" @click.stop="showTips" v-if="isReceiptStatus">
 				<view class="pay-bring-line"><text class="line"></text></view>
 				<view class="pay-bring-content" v-if="!isShowTip">
 					<view class="text bg-color">查看转账信息</view>
@@ -64,7 +74,6 @@
 
 <script>
 	const thorui = require("@/components/clipboard/clipboard.thorui.js")
-	import { PayOrderCheckoutCounter } from "@/api/order.js"
 	export default{
 		data(){
 			return{
@@ -85,8 +94,11 @@
 				tabCurrentIndex:0,
 				isShowTip:false,
 				isConfirm:false,
+				isReceiptStatus:false,
 				buttonText:'使用微信支付',
-				btnColor:'#09BB07'
+				btnColor:'#09BB07',
+				receiptStatus:'',
+				payStatusText:'使用微信和企业网银支付全部金额后,供应商会在24小时后发货(周末、节假日顺延)。若着急发货,可以选择使用线下转账进行付款。'
 			}
 		},
 		onLoad(option) {
@@ -106,9 +118,17 @@
 						break;
 				}
 				this.orderID = e.orderID
-				PayOrderCheckoutCounter({orderId:this.orderID}).then(response =>{
-					console.log(response)
-					this.payableAmount = response.data.order.payableAmount - response.data.order.receiptAmount  //待付金额
+				this.PayService.PayOrderCheckoutCounter({orderId:this.orderID}).then(response =>{
+					let data = response.data.order
+					this.payableAmount = data.payableAmount - data.receiptAmount  //待付金额
+					this.receiptStatus =  data.receiptStatus
+					if(this.receiptStatus =='2'){
+						this.payStatusText = '使用微信和企业网银支付全部金额后,供应商会在24小时后发货(周末、节假日顺延)。'
+						this.isReceiptStatus = false
+					}else{
+						this.payStatusText = '使用微信和企业网银支付全部金额后,供应商会在24小时后发货(周末、节假日顺延)。若着急发货,可以选择使用线下转账进行付款。'
+						this.isReceiptStatus = true
+					}
 				}).catch(error =>{
 					this.$util.msg(error.msg,2000)
 				})
@@ -144,9 +164,6 @@
 			showTips(){
 				this.isShowTip=!this.isShowTip
 			},
-			hideTips(){
-				this.isShowTip=false
-			},
 			clipboard(data) {
 				thorui.getClipboardData(data, (res) => {
 					// #ifdef H5
@@ -167,7 +184,7 @@
 
 <style lang="scss">
 	page{
-		height: 100% !important;
+		height: auto !important;
 		background-color: #F7F7F7;
 	}
 	.container-cash{
@@ -180,7 +197,7 @@
 				line-height: 44rpx;
 				text-align: center;
 				color: #2A86FF;
-				margin: 54rpx 0;
+				margin: 40rpx 0 0 0;
 				width: 100%;
 				float: left;
 			}
@@ -191,7 +208,7 @@
 				background: url(https://admin-b.caimei365.com/userfiles/1/images/photo/2020/05/%E4%BB%A3%E4%BB%98%E9%87%91%E9%A2%9Dbg%402x.png) no-repeat;
 				background-size: cover;
 				float: left;
-				margin-top: 54rpx;
+				margin-top: 40rpx;
 				margin-bottom: 40rpx;
 				.pay-p{
 					font-size: $font-size-26;
@@ -309,7 +326,7 @@
 		.pay-button{
 			width: 100%;
 			float: left;
-			margin-top:120rpx;
+			margin-top:30rpx;
 			.btn{
 				width: 662rpx;
 				height: 88rpx;
@@ -322,6 +339,37 @@
 				background:$btn-confirm;
 			}
 		}
+		.pay-statustext{
+			width: 100%;
+			height: 120rpx;
+			float: left;
+			margin-top:40rpx;
+			.pay-statustext-inner{
+				width: 662rpx;
+				height: 100%;
+				margin: 0 auto;
+				.pay-icon{
+					width: 62rpx;
+					height: 100%;
+					float: left;
+					text-align: center;
+					.iconfont{
+						color: #FF2A2A;
+						font-size:$font-size-36;
+						line-height: 20rpx;
+					}
+				}
+				.pay-text{
+					width: 560rpx;
+					height: 100%;
+					float: left;
+					line-height: 40rpx;
+					font-size: $font-size-26;
+					color: #FF2A2A;
+					text-align: justify;
+				}
+			}
+		}
 		.pay-bring{
 			width: 702rpx;
 			min-height: 190rpx;

+ 2 - 2
services/ajax.env.js

@@ -3,8 +3,8 @@ if(process.env.NODE_ENV === 'development'){
     // 开发环境
 	// URL_CONFIG = 'http://192.168.1.24:8008'	 //俊俊联调地址
 	// URL_CONFIG = 'http://192.168.1.22:8008'	 //裴裴联调地址
-	URL_CONFIG = 'http://192.168.1.20:8008'	 //超超联调地址
-    // URL_CONFIG = 'https://spi-b.caimei365.com'	 //采美测试地址
+	// URL_CONFIG = 'http://192.168.1.20:8008'	 //超超联调地址
+    URL_CONFIG = 'https://spi-b.caimei365.com'	 //采美测试地址
 	// URL_CONFIG = 'https://spi.caimei365.com'
 }else{
     // 生产环境

+ 3 - 0
services/index.js

@@ -3,16 +3,19 @@ import CommonService from './common.service'
 import LocateService from './locate.service'
 import UserService from './user.service'
 import ShopService from './shop.service'
+import PayService from './pay.service'
 import PhotoService from './photo.service'
 import Vue from 'vue'
 let commonService = new CommonService(ajaxService)
 let locateService = new LocateService(ajaxService)
 let userService = new UserService(ajaxService)
 let shopService = new ShopService(ajaxService)
+let payService = new PayService(ajaxService)
 let photoService = new PhotoService(ajaxService)
 Vue.prototype.AjaxService = ajaxService
 Vue.prototype.CommonService = commonService
 Vue.prototype.LocateService = locateService
 Vue.prototype.UserService = userService
 Vue.prototype.ShopService = shopService
+Vue.prototype.PayService = payService
 Vue.prototype.PhotoService = photoService

+ 32 - 0
services/pay.service.js

@@ -0,0 +1,32 @@
+/**
+ * 这是支付相关的业务逻辑的服务
+ */
+export default class PayService {
+	constructor(AjaxService) {
+		Object.assign(this, { AjaxService })
+		this.name = 'PayService'
+	}
+	/* 小程序支付-初始化收银台 */
+	PayOrderCheckoutCounter (data = {}) {
+		return this.AjaxService.get({ url:'/PayOrder/checkoutCounter', data, isLoading: true })
+	}
+	/**
+	 *小程序支付-微信支付
+	 *@param  amount支付金额,单位分,必须大于2
+	 *@param  payWay银联:UNIONPAY,微信:WEIXIN,支付宝:ALIPAY
+	 *@param  payType 微信小程序支付: MINIAPP_WEIXIN ,微信公众号支付: JSAPI_WEIXIN
+	 *@param  code  微信小程序code,微信小程序支付使用
+	 *@param  orderId  主订单ID
+	 */
+	WeChatMiniWxPay (data = {}) {
+		return this.AjaxService.post({ url:'/PayOrder/miniWxPay', data, isLoading: true })
+	}
+	/**
+	 *生成支付链接
+	 *@param  unpaidAmount 本次待付款金额
+	 *@param  orderId  主订单ID
+	 */
+	PayOrderPayLink (data = {}) {
+		return this.AjaxService.post({ url:'/PayOrder/payLink', data, isLoading: true })
+	}
+}