"use strict"; const common_vendor = require("../../common/vendor.js"); const api_index = require("../../api/index.js"); const utils_config = require("../../utils/config.js"); if (!Array) { const _easycom_nav_bar_1 = common_vendor.resolveComponent("nav-bar"); const _easycom_service_card_1 = common_vendor.resolveComponent("service-card"); const _easycom_section_header_1 = common_vendor.resolveComponent("section-header"); const _easycom_case_card_1 = common_vendor.resolveComponent("case-card"); (_easycom_nav_bar_1 + _easycom_service_card_1 + _easycom_section_header_1 + _easycom_case_card_1)(); } const _easycom_nav_bar = () => "../../components/nav-bar/nav-bar.js"; const _easycom_service_card = () => "../../components/service-card/service-card.js"; const _easycom_section_header = () => "../../components/section-header/section-header.js"; const _easycom_case_card = () => "../../components/case-card/case-card.js"; if (!Math) { (_easycom_nav_bar + _easycom_service_card + _easycom_section_header + _easycom_case_card)(); } class BannerItem extends UTS.UTSType { static get$UTSMetadata$() { return { kind: 2, get fields() { return { id: { type: String, optional: false }, image: { type: String, optional: false }, title: { type: String, optional: false }, link: { type: String, optional: false } }; }, name: "BannerItem" }; } constructor(options, metadata = BannerItem.get$UTSMetadata$(), isJSONParse = false) { super(); this.__props__ = UTS.UTSType.initProps(options, metadata, isJSONParse); this.id = this.__props__.id; this.image = this.__props__.image; this.title = this.__props__.title; this.link = this.__props__.link; delete this.__props__; } } class CaseItem extends UTS.UTSType { static get$UTSMetadata$() { return { kind: 2, get fields() { return { id: { type: String, optional: false }, title: { type: String, optional: false }, category: { type: String, optional: false }, categoryName: { type: String, optional: false }, coverImage: { type: String, optional: false }, material: { type: String, optional: false }, duration: { type: String, optional: false }, price: { type: String, optional: false }, views: { type: Number, optional: false }, likes: { type: Number, optional: false } }; }, name: "CaseItem" }; } constructor(options, metadata = CaseItem.get$UTSMetadata$(), isJSONParse = false) { super(); this.__props__ = UTS.UTSType.initProps(options, metadata, isJSONParse); this.id = this.__props__.id; this.title = this.__props__.title; this.category = this.__props__.category; this.categoryName = this.__props__.categoryName; this.coverImage = this.__props__.coverImage; this.material = this.__props__.material; this.duration = this.__props__.duration; this.price = this.__props__.price; this.views = this.__props__.views; this.likes = this.__props__.likes; delete this.__props__; } } class ServiceType extends UTS.UTSType { static get$UTSMetadata$() { return { kind: 2, get fields() { return { id: { type: String, optional: false }, name: { type: String, optional: false }, icon: { type: String, optional: false } }; }, name: "ServiceType" }; } constructor(options, metadata = ServiceType.get$UTSMetadata$(), isJSONParse = false) { super(); this.__props__ = UTS.UTSType.initProps(options, metadata, isJSONParse); this.id = this.__props__.id; this.name = this.__props__.name; this.icon = this.__props__.icon; delete this.__props__; } } class AdvantageItem extends UTS.UTSType { static get$UTSMetadata$() { return { kind: 2, get fields() { return { icon: { type: String, optional: false }, title: { type: String, optional: false }, desc: { type: String, optional: false } }; }, name: "AdvantageItem" }; } constructor(options, metadata = AdvantageItem.get$UTSMetadata$(), isJSONParse = false) { super(); this.__props__ = UTS.UTSType.initProps(options, metadata, isJSONParse); this.icon = this.__props__.icon; this.title = this.__props__.title; this.desc = this.__props__.desc; delete this.__props__; } } const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({ __name: "index", setup(__props) { const bannerList = common_vendor.ref([]); const serviceTypes = common_vendor.ref([]); const hotCases = common_vendor.ref([]); const advantages = common_vendor.ref([ new AdvantageItem({ icon: "👨‍🔧", title: "专业团队", desc: "10年+经验" }), new AdvantageItem({ icon: "✅", title: "品质保证", desc: "质保2年" }), new AdvantageItem({ icon: "🚗", title: "上门服务", desc: "免费评估" }), new AdvantageItem({ icon: "💰", title: "价格透明", desc: "无隐形消费" }) ]); const initServiceTypes = () => { serviceTypes.value = utils_config.SERVICE_TYPES.map((item) => { return new ServiceType({ id: item.id, name: item.name, icon: item.icon }); }); }; const fetchBanners = () => { return common_vendor.__awaiter(this, void 0, void 0, function* () { try { const res = yield api_index.getBanners(); const data = res.data; bannerList.value = data.map((item) => { return new BannerItem({ id: item["id"], image: item["image"], title: item["title"], link: item["link"] }); }); } catch (e) { common_vendor.index.__f__("error", "at pages/index/index.uvue:174", "获取轮播图失败", e); } }); }; const fetchHotCases = () => { return common_vendor.__awaiter(this, void 0, void 0, function* () { try { const res = yield api_index.getHotCases(); const data = res.data; const list = data["items"] || []; hotCases.value = list.map((item) => { return new CaseItem({ id: item["id"], title: item["title"], category: item["category"], categoryName: item["categoryName"], coverImage: item["coverImage"], material: item["material"], duration: item["duration"], price: item["price"], views: item["views"], likes: item["likes"] }); }); } catch (e) { common_vendor.index.__f__("error", "at pages/index/index.uvue:200", "获取热门案例失败", e); } }); }; const handleBannerClick = (item) => { if (item.link != "") { common_vendor.index.navigateTo({ url: item.link, fail: () => { common_vendor.index.switchTab({ url: item.link }); } }); } }; const handleServiceClick = (id) => { common_vendor.index.switchTab({ url: "/pages/service/index" }); }; const goToCaseList = () => { common_vendor.index.switchTab({ url: "/pages/cases/list" }); }; const goToCaseDetail = (id) => { common_vendor.index.navigateTo({ url: `/pages/cases/detail?id=${id}` }); }; const goToBooking = () => { common_vendor.index.navigateTo({ url: "/pages/booking/index" }); }; common_vendor.onLoad(() => { initServiceTypes(); fetchBanners(); fetchHotCases(); }); return (_ctx, _cache) => { "raw js"; const __returned__ = { a: common_vendor.p({ title: "优艺家沙发翻新" }), b: common_vendor.f(common_vendor.unref(bannerList), (item, k0, i0) => { return { a: item.image, b: common_vendor.o(($event) => { return handleBannerClick(item); }, item.id), c: item.id }; }), c: common_vendor.f(common_vendor.unref(serviceTypes), (item, k0, i0) => { return { a: item.id, b: item.id, c: common_vendor.o(handleServiceClick, item.id), d: "767a328a-1-" + i0, e: common_vendor.p({ id: item.id, name: item.name, icon: item.icon }) }; }), d: common_vendor.f(common_vendor.unref(advantages), (item, k0, i0) => { return { a: common_vendor.t(item.icon), b: common_vendor.t(item.title), c: common_vendor.t(item.desc), d: item.title }; }), e: common_vendor.o(goToCaseList), f: common_vendor.p({ title: "热门案例", showMore: true }), g: common_vendor.f(common_vendor.unref(hotCases), (item, k0, i0) => { return { a: item.id, b: common_vendor.o(goToCaseDetail, item.id), c: "767a328a-3-" + i0, d: common_vendor.p({ caseData: item }) }; }), h: common_vendor.o(goToBooking), i: common_vendor.sei(common_vendor.gei(_ctx, ""), "view") }; return __returned__; }; } }); wx.createPage(_sfc_main); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/index.js.map