Novecane
2025-02-15 a12e5f63a90446525b2f322fb2bbd21d5285cd6d
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
"use strict";
const common_vendor = require("../../common/vendor.js");
const common_assets = require("../../common/assets.js");
const api_index = require("../../api/index.js");
const config_config = require("../../config/config.js");
const _sfc_main = {
  __name: "index",
  setup(__props) {
    common_vendor.ref(config_config.BASE_URL);
    function wxLogin() {
      if (!common_vendor.index.getStorageSync("openId") || !common_vendor.index.getStorageSync("token")) {
        common_vendor.wx$1.login({
          success: async (res1) => {
            common_vendor.index.setStorageSync("code", res1.code);
            await api_index.wxLoginApi({
              code: res1.code
            }).then((res2) => {
              if (res2.code == 200) {
                common_vendor.index.redirectTo({
                  url: "/pages/layout/index"
                });
                common_vendor.index.setStorageSync("openId", res2.data.userId);
                common_vendor.index.setStorageSync("token", res2.data.token);
              } else {
                common_vendor.index.showToast({
                  title: "登录失败",
                  icon: "none"
                });
              }
            });
          },
          fail: (e) => {
            common_vendor.index.showToast({
              title: "微信登录失败,请退出重试!",
              duration: 2e3,
              icon: "fail"
            });
          }
        });
      } else {
        common_vendor.index.redirectTo({
          url: "/pages/layout/index"
        });
      }
    }
    return (_ctx, _cache) => {
      return {
        a: common_assets._imports_0,
        b: common_assets._imports_1,
        c: common_vendor.o(wxLogin)
      };
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-d08ef7d4"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/login/index.js.map