target_logic.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. * 目标详情页跳转逻辑
  3. * Centralized logic for target detail page selection
  4. */
  5. function getTargetDetail() {
  6. // 1. Date Check (Holidays) - Top Priority
  7. const now = new Date();
  8. const month = now.getMonth() + 1; // 1-12
  9. const date = now.getDate();
  10. // Christmas: Dec 18 - Dec 31
  11. if (month === 12 && date >= 18) {
  12. return 'detail-christmas.html';
  13. }
  14. // New Year: Jan 1 - Jan 7
  15. if (month === 1 && date <= 7) {
  16. // 增加一点随机性:50% 概率看普通元旦,50% 看烟花版
  17. return Math.random() < 0.5 ? 'detail-newyear.html' : 'detail-newyear-fireworks.html';
  18. }
  19. // 2. Random Logic for Regular Days
  20. // 50% Chance for default detail.html
  21. if (Math.random() < 0.5) {
  22. return 'detail.html';
  23. }
  24. // 3. 50% Chance for other random weather/seasonal cards
  25. const others = [
  26. 'detail-cloud.html',
  27. 'detail-rain.html',
  28. 'detail-snow.html',
  29. 'detail-sun.html',
  30. 'detail-windy.html'
  31. ];
  32. // Random selection from the pool
  33. const randomIndex = Math.floor(Math.random() * others.length);
  34. return others[randomIndex];
  35. }