target_logic.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. }
  36. /**
  37. * 目标首页跳转逻辑
  38. * Centralized logic for target index page selection
  39. */
  40. function getTargetIndex() {
  41. const indexPages = [
  42. 'index-ori.html',
  43. 'index-style3.html',
  44. 'index-style4.html',
  45. 'index-style5.html',
  46. 'index-style6.html',
  47. 'index-style7.html',
  48. 'index-style8.html'
  49. ];
  50. const randomIndex = Math.floor(Math.random() * indexPages.length);
  51. return indexPages[randomIndex];
  52. }