计算价格
이 스크립트는 직접 설치하는 용도가 아닙니다. 다른 스크립트에서 메타 지시문 // @require https://updategf.qytechs.cn/scripts/485233/1451841/getPrice.js을(를) 사용하여 포함하는 라이브러리입니다.
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;
}