fix(marketing): تصحيح حاسبة التوفير ونسبة GMV لباقة النمو

- باقة النمو صارت شريحتين: 2% حتى $50k ثم 1.5% حتى $200k (كانت 2% حتى
  $200k)، محدَّثة في الخمس لغات
- مقارنة المنافس صارت 15% من GMV مع حدّ أدنى $0.10 للرحلة، بدل 10%/5%
- استُخرجت tripzMonthly كدالة مستقلة، وأُضيفت crossoverTripsPerDay
- تُعرض الآن نقطة التعادل تحت رقم التوفير، وكذلك حين لا يوجد توفير بعد

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Hamza-Ayed
2026-08-04 21:21:34 +03:00
co-authored by Claude Opus 5
parent 69da4abc01
commit 0de8573d27
3 changed files with 69 additions and 26 deletions
+63 -21
View File
@@ -27,16 +27,7 @@ function buildCalcDropdowns(){
curSel.value=curVal;planSel.value=planVal;
}
function calc(){
const trips=+$("#trips").value;
const fare=+$("#fare").value||0;
const [curCode, rate]=$("#cur").value.split(":");
const [baseVal, gmvVal, minVal, pKey]=$("#plan").value.split(":");
const base = +baseVal, minRate = +minVal;
const usd = fare * (+rate);
const monthlyTrips = trips * 30;
const gmv = monthlyTrips * usd;
function tripzMonthly(base, pKey, gmv, monthlyTrips, minRate){
let gmvFee;
if(pKey === "launch"){
if(gmv <= 50000) gmvFee = gmv * 0.025;
@@ -49,25 +40,76 @@ function calc(){
} else {
gmvFee = gmv * 0.01;
}
const minMonthly = monthlyTrips * minRate;
const tripz = base + Math.max(minMonthly, gmvFee);
const commission = monthlyTrips * 0.10;
const floor = monthlyTrips * 0.05;
return base + Math.max(minMonthly, gmvFee);
}
function crossoverTripsPerDay(base, pKey, minRate, usd){
for(let t = 1; t <= 10000; t++){
const mTrips = t * 30;
const gmv = mTrips * usd;
const tMonthly = tripzMonthly(base, pKey, gmv, mTrips, minRate);
const cMonthly = Math.max(gmv * 0.15, mTrips * 0.10);
if(cMonthly >= tMonthly){
return t;
}
}
return null;
}
function calc(){
const trips=+$("#trips").value;
const fare=+$("#fare").value||0;
const [curCode, rate]=$("#cur").value.split(":");
const [baseVal, gmvVal, minVal, pKey]=$("#plan").value.split(":");
const base = +baseVal, minRate = +minVal;
const usd = fare * (+rate);
const monthlyTrips = trips * 30;
const gmv = monthlyTrips * usd;
const tripz = tripzMonthly(base, pKey, gmv, monthlyTrips, minRate);
const commission = gmv * 0.15;
const floor = monthlyTrips * 0.10;
$("#rTripz").textContent = fmt(tripz);
$("#rComm").textContent = fmt(commission);
$("#rFloor").textContent = fmt(floor);
const save = Math.max(commission, floor) - tripz;
const rivalMax = Math.max(commission, floor);
const save = rivalMax - tripz;
const bigEl = $("#saveBig");
bigEl.textContent = (save > 0 ? fmt(save * 12) : "$0") + "/yr";
const noteEl = $("#saveNote");
const crossover = crossoverTripsPerDay(base, pKey, minRate, usd);
if(save > 0){
bigEl.textContent = fmt(save * 12) + "/yr";
if(noteEl){
noteEl.style.display = "block";
const crossTxt = (I18N[LANG] && I18N[LANG]["calc.r.crossover"])
? I18N[LANG]["calc.r.crossover"].replace("{n}", crossover || 101)
: (LANG === "ar" ? `نقطة التعادل والتوفير تبدأ من ${crossover || 101} رحلة/يومياً` : `Break-even and real savings start at ${crossover || 101} trips/day`);
noteEl.textContent = crossTxt;
}
} else {
bigEl.textContent = "$0/yr";
if(noteEl){
noteEl.style.display = "block";
const crossTxt = (I18N[LANG] && I18N[LANG]["calc.r.crossover"])
? I18N[LANG]["calc.r.crossover"].replace("{n}", crossover || 101)
: (LANG === "ar" ? `تبدأ بالربح والتوفير مع Tripz عند وصولك لـ ${crossover || 101} رحلة/يومياً` : `You start saving with Tripz once you reach ${crossover || 101} trips/day`);
noteEl.textContent = crossTxt;
}
}
const sv = $("#savings"); sv.classList.remove("bump"); void sv.offsetWidth; sv.classList.add("bump");
const pct = ((trips - 50) / (5000 - 50)) * 100;
$("#trips").style.setProperty("--p", pct + "%");
const tripsEl = $("#trips");
const minTrips = +tripsEl.min || 50;
const maxTrips = +tripsEl.max || 5000;
const pct = ((trips - minTrips) / (maxTrips - minTrips)) * 100;
tripsEl.style.setProperty("--p", pct + "%");
$("#tripsVal").textContent = trips.toLocaleString("en-US") + " / day";
const msg = encodeURIComponent(`Tripz — ${I18N[LANG]["calc.r.savecap"]}: ${bigEl.textContent} | ${trips}/day @ ${fare} ${curCode}`);
$("#waCalc").href = "https://wa.me/201023248456?text=" + msg;
}