From db03391c6bde1f7b1a93164930799fc434c0f9f2 Mon Sep 17 00:00:00 2001
From: 石广澎 <shiguangpeng@163.com>
Date: 星期四, 10 十月 2024 17:16:48 +0800
Subject: [PATCH] feat(支付): 数学计算工具
---
pay/scanpay.vue | 36 +++++++++++++++++++-----------------
1 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/pay/scanpay.vue b/pay/scanpay.vue
index c9162ca..4256502 100644
--- a/pay/scanpay.vue
+++ b/pay/scanpay.vue
@@ -60,10 +60,10 @@
<view @click="showCoupon" class="u-flex">
<block v-if="couponInfo.id">
<view v-if="couponInfo.discountType==1" class="tag-pain">
- 婊{ parseFloat((couponInfo.thresholdValue / 100).toFixed(2)) }}鍏冨噺{{ parseFloat((couponInfo.discount / 100).toFixed(2)) }}鍏冨埜
+ 婊{ $utils.fenToYuan(couponInfo.thresholdValue) }}鍏冨噺{{ $utils.fenToYuan(couponInfo.discount) }}鍏冨埜
</view>
<view v-if="couponInfo.discountType==2" class="tag-pain">
- {{ parseFloat(couponInfo.discount * 10).toFixed(1) }}鎶樺埜
+ {{ $utils.accMul(couponInfo.discount, 10) }}鎶樺埜
</view>
</block>
@@ -108,14 +108,14 @@
<view class="num-box">
<view v-if="item.discountType==1" class="font-bold" style="color: #D31F28;">
<text class="u-font-36">锟�</text>
- <text class="money">{{ parseFloat(item.discount / 100) }}</text>
+ <text class="money">{{ $utils.fenToYuan(item.discount) }}</text>
</view>
<view v-if="item.discountType==2" class="font-bold" style="color: #D31F28;">
- <text class="money">{{ parseFloat(item.discount * 10).toFixed(1) }}</text>
+ <text class="money">{{ $utils.accMul(item.discount, 10) }}</text>
<text class="u-font-36">鎶�</text>
</view>
- <view v-if="item.orderMax" class="u-font-24 u-m-t-20">浣庝簬{{ parseFloat(item.orderMax / 100) }}鍏冨彲鐢�</view>
- <view v-else-if="item.thresholdValue" class="u-font-24 u-m-t-20">婊{ parseFloat(item.thresholdValue / 100) }}鍏冨彲鐢�</view>
+ <view v-if="item.orderMax" class="u-font-24 u-m-t-20">浣庝簬{{ $utils.fenToYuan(item.orderMax) }}鍏冨彲鐢�</view>
+ <view v-else-if="item.thresholdValue" class="u-font-24 u-m-t-20">婊{ $utils.fenToYuan(item.thresholdValue) }}鍏冨彲鐢�</view>
<view v-else class="u-font-24 u-m-t-20">鏃犻棬妲�</view>
</view>
<view class="butt"></view>
@@ -165,7 +165,8 @@
saveOrder,
} from 'common/api/index'
-import wx from 'weixin-js-sdk'; // 浣跨敤js-sdk
+import wx from 'weixin-js-sdk';
+import {accMul, fenToYuan} from 'common/util' // 浣跨敤js-sdk
export default {
data() {
@@ -215,31 +216,31 @@
return 0
}
if (this.checkCoupon.discountType == 1) {
- const num = (this.checkCoupon.discount / 100).toFixed(2)
+ const num = this.$utils.fenToYuan(this.couponInfo.discount)
return parseFloat(num);
}
const dis = 1 - parseFloat(this.checkCoupon.discount)
- const dic = Math.floor(Number((this.money || 0) * 100) * dis)
- return (dic / 100).toFixed(2);
+ const dic = Math.floor(this.$utils.accMul(this.money,100) * dis)
+ return this.$utils.fenToYuan(dic).toFixed(2);
},
discount() {
if(!(this.money || 0)||!this.couponInfo.id){
return 0
}
if (this.couponInfo.discountType == 1) {
- const num = (this.couponInfo.discount / 100).toFixed(2)
+ const num = this.$utils.fenToYuan(this.couponInfo.discount)
return parseFloat(num);
}
const dis = 1 - parseFloat(this.couponInfo.discount)
- const dic = Math.floor(Number((this.money || 0) * 100) * dis)
- return (dic / 100).toFixed(2);
+ const dic = Math.floor(this.$utils.accMul(this.money,100) * dis)
+ return this.$utils.fenToYuan(dic).toFixed(2);
},
payMoney() {
if(this.discount===0||!Number(this.money || 0)){
return 0
}
- const num = Number((this.money || 0) * 100) - Number(this.discount*100);
- return (num / 100).toFixed(2);
+ const num = this.$utils.accMul(this.money,100) - this.$utils.accMul(this.discount,100);
+ return this.$utils.fenToYuan(num).toFixed(2);
}
},
onLoad(opt) {
@@ -451,9 +452,10 @@
queryUseSweepPayCoupon() {
queryUseSweepPayCoupon({
params: {
+ score: 0,
applyPayWayStr: this.payWay,
cusid: this.shopInfo.id,
- money: (this.money * 100).toFixed(0),
+ money: this.$utils.accMul(this.money,100),
}
}).then(res => {
this.couponList = res
@@ -489,7 +491,7 @@
// 閲戦 this.money
uni.showLoading()
const params = {
- money: (this.money * 100).toFixed(0),
+ money: this.$utils.accMul(this.money,100),
shopId: this.shopInfo.id,
payWay: this.payWay,
buyerNote: this.buyerNote,
--
Gitblit v1.9.1