Sfoglia il codice sorgente

Merge branch 'master' of http://git.ycjcjy.com/whole-estate/wxmini

zjxpcyc 6 anni fa
parent
commit
d1ffbad0f8

+ 1
- 0
pages/components/Concessions/index.json Vedi File

@@ -1,4 +1,5 @@
1 1
 {
2
+  "component": true,
2 3
   "usingComponents": {
3 4
     "ConcessionsListItem": "/pages/components/ConcessionsListItem/index"
4 5
   }

+ 1
- 0
pages/components/ConcessionsListItem/index.json Vedi File

@@ -1,4 +1,5 @@
1 1
 {
2
+  "component": true,
2 3
   "usingComponents": {
3 4
   }
4 5
 }

+ 31
- 2
pages/components/Estate/index.js Vedi File

@@ -56,7 +56,24 @@ Component({
56 56
         url: '/pages/EstateDetail/index?id='
57 57
       })
58 58
     },
59
+    GetGreatCircleDistance(lat1, lng1, lat2, lng2) {
60
+      if (lat1 === lat2 && lng1 === lng2) {
61
+        return 0
62
+      }
63
+      var EARTH_RADIUS = 6378137.0//单位M
64
+      var PI = Math.PI
65
+      var radLat1 = lat1 * PI / 180.0
66
+      var radLat2 = lat2 * PI / 180.0
67
+      var a = radLat1 - radLat2
68
+      var b = lng1 * PI / 180.0 - lng2 * PI / 180.0
69
+      var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)))
70
+      s = s * EARTH_RADIUS
71
+      s = Math.round(s * 10000) / 10000.0
72
+      console.log(s)
73
+      return s
74
+    },
59 75
     ShowLocation() {
76
+      const _that = this
60 77
       wx.getLocation({
61 78
         type: 'wgs84',
62 79
         success(res) {
@@ -64,8 +81,20 @@ Component({
64 81
           HttpSever.Ajax({
65 82
             url: $api.building.list.url,
66 83
             method: $api.building.list.method,
67
-          }).then((date) => {
68
-            console.log(date)
84
+          }).then((data) => {
85
+            const eslist = data.data.map(x => {
86
+              const distance = parseInt(_that.GetGreatCircleDistance(res.latitude, res.longitude, x.coordinate.split(',')[0], x.coordinate.split(',')[1] || res.longitude))
87
+              return {
88
+                buildingName: x.buildingName,
89
+                price: x.price,
90
+                address: x.address,
91
+                buildingImg: (x.buildingImg[0] || {}).url,
92
+                distance: distance / 1000
93
+              }
94
+            })
95
+            _that.setData({
96
+              EstateList: eslist
97
+            })
69 98
           })
70 99
         }
71 100
       })

+ 1
- 0
pages/components/Estate/index.json Vedi File

@@ -1,4 +1,5 @@
1 1
 {
2
+  "component": true,
2 3
   "usingComponents": {
3 4
   }
4 5
 }

+ 4
- 4
pages/components/Estate/index.wxml Vedi File

@@ -9,12 +9,12 @@
9 9
     <text>附近楼盘</text>
10 10
     <view class="list">
11 11
       <view wx:for="{{EstateList}}" wx:for-item="item" wx:for-index="index" wx:key="key" bindtap="ListTap">
12
-        <image mode="aspectFill" src="{{item.Img}}" class="centerLabel cover"></image>
13
-        <text class="price">均价:{{item.Price}}万/平</text>
14
-        <text class="name">{{item.Name}}</text>
12
+        <image mode="aspectFill" src="{{item.buildingImg}}" class="centerLabel cover"></image>
13
+        <text class="price">均价:{{item.price}}</text>
14
+        <text class="name">{{item.buildingName}}</text>
15 15
         <view class="address flex-h">
16 16
           <image mode="widthFix" src="/assets/images/icon8.png"></image>
17
-          <text class="flex-item">{{item.Address}} 距您{{item.Distance}}km</text>
17
+          <text class="flex-item">{{item.address}} 距您{{item.distance}}km</text>
18 18
         </view>
19 19
       </view>
20 20
     </view>

+ 1
- 0
pages/components/Mine/index.json Vedi File

@@ -1,4 +1,5 @@
1 1
 {
2
+  "component": true,
2 3
   "usingComponents": {
3 4
   }
4 5
 }

+ 1
- 0
pages/components/Radio/index.json Vedi File

@@ -1,4 +1,5 @@
1 1
 {
2
+  "component": true,
2 3
   "usingComponents": {
3 4
   }
4 5
 }

+ 1
- 0
pages/components/SubIndex/index.json Vedi File

@@ -1,4 +1,5 @@
1 1
 {
2
+  "component": true,
2 3
   "usingComponents": {
3 4
   }
4 5
 }