diff --git a/src/utils/util.js b/src/utils/util.js index bfee989..32c39b2 100644 --- a/src/utils/util.js +++ b/src/utils/util.js @@ -16,7 +16,11 @@ export const setCookies = (key, val, cookieExpires) => { export const getCookies = key => { return Cookies.get(key); }; - +// 保留两位小数; +// num +export function toFixedNoRounding(num) { + return Math.floor(num * 100) / 100; +} export const removeCookies = key => { return Cookies.remove(key); }; diff --git a/src/views/product/addProduct/index.vue b/src/views/product/addProduct/index.vue index 6950cb1..69910ba 100644 --- a/src/views/product/addProduct/index.vue +++ b/src/views/product/addProduct/index.vue @@ -2074,7 +2074,7 @@ import { getToken } from '@/utils/auth' import taoBao from './taoBao' import copyRecord from './copyRecord' import addCarMy from './addCarMy' - +import { toFixedNoRounding } from '@/utils/util' const defaultObj = { image: '', refund_switch: 1, @@ -2716,7 +2716,7 @@ export default { }, // 占比值变化处理 proportionChange(val,i,e){ - val.cost = (val.price * e).toFixed(2) + val.cost = toFixedNoRounding(val.price * e) let obj = this.proportionList.find(item=>item.value==e) val.coupon = Math.floor(val.price*obj.coupon) val.growth = Math.floor(val.price*obj.growth) @@ -2724,11 +2724,11 @@ export default { // 规格值变化 handleCost(val,i,e,type){ if(type == 'batchAdd'){ - i=='price'?val.cost = (val.price * 0.6).toFixed(2):'' + i=='price'?val.cost = toFixedNoRounding(val.price * 0.6):'' } if(i=='price'){ val.price=val.price.replace(/^([0-9-]\d*\.?\d{0,2})?.*$/,'$1') - val.cost = (e * val.proportion).toFixed(2) + val.cost = toFixedNoRounding(e * val.proportion) let obj = this.proportionList.find(item=>item.value==val.proportion) val.coupon = Math.floor(val.price*obj.coupon) diff --git a/src/views/product/productList/proDetails.vue b/src/views/product/productList/proDetails.vue index 5ec79d8..7de6358 100644 --- a/src/views/product/productList/proDetails.vue +++ b/src/views/product/productList/proDetails.vue @@ -165,7 +165,7 @@ - + - +