app.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. "use strict";
  2. Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
  3. const common_vendor = require("./common/vendor.js");
  4. const util_api = require("./util/api.js");
  5. if (!Math) {
  6. "./pages/index/index.js";
  7. "./pages/user/index.js";
  8. "./pages/planning/index.js";
  9. "./pages/info/index.js";
  10. "./pages/ai-assistant/index.js";
  11. "./pages/ai-assistant/simple.js";
  12. "./pages/custom-trip/map.js";
  13. "./pages/custom-trip/plan-detail.js";
  14. "./pages/planning/all-trips.js";
  15. "./pages/travel-detail/index.js";
  16. }
  17. const _sfc_main = {
  18. globalData: {
  19. schemeUrl: null
  20. },
  21. onLaunch: function(options) {
  22. common_vendor.index.__f__("log", "at App.vue:7", "App Launch", options);
  23. this.handleSchemeUrl(options);
  24. },
  25. onShow: function(options) {
  26. common_vendor.index.__f__("log", "at App.vue:12", "App Show", options);
  27. this.handleSchemeUrl(options);
  28. },
  29. onHide: function() {
  30. common_vendor.index.__f__("log", "at App.vue:17", "App Hide");
  31. },
  32. methods: {
  33. // 处理URL Scheme
  34. handleSchemeUrl(options) {
  35. try {
  36. common_vendor.index.__f__("log", "at App.vue:23", "检查URL Scheme启动参数:", options);
  37. let schemeUrl = "";
  38. if (options && options.query && options.query.url) {
  39. schemeUrl = decodeURIComponent(options.query.url);
  40. } else if (options && options.path && options.query) {
  41. schemeUrl = options.path + "?" + Object.keys(options.query).map((key) => {
  42. return key + "=" + options.query[key];
  43. }).join("&");
  44. } else if (options && options.scene) {
  45. schemeUrl = decodeURIComponent(options.scene);
  46. } else if (common_vendor.index.getEnv && common_vendor.index.getEnv().uniPlatform === "app-plus") {
  47. if (options && options.arguments) {
  48. if (typeof options.arguments === "string") {
  49. if (options.arguments.indexOf("traveler://") === 0) {
  50. schemeUrl = options.arguments;
  51. }
  52. } else if (options.arguments.data && typeof options.arguments.data === "string") {
  53. schemeUrl = options.arguments.data;
  54. }
  55. }
  56. }
  57. if (schemeUrl && schemeUrl.indexOf("traveler://") === 0) {
  58. common_vendor.index.__f__("log", "at App.vue:56", "发现URL Scheme:", schemeUrl);
  59. this.globalData.schemeUrl = schemeUrl;
  60. this.parseSchemeUrl(schemeUrl);
  61. }
  62. } catch (e) {
  63. common_vendor.index.__f__("error", "at App.vue:61", "处理URL Scheme出错:", e);
  64. }
  65. },
  66. // 解析URL Scheme并执行相应操作
  67. parseSchemeUrl(url) {
  68. try {
  69. const path = url.replace("traveler://", "");
  70. const [routePath, paramStr] = path.split("?");
  71. const params = {};
  72. if (paramStr) {
  73. paramStr.split("&").forEach((item) => {
  74. const [key, value] = item.split("=");
  75. if (key && value) {
  76. params[key] = decodeURIComponent(value);
  77. }
  78. });
  79. }
  80. common_vendor.index.__f__("log", "at App.vue:85", "解析URL Scheme:", routePath, params);
  81. switch (routePath) {
  82. case "trip/detail":
  83. case "trip":
  84. if (params.id) {
  85. common_vendor.index.__f__("log", "at App.vue:93", "准备跳转到行程详情页:", params.id);
  86. setTimeout(() => {
  87. common_vendor.index.navigateTo({
  88. url: "/pages/travel-detail/index?planId=" + params.id,
  89. success: () => {
  90. common_vendor.index.__f__("log", "at App.vue:100", "成功跳转到行程详情页");
  91. },
  92. fail: (err) => {
  93. common_vendor.index.__f__("error", "at App.vue:103", "跳转失败:", err);
  94. common_vendor.index.switchTab({
  95. url: "/pages/planning/index",
  96. success: () => {
  97. common_vendor.index.$emit("loadTripDetail", { tripId: params.id });
  98. }
  99. });
  100. }
  101. });
  102. }, 1e3);
  103. } else if (params.name && params.days && params.budget) {
  104. const tempTrip = {
  105. id: "temp_" + Date.now(),
  106. name: params.name,
  107. days: params.days,
  108. budget: params.budget,
  109. startDate: params.startDate || (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
  110. peopleCount: params.peopleCount || 1
  111. };
  112. const savedTrips = common_vendor.index.getStorageSync("savedTrips") || [];
  113. savedTrips.push(tempTrip);
  114. common_vendor.index.setStorageSync("savedTrips", savedTrips);
  115. setTimeout(() => {
  116. common_vendor.index.navigateTo({
  117. url: "/pages/travel-detail/index?planId=" + tempTrip.id
  118. });
  119. }, 1e3);
  120. }
  121. break;
  122. default:
  123. common_vendor.index.__f__("log", "at App.vue:142", "未知的URL Scheme路径:", routePath);
  124. setTimeout(() => {
  125. common_vendor.index.switchTab({
  126. url: "/pages/index/index"
  127. });
  128. }, 1e3);
  129. break;
  130. }
  131. } catch (e) {
  132. common_vendor.index.__f__("error", "at App.vue:153", "解析URL Scheme出错:", e);
  133. }
  134. }
  135. }
  136. };
  137. const tabBarMidButtonEventCallbacksVue3 = [];
  138. common_vendor.index.onTabBarMidButtonTap = function() {
  139. tabBarMidButtonEventCallbacksVue3.forEach((callback) => {
  140. callback();
  141. });
  142. };
  143. function createApp() {
  144. const app = common_vendor.createSSRApp(_sfc_main);
  145. app.config.globalProperties.$onTabBarMidButtonTap = function(callback) {
  146. tabBarMidButtonEventCallbacksVue3.push(callback);
  147. };
  148. app.config.globalProperties.$api = util_api.API;
  149. app.config.globalProperties.$baseUrl = util_api.BASE_URL;
  150. return {
  151. app
  152. };
  153. }
  154. createApp().app.mount("#app");
  155. exports.createApp = createApp;
  156. //# sourceMappingURL=../.sourcemap/mp-weixin/app.js.map