Greasy Fork is available in English.

getPrice

计算价格

สคริปต์นี้ไม่ควรถูกติดตั้งโดยตรง มันเป็นคลังสำหรับสคริปต์อื่น ๆ เพื่อบรรจุด้วยคำสั่งเมทา // @require https://update.greasyfork.org/scripts/485233/1392910/getPrice.js

  const defaultRate = 7;
  const defaultShippingCost = 70;

  function getPrice(cost, weight) {
    if (cost > 300) {
      alert('价格太高,请自行计算!');
      return 0;
    }
    let proRate = 0;
    if (cost <= 50) {
      proRate = 0.45;
    }
    if (cost <= 100 && cost > 50) {
      proRate = 0.375;
    }
    if (cost <= 200 && cost > 100) {
      proRate = 0.275;
    }
    if (cost <= 300 && cost > 200) {
      proRate = 0.325;
    }
    const rate = defaultRate * 0.92;
    const shippingCost = defaultShippingCost + 10;
    if (weight !== 0) {
      const price = (cost + cost * proRate + weight * shippingCost) / rate;
      return Math.ceil(price);
    }
    return 0;
  }