"use strict"; const common_vendor = require("../../common/vendor.js"); const utils_tabbarI18n = require("../../utils/tabbar-i18n.js"); const modules_api_AppServer = require("../../modules/api/AppServer.js"); const modules_Config = require("../../modules/Config.js"); const utils_auth = require("../../utils/auth.js"); const _sfc_main = { data() { return { currentIndex: 0, currentCategoryKey: null, categories: [], services: [], loading: false, currentLanguage: "zh" }; }, onLoad() { this.currentLanguage = common_vendor.index.getStorageSync("language") || "zh"; this.loadCategories(); }, onShow() { utils_tabbarI18n.updateTabBarI18n(this); this.checkUnreadNotifications(); }, methods: { // 加载分类列表 async loadCategories() { try { const appserver = new modules_api_AppServer.AppServer(); const response = await appserver.GetCategories({ language: this.currentLanguage }); common_vendor.index.__f__("log", "at pages/appointment/appointment-page.vue:102", "分类列表响应:", response); if (response.code === 0 && response.data) { this.categories = response.data.categories || response.data || []; if (this.categories.length > 0) { this.currentIndex = 0; this.currentCategoryKey = this.categories[0].key; this.loadServices(this.currentCategoryKey); } } else { common_vendor.index.__f__("error", "at pages/appointment/appointment-page.vue:114", "获取分类失败:", response.message); common_vendor.index.showToast({ title: response.message || "获取分类失败", icon: "none" }); } } catch (error) { common_vendor.index.__f__("error", "at pages/appointment/appointment-page.vue:121", "加载分类异常:", error); common_vendor.index.showToast({ title: "加载分类失败", icon: "none" }); } }, // 加载服务列表 async loadServices(categoryKey) { this.loading = true; try { const appserver = new modules_api_AppServer.AppServer(); const params = { language: this.currentLanguage }; if (categoryKey) { params.categoryKey = categoryKey; } const response = await appserver.GetServices(params); common_vendor.index.__f__("log", "at pages/appointment/appointment-page.vue:143", "服务列表响应:", response); if (response.code === 0 && response.data) { this.services = response.data.services || response.data || []; } else { common_vendor.index.__f__("error", "at pages/appointment/appointment-page.vue:148", "获取服务失败:", response.message); this.services = []; } } catch (error) { common_vendor.index.__f__("error", "at pages/appointment/appointment-page.vue:152", "加载服务异常:", error); this.services = []; } finally { this.loading = false; } }, // 点击分类 clickType(index, categoryKey) { this.currentIndex = index; this.currentCategoryKey = categoryKey; this.loadServices(categoryKey); }, // 获取分类名称(根据当前语言) getCategoryName(category) { if (!category) return ""; return category.name || ""; }, // 获取服务名称(根据当前语言) getServiceName(service) { if (!service) return ""; return service.title || ""; }, // 获取完整的图片 URL getImageUrl(imagePath) { if (!imagePath) return ""; if (imagePath.startsWith("http")) return imagePath; const baseUrl = modules_Config.Config.API_BASE_URL || "http://localhost:3000"; return `${baseUrl}${imagePath}`; }, // 根据服务类型跳转到对应的预约填写页面 goToServiceDetail(service) { const servicePageMap = { "flight": "airfare-info-entry-page", "hotel": "hotel-reservation-page", "lounge": "vip-lounge-page", "airport_transfer": "airport-transfer-page", "unaccompanied_minor": "unaccompanied-minor-page", "rail_ticket": "rail-ticket-page", "medical_consultation": "medical-consultation-page", "special_passenger": "special-needs-page", "pet_transportation": "pet-transportation-page", "guide_translation": "guide-translation-page", "visa_consultation": "visa-consultation-page", "exhibition_service": "exhibition-service-page", "air_logistics": "air-logistics-page", "sea_freight": "sea-freight-page", "travel_planning": "travel-planning-page", "insurance_consultation": "insurance-consultation-page" }; const serviceType = service.serviceType; const pageName = servicePageMap[serviceType]; if (pageName) { const title = this.getServiceName(service); common_vendor.index.navigateTo({ url: `/pages/appointment/${pageName}?id=${service.id}&title=${encodeURIComponent(title)}` }); } else { common_vendor.index.showToast({ title: this.$t("common.serviceNotAvailable") || "该服务暂未开放预约", icon: "none" }); } }, // 处理图片加载错误 handleImageError(service) { common_vendor.index.__f__("error", "at pages/appointment/appointment-page.vue:230", "图片加载失败:", service.image); service.image = null; }, // 检查未读通知并更新TabBar红点 async checkUnreadNotifications() { if (!utils_auth.isLoggedIn()) { common_vendor.index.removeTabBarBadge({ index: 2 }); return; } try { const appserver = new modules_api_AppServer.AppServer(); const response = await appserver.GetNotificationUnreadCount(); if (response.code === 0 && response.data) { const unreadCount = response.data.all || 0; if (unreadCount > 0) { common_vendor.index.setTabBarBadge({ index: 2, text: unreadCount > 99 ? "99+" : String(unreadCount) }); } else { common_vendor.index.removeTabBarBadge({ index: 2 }); } } } catch (error) { common_vendor.index.__f__("error", "at pages/appointment/appointment-page.vue:256", "检查未读通知失败:", error); } } } }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return common_vendor.e({ a: common_vendor.t(_ctx.$t("appointment.allServices")), b: common_vendor.f($data.categories, (category, index, i0) => { return common_vendor.e({ a: $data.currentIndex === index }, $data.currentIndex === index ? {} : {}, { b: common_vendor.t($options.getCategoryName(category)), c: category.key, d: common_vendor.o(($event) => $options.clickType(index, category.key), category.key), e: $data.currentIndex === index ? 1 : "" }); }), c: $data.loading }, $data.loading ? { d: common_vendor.t(_ctx.$t("common.loading") || "加载中...") } : $data.services.length > 0 ? { f: common_vendor.f($data.services, (service, k0, i0) => { return common_vendor.e({ a: service.image }, service.image ? { b: $options.getImageUrl(service.image), c: common_vendor.o(($event) => $options.handleImageError(service), service.key) } : {}, { d: common_vendor.t($options.getServiceName(service)), e: service.key, f: common_vendor.o(($event) => $options.goToServiceDetail(service), service.key) }); }) } : { g: common_vendor.t(_ctx.$t("common.noData") || "暂无服务") }, { e: $data.services.length > 0 }); } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/appointment/appointment-page.js.map