shish 11 місяців тому
батько
коміт
059708b681
2 змінених файлів з 77 додано та 15 видалено
  1. 72 15
      hdh5/admin/ghs/pay.vue
  2. 5 0
      hdh5/api/custom-recharge/index.js

+ 72 - 15
hdh5/admin/ghs/pay.vue

@@ -106,6 +106,7 @@
 
 
 <script>
 <script>
 import { getGhsData } from '@/api/ghs';
 import { getGhsData } from '@/api/ghs';
+import { rechargeFn } from '@/api/custom-recharge'
 
 
 // 优化:使用常量避免重复创建
 // 优化:使用常量避免重复创建
 const KEY_TYPES = {
 const KEY_TYPES = {
@@ -157,7 +158,10 @@ export default {
 			// 弹框状态
 			// 弹框状态
 			showConfirm: false,
 			showConfirm: false,
 			id:0,
 			id:0,
-			salt:''
+			salt:'',
+			ghsInfo:[],
+			customInfo:[],
+			payWay:1
 		}
 		}
 	},
 	},
 	computed: {
 	computed: {
@@ -179,9 +183,16 @@ export default {
 		if (options.salt) {
 		if (options.salt) {
 			this.salt = options.salt;
 			this.salt = options.salt;
 		}
 		}
+		let that = this
 		if (this.id && this.salt) {
 		if (this.id && this.salt) {
 			getGhsData({id:this.id,salt:this.salt}).then(res => {
 			getGhsData({id:this.id,salt:this.salt}).then(res => {
-				console.log(res)
+				if (res.data && res.data.ghs && !this.$util.isEmpty(res.data.ghs)){
+					that.ghsInfo = res.data.ghs
+					that.customInfo = res.data.custom?res.data.custom:[]
+					if(that.customInfo.remainDebtAmount && Number(that.customInfo.remainDebtAmount)>0){
+						that.displayAmount = parseFloat(that.customInfo.remainDebtAmount)
+					}
+				}
 			})
 			})
 		}
 		}
 	},
 	},
@@ -251,11 +262,21 @@ export default {
 
 
 			// 整数部分限制
 			// 整数部分限制
 			if (!decimalPart && integerPart.length >= MAX_INTEGER_LENGTH) {
 			if (!decimalPart && integerPart.length >= MAX_INTEGER_LENGTH) {
+				uni.showToast({
+					title: '金额不能超过8位数',
+					icon: 'none',
+					duration: 1500
+				})
 				return;
 				return;
 			}
 			}
 
 
 			// 小数部分限制
 			// 小数部分限制
 			if (decimalPart && decimalPart.length >= MAX_DECIMAL_LENGTH) {
 			if (decimalPart && decimalPart.length >= MAX_DECIMAL_LENGTH) {
+				uni.showToast({
+					title: '最多支持2位小数',
+					icon: 'none',
+					duration: 1500
+				})
 				return;
 				return;
 			}
 			}
 
 
@@ -324,25 +345,61 @@ export default {
 		hideConfirmDialog() {
 		hideConfirmDialog() {
 			this.showConfirm = false;
 			this.showConfirm = false;
 		},
 		},
-
 		// 处理支付
 		// 处理支付
-		async handlePay() {
+		handlePay() {
 			if (!this.canPay) return;
 			if (!this.canPay) return;
 			const amount = parseFloat(this.currentAmount);
 			const amount = parseFloat(this.currentAmount);
 			// 隐藏弹框
 			// 隐藏弹框
 			this.hideConfirmDialog();
 			this.hideConfirmDialog();
-		},
-
-		// 请求支付
-		async requestPayment(amount) {
-
-		},
+			if (Number(amount)<=0) {
+				uni.showToast({
+					title: '请输入金额!',
+					icon: 'none',
+					duration: 2000
+				})
+				return false
+			}
+			let params = {}
+			params = {
+				actPrice: amount,
+				payWay: this.payWay,
+			}
+			params.ghsId = this.id
+			params.salt = this.salt
+			rechargeFn(params).then(res => {
+				//错误返回判断
+				if(res.code == 0){
+					uni.hideLoading()
+					uni.showToast({
+						title: res.msg,
+						icon: 'none',
+						duration: 2000
+					})
+					return false
+				}			
+				// 隐藏加载提示
+				uni.hideLoading()
+				// 显示成功提示
+				uni.showToast({
+					title: '正在跳转支付...',
+					icon: 'success',
+					duration: 1500
+				})
+				// 延迟跳转到支付页面
+				setTimeout(() => {
+					window.location.href = res.data.url;
+				}, 300)					
+			}).catch(err => {
+				// 隐藏加载提示
+				uni.hideLoading()
+				// 显示错误提示
+				uni.showToast({
+					title: '请求失败,请重试',
+					icon: 'none',
+					duration: 2000
+				})
+			})
 
 
-		// 生成订单ID
-		generateOrderId() {
-			const timestamp = Date.now();
-			const random = Math.floor(Math.random() * 10000);
-			return `ORDER${timestamp}${random}`;
 		}
 		}
 	}
 	}
 }
 }

+ 5 - 0
hdh5/api/custom-recharge/index.js

@@ -0,0 +1,5 @@
+import https from '@/plugins/luch-request_0.0.7/request'
+
+export const rechargeFn = data => {
+	return https.post('/custom-recharge/recharge', data)
+}