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
"use strict";
const common_vendor = require("../../common/vendor.js");
const apiservice_apiService = require("../../apiservice/apiService.js");
const stores_user = require("../../stores/user.js");
const userStore = stores_user.useUserStore();
const _sfc_main = {
  setup() {
    const tabs = ["已预约", "已使用", "已取消", "已过期"];
    const currentTab = common_vendor.ref(0);
    let sitebooking = common_vendor.ref([]);
    const loading = common_vendor.ref(false);
    const fetchsitebooking = async () => {
      loading.value = true;
      try {
        const res = await apiservice_apiService.apiService.bookingListByUuid(userStore.uuid);
        if (res.code === 1e3) {
          sitebooking.value = res.data;
        } else {
          common_vendor.index.__f__("warn", "at pages/ucenter/my-booking.vue:109", "查询失败:", res.message);
        }
      } catch (error) {
        common_vendor.index.__f__("error", "at pages/ucenter/my-booking.vue:113", "获取预约信息错误:", error);
        common_vendor.index.showToast({
          title: "网络错误",
          icon: "none"
        });
      } finally {
        loading.value = false;
      }
    };
    const filteredsitebooking = common_vendor.computed(() => {
      return sitebooking.value.filter((item) => item.status === tabs[currentTab.value]);
    });
    const getNowString = () => {
      const now = /* @__PURE__ */ new Date();
      const pad = (n) => n.toString().padStart(2, "0");
      return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`;
    };
    const onTabChange = (e) => {
      currentTab.value = e.currentIndex;
    };
    const cancelReservation = async (item) => {
      common_vendor.index.showModal({
        title: "提示",
        content: "确定取消预约吗?",
        success: async (res) => {
          if (res.confirm) {
            try {
              common_vendor.index.__f__("log", "at pages/ucenter/my-booking.vue:148", item);
              const cancelRes = await apiservice_apiService.apiService.bookingCancel({
                id: item.id,
                canceltime: getNowString(),
                status: "已取消"
              });
              common_vendor.index.__f__("log", "at pages/ucenter/my-booking.vue:156", cancelRes);
              if (cancelRes.code === 1e3) {
                common_vendor.index.showToast({
                  title: "预约已取消",
                  icon: "success"
                });
                await fetchsitebooking();
              } else {
                common_vendor.index.showToast({
                  title: cancelRes.message || "取消失败",
                  icon: "none"
                });
              }
            } catch (error) {
              common_vendor.index.__f__("error", "at pages/ucenter/my-booking.vue:172", "取消预约错误:", error);
              common_vendor.index.showToast({
                title: "取消失败,请重试",
                icon: "none"
              });
            }
          }
        }
      });
    };
    const verifyReservation = async (item) => {
      try {
        common_vendor.index.__f__("log", "at pages/ucenter/my-booking.vue:185", item);
        const scanRes = await new Promise((resolve, reject) => {
          common_vendor.index.scanCode({
            scanType: ["qrCode"],
            success: resolve,
            fail: reject
          });
        });
        common_vendor.index.__f__("log", "at pages/ucenter/my-booking.vue:194", scanRes.result);
        const match = scanRes.result.match(/farm\.evcc\.top.*?sitename=([^&]+)/);
        if (!match) {
          common_vendor.index.showToast({
            title: "二维码无效,请扫描正确的核销码",
            icon: "none"
          });
          return;
        }
        const qrSitename = decodeURIComponent(match[1]);
        const now = /* @__PURE__ */ new Date();
        const todayStr = now.toISOString().split("T")[0];
        const currentHour = now.getHours();
        const isAm = !!item.visittimeam && item.visittimeam !== "";
        let message = "";
        if (qrSitename !== item.sitename) {
          message = `二维码场馆不匹配(扫码场馆:${qrSitename})`;
        } else if (item.visitdate !== todayStr) {
          message = `未到预约日期(预约日期:${item.visitdate})`;
        } else if (isAm && currentHour >= 12) {
          message = "上午时段已过,无法核销";
        } else if (!isAm && currentHour < 12) {
          message = "还未到下午时段,请稍后核销";
        }
        if (message) {
          common_vendor.index.showModal({
            title: "无法核销",
            content: message,
            showCancel: false,
            confirmText: "我知道了"
          });
          return;
        }
        const verifyRes = await apiservice_apiService.apiService.bookingUse({
          id: item.id,
          usedtime: getNowString(),
          status: "已使用"
        });
        if (verifyRes.code === 1e3) {
          common_vendor.index.showModal({
            title: "核销成功",
            content: "预约已核销,请工作人员确认",
            showCancel: false,
            confirmText: "确定",
            success: async () => {
              await fetchsitebooking();
            }
          });
        } else {
          common_vendor.index.showToast({
            title: verifyRes.message || "核销失败",
            icon: "none"
          });
        }
      } catch (error) {
        common_vendor.index.__f__("error", "at pages/ucenter/my-booking.vue:259", "核销错误:", error);
        common_vendor.index.showToast({
          title: "核销失败,请重试",
          icon: "none"
        });
      }
    };
    common_vendor.onMounted(() => {
      fetchsitebooking();
    });
    return {
      tabs,
      currentTab,
      sitebooking,
      filteredsitebooking,
      loading,
      onTabChange,
      cancelReservation,
      verifyReservation
    };
  }
};
if (!Array) {
  const _easycom_uni_segmented_control2 = common_vendor.resolveComponent("uni-segmented-control");
  _easycom_uni_segmented_control2();
}
const _easycom_uni_segmented_control = () => "../../uni_modules/uni-segmented-control/components/uni-segmented-control/uni-segmented-control.js";
if (!Math) {
  _easycom_uni_segmented_control();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return common_vendor.e({
    a: common_vendor.o($setup.onTabChange),
    b: common_vendor.p({
      current: $setup.currentTab,
      values: $setup.tabs,
      ["style-type"]: "button",
      ["active-color"]: "#3b82f6"
    }),
    c: $setup.loading
  }, $setup.loading ? {} : {}, {
    d: common_vendor.f($setup.filteredsitebooking, (item, index, i0) => {
      return common_vendor.e({
        a: item.status === "已预约"
      }, item.status === "已预约" ? {
        b: common_vendor.o(($event) => $setup.cancelReservation(item), index)
      } : {}, {
        c: common_vendor.t(item.sitename),
        d: item.status != "已预约"
      }, item.status != "已预约" ? {
        e: common_vendor.t(item.status)
      } : {}, {
        f: common_vendor.t(item.visitdate),
        g: common_vendor.t(item.visittimeam && item.visittimeam !== "" ? "上午(09:00-12:00)" : "下午(13:00-17:00)"),
        h: common_vendor.t(item.contactperson),
        i: common_vendor.t(item.contactphone),
        j: common_vendor.t(item.personcount),
        k: item.status === "已使用"
      }, item.status === "已使用" ? {
        l: common_vendor.t(item.usedtime)
      } : {}, {
        m: item.status === "已取消"
      }, item.status === "已取消" ? {
        n: common_vendor.t(item.canceltime)
      } : {}, {
        o: item.status === "已预约"
      }, item.status === "已预约" ? {
        p: common_vendor.o(($event) => $setup.verifyReservation(item), index)
      } : {}, {
        q: index
      });
    }),
    e: !$setup.filteredsitebooking.length
  }, !$setup.filteredsitebooking.length ? {
    f: common_vendor.t($setup.tabs[$setup.currentTab])
  } : {});
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/ucenter/my-booking.js.map