diff --git a/src/style/iconfonts.scss b/src/style/iconfonts.scss new file mode 100644 index 0000000..fd88ad5 --- /dev/null +++ b/src/style/iconfonts.scss @@ -0,0 +1,7 @@ +// iconfont 圆圈白勾选中 () +@mixin circleSelected { + @font-face { + font-family: 'circleSelected'; + src: url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAALMAAsAAAAABoQAAAKBAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHFQGYACCcAp8gQ4BNgIkAwgLBgAEIAWEZwcyG8wFyJ6aPIECCiFAG9Z64OAyRBCtsdm7Q0SSehbLoiGSIFGSWKuETKZBEyvhf35/7xnAdOP4FUenrzQ93Pfh+85nGtpWwQhHqTkqbZGKQ4bcuXlAiXC5XLju838/+ZcX8D0+5w6Kakp8YPOB7IMu22YtvjPzgU9heNVB7sQ1Ao2WVAnfberQQ/IFh07IF8nuD7L6uLCYOIiVIopC8/VCLbq2QDyJIl2nC+Ax+nz800QsSGoy2E0H540iHN2nOhNyX9UH8pu++TroZQk1yJgDCnHSndkTIZqkCI2eSCO0tQi+UqsqcItdO4T419m1zWCYKu9J5alvVTGBwnDGgNVR7yBHUrac2Pd6NXxz0399PXR5Sfsh+6bGsf6V4SyDML6+NJMpjsxG4KYXz3lfXN57Pg9ffgSe1w5hut+np28LXwreQ6Gwz7e+tZi3tRuiYROget7NpRCG4LJzKj0pFX/1CZEAH/pajELVC2A+UL9rT/CfTJ0gsRgxUjlciUBSrBGn1jc6cSp2oNPdWGvX/RRCva678tUZypDVG6EKN4MaTVZQq94aGs1q3Nyki1uEKHHAhEGC0G4JSatnZO2OqcLdoEavB9Rq949GZ5G0X5OJEOoZ5ZCKhA8Si+BySq4FI7laavLaOVaXNFImW2icqBWqcr6ZOimbYoHsM2kQJSIxl4M0CZdRu91F3MxlpQIqzIjuMqVSarqJQnA5oB5DcRAlInhBhIXAxUkKyFj8Pi3KxMuOw0DKmGFkFiqfUFNQAVSz0Qn13MkhMh8TDYQkhISRnAPRJI2i7OxcCHfzKCtKgBTMI1JuZZQOSUKNivXNjk87AI1sWwqnJALqr6j9DsNUBAA=') format('woff2'); + } +} \ No newline at end of file diff --git a/src/subpackage/common/components/card_search.vue b/src/subpackage/common/components/card_search.vue index aa3011c..2a4b789 100644 --- a/src/subpackage/common/components/card_search.vue +++ b/src/subpackage/common/components/card_search.vue @@ -54,6 +54,7 @@ export default { }, data(){ return { + initData: { /* stadium_id: '', pay_amount: 0 */ }, isShow: false, searchKey: '', cardLs: [], @@ -61,6 +62,10 @@ export default { } }, methods: { + init(data){ + this.initData = { ...data }; + this.show(); + }, // 关闭 hide(){ this.isShow = false; @@ -71,8 +76,9 @@ export default { this.$emit('show'); }, confirmBtn(){ - let { selectedCard } = this; + let { selectedCard, initData } = this; if(!selectedCard?.card_no)return util.showNone('请选择储值卡'); + initData?.success?.(selectedCard); this.hide(); this.$emit('confirm', selectedCard); }, @@ -123,15 +129,12 @@ export default { left: 0; bottom: 0; padding: 46upx 24upx 0upx; - padding-bottom: calc( 0upx + constant(safe-area-inset-bottom)); /* 兼容 iOS < 11.2 */ - padding-bottom: calc( 0upx + env(safe-area-inset-bottom)); /* 兼容 iOS >= 11.2 */ width: 100%; background-color: #fff; + @include isPd(0upx); .cc-tit{ - line-height: 44upx; text-align: center; - font-size: 32upx; - font-weight: 500; + @include flcw(32upx, 44upx, #1a1a1a, 500); } .cc-close{ position: absolute; @@ -149,8 +152,7 @@ export default { .cs-input{ width: 100%; height: 100%; - font-size: 32upx; - color: #1A1A1A; + @include flcw(32upx, 44upx, #1a1a1a); } } .cc-list{ @@ -161,17 +163,15 @@ export default { padding: 20upx; border: 2upx solid #979797; border-radius: 10upx; - @include centerFlex(space-between); + @include ctf(space-between); &:not(:first-child){ margin-top: 24upx; } .ci-content{ flex-grow: 1; .cc-line{ - line-height: 40upx; - font-size: 28upx; - color: #1A1A1A; - @include textHide(1); + @include flcw(28upx, 40upx, #1a1a1a); + @include tHide(1); .cc-txt{ color: #9C9C9F; } @@ -204,12 +204,11 @@ export default { } .cc-btn{ margin-top: 14upx; - line-height: 112upx; text-align: center; - font-size: 32upx; border-radius: 10upx; - background-color: $themeColor; - color: #fff; + background-color: $mColor; + @include flcw(32upx, 112upx, #fff); + } } \ No newline at end of file diff --git a/src/subpackage/common/pages/pay_type_select.vue b/src/subpackage/common/pages/pay_type_select.vue index 78937d3..ab89d2d 100644 --- a/src/subpackage/common/pages/pay_type_select.vue +++ b/src/subpackage/common/pages/pay_type_select.vue @@ -13,40 +13,47 @@ - - 支付方式 - - - - - - {{ e.name || '-' }} - - - - - - - - - - 储值卡卡号:{{ selectedCard.card_no || '-' }} - 使用会员卡支付{{ selectedCard.discount || '-' }}折 - - - 微信昵称:{{ selectedCard.nickname || '-' }} - - - 手机号码:{{ selectedCard.mobile || '-' }} - - - 卡名称:{{ selectedCard.card_name || '-' }} - - - 卡余额:¥{{ selectedCard.balance || '0' }} - - - + + + + + 押金抵扣 + + + + 押金订单号:cs202001101505698956 + 押金金额:¥50元 + 注:押金金额≥实收金额才可支付,扣除费用后剩余押金会原路退回给用户! + + + + + + 储值卡支付 + + + + 使用会员卡支付{{ selectedCard.discount || '-' }}折 + 储值卡卡号:{{ selectedCard.card_no || '-' }} + 微信昵称:{{ selectedCard.nickname || '-' }} + 手机号码:{{ selectedCard.mobile || '-' }} + 卡名称:{{ selectedCard.card_name || '-' }} + 卡余额:¥{{ selectedCard.balance || '0' }} + + + + + + {{ e }} + + + + + + + 其他 + + @@ -73,10 +80,9 @@ import server from '../js/server.js'; import API from '../js/api.js'; import util from '../../../utils/util.js'; import cardSearch from '../components/card_search'; +import { accAdd, accSub, accMul, accDiv } from "@/utils/calculate"; export default { - components: { - 'card-search': cardSearch - }, + components: { 'card-search': cardSearch }, computed: { stadiumInfo(){ return this?.optionsQuery?.stadiumInfo || {}; @@ -87,22 +93,21 @@ export default { discountAmount(){ let { selectedCard, optionsQuery, payAmount, payMethodsID } = this; if(selectedCard?.discount && payMethodsID == 3){ - return Math.floor((optionsQuery?.amount * 100) - (payAmount * 100))/100; + return accSub(optionsQuery?.amount ?? 0, payAmount ?? 0); } return 0; }, payAmount(){ let { selectedCard, optionsQuery, payMethodsID } = this; - if(selectedCard?.discount && payMethodsID == 3){ - return Math.floor((optionsQuery?.amount * 100) * (selectedCard?.discount / 10))/100; + if(selectedCard?.discount && payMethodsID === 3){ + return accMul(optionsQuery?.amount ?? 0, accDiv(selectedCard?.discount ?? 0, 10)); } - return optionsQuery?.amount; + return optionsQuery?.amount ?? 0; } }, data() { return { isCardSelectModal: false, - payMethodsLs: this.getPayMethodsLs(), payMethodsID: 0, optionsQuery: {}, otherTypeRemark: '', @@ -135,13 +140,24 @@ export default { }, submitBtn: util.debounce(function(){ let _type = this.optionsQuery?.type; + // 挂账订单支付提交 if(+_type === 4)return this.takeUpBbocPay(); if(_type !== 4)return this.takeUpSubmit(); }, 300, true), - payMethodsChange(e){ - if(e.id == 3)return this.$refs.cardSearch.show(); - this.payMethodsID = e.id; + payMethodsChange(typeNum){ + let { stadiumInfo, optionsQuery } = this; + // 储值卡 + if(+typeNum === 3)return this.$refs.cardSearch.init({ + stadium_id: stadiumInfo?.id ?? '', + pay_amount: optionsQuery?.amount ?? '', + success: cardRes =>{ + if(!cardRes?.card_no)return this.payMethodsID = 0; + this.selectedCard = cardRes; + this.payMethodsID = 3; + } + }); + this.payMethodsID = +typeNum; }, getPayMethodsLs(){ return [ @@ -224,8 +240,7 @@ export default { padding-bottom: calc( 120rpx + env(safe-area-inset-bottom)); /* 兼容 iOS >= 11.2 */ } .pts-header{ - margin-bottom: 24upx; - padding: 26upx 36upx 110upx; + padding: 26upx 36upx 62upx; background-color: #fff; .ph-stadium-info{ padding-bottom: 34upx; @@ -245,7 +260,7 @@ export default { } } .ph-type-text{ - margin-top: 76upx; + margin-top: 26upx; text-align: center; font-size: 28upx; font-weight: 500; @@ -253,7 +268,7 @@ export default { @include textHide(1); } .ph-price{ - margin-top: 84upx; + margin-top: 28upx; text-align: center; font-size: 80upx; font-weight: 500; @@ -276,108 +291,69 @@ export default { } } } - .pts-container{ - - background-color: #fff; - .pc-tit-bar{ - padding-left: 24upx; - line-height: 72upx; - font-size: 28upx; - color: #9A9A9D; + .pts-content{ + padding: 24upx; + .pc-box{ + padding: 40upx 20upx; + border-radius: 10upx; + background-color: #fff; + &+.pc-box{ + margin-top: 24upx; + } } - .pc-ls{ - padding: 16upx 30upx 0; - .pl-item{ - display: flex; - &:not(:last-child){ - .pi-right{ - border-bottom: 1px solid #D8D8D8; - } - } - >image{ - flex-shrink: 0; - margin-right: 16upx; - width: 54upx; - height: 54upx; - transform: translateY(24upx); - } - .pi-right{ - flex-grow: 1; - .pr-top{ - width: 100%; - height: 102upx; - @include centerFlex(space-between); - .pr-txt{ - flex-shrink: 0; - font-size: 28upx; - color: #181818; - } - .pr-ipt{ - margin-left: 40upx; - margin-right: auto; - padding: 0 16upx; - width: 340upx; - height: 64upx; - border: 2upx solid #D8D8D8; - border-radius: 10upx; - >input{ - width: 100%; - height: 100%; - font-size: 28upx; - color: #181818; - } - } - .pr-icon{ - flex-shrink: 0; - width: 36upx; - height: 36upx; - border-radius: 50%; - border: 2upx solid #aaaaaa; - overflow: hidden; - @include centerFlex(center); - &.active{ - border-color: transparent; - >image{ - visibility: visible; - - } - } - >image{ - visibility: hidden; - display: block; - border: none; - width: 100%; - height: 100%; - } - } - } - .pr-content{ - padding-top: 4upx; - padding-bottom: 30upx; - .pc-line{ - @include centerFlex(flex-start); - .pl-txt{ - line-height: 44upx; - font-size: 24upx; - color: #181818; - @include textHide(1); - } - .pl-tag{ - flex-shrink: 0; - margin-left: 10upx; - padding: 0 6upx; - line-height: 28upx; - font-size: 24upx; - color: #FF873D; - border: 1px solid #FF873D; - border-radius: 4upx; - } - } - } - + .pc-methods-item{ + font-size: 0; + @include ctf; + .pi-icon{ + display: block; + flex-shrink: 0; + width: 44upx; + height: 44upx; + } + .pi-txt{ + margin-left: 20upx; + @include flcw(32upx, 44upx, #1a1a1a); + } + .pi-ipt{ + flex-shrink: 0; + padding: 0 20upx; + margin-left: 40upx; + width: 340upx; + height: 64upx; + border: 2upx solid #D8D8D8; + border-radius: 10upx; + @include flcw(28upx, 1.2em, #181818); + } + @include circleSelected; + .pi-selected{ + flex-shrink: 0; + margin-left: auto; + margin-right: 20upx; + font-size: 36upx; + font-family: circleSelected; + color: $mColor; + } + } + .pc-info{ + margin: 0 auto; + padding: 18upx 46upx; + width: 622upx; + margin-top: 20upx; + background: rgba($color: #70F4D5, $alpha: .1); + .pi-txt{ + @include flcw(24upx, 44upx, #FF801D); + .pt-black{ + @include flcw(24upx, 44upx, #1A1A1A); } } } + .pc-box-succession{ + padding: 10upx 20upx; + .pc-methods-item{ + padding: 30upx 0; + } + } + } .sc-fixed-bot{ position: fixed; @@ -385,20 +361,15 @@ export default { bottom: 0; width: 100%; padding-top: 10upx; - padding-bottom: 10upx; - padding-bottom: calc( 10upx + constant(safe-area-inset-bottom)); /* 兼容 iOS < 11.2 */ - padding-bottom: calc( 10upx + env(safe-area-inset-bottom)); /* 兼容 iOS >= 11.2 */ background-color: #fff; + @include isPd(10upx); .sfb-view{ margin: 0 auto; width: 702upx; - height: 88upx; - line-height: 88upx; text-align: center; - font-size: 32upx; background-color: #FF873D; - color: #fff; - border-radius: 44upx; + border-radius: 10upx; + @include flcw(32upx, 88upx, #fff); } } \ No newline at end of file diff --git a/src/subpackage/common/static/images/ic_0.png b/src/subpackage/common/static/images/ic_0.png deleted file mode 100644 index 2d297ad..0000000 Binary files a/src/subpackage/common/static/images/ic_0.png and /dev/null differ diff --git a/src/subpackage/common/static/images/ic_1.png b/src/subpackage/common/static/images/ic_1.png deleted file mode 100644 index ac4640e..0000000 Binary files a/src/subpackage/common/static/images/ic_1.png and /dev/null differ diff --git a/src/subpackage/common/static/images/ic_2.png b/src/subpackage/common/static/images/ic_2.png deleted file mode 100644 index c95d079..0000000 Binary files a/src/subpackage/common/static/images/ic_2.png and /dev/null differ diff --git a/src/subpackage/common/static/images/ic_3.png b/src/subpackage/common/static/images/ic_3.png deleted file mode 100644 index d077fec..0000000 Binary files a/src/subpackage/common/static/images/ic_3.png and /dev/null differ diff --git a/src/subpackage/common/static/images/ic_4.png b/src/subpackage/common/static/images/ic_4.png deleted file mode 100644 index 1e5fcea..0000000 Binary files a/src/subpackage/common/static/images/ic_4.png and /dev/null differ diff --git a/src/subpackage/common/static/images/pay_types/ic_0.png b/src/subpackage/common/static/images/pay_types/ic_0.png new file mode 100644 index 0000000..ed74f5a Binary files /dev/null and b/src/subpackage/common/static/images/pay_types/ic_0.png differ diff --git a/src/subpackage/common/static/images/pay_types/ic_1.png b/src/subpackage/common/static/images/pay_types/ic_1.png new file mode 100644 index 0000000..4dcc8be Binary files /dev/null and b/src/subpackage/common/static/images/pay_types/ic_1.png differ diff --git a/src/subpackage/common/static/images/pay_types/ic_2.png b/src/subpackage/common/static/images/pay_types/ic_2.png new file mode 100644 index 0000000..95d484e Binary files /dev/null and b/src/subpackage/common/static/images/pay_types/ic_2.png differ diff --git a/src/subpackage/common/static/images/pay_types/ic_3.png b/src/subpackage/common/static/images/pay_types/ic_3.png new file mode 100644 index 0000000..c9e21c7 Binary files /dev/null and b/src/subpackage/common/static/images/pay_types/ic_3.png differ diff --git a/src/subpackage/common/static/images/pay_types/ic_4.png b/src/subpackage/common/static/images/pay_types/ic_4.png new file mode 100644 index 0000000..cfcaccf Binary files /dev/null and b/src/subpackage/common/static/images/pay_types/ic_4.png differ diff --git a/src/subpackage/common/static/images/pay_types/ic_5.png b/src/subpackage/common/static/images/pay_types/ic_5.png new file mode 100644 index 0000000..b151865 Binary files /dev/null and b/src/subpackage/common/static/images/pay_types/ic_5.png differ diff --git a/src/subpackage/order/pages/timekeeping/modules/order_detail/end_billing_modal.vue b/src/subpackage/order/pages/timekeeping/modules/order_detail/end_billing_modal.vue index 214c9ab..bffde41 100644 --- a/src/subpackage/order/pages/timekeeping/modules/order_detail/end_billing_modal.vue +++ b/src/subpackage/order/pages/timekeeping/modules/order_detail/end_billing_modal.vue @@ -13,6 +13,14 @@ + + 支付订单 + + @@ -20,6 +28,7 @@ 停止计时 - *请输入金额 - + 确认 @@ -53,7 +61,7 @@ export default { // duration: '1小时25分9秒', // amount: '¥100.2' }, - end_type: 'end_timing', // end_timing/ end_order + end_type: 'end_timing', // end_timing/ end_order/ pay_timing[md250612 新增] amount: '', initOptions: {} } @@ -71,12 +79,16 @@ export default { this.info.duration = duration || ''; this.info.amount = amount || ''; this.initOptions = opts; + if(amount)this.amount = amount; this.show(); }, async confirmBtn(){ let { end_type, amount, initOptions } = this; // initOptions?.success?.({ type: end_type, amount: +amount || 0 }); // this.hide(); + if(end_type === 'pay_timing')return initOptions?.toPay?.({ + amount: +amount, + }); try{ let { end_type, amount, initOptions } = this; showLoad(); @@ -242,12 +254,6 @@ export default { .ec-amount{ padding-top: 48upx; - .et-name{ - @include flcw(28upx, 48upx, #1A1A1A); - .en-txt{ - color: #EA5061; - } - } .ea-ipt{ margin-top: 8upx; padding: 0 12upx; diff --git a/src/subpackage/order/pages/timekeeping/order_detail/site.vue b/src/subpackage/order/pages/timekeeping/order_detail/site.vue index 8d9d7b9..767de40 100644 --- a/src/subpackage/order/pages/timekeeping/order_detail/site.vue +++ b/src/subpackage/order/pages/timekeeping/order_detail/site.vue @@ -180,7 +180,7 @@ import refundButton from "@/components/order_refund/permission_btn.vue"; import orderRefundModal from '@/components/order_refund/modal.vue'; import orderRefundInfo from '@/components/order_refund/info.vue'; -import { showModal, routeTo } from '@/utils/util'; +import { showModal, routeTo, jsonStr } from '@/utils/util'; import { getOrderDetail, cancelOrderServer, finishOrder, siteAndPeopleRefundServer } from "./common"; export default { components: { @@ -288,6 +288,19 @@ export default { order_no: orderInfo?.order_no }); }, 1000); + }, + toPay: res=>{ + console.log(res); + let _query = { + brand_id: orderInfo?.brand_id ?? '', + amount: res?.amount ?? 0, + stadiumInfo: { + id: orderInfo?.stadium_id, + name: orderInfo?.stadium_name, + logo: orderInfo?.stadium_logo, + }, + }; + routeTo(`/subpackage/common/pages/pay_type_select?query=${jsonStr(_query)}`, 'rT') } }); }, diff --git a/src/uni.scss b/src/uni.scss index 082358c..b2e1efa 100644 --- a/src/uni.scss +++ b/src/uni.scss @@ -1,79 +1,4 @@ -/** - * 这里是uni-app内置的常用样式变量 - * - * uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量 - * 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App - * - */ - -/** - * 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能 - * - * 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件 - */ - -/* 颜色变量 */ - -/* 行为相关颜色 */ -$uni-color-primary: #007aff; -$uni-color-success: #4cd964; -$uni-color-warning: #f0ad4e; -$uni-color-error: #dd524d; - -/* 文字基本颜色 */ -$uni-text-color:#333;//基本色 -$uni-text-color-inverse:#fff;//反色 -$uni-text-color-grey:#999;//辅助灰色,如加载更多的提示信息 -$uni-text-color-placeholder: #808080; -$uni-text-color-disable:#c0c0c0; - -/* 背景颜色 */ -$uni-bg-color:#ffffff; -$uni-bg-color-grey:#f8f8f8; -$uni-bg-color-hover:#f1f1f1;//点击状态颜色 -$uni-bg-color-mask:rgba(0, 0, 0, 0.4);//遮罩颜色 - -/* 边框颜色 */ -$uni-border-color:#c8c7cc; - -/* 尺寸变量 */ - -/* 文字尺寸 */ -$uni-font-size-sm:24rpx; -$uni-font-size-base:28rpx; -$uni-font-size-lg:32rpx; - -/* 图片尺寸 */ -$uni-img-size-sm:40rpx; -$uni-img-size-base:52rpx; -$uni-img-size-lg:80rpx; - -/* Border Radius */ -$uni-border-radius-sm: 4rpx; -$uni-border-radius-base: 6rpx; -$uni-border-radius-lg: 12rpx; -$uni-border-radius-circle: 50%; - -/* 水平间距 */ -$uni-spacing-row-sm: 10px; -$uni-spacing-row-base: 20rpx; -$uni-spacing-row-lg: 30rpx; - -/* 垂直间距 */ -$uni-spacing-col-sm: 8rpx; -$uni-spacing-col-base: 16rpx; -$uni-spacing-col-lg: 24rpx; - -/* 透明度 */ -$uni-opacity-disabled: 0.3; // 组件禁用态的透明度 - -/* 文章场景相关 */ -$uni-color-title: #2C405A; // 文章标题颜色 -$uni-font-size-title:40rpx; -$uni-color-subtitle: #555555; // 二级标题颜色 -$uni-font-size-subtitle:36rpx; -$uni-color-paragraph: #3F536E; // 文章段落颜色 -$uni-font-size-paragraph:30rpx; +@import '~style/iconfonts.scss'; $mColor: #009874; diff --git a/src/utils/calculate.js b/src/utils/calculate.js new file mode 100644 index 0000000..b41a32c --- /dev/null +++ b/src/utils/calculate.js @@ -0,0 +1,81 @@ +/** + * 加法函数 + * @param {number} arg1 数字1 + * @param {number} arg2 数字2 + * @returns {number} 返回两数相加的结果 + * */ +export function accAdd(arg1, arg2) { + var r1, r2, m, c; + try { r1 = arg1.toString().split(".")[1].length; }catch (e) { r1 = 0 }; + try { r2 = arg2.toString().split(".")[1].length }catch (e) { r2 = 0 }; + c = Math.abs(r1 - r2); + m = Math.pow(10, Math.max(r1, r2)); + if (c > 0) { + var cm = Math.pow(10, c); + if (r1 > r2) { + arg1 = Number(arg1.toString().replace(".", "")); + arg2 = Number(arg2.toString().replace(".", "")) * cm; + }else { + arg1 = Number(arg1.toString().replace(".", "")) * cm; + arg2 = Number(arg2.toString().replace(".", "")); + } + }else { + arg1 = Number(arg1.toString().replace(".", "")); + arg2 = Number(arg2.toString().replace(".", "")); + } + return (arg1 + arg2) / m; +} + +/** + * 减法函数 + * @param {number} arg1 数字1 + * @param {number} arg2 数字2 + * @returns {number} 返回两数相减的结果 + * +*/ +export function accSub(arg1, arg2) { + var r1, r2, m, n; + try { r1 = arg1.toString().split(".")[1].length }catch (e) { r1 = 0 }; + try { r2 = arg2.toString().split(".")[1].length }catch (e) { r2 = 0 }; + + m = Math.pow(10, Math.max(r1, r2)); //last modify by deeka //动态控制精度长度 + n = (r1 >= r2) ? r1 : r2; + return ((arg1 * m - arg2 * m) / m).toFixed(n); +} + +/** + * 乘法函数 + * @param {number} arg1 数字1 + * @param {number} arg2 数字2 + * @returns {number} 返回两数相乘的结果 + * +*/ +export function accMul(arg1, arg2) { + var m = 0, s1 = arg1.toString(), s2 = arg2.toString(); + try { m += s1.split(".")[1].length }catch (e) { }; + try { m += s2.split(".")[1].length }catch (e) { }; + + return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m); +} + +/** + * 除法函数 + * @param {number} arg1 数字1 + * @param {number} arg2 数字2 + * @param {number} precision 数字2 + * + * @returns {number} 返回两数相除的结果 + * +*/ +export function accDiv(arg1, arg2, precision = 10) { + var t1 = 0, t2 = 0, r1, r2; + try { t1 = arg1.toString().split(".")[1].length } catch (e) { } + try { t2 = arg2.toString().split(".")[1].length } catch (e) { } + + r1 = Number(arg1.toString().replace(".", "")); + r2 = Number(arg2.toString().replace(".", "")); + const result = (r1 / r2) * Math.pow(10, t2 - t1); + + // 使用四舍五入控制精度 + return parseFloat(result.toFixed(precision)); +}