"use strict"; const common_vendor = require("../../common/vendor.js"); const pages_index_assets = require("./assets.js"); const apiservice_apiService = require("../../apiservice/apiService.js"); const stores_user = require("../../stores/user.js"); const userStore = stores_user.useUserStore(); const _sfc_main = { name: "Home", data() { return { ASSETS: pages_index_assets.ASSETS, isVideoPlaying: false, currentImage: "", // 当前轮播图片 currentIndex: 0, // 当前图片索引 noticesList: [], // 后台数据 visibleNotices: [], // 当前显示的3条 noticeIndex: 0, // 当前起始索引 noticeTimer: null, // 定时器 userStore, showAuth: true }; }, onShareAppMessage() { return { title: "欢迎来荆门市园博园游玩!", path: "/pages/index/index" }; }, onShareTimeline() { return { title: "欢迎来荆门市园博园游玩!" }; }, methods: { goToGuide() { common_vendor.index.switchTab({ url: "/pages/guide/guide" }); }, goTo(page) { common_vendor.index.navigateTo({ url: `/pages/index/${page}` }); }, playVideo() { this.isVideoPlaying = true; }, gotoVR() { common_vendor.index.showModal({ title: "提示", content: "小程序无法直接打开全景页面,是否在浏览器中查看?", success: (res) => { if (res.confirm) { common_vendor.index.openUrl({ url: pages_index_assets.ASSETS.vr_url }); } } }); }, gotoMini() { common_vendor.index.navigateToMiniProgram({ appId: pages_index_assets.ASSETS.parking_appid, // 目标小程序的 AppID //path: 'pages/index/index', // 打开的页面路径,可选 //extraData: { // foo: 'bar' //}, // 传递参数,可选 envVersion: "release", // 打开版本:develop / trial / release success(res) { common_vendor.index.__f__("log", "at pages/index/index.vue:287", "跳转成功", res); }, fail(err) { common_vendor.index.__f__("error", "at pages/index/index.vue:290", "跳转失败", err); } }); }, goToSpotDetail(spot) { common_vendor.index.setStorageSync("scenic_id", spot.id); common_vendor.index.navigateTo({ url: `/pages/index/scenic-detail?id=${spot.id}&t=${Date.now()}` }); }, callRescue() { common_vendor.index.showModal({ title: "提示", content: `是否拨打救援电话:${pages_index_assets.ASSETS.rescure_phoneNumber}`, cancelText: "取消", confirmText: "拨打", success: (res) => { if (res.confirm) { common_vendor.index.makePhoneCall({ phoneNumber: pages_index_assets.ASSETS.rescure_phoneNumber }); } } }); }, startCarousel() { if (!pages_index_assets.ASSETS.jiaonang || pages_index_assets.ASSETS.jiaonang.length === 0) return; this.currentImage = pages_index_assets.ASSETS.jiaonang[0]; this.currentIndex = 0; this.carouselInterval = setInterval(() => { this.currentIndex = (this.currentIndex + 1) % pages_index_assets.ASSETS.jiaonang.length; this.currentImage = pages_index_assets.ASSETS.jiaonang[this.currentIndex]; }, 3e3); }, stopCarousel() { if (this.carouselInterval) { clearInterval(this.carouselInterval); this.carouselInterval = null; } }, updateVisibleNotices() { const total = this.noticesList.length; if (total === 0) return; this.visibleNotices = []; for (let i = 0; i < 3; i++) { this.visibleNotices.push(this.noticesList[(this.noticeIndex + i) % total]); } this.noticeIndex = (this.noticeIndex + 1) % total; }, // 启动定时器 startNoticeRotation() { this.updateVisibleNotices(); this.noticeTimer = setInterval(() => { this.updateVisibleNotices(); }, 5e3); }, stopNoticeRotation() { if (this.noticeTimer) clearInterval(this.noticeTimer); }, // 获取数据 async fetchNotices() { try { const res = await apiservice_apiService.apiService.noticeList(); this.noticesList = res.data; this.startNoticeRotation(); } catch (err) { common_vendor.index.__f__("error", "at pages/index/index.vue:371", "获取公告失败", err); } }, parseContentImg(content) { if (!content || typeof content !== "string") { return null; } const imgMatch = content.match(/]+src=["']?([^"'>]+)["']?/i); const imgSrc = imgMatch ? imgMatch[1] : null; return imgSrc; }, getUserinfoCancel() { this.showAuth = false; }, async handleGetUserInfo(e) { common_vendor.index.__f__("log", "at pages/index/index.vue:387", "getUserProfile detail:", e.detail); if (e.detail.errMsg === "getUserProfile:ok") { const userInfo = e.detail.userInfo; const jsonData = { id: userStore.id, uuid: userStore.uuid, username: userInfo.nickName, sex: userInfo.gender === 2 ? "female" : "male", avatarurl: userInfo.avatarUrl }; if (jsonData.id) { try { const res = await apiservice_apiService.apiService.touristUpdate(jsonData); if (res.code === 1e3) { userStore.saveUserInfo({ username: jsonData.username, avatarUrl: jsonData.avatarurl, sex: jsonData.sex }); common_vendor.index.showToast({ title: "更新成功", icon: "success" }); } else { common_vendor.index.showToast({ title: "更新失败", icon: "error" }); } } catch (err) { common_vendor.index.__f__("error", "at pages/index/index.vue:418", err); common_vendor.index.showToast({ title: "网络错误", icon: "error" }); } finally { this.showAuth = false; } } this.showAuth = false; } else { common_vendor.index.__f__("log", "at pages/index/index.vue:429", "用户拒绝授权"); } this.showAuth = false; }, async getUserinfoAllow() { common_vendor.index.navigateTo({ url: `/pages/ucenter/settings` }); } }, mounted() { this.startCarousel(); this.fetchNotices(); }, beforeUnmount() { this.stopCarousel(); this.stopNoticeRotation(); } }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return common_vendor.e({ a: !$data.isVideoPlaying }, !$data.isVideoPlaying ? { b: $data.ASSETS.video.promoImg, c: common_vendor.o((...args) => $options.playVideo && $options.playVideo(...args)) } : {}, { d: $data.isVideoPlaying }, $data.isVideoPlaying ? { e: $data.ASSETS.video.promo } : {}, { f: `https://farm.evcc.top/Uploads/yuanboyuan/index/01.png`, g: common_vendor.o((...args) => $options.goToGuide && $options.goToGuide(...args)), h: `https://farm.evcc.top/Uploads/yuanboyuan/index/02.png`, i: common_vendor.o(($event) => $options.goTo("hotels")), j: `https://farm.evcc.top/Uploads/yuanboyuan/index/03.png`, k: common_vendor.o(($event) => $options.goTo("foods")), l: `https://farm.evcc.top/Uploads/yuanboyuan/index/04.png`, m: common_vendor.o(($event) => $options.goTo("traffic")), n: `https://farm.evcc.top/Uploads/yuanboyuan/index/05.png`, o: common_vendor.o((...args) => $options.gotoMini && $options.gotoMini(...args)), p: `https://farm.evcc.top/Uploads/yuanboyuan/index/06.png`, q: common_vendor.o((...args) => $options.callRescue && $options.callRescue(...args)), r: `https://farm.evcc.top/Uploads/yuanboyuan/index/07.png`, s: common_vendor.o(($event) => $options.goTo("advice")), t: `https://farm.evcc.top/Uploads/yuanboyuan/index/08.png`, v: common_vendor.o(($event) => $options.goTo("booking")), w: `https://farm.evcc.top/Uploads/yuanboyuan/index/09.png`, x: common_vendor.o(($event) => $options.goTo("wifi")), y: `https://farm.evcc.top/Uploads/yuanboyuan/index/10.png`, z: common_vendor.o(($event) => $options.goTo("vr-page")), A: $data.currentImage, B: common_vendor.o(($event) => $options.goTo("notices")), C: common_vendor.f($data.visibleNotices, (item, index, i0) => { return { a: $options.parseContentImg(item.content) || `https://farm.evcc.top/Uploads/yuanboyuan/news/${encodeURIComponent(item.category)}.jpg`, b: common_vendor.t(item.title.length > 18 ? item.title.slice(0, 18) + "……" : item.title), c: common_vendor.t(item.createTime), d: item.id }; }), D: common_vendor.o(($event) => $options.goTo("notices")), E: common_vendor.f($data.ASSETS.spots, (scenic, index, i0) => { return { a: scenic.imgUrl, b: common_vendor.t(scenic.name), c: index, d: common_vendor.o(($event) => $options.goToSpotDetail(scenic), index) }; }), F: !$data.userStore.username && $data.showAuth }, !$data.userStore.username && $data.showAuth ? { G: common_vendor.o((...args) => $options.getUserinfoCancel && $options.getUserinfoCancel(...args)), H: common_vendor.o((...args) => $options.getUserinfoAllow && $options.getUserinfoAllow(...args)) } : {}); } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]); _sfc_main.__runtimeHooks = 6; wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/index.js.map