wangzhibo
2025-10-23 cad64c1de2c45856b0774933c5801b05b64984e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
"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(/<img[^>]+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