Liuyi
2024-11-12 0ed8e370659ad4e0582301ae31cfa155da114590
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
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const common_vendor = require("./common/vendor.js");
const api_index = require("./api/index.js");
if (!Math) {
  "./pages/index/index.js";
  "./pages/userInfo/index.js";
  "./pages/functionList/balanceRecord/index.js";
  "./pages/functionList/paymentRecord/index.js";
  "./pages/functionList/rechargeRecord/index.js";
  "./pages/functionList/share/cardShare/index.js";
  "./pages/functionList/share/shareConfirm/index.js";
  "./pages/functionList/share/shareList/index.js";
  "./pages/scanWater/index.js";
  "./pages/recharge/index.js";
  "./pages/sendWater/index.js";
  "./pages/preSendWater/index.js";
  "./pages/address/index.js";
  "./pages/addressLocate/index.js";
  "./pages/success/index.js";
  "./pages/facilityList/index.js";
  "./pages/station/index.js";
  "./pages/infoBreakdown/index.js";
  "./pages/scanRecharge/index.js";
  "./pages/scanSuccess/index.js";
  "./pages/counterRecharge/index.js";
}
const _sfc_main = {
  __name: "App",
  setup(__props) {
    function wxLogin() {
      if (!common_vendor.index.getStorageSync("openId")) {
        common_vendor.wx$1.login({
          success: async (res1) => {
            common_vendor.index.setStorageSync("code", res1.code);
            await api_index.wxLoginApi({ code: res1.code }).then((res2) => {
              common_vendor.index.setStorageSync("openId", res2.data.userId);
              common_vendor.index.setStorageSync("token", res2.data.token);
            });
          },
          fail: (e) => {
            common_vendor.index.showToast({
              title: "登录失败,请退出重试!",
              duration: 2e3
            });
            console.log(e);
          }
        });
      }
    }
    let userLocation = {
      lat: "",
      lon: ""
    };
    function getUserLocation() {
      common_vendor.index.authorize({
        scope: "scope.userLocation",
        success() {
          console.log("成功授权位置信息1");
          storageLocation();
        },
        fail() {
          console.log("用户拒绝授权位置信息,再次提示用户授权");
          showToast();
        }
      });
      function storageLocation() {
        common_vendor.index.getLocation({
          type: "gcj02",
          isHighAccuracy: true,
          success: (res) => {
            userLocation.lat = res.latitude;
            userLocation.lon = res.longitude;
            common_vendor.index.setStorageSync("userLocation", JSON.stringify(userLocation));
          },
          fail: () => {
            showToast();
          }
        });
      }
      function showToast() {
        common_vendor.index.showModal({
          title: "请求授权当前位置",
          content: "我们需要获取地理位置信息,为您获取附近站点信息!",
          confirmText: "前往设置",
          success: (res) => {
            if (res.confirm) {
              common_vendor.index.openSetting({
                success: (res1) => {
                  if (res1.authSetting["scope.userLocation"]) {
                    console.log("用户二次授权成功");
                    storageLocation();
                  } else {
                    showToast();
                    console.log("用户拒绝授权");
                  }
                }
              });
            } else {
              common_vendor.index.showToast({
                title: "请先授权!",
                duration: 2e3,
                icon: "none"
              });
              showToast();
            }
          }
        });
      }
    }
    common_vendor.onLaunch(async () => {
      await wxLogin();
      await getUserLocation();
    });
    common_vendor.onShow(() => {
      console.log("App Show");
    });
    common_vendor.onHide(() => {
      console.log("App Hide");
    });
    return () => {
    };
  }
};
const navbar = () => "./components/navbar/navbar.js";
const DaTree = () => "./components/da-tree/index.js";
function createApp() {
  const app = common_vendor.createSSRApp(_sfc_main);
  app.component("navbar", navbar).component("DaTree", DaTree);
  return {
    app
  };
}
createApp().app.mount("#app");
exports.createApp = createApp;