|
|
@@ -106,6 +106,7 @@
|
|
|
|
|
|
<script>
|
|
|
import { getGhsData } from '@/api/ghs';
|
|
|
+import { rechargeFn } from '@/api/custom-recharge'
|
|
|
|
|
|
// 优化:使用常量避免重复创建
|
|
|
const KEY_TYPES = {
|
|
|
@@ -157,7 +158,10 @@ export default {
|
|
|
// 弹框状态
|
|
|
showConfirm: false,
|
|
|
id:0,
|
|
|
- salt:''
|
|
|
+ salt:'',
|
|
|
+ ghsInfo:[],
|
|
|
+ customInfo:[],
|
|
|
+ payWay:1
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -179,9 +183,16 @@ export default {
|
|
|
if (options.salt) {
|
|
|
this.salt = options.salt;
|
|
|
}
|
|
|
+ let that = this
|
|
|
if (this.id && this.salt) {
|
|
|
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) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '金额不能超过8位数',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 1500
|
|
|
+ })
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 小数部分限制
|
|
|
if (decimalPart && decimalPart.length >= MAX_DECIMAL_LENGTH) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '最多支持2位小数',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 1500
|
|
|
+ })
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -324,25 +345,61 @@ export default {
|
|
|
hideConfirmDialog() {
|
|
|
this.showConfirm = false;
|
|
|
},
|
|
|
-
|
|
|
// 处理支付
|
|
|
- async handlePay() {
|
|
|
+ handlePay() {
|
|
|
if (!this.canPay) return;
|
|
|
const amount = parseFloat(this.currentAmount);
|
|
|
// 隐藏弹框
|
|
|
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}`;
|
|
|
}
|
|
|
}
|
|
|
}
|