calculatePrice.js 437 B

123456789101112131415
  1. import currency from "../../../utils/currency";
  2. let CNY = value => currency(value, {
  3. symbol: "¥",
  4. precision: 2
  5. }).format();
  6. function getPrice(price, w, l, divide) {
  7. return CNY(CNY(currency(price).multiply(w).multiply(l).divide(divide)))
  8. }
  9. module.exports = {
  10. getItem: (item, showname = 'showPrice', pname = 'price', divide = 1000000) => {
  11. item[showname] = getPrice(item[pname], item.width, item.length, divide)
  12. return item
  13. }
  14. }