Greasy Fork 还支持 简体中文。

getPrice

计算价格

Verze ze dne 22. 09. 2024. Zobrazit nejnovější verzi.

Tento skript by neměl být instalován přímo. Jedná se o knihovnu, kterou by měly jiné skripty využívat pomocí meta příkazu // @require https://updategf.qytechs.cn/scripts/485233/1451841/getPrice.js

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

  const defaultRate = 6.85;
  const defaultShippingCost = 80;

  function getPrice(cost, weight) {
    if (cost > 350) {
      alert('价格太高,请自行计算!');
      return 0;
    }
    let proRate = 0;
    if (cost <= 50) {
      proRate = 0.5;
    }
    if (cost <= 100 && cost > 50) {
      proRate = 0.4;
    }
    if (cost <= 250 && cost > 100) {
      proRate = 0.32;
    }
    if (cost <= 350 && cost > 250) {
      proRate = 0.35;
    }
    const rate = defaultRate * 0.944 * 0.985;
    const shippingCost = defaultShippingCost + 10;
    if (weight !== 0) {
      const price = (cost + cost * proRate + weight * shippingCost) / rate;
      return Math.ceil(price);
    }
    return 0;
  }