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
     "navigationBarBackgroundColor": "#bb9c79",
19
     "navigationBarBackgroundColor": "#bb9c79",
20
     "navigationBarTitleText": "",
20
     "navigationBarTitleText": "",
21
     "navigationBarTextStyle":"white"
21
     "navigationBarTextStyle":"white"
22
+  },
23
+  "permission": {
24
+    "scope.userLocation": {
25
+      "desc": "您的位置将用于效果展示"
26
+    }
22
   }
27
   }
23
 }
28
 }

+ 3
- 0
config/api.js 파일 보기

32
       methods: 'GET',
32
       methods: 'GET',
33
       url: `${BaseAPIURl}/wx/buildingDynamiceInfo/:id`
33
       url: `${BaseAPIURl}/wx/buildingDynamiceInfo/:id`
34
     }
34
     }
35
+  },
36
+  activity: {
37
+    
35
   }
38
   }
36
 }
39
 }
37
 
40
 

+ 1
- 1
config/baseUrl.js 파일 보기

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

+ 33
- 1
pages/components/Estate/index.js 파일 보기

1
 //index.js
1
 //index.js
2
 //获取应用实例
2
 //获取应用实例
3
 const app = getApp()
3
 const app = getApp()
4
+const HttpSever = require('../../../utils/http.js').HttpSever;
5
+const $api = require('../../../config/api.js').$api;
4
 
6
 
5
 Component({
7
 Component({
6
   behaviors: [],
8
   behaviors: [],
28
     }]
30
     }]
29
   },
31
   },
30
   lifetimes: {},
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
   pageLifetimes: {
50
   pageLifetimes: {
33
     show: function() {},
51
     show: function() {},
34
   },
52
   },
37
       wx.navigateTo({
55
       wx.navigateTo({
38
         url: '/pages/EstateDetail/index?id='
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
 const $api = require('../config/api.js').$api;
2
 const $api = require('../config/api.js').$api;
3
 const $HttpSever = function () { }
3
 const $HttpSever = function () { }
4
 
4
 
5
-var app = getApp();
6
-
7
 $HttpSever.prototype = {
5
 $HttpSever.prototype = {
8
   /**
6
   /**
9
    *  通用请求方法
7
    *  通用请求方法
17
         url: config.url,
15
         url: config.url,
18
         method: config.method,
16
         method: config.method,
19
         data: {
17
         data: {
20
-          ...config.data,
21
-          openid: app.globalData.openID
18
+          ...config.data
22
         },
19
         },
23
         header: {
20
         header: {
24
           'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
21
           'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
25
         },
22
         },
26
         success(res) {
23
         success(res) {
27
           if (res.statusCode && res.statusCode === apiCode.common.successCode) {
24
           if (res.statusCode && res.statusCode === apiCode.common.successCode) {
28
-            resolve(res.data.message)
25
+            resolve(res.data)
29
           } else {
26
           } else {
30
             resolve(res.data.message + "失败")
27
             resolve(res.data.message + "失败")
31
           }
28
           }