123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- const pages_api_ai = require("../api/ai.js");
- const _sfc_main = {
- data() {
- return {
- formData: {
- userId: "user_123",
- // 模拟用户ID
- destination: "保定",
- days: 3,
- budget: 3e3,
- season: "春季",
- preferences: ["景点", "美食"],
- transportation: "公共交通",
- accommodation: "经济型酒店",
- includeTransportation: true,
- includeMeals: true,
- includeTickets: true
- },
- seasons: ["春季", "夏季", "秋季", "冬季", "四季皆宜"],
- preferences: ["景点", "美食", "文化", "购物", "自然", "摄影", "历史", "休闲"],
- transportations: ["公共交通", "自驾", "步行", "共享单车", "出租车"],
- accommodations: ["经济型酒店", "舒适型酒店", "豪华酒店", "民宿", "青旅"]
- };
- },
- methods: {
- goBack() {
- common_vendor.index.navigateBack();
- },
- onDaysChange(e) {
- this.formData.days = e.detail.value;
- },
- onBudgetChange(e) {
- this.formData.budget = e.detail.value;
- },
- togglePreference(preference) {
- const index = this.formData.preferences.indexOf(preference);
- if (index > -1) {
- this.formData.preferences.splice(index, 1);
- } else {
- if (this.formData.preferences.length < 5) {
- this.formData.preferences.push(preference);
- } else {
- common_vendor.index.showToast({
- title: "最多选择5个偏好",
- icon: "none"
- });
- }
- }
- },
- resetForm() {
- this.formData = {
- userId: "user_123",
- destination: "保定",
- days: 3,
- budget: 3e3,
- season: "春季",
- preferences: ["景点", "美食"],
- transportation: "公共交通",
- accommodation: "经济型酒店",
- includeTransportation: true,
- includeMeals: true,
- includeTickets: true
- };
- },
- generatePlan() {
- if (!this.formData.destination) {
- common_vendor.index.showToast({
- title: "请输入目的地",
- icon: "none"
- });
- return;
- }
- if (this.formData.preferences.length === 0) {
- common_vendor.index.showToast({
- title: "请至少选择一个偏好",
- icon: "none"
- });
- return;
- }
- common_vendor.index.showLoading({
- title: "正在生成行程..."
- });
- pages_api_ai.generateAIPlan(this.formData).then((res) => {
- common_vendor.index.hideLoading();
- common_vendor.index.__f__("log", "at pages/ai-assistant/simple.vue:208", "AI响应:", res);
- if (res && res.data) {
- pages_api_ai.saveAIPlan(this.formData).then((saveRes) => {
- common_vendor.index.__f__("log", "at pages/ai-assistant/simple.vue:214", "保存行程成功:", saveRes);
- common_vendor.index.navigateTo({
- url: `/pages/travel-detail/index?planId=${saveRes.data.planId}`
- });
- }).catch((err) => {
- common_vendor.index.__f__("error", "at pages/ai-assistant/simple.vue:222", "保存行程失败:", err);
- common_vendor.index.showModal({
- title: "保存失败",
- content: "行程已生成但保存失败,请重试",
- showCancel: false
- });
- });
- } else {
- common_vendor.index.showModal({
- title: "生成失败",
- content: "无法生成行程,请稍后再试",
- showCancel: false
- });
- }
- }).catch((err) => {
- common_vendor.index.hideLoading();
- common_vendor.index.__f__("error", "at pages/ai-assistant/simple.vue:239", "生成行程失败:", err);
- common_vendor.index.showModal({
- title: "生成失败",
- content: "无法连接服务器,请检查网络连接",
- showCancel: false
- });
- });
- }
- }
- };
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
- return {
- a: common_vendor.o((...args) => $options.goBack && $options.goBack(...args)),
- b: $data.formData.destination,
- c: common_vendor.o(($event) => $data.formData.destination = $event.detail.value),
- d: $data.formData.days,
- e: common_vendor.o((...args) => $options.onDaysChange && $options.onDaysChange(...args)),
- f: $data.formData.budget,
- g: common_vendor.o((...args) => $options.onBudgetChange && $options.onBudgetChange(...args)),
- h: common_vendor.t($data.formData.budget),
- i: common_vendor.f($data.seasons, (season, index, i0) => {
- return {
- a: common_vendor.t(season),
- b: index,
- c: $data.formData.season === season ? 1 : "",
- d: common_vendor.o(($event) => $data.formData.season = season, index)
- };
- }),
- j: common_vendor.f($data.preferences, (preference, index, i0) => {
- return {
- a: common_vendor.t(preference),
- b: index,
- c: $data.formData.preferences.includes(preference) ? 1 : "",
- d: common_vendor.o(($event) => $options.togglePreference(preference), index)
- };
- }),
- k: common_vendor.f($data.transportations, (transport, index, i0) => {
- return {
- a: common_vendor.t(transport),
- b: index,
- c: $data.formData.transportation === transport ? 1 : "",
- d: common_vendor.o(($event) => $data.formData.transportation = transport, index)
- };
- }),
- l: common_vendor.f($data.accommodations, (accom, index, i0) => {
- return {
- a: common_vendor.t(accom),
- b: index,
- c: $data.formData.accommodation === accom ? 1 : "",
- d: common_vendor.o(($event) => $data.formData.accommodation = accom, index)
- };
- }),
- m: $data.formData.includeTransportation,
- n: common_vendor.o(($event) => $data.formData.includeTransportation = $event.detail.value),
- o: $data.formData.includeMeals,
- p: common_vendor.o(($event) => $data.formData.includeMeals = $event.detail.value),
- q: $data.formData.includeTickets,
- r: common_vendor.o(($event) => $data.formData.includeTickets = $event.detail.value),
- s: common_vendor.o((...args) => $options.resetForm && $options.resetForm(...args)),
- t: common_vendor.o((...args) => $options.generatePlan && $options.generatePlan(...args))
- };
- }
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
- wx.createPage(MiniProgramPage);
- //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/ai-assistant/simple.js.map
|