Răsfoiți Sursa

支付策略

hmp 4 ani în urmă
părinte
comite
6b4d6a4450
3 a modificat fișierele cu 45 adăugiri și 19 ștergeri
  1. 2 0
      assets/http/api.js
  2. 21 2
      assets/http/global.js
  3. 22 17
      pages/checkstand/index.vue

+ 2 - 0
assets/http/api.js

@@ -72,6 +72,8 @@ const pay={
 	payOrder:p => http.get('payment/payOrder/YEE_PAY/MINI_PROGRAM',{params:p}),
 	//扫码支付
 	payOrderOfscanCode:p => http.get('payment/payOrder/YEE_PAY/SCAN_CODE',{params:p}),
+	//支付策略
+	getPointPayType:p => http.post('cyzh-ldt/loginuser/getPointPayType',p),
 }
 
 const billRecord={

+ 21 - 2
assets/http/global.js

@@ -1,9 +1,9 @@
 let global = {}
 
 // global.baseUrl='http://192.168.1.244:1888/api/'
-global.baseUrl='https://ldt.guosen-fumao.cn/api/'
+// global.baseUrl='https://ldt.guosen-fumao.cn/api/'
 
-// global.baseUrl='http://localhost:2539/'
+global.baseUrl='http://localhost:2539/'
 
 global.WebSocketUrl='wss://ldt.guosen-fumao.cn/websocket/'
 
@@ -38,6 +38,25 @@ global.socketMessage={
 }
 
 
+// 用户积分足够够有三种情况,分别是CHANNEL_ENOUGN、CHANNEL_ZERO_RARE_ENOUGH、CHANNEL_NOENOUGH_RARE_ENOUGH
+global.pointPayType={
+	//渠道积分足够支付
+	CHANNEL_ENOUGN:'CHANNEL_ENOUGN',
+	//渠道积分为0,用户余额为0
+	CHANNEL_ZERO_RARE_ZERO:'CHANNEL_ZERO_RARE_ZERO',
+	//渠道积分为0,用户余额够扣
+	CHANNEL_ZERO_RARE_ENOUGH:'CHANNEL_ZERO_RARE_ENOUGH',
+	//渠道积分为0,用户余额不够扣
+	CHANNEL_ZERO_RARE_NOENOUGH:'CHANNEL_ZERO_RARE_NOENOUGH',
+	//渠道积分不为0,用户余额为0
+	CHANNEL_NOENOUGH_RARE_ZERO:'CHANNEL_NOENOUGH_RARE_ZERO',
+	//渠道积分不为0,用户余额足够扣
+	CHANNEL_NOENOUGH_RARE_ENOUGH:'CHANNEL_NOENOUGH_RARE_ENOUGH',
+	//渠道积分不为0,用户余额不够扣
+	CHANNEL_NOENOUGH_RARE_NOENOUGH:'CHANNEL_NOENOUGH_RARE_NOENOUGH'
+}
+
+
 global.TRANSFORM_PARAMS='95963'
 
 

+ 22 - 17
pages/checkstand/index.vue

@@ -25,7 +25,7 @@
 		<amountInput ref="amountInput" confirmText="付款" btnColor="#ff9900" placeholder="请输入交易金额" @change="change"
 			@confirm="debouncePay"></amountInput>
 
-		<u-modal v-model="payModalShow" :showCancelButton="true" confirm-color="#FF9447">
+		<u-modal v-model="payModalShow" confirmText="确认支付" cancelText="暂不支付" @confirm="toWXPay(pointPayType)" @cancel="$back()" :showCancelButton="true" confirm-color="#FF9447">
 			<view class="center flex-direction text-df" style="padding: 30rpx 40rpx;">
 				<view>您的积分可足额抵扣支付</view>
 				<view class="padding-top-10">本次支付不会扣除您的现金</view>
@@ -51,7 +51,8 @@
 				payModalShow: false,
 				modalShow: false,
 				shopId: '',
-				shopDetail: {}
+				shopDetail: {},
+				pointPayType:''
 			}
 		},
 		async onLoad(options) {
@@ -102,7 +103,7 @@
 					this.$u.debounce(this.pay, 500)
 				}
 			},
-			//获取商户i信息
+			//获取商户信息
 			fetchShopDetail() {
 				this.$api.shop.detail({
 					id: this.shopId
@@ -185,15 +186,6 @@
 					this.$u.toast('支付失败')
 				}
 			},
-			isMoney(s) {
-				var str = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
-				var reg = new RegExp(str)
-				if (reg.test(s)) {
-				   return true;
-				}else {
-					return false;
-				}
-			},
 			async pay() {
 				if (!this.orderAmount.length || this.orderAmount == 0) {
 					this.$u.toast('请输入交易金额')
@@ -204,16 +196,28 @@
 				// #endif
 
 				// #ifdef MP-WEIXIN
-				let flag = false
-				if (flag) {
+				let res= await this.getPointPayType()
+				this.pointPayType=res.data
+				if (this.pointPayType==this.$global.pointPayType.CHANNEL_ENOUGN 
+				|| this.pointPayType==this.$global.pointPayType.CHANNEL_ZERO_RARE_ENOUGH
+				|| this.pointPayType==this.$global.pointPayType.CHANNEL_NOENOUGH_RARE_ENOUGH) {
 					//可以足额支付
 					this.payModalShow = true
-				} else {
-					//积分不足额支付,调易宝支付
+				}else{
 					this.toWXPay()
 				}
 				// #endif
 			},
+			//获取积分策略
+			async getPointPayType(){
+				let params={
+					shopId: this.shopId,
+					loginUserId: this.vuex_userId,
+					money: this.orderAmount
+				}
+				let res=await this.$api.pay.getPointPayType(params)
+				return res
+			},
 			async toWXPay() {
 				let expireTime = this.$dateTime.getExpireTime(5)
 				let params = {
@@ -224,7 +228,8 @@
 					expireTime,
 					appId: this.$global.wxParams.APPID,
 					openId: this.$cache.get('userInfo').openId,
-					type: 1 //type: 1-用户扫商户收款码支付 2-商户扫用户付款码支付
+					type: 1 ,//type: 1-用户扫商户收款码支付 2-商户扫用户付款码支付
+					pointPayType:this.pointPayType
 				}
 				let resp = await this.$api.loginUser.payBefore(params)
 				if (!resp.success) {