张涛 1 jaar geleden
bovenliggende
commit
20b342ce5f
4 gewijzigde bestanden met toevoegingen van 40 en 46 verwijderingen
  1. 1
    1
      config/index.js
  2. 1
    1
      src/components/map/index.jsx
  3. 16
    24
      src/index.html
  4. 22
    20
      src/utils/authorize.js

+ 1
- 1
config/index.js Bestand weergeven

@@ -4,7 +4,7 @@ const path = require("path");
4 4
 
5 5
 import devConfig from "./dev";
6 6
 import prodConfig from "./prod";
7
-const url = "http://localhost:9087";
7
+const url = "http://localhost:8090";
8 8
 const url2 = "https://apis.map.qq.com";
9 9
 
10 10
 export default defineConfig(async (merge, { command, mode }) => {

+ 1
- 1
src/components/map/index.jsx Bestand weergeven

@@ -93,7 +93,7 @@ export default (props) => {
93 93
       return h5GetLocation()
94 94
         .then((res) => {
95 95
           Taro.hideLoading();
96
-          resolve(res.data.result);
96
+          resolve(res.result);
97 97
         })
98 98
         .catch((err) => {
99 99
           console.error(err);

+ 16
- 24
src/index.html Bestand weergeven

@@ -1,27 +1,19 @@
1 1
 <!DOCTYPE html>
2 2
 <html>
3
-  <head>
4
-    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
5
-    <meta
6
-      content="width=device-width,initial-scale=1,user-scalable=no"
7
-      name="viewport"
8
-    />
9
-    <meta name="apple-mobile-web-app-capable" content="yes" />
10
-    <meta name="apple-touch-fullscreen" content="yes" />
11
-    <meta name="format-detection" content="telephone=no,address=no" />
12
-    <meta name="apple-mobile-web-app-status-bar-style" content="white" />
13
-    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
14
-    <!-- <script src="http://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script> -->
15
-    <script
16
-      charset="utf-8"
17
-      src="https://map.qq.com/api/gljs?v=1.exp&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77"
18
-    ></script>
19
-    <title>civilized-miniapp</title>
20
-    <script>
21
-      <%= htmlWebpackPlugin.options.script %>
22
-    </script>
23
-  </head>
24
-  <body>
25
-    <div id="app"></div>
26
-  </body>
3
+<head>
4
+  <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
5
+  <meta content="width=device-width,initial-scale=1,user-scalable=no" name="viewport">
6
+  <meta name="apple-mobile-web-app-capable" content="yes">
7
+  <meta name="apple-touch-fullscreen" content="yes">
8
+  <meta name="format-detection" content="telephone=no,address=no">
9
+  <meta name="apple-mobile-web-app-status-bar-style" content="white">
10
+  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" >
11
+  <!-- <script src="http://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script> -->
12
+  <script charset="utf-8" src="https://map.qq.com/api/gljs?v=1.exp&key=HTPBZ-HHJA7-XD2XD-PRS37-H3HVJ-U5BAA&libraries=service"></script>
13
+  <title>civilized-miniapp</title>
14
+  <script><%= htmlWebpackPlugin.options.script %></script>
15
+</head>
16
+<body>
17
+  <div id="app"></div>
18
+</body>
27 19
 </html>

+ 22
- 20
src/utils/authorize.js Bestand weergeven

@@ -46,24 +46,26 @@ export const getLocation = async (options) => {
46 46
 };
47 47
 const key = "HTPBZ-HHJA7-XD2XD-PRS37-H3HVJ-U5BAA";
48 48
 export const h5GetLocation = () => {
49
-  return new Promise((resolve, reject) => {
50
-    const url = `${MAPHOST}/ws/location/v1/ip?key=${key}`;
51
-    const res = Taro.request({
52
-      url: url,
53
-      method: "GET",
54
-      dataType: "json",
55
-      header: {
56
-        "content-type": "application/json",
57
-      },
58
-    });
59
-    resolve(res);
60
-    reject(res);
61
-    // .then((res) => {
62
-    //   resolve(res.result);
63
-    // })
64
-    // .catch((error) => {
65
-    //   reject(error);
66
-    //   console.error("请求失败", error);
67
-    // });
68
-  });
49
+  return new TMap.service.IPLocation().locate();
50
+
51
+  // return new Promise((resolve, reject) => {
52
+  //   const url = `${MAPHOST}/ws/location/v1/ip?key=${key}`;
53
+  //   const res = Taro.request({
54
+  //     url: url,
55
+  //     method: "GET",
56
+  //     dataType: "json",
57
+  //     header: {
58
+  //       "content-type": "application/json",
59
+  //     },
60
+  //   });
61
+  //   resolve(res);
62
+  //   reject(res);
63
+  //   // .then((res) => {
64
+  //   //   resolve(res.result);
65
+  //   // })
66
+  //   // .catch((error) => {
67
+  //   //   reject(error);
68
+  //   //   console.error("请求失败", error);
69
+  //   // });
70
+  // });
69 71
 };