wangfei 6 年之前
父節點
當前提交
db04b7b294
共有 5 個檔案被更改,包括 44 行新增7 行删除
  1. 5
    0
      app.json
  2. 3
    0
      config/api.js
  3. 1
    1
      config/baseUrl.js
  4. 33
    1
      pages/components/Estate/index.js
  5. 2
    5
      utils/http.js

+ 5
- 0
app.json 查看文件

@@ -19,5 +19,10 @@
19 19
     "navigationBarBackgroundColor": "#bb9c79",
20 20
     "navigationBarTitleText": "",
21 21
     "navigationBarTextStyle":"white"
22
+  },
23
+  "permission": {
24
+    "scope.userLocation": {
25
+      "desc": "您的位置将用于效果展示"
26
+    }
22 27
   }
23 28
 }

+ 3
- 0
config/api.js 查看文件

@@ -32,6 +32,9 @@ const $api = {
32 32
       methods: 'GET',
33 33
       url: `${BaseAPIURl}/wx/buildingDynamiceInfo/:id`
34 34
     }
35
+  },
36
+  activity: {
37
+    
35 38
   }
36 39
 }
37 40
 

+ 1
- 1
config/baseUrl.js 查看文件

@@ -1,4 +1,4 @@
1 1
 module.exports.basePath = {
2
-  BASE_API_URL: 'https://api.jinchengjiaye.com/newnbapi',
2
+  BASE_API_URL: 'https://dev.jinchengjiaye.com/api',
3 3
   BASE_IMG_URL: 'https://whole-estate.oss-cn-beijing.aliyuncs.com/',
4 4
 }

+ 33
- 1
pages/components/Estate/index.js 查看文件

@@ -1,6 +1,8 @@
1 1
 //index.js
2 2
 //获取应用实例
3 3
 const app = getApp()
4
+const HttpSever = require('../../../utils/http.js').HttpSever;
5
+const $api = require('../../../config/api.js').$api;
4 6
 
5 7
 Component({
6 8
   behaviors: [],
@@ -28,7 +30,23 @@ Component({
28 30
     }]
29 31
   },
30 32
   lifetimes: {},
31
-  ready: function() {},
33
+  ready: function() {
34
+    const _that = this
35
+    wx.getSetting({
36
+      success(res) {
37
+        if (!res.authSetting['scope.userLocation']) {
38
+          wx.authorize({
39
+            scope: 'scope.userLocation',
40
+            success() {
41
+              _that.ShowLocation()
42
+            }
43
+          })
44
+        } else {
45
+          _that.ShowLocation()
46
+        }
47
+      }
48
+    })
49
+  },
32 50
   pageLifetimes: {
33 51
     show: function() {},
34 52
   },
@@ -37,6 +55,20 @@ Component({
37 55
       wx.navigateTo({
38 56
         url: '/pages/EstateDetail/index?id='
39 57
       })
58
+    },
59
+    ShowLocation() {
60
+      wx.getLocation({
61
+        type: 'wgs84',
62
+        success(res) {
63
+          console.log(res)
64
+          HttpSever.Ajax({
65
+            url: $api.building.list.url,
66
+            method: $api.building.list.method,
67
+          }).then((date) => {
68
+            console.log(date)
69
+          })
70
+        }
71
+      })
40 72
     }
41 73
   }
42 74
 })

+ 2
- 5
utils/http.js 查看文件

@@ -2,8 +2,6 @@ const apiCode = require('../config/code.js').apiCode;
2 2
 const $api = require('../config/api.js').$api;
3 3
 const $HttpSever = function () { }
4 4
 
5
-var app = getApp();
6
-
7 5
 $HttpSever.prototype = {
8 6
   /**
9 7
    *  通用请求方法
@@ -17,15 +15,14 @@ $HttpSever.prototype = {
17 15
         url: config.url,
18 16
         method: config.method,
19 17
         data: {
20
-          ...config.data,
21
-          openid: app.globalData.openID
18
+          ...config.data
22 19
         },
23 20
         header: {
24 21
           'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
25 22
         },
26 23
         success(res) {
27 24
           if (res.statusCode && res.statusCode === apiCode.common.successCode) {
28
-            resolve(res.data.message)
25
+            resolve(res.data)
29 26
           } else {
30 27
             resolve(res.data.message + "失败")
31 28
           }