wangfei 6 yıl önce
ebeveyn
işleme
f6df2ca391

BIN
assets/images/daohang.png Dosyayı Görüntüle


BIN
assets/images/firstpage.png Dosyayı Görüntüle


BIN
assets/images/share.png Dosyayı Görüntüle


+ 4
- 0
config/api.js Dosyayı Görüntüle

@@ -127,6 +127,10 @@ const $api = {
127 127
     method: 'POST',
128 128
     url: `${BaseAPIURl}uploadImage`
129 129
   },
130
+  visit: {
131
+    method: 'POST',
132
+    url: `${BaseAPIURl}/wx/building/visit/:id`
133
+  }
130 134
 }
131 135
 
132 136
 const hasKey = (o, k) => Object.keys(o).indexOf(k) > -1

+ 66
- 95
pages/EstateDetail/index.js Dosyayı Görüntüle

@@ -17,7 +17,6 @@ Page({
17 17
   onLoad: function(options) {
18 18
     const id = page.getCurrentPageOptions().id
19 19
     const _that = this
20
-
21 20
     //调用wx.getSystemInfo接口,然后动态绑定组件高度
22 21
     wx.getSystemInfo({
23 22
       success: function(res) {
@@ -32,51 +31,70 @@ Page({
32 31
     })
33 32
 
34 33
     fetch({
35
-      url: $api.collection.getByUser.url.replace(':openid', app.globalData.UserInfo.openid),
36
-      method: $api.collection.getByUser.method,
34
+      url: $api.visit.url.replace(':id', id),
35
+      method: $api.visit.method,
37 36
       data: {
38
-        pageNum: 1,
39
-        pageSize: 100
37
+        customerId: app.globalData.UserInfo.customerId,
38
+        customerName: app.globalData.UserInfo.name,
39
+        avatar: app.globalData.UserInfo.avatar,
40
+        visitType: 'building',
41
+        visitContent: id
40 42
       }
41
-    }).then((collects) => {
42
-      _that.setData({
43
-        Collects: collects.data.records
44
-      })
43
+    }).then(() => {
45 44
       fetch({
46
-        url: $api.building.detail.url.replace(':id', id),
47
-        method: $api.building.detail.method,
48
-      }).then((data) => {
49
-        const dicts = app.globalData.Dict
50
-        const apart = data.data.buildingApartment.filter(x => x.apartmentType === 'apart').map(x => {
51
-          return {
52
-            ...x,
53
-            imgUrl: (x.buildingImgList[0] || {}).url,
54
-            marketStatus: (dicts.filter(d => d.id == x.marketStatus)[0] || {}).name
55
-          }
56
-        })
57
-        const photo = data.data.buildingApartment.filter(x => x.apartmentType === 'photo').map(x => {
58
-          return {
59
-            ...x,
60
-            imgUrl: (x.buildingImgList[0] || {}).url,
61
-            marketStatus: (dicts.filter(d => d.id == x.marketStatus)[0] || {}).name
62
-          }
63
-        })
64
-        let propertyType = ''
65
-        data.data.propertyType.split(',').map(x => {
66
-          const f = dicts.filter(d => d.id == x)
67
-          if (f.length > 0) {
68
-            propertyType += (propertyType === '' ? '' : ',') + f[0].name
69
-          }
70
-        })
45
+        url: $api.collection.getByUser.url.replace(':openid', app.globalData.UserInfo.openid),
46
+        method: $api.collection.getByUser.method,
47
+        data: {
48
+          pageNum: 1,
49
+          pageSize: 100
50
+        }
51
+      }).then((collects) => {
71 52
         _that.setData({
72
-          EstateDetail: {
73
-            ...data.data,
74
-            openingDate: data.data.openingDate.split(' ')[0],
75
-            propertyType: propertyType,
76
-            buildingApartment: apart,
77
-            IsCollect: (_that.data.Collects.filter(x => x.buildingId == data.data.buildingId).length > 0 ? true : false),
78
-            Photos: photo || []
79
-          }
53
+          Collects: collects.data.records
54
+        })
55
+        fetch({
56
+          url: $api.building.detail.url.replace(':id', id),
57
+          method: $api.building.detail.method,
58
+        }).then((data) => {
59
+          const dicts = app.globalData.Dict
60
+          const apart = data.data.buildingApartment.filter(x => x.apartmentType === 'apart').map(x => {
61
+            return {
62
+              ...x,
63
+              imgUrl: (x.buildingImgList[0] || {}).url,
64
+              marketStatus: (dicts.filter(d => d.id == x.marketStatus)[0] || {}).name
65
+            }
66
+          })
67
+          const photo = data.data.buildingApartment.filter(x => x.apartmentType === 'photo').map(x => {
68
+            return {
69
+              ...x,
70
+              imgUrl: (x.buildingImgList[0] || {}).url,
71
+              marketStatus: (dicts.filter(d => d.id == x.marketStatus)[0] || {}).name
72
+            }
73
+          })
74
+          let propertyType = ''
75
+          data.data.propertyType.split(',').map(x => {
76
+            const f = dicts.filter(d => d.id == x)
77
+            if (f.length > 0) {
78
+              propertyType += (propertyType === '' ? '' : ',') + f[0].name
79
+            }
80
+          })
81
+          _that.setData({
82
+            EstateDetail: {
83
+              ...data.data,
84
+              latitude: data.data.coordinate.split(',')[0] - 0,
85
+              longitude: data.data.coordinate.split(',')[1] - 0,
86
+              markers: [{
87
+                id: data.data.buildingId,
88
+                latitude: data.data.coordinate.split(',')[0] - 0,
89
+                longitude: data.data.coordinate.split(',')[1] - 0,
90
+              }],
91
+              openingDate: data.data.openingDate.split(' ')[0],
92
+              propertyType: propertyType,
93
+              buildingApartment: apart,
94
+              IsCollect: (_that.data.Collects.filter(x => x.buildingId == data.data.buildingId).length > 0 ? true : false),
95
+              Photos: photo || []
96
+            }
97
+          })
80 98
         })
81 99
       })
82 100
     })
@@ -89,59 +107,7 @@ Page({
89 107
     Collects: [],
90 108
     ShowMaxSwiper: false,
91 109
     CurrentImgList: [],
92
-    CurrentIndex: 0,
93
-    LookerList: [{
94
-      icon: '/assets/images/img1.jpg',
95
-      id: ''
96
-    }, {
97
-      icon: '/assets/images/img1.jpg',
98
-      id: ''
99
-    }, {
100
-      icon: '/assets/images/img1.jpg',
101
-      id: ''
102
-    }, {
103
-      icon: '/assets/images/img1.jpg',
104
-      id: ''
105
-    }, {
106
-      icon: '/assets/images/img1.jpg',
107
-      id: ''
108
-    }, {
109
-      icon: '/assets/images/img1.jpg',
110
-      id: ''
111
-    }, {
112
-      icon: '/assets/images/img1.jpg',
113
-      id: ''
114
-    }, {
115
-      icon: '/assets/images/img1.jpg',
116
-      id: ''
117
-    }, {
118
-      icon: '/assets/images/img1.jpg',
119
-      id: ''
120
-    }, {
121
-      icon: '/assets/images/img1.jpg',
122
-      id: ''
123
-    }, {
124
-      icon: '/assets/images/img1.jpg',
125
-      id: ''
126
-    }, {
127
-      icon: '/assets/images/img1.jpg',
128
-      id: ''
129
-    }, {
130
-      icon: '/assets/images/img1.jpg',
131
-      id: ''
132
-    }, {
133
-      icon: '/assets/images/img1.jpg',
134
-      id: ''
135
-    }, {
136
-      icon: '/assets/images/img1.jpg',
137
-      id: ''
138
-    }, {
139
-      icon: '/assets/images/img1.jpg',
140
-      id: ''
141
-    }, {
142
-      icon: '/assets/images/img1.jpg',
143
-      id: ''
144
-    }]
110
+    CurrentIndex: 0
145 111
   },
146 112
   CloseMaxSwiper() { // 关闭大图
147 113
     this.setData({
@@ -189,5 +155,10 @@ Page({
189 155
       path: '/pages/EstateDetail/index?id=' + this.data.EstateDetail.buildingId,
190 156
       imageUrl: this.data.EstateDetail.buildingImg[0].url
191 157
     }
158
+  },
159
+  toMore () {
160
+    wx.navigateTo({
161
+      url: '/pages/VisitorList/index?id=' + this.data.EstateDetail.buildingId,
162
+    })
192 163
   }
193 164
 })

+ 10
- 8
pages/EstateDetail/index.wxml Dosyayı Görüntüle

@@ -2,7 +2,6 @@
2 2
 <view class="container flex-v">
3 3
   <view class="flex-item">
4 4
     <view class="content">
5
-
6 5
       <!-- 轮播图 -->
7 6
       <view class="banner">
8 7
         <view class="imgContent">
@@ -30,11 +29,14 @@
30 29
       <!-- 围观 -->
31 30
       <view class="looker">
32 31
         <text>
33
-          <text>123</text>人围观
32
+          <text>{{EstateDetail.visits.length}}</text>人围观
34 33
         </text>
35 34
         <view class="list">
36
-          <view class="item" wx:for="{{LookerList}}" wx:for-index="index" wx:for-item="item" wx:key="key" wx:if="{{index <= 12}}">
37
-            <image mode="aspectFill" src="{{item.icon}}" class="centerLabel cover"></image>
35
+          <view class="item" wx:for="{{EstateDetail.visits}}" wx:for-index="index" wx:for-item="item" wx:key="key" wx:if="{{index <= 12}}">
36
+            <image mode="aspectFill" src="{{item.avatar}}" data-index="index" class="centerLabel cover"></image>
37
+            <view class="centerLabel" wx:if="{{index === 12}}" bindtap='toMore'>
38
+              <text class="centerLabel">···</text>
39
+            </view>
38 40
           </view>
39 41
         </view>
40 42
       </view>
@@ -100,14 +102,14 @@
100 102
         <view class="map">
101 103
           <view>
102 104
             <view class="mapBox">
103
-              <view>
104
-                <map id="map" markers="{{[]}}" longitude="116.313972" latitude="39.980014" scale="14" style="width: 100%; height: {{height}}px;"></map>
105
+              <view wx:if="EstateDetail">
106
+                <map id="map" markers="{{EstateDetail.markers}}" longitude="{{EstateDetail.longitude}}" latitude="{{EstateDetail.latitude}}" scale="14" style="width: 100%; height: {{height}}px;"></map>
105 107
               </view>
106 108
             </view>
107 109
             <view class="flex-h">
108 110
               <view class="flex-item">
109
-                <text>银城颐居悦见山</text>
110
-                <text>白马路111号</text>
111
+                <text>{{EstateDetail.buildingName}}</text>
112
+                <text>{{EstateDetail.address}}</text>
111 113
               </view>
112 114
               <text>前往</text>
113 115
               <image mode="widthFix" src="/assets/images/icon1.png"></image>

+ 5
- 4
pages/EstateDetail/index.wxss Dosyayı Görüntüle

@@ -88,6 +88,7 @@
88 88
   line-height: 44rpx;
89 89
   margin-right: 40rpx;
90 90
   margin-left: 20rpx;
91
+  max-width:50%;
91 92
 }
92 93
 
93 94
 .remark > view > text {
@@ -356,17 +357,17 @@
356 357
   margin-left: 0;
357 358
 }
358 359
 
359
-.looker .list > view:last-child::after {
360
-  content: '···';
360
+.looker .list > view > view{
361 361
   width: 100%;
362 362
   height: 100%;
363 363
   position: absolute;
364 364
   display: block;
365 365
   z-index: 2;
366 366
   background: rgba(0, 0, 0, 0.5);
367
+}
368
+
369
+.looker .list > view > view text {
367 370
   color: #fff;
368
-  text-align: center;
369
-  line-height: 64rpx;
370 371
 }
371 372
 
372 373
 .map {

+ 13
- 18
pages/VisitorList/index.js Dosyayı Görüntüle

@@ -11,25 +11,20 @@ Page({
11 11
       title: '访客列表'
12 12
     })
13 13
   },
14
-  onLoad: function(options) {},
14
+  onLoad: function(options) {
15
+    const id = page.getCurrentPageOptions().id
16
+    const _that = this
17
+    fetch({
18
+      url: $api.building.detail.url.replace(':id', id),
19
+      method: $api.building.detail.method,
20
+    }).then((data) => {
21
+      _that.setData({
22
+        list: data.data.visits
23
+      })
24
+    })
25
+  },
15 26
   data: {
16 27
     UserInfo: app.globalData.UserInfo,
17
-    list: [{
18
-      icon: '/assets/images/img1.jpg',
19
-      createDate: '2019-02-02',
20
-      name: '示例用户名'
21
-    }, {
22
-      icon: '/assets/images/img1.jpg',
23
-      createDate: '2019-02-02',
24
-      name: '示例用户名'
25
-    }, {
26
-      icon: '/assets/images/img1.jpg',
27
-      createDate: '2019-02-02',
28
-      name: '示例用户名'
29
-    }, {
30
-      icon: '/assets/images/img1.jpg',
31
-      createDate: '2019-02-02',
32
-      name: '示例用户名'
33
-    }]
28
+    list: []
34 29
   }
35 30
 })

+ 3
- 3
pages/VisitorList/index.wxml Dosyayı Görüntüle

@@ -3,10 +3,10 @@
3 3
   <view>
4 4
     <view class="flex-h" wx:for="{{list}}" wx:for-item="item" wx:for-index="index" wx:key="key">
5 5
       <view class="icon">
6
-        <image mode="aspectFill" src="{{item.icon}}" class="centerLabel cover"></image>
6
+        <image mode="aspectFill" src="{{item.avatar}}" class="centerLabel cover"></image>
7 7
       </view>
8
-      <text class="flex-item">{{item.name}}</text>
9
-      <text>{{item.createDate}}</text>
8
+      <text class="flex-item">{{item.customerName}}</text>
9
+      <text>{{item.visitDate}}</text>
10 10
     </view>
11 11
   </view>
12 12
 </view>

+ 21
- 0
pages/components/SubIndex/index.js Dosyayı Görüntüle

@@ -104,6 +104,7 @@ Component({
104 104
       return s / 100
105 105
     },
106 106
     ItemTap(e) {
107
+      console.log(e)
107 108
       wx.navigateTo({
108 109
         url: '/pages/EstateDetail/index?id=' + e.target.dataset.id
109 110
       })
@@ -122,6 +123,26 @@ Component({
122 123
           phoneNumber: '025-86505555'
123 124
         })
124 125
       }
126
+    },
127
+    toMap() {
128
+      wx.navigateTo({
129
+        url: '/pages/map/testmap',
130
+      })
131
+    },
132
+    toBuildingShow() {
133
+      this.triggerEvent('myevent', {
134
+        index: 1
135
+      })
136
+    },
137
+    toGf() {
138
+      wx.navigateTo({
139
+        url: '/pages/SelfServiceTool/index'
140
+      })
141
+    },
142
+    toTel() {
143
+      wx.makePhoneCall({
144
+        phoneNumber: '025-86505555'
145
+      })
125 146
     }
126 147
   }
127 148
 })

+ 35
- 28
pages/components/SubIndex/index.wxml Dosyayı Görüntüle

@@ -53,45 +53,54 @@
53 53
   </view> -->
54 54
 
55 55
   <view class="top">
56
-    <image mode="aspectFill" src="/assets/images/img1.jpg" class="centerLabel cover"></image>
56
+    <!-- <image mode="aspectFill" src="/assets/images/img1.jpg" class="centerLabel cover"></image> -->
57
+    <view class="topView">
58
+      <swiper style='height:100%' autoplay="{{true}}" indicator-dots="{{false}}" indicator-color="#83837d" indicator-active-color="#e23838">
59
+        <block wx:for="{{banner}}" wx:for-item="item" wx:for-index="index" wx:key="key">
60
+          <swiper-item>
61
+            <view class="swiper-item">
62
+              <image mode="aspectFill" src="{{item.url}}" class="centerLabel cover"></image>
63
+            </view>
64
+          </swiper-item>
65
+        </block>
66
+      </swiper>
67
+    </view>
57 68
   </view>
58 69
 
59 70
   <view class="nav">
60 71
     <view class="flex-h">
61
-      <view class="flex-item">
72
+      <view class="flex-item" bindtap="toBuildingShow">
62 73
         <image mode="widthFix" src="/assets/images/icon5.png"></image>
63 74
         <text>楼盘展示</text>
64 75
       </view>
65
-      <view class="flex-item">
76
+      <view class="flex-item" bindtap="toGf">
66 77
         <image mode="widthFix" src="/assets/images/icon6.png"></image>
67 78
         <text>购房工具</text>
68 79
       </view>
69
-      <view class="flex-item">
80
+      <view class="flex-item" bindtap='toTel'>
70 81
         <image mode="widthFix" src="/assets/images/icon7.png"></image>
71 82
         <text>电话咨询</text>
72 83
       </view>
73 84
     </view>
74 85
   </view>
75 86
 
76
-  <text class="title">地图看房</text>
87
+  <text class="title" >地图看房</text>
77 88
 
78 89
   <view class="mapList">
79 90
     <view class="flex-h">
80 91
       <view class="flex-item">
81
-        <!-- <text>银城颐居悦见山</text>
82
-        <text>均价:<text>¥18000</text>元/m²</text> -->
83 92
         <swiper autoplay="{{true}}" style="height: 100rpx;" vertical="{{true}}">
84
-          <block wx:for="{{['','','']}}" wx:for-item="item" wx:for-index="index" wx:key="key">
93
+          <block wx:for="{{EstateList}}" wx:for-item="item" wx:for-index="index" wx:key="key">
85 94
             <swiper-item>
86 95
               <view class="swiper-item">
87
-                <text>银城颐居悦见山</text>
88
-                <text>均价:<text>¥18000</text>元/m²</text>
96
+                <text>{{item.buildingName}}</text>
97
+                <text>均价:<text>{{item.price}}</text></text>
89 98
               </view>
90 99
             </swiper-item>
91 100
           </block>
92 101
         </swiper>
93 102
       </view>
94
-      <view>
103
+      <view bindtap="toMap">
95 104
         <image mode="widthFix" src="/assets/images/icon7.png"></image>
96 105
         <text>地图看新房</text>
97 106
       </view>
@@ -101,28 +110,26 @@
101 110
   <text class="title">精选房源</text>
102 111
 
103 112
   <view class="roomList">
104
-    <view wx:for="{{['', '', '']}}" wx:for-index="index" wx:for-item="item" wx:key="key">
113
+    <view wx:for="{{EstateList}}" wx:for-item="item" wx:for-index="index" wx:key="key" data-id="{{item.buildingId}}" bindtap='ItemTap'>
105 114
       <view class="img">
106
-        <image mode="aspectFill" src="/assets/images/img1.jpg" class="centerLabel cover"></image>
107
-        <view class="flex-h">
108
-          <view class="flex-item">
109
-            <text>111</text>
110
-            <text>111</text>
111
-            <text>111</text>
115
+        <image mode="aspectFill" data-id="{{item.buildingId}}" src="{{item.buildingImg[0].url}}" class="centerLabel cover"></image>
116
+        <view class="flex-h" data-id="{{item.buildingId}}" >
117
+          <view class="flex-item" data-id="{{item.buildingId}}" >
118
+            <text data-id="{{item.buildingId}}" wx:for="{{item.buildingTag}}" wx:for-item="tag" wx:for-index="index" wx:key="key">{{tag.tagName}}</text>
112 119
           </view>
113
-          <image mode="widthFix" src="/assets/images/icon7.png"></image>
114
-          <text>浦口区</text>
120
+          <image data-id="{{item.buildingId}}" mode="widthFix" src="/assets/images/icon7.png"></image>
121
+          <text data-id="{{item.buildingId}}">{{item.buildingArea}}</text>
115 122
         </view>
116 123
       </view>
117
-      <text class="icon">热销</text>
118
-      <view class="info">
119
-        <view class="flex-h">
120
-          <text class="flex-item">示例标题</text>
121
-          <text>均价:<text>¥1.8</text>万元/m²</text>
124
+      <text data-id="{{item.buildingId}}" class="icon">{{item.marketStatus || ''}}</text>
125
+      <view data-id="{{item.buildingId}}" class="info">
126
+        <view data-id="{{item.buildingId}}" class="flex-h">
127
+          <text class="flex-item" data-id="{{item.buildingId}}">{{item.buildingName}}</text>
128
+          <text data-id="{{item.buildingId}}">均价:<text>{{item.price}}</text></text>
122 129
         </view>
123
-        <view class="flex-h">
124
-          <text class="flex-item">江北白马路 距您21.2km</text>
125
-          <text>114人围观</text>
130
+        <view data-id="{{item.buildingId}}" class="flex-h">
131
+          <text class="flex-item" data-id="{{item.buildingId}}">{{item.address}} 距您{{item.distance}}km</text>
132
+          <text data-id="{{item.buildingId}}">{{item.visits.length}}人围观</text>
126 133
         </view>
127 134
       </view>
128 135
     </view>

+ 13
- 1
pages/components/SubIndex/index.wxss Dosyayı Görüntüle

@@ -14,6 +14,14 @@
14 14
   background: #eee;
15 15
 }
16 16
 
17
+.topView{
18
+  position: absolute;
19
+  width: 100%;
20
+  top: 0;
21
+  left: 0;
22
+  bottom: 0;
23
+}
24
+
17 25
 .nav {
18 26
   padding: 0 40rpx;
19 27
   position: relative;
@@ -265,7 +273,11 @@
265 273
 
266 274
 .roomList .info > view:nth-child(1) > text:nth-child(2) {
267 275
   line-height: 52rpx;
268
-  font-size: 22rpx;
276
+  font-size:22rpx;
277
+  max-width:50%;
278
+  overflow:hidden;
279
+  white-space:nowrap;
280
+  text-overflow:ellipsis;
269 281
 }
270 282
 
271 283
 .roomList .info > view:nth-child(1) > text text {

+ 231
- 0
pages/map/testmap.js Dosyayı Görüntüle

@@ -0,0 +1,231 @@
1
+// pages/map/testmap.js
2
+var QQMapWX = require('../../utils/qqmap-wx-jssdk.js');
3
+var qqmapsdk;
4
+import fetch from '../../utils/http'
5
+const $api = require('../../config/api.js').$api;
6
+
7
+Page({
8
+
9
+      /**
10
+   * 页面的初始数据
11
+   */
12
+      data: {
13
+        longitude: 116.313972,
14
+        latitude: 39.980014,
15
+        controls: [],
16
+        markers: [],
17
+        height: 'auto',
18
+        markers: [],
19
+        showLayer: false,
20
+        windowHeight: 0,
21
+        scale: 12,
22
+        defaultMarkers: [],
23
+        buildings: [],
24
+        navList: [{
25
+          value: '交通',
26
+          id: 'bus',
27
+          count: '20'
28
+        }, {
29
+          value: '教育',
30
+          id: 'school',
31
+          count: '20'
32
+        }, {
33
+          value: '医疗',
34
+          id: 'hospital',
35
+          count: '20'
36
+        }, {
37
+          value: '商业',
38
+          id: 'business',
39
+          count: '20'
40
+        }],
41
+        navIndex: 0,
42
+        list: [],
43
+        actionBuilding: {}
44
+      },
45
+    
46
+      /**
47
+   * 生命周期函数监听页面加载
48
+   */
49
+  onLoad: function (options) {
50
+    qqmapsdk = new QQMapWX({
51
+      key: 'KJCBZ-G2MKX-DB443-Z4CBR-7E6K2-GJF5D'
52
+    });
53
+    //保证wx.getSystemInfo的回调函数中能够使用this
54
+    var that = this
55
+    //调用wx.getSystemInfo接口,然后动态绑定组件高度
56
+    wx.getSystemInfo({
57
+      success: function (res) {
58
+        that.setData({
59
+          windowHeight: res.windowHeight,
60
+          height: res.windowHeight
61
+        })}
62
+    })
63
+  },
64
+
65
+  clickMarker(marker) {
66
+    const building = this.data.buildings.filter(x => x.buildingId == marker.markerId)[0]
67
+    if (!building) {
68
+      return
69
+    }
70
+    this.setData({
71
+      actionBuilding: building
72
+    })
73
+
74
+    this.search()
75
+  },
76
+
77
+  search() {
78
+    const building = this.data.actionBuilding
79
+    const _this = this
80
+    qqmapsdk.search({
81
+      keyword: _this.data.navList[_this.data.navIndex].value, //搜索关键词
82
+      page_size: 20,
83
+      location: building.coordinate, //设置周边搜索中心点
84
+      success: function (res) { //搜索成功后的回调
85
+        var navlist = []
86
+        for (var i = 0; i < res.data.length; i++) {
87
+          navlist.push({
88
+            value: res.data[i].title,
89
+            id: res.data[i].id,
90
+            distance: res.data[i]._distance
91
+          })
92
+        }
93
+        _this.setData({ //设置markers属性,将搜索结果显示在地图中
94
+          showLayer: true,
95
+          scale: 14,
96
+          latitude: building.coordinate.split(',')[0],
97
+          longitude: building.coordinate.split(',')[1],
98
+          height: 300,
99
+          list: navlist,
100
+        })
101
+      },
102
+      fail: function (res) {
103
+        console.log(res);
104
+      },
105
+      complete: function (res) {
106
+        console.log(res);
107
+      }
108
+    });
109
+  },
110
+
111
+  GetGreatCircleDistance(lat1, lng1, lat2, lng2) {
112
+    if (lat1 === lat2 && lng1 === lng2) {
113
+      return 0
114
+    }
115
+    var EARTH_RADIUS = 6378137.0//单位M
116
+    var PI = Math.PI
117
+    var radLat1 = lat1 * PI / 180.0
118
+    var radLat2 = lat2 * PI / 180.0
119
+    var a = radLat1 - radLat2
120
+    var b = lng1 * PI / 180.0 - lng2 * PI / 180.0
121
+    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)))
122
+    s = s * EARTH_RADIUS
123
+    s = Math.round(s * 10000) / 10000.0
124
+    return s / 100
125
+  },
126
+
127
+    /**
128
+   * 生命周期函数监听页面初次渲染完成
129
+   */
130
+    onReady: function() {
131
+      const _that = this
132
+      fetch({
133
+        url: $api.building.mainlist.url,
134
+        method: $api.building.mainlist.method,
135
+        data: {
136
+          pageNum: 1,
137
+          pageSize: 10
138
+        }
139
+      }).then((buildings) => {
140
+        const markers = buildings.data.map(x => {
141
+          return {
142
+            id: x.buildingId,
143
+            latitude: x.coordinate.split(',')[0],
144
+            longitude: x.coordinate.split(',')[1],
145
+            iconPath: '',
146
+            label: {
147
+              content: x.buildingName,
148
+              color: '#fff',
149
+              bgColor: '#bb9c79',
150
+              padding: 5,
151
+              borderRadius: 5
152
+            }
153
+          }
154
+        })
155
+        _that.setData({
156
+          defaultMarkers: markers,
157
+          markers: markers,
158
+          longitude: markers[0].longitude,
159
+          latitude: markers[0].latitude,
160
+          buildings: buildings.data
161
+        })
162
+      })
163
+
164
+    },
165
+
166
+    /**
167
+   * 生命周期函数监听页面显示
168
+   */
169
+    onShow: function() {
170
+    
171
+    },
172
+
173
+    /**
174
+   * 生命周期函数监听页面隐藏
175
+   */
176
+    onHide: function() {
177
+    
178
+    },
179
+
180
+    /**
181
+   * 生命周期函数监听页面卸载
182
+   */
183
+    onUnload: function() {
184
+    
185
+    },
186
+
187
+    /**
188
+   * 页面相关事件处理函数监听用户下拉动作
189
+   */
190
+    onPullDownRefresh: function() {
191
+    
192
+    },
193
+
194
+    /**
195
+   * 页面上拉触底事件的处理函数
196
+   */
197
+    onReachBottom: function() {
198
+    
199
+    },
200
+
201
+    /**
202
+   * 用户点击右上角分享
203
+   */
204
+    onShareAppMessage: function() {
205
+    
206
+    },
207
+    cutNav(e) {
208
+      this.setData({
209
+        navIndex: e.target.dataset.index
210
+      })
211
+      this.search()
212
+  },
213
+  closeLayer(){
214
+    this.setData({
215
+      showLayer: false,
216
+      height: this.data.windowHeight
217
+    })
218
+  },
219
+  toFirstPage() {
220
+    wx.navigateTo({
221
+      url: '/pages/index/index'
222
+    })
223
+  },
224
+  toDaohang() {
225
+    wx.openLocation({
226
+      latitude: this.data.actionBuilding.coordinate.split(',')[0] - 0,
227
+      longitude: this.data.actionBuilding.coordinate.split(',')[1] - 0,
228
+      scale: 16
229
+    })
230
+  }
231
+})

+ 14
- 14
pages/map/testmap.wxml Dosyayı Görüntüle

@@ -1,39 +1,39 @@
1 1
 <view class="container">
2 2
   <view class="map">
3
-    <map bindtouchstart="closeLayer" id="map" markers="{{markers}}" longitude="116.313972" latitude="39.980014" scale="14" style="width: 100%; height: {{height}}px;"></map>
3
+    <map bindtouchstart="closeLayer" bindmarkertap="clickMarker" id="map" markers="{{markers}}" longitude="{{longitude}}" latitude="{{latitude}}" scale="{{scale}}" style="width: 100%; height: {{height}}px;"></map>
4 4
   </view>
5 5
   <cover-view class="layer flex-v {{showLayer ? 'active' : ''}}">
6 6
     <cover-view class="nav">
7
-      <cover-view class="navItem">
7
+      <cover-view class="navItem" bindtap="toFirstPage">
8 8
         <cover-view class="centerLabel">
9
-          <cover-image class="navImg" mode="widthFix" src="/assets/images/icon1.png"></cover-image>
9
+          <cover-image class="navImg" mode="widthFix" src="/assets/images/firstpage.png"></cover-image>
10 10
           <cover-view class="navText">首页</cover-view>
11 11
         </cover-view>
12 12
       </cover-view>
13
-      <cover-view class="navItem">
14
-        <cover-view class="centerLabel">
15
-          <cover-image class="navImg" mode="widthFix" src="/assets/images/icon1.png"></cover-image>
13
+      <cover-view class="navItem" >
14
+        <button class="centerLabel" open-type="share">
15
+          <cover-image class="navImg" mode="widthFix" src="/assets/images/share.png"></cover-image>
16 16
           <cover-view class="navText">分享</cover-view>
17
-        </cover-view>
17
+        </button>
18 18
       </cover-view>
19
-      <cover-view class="navItem">
19
+      <!-- <cover-view class="navItem">
20 20
         <cover-view class="centerLabel">
21 21
           <cover-image class="navImg" mode="widthFix" src="/assets/images/icon1.png"></cover-image>
22 22
           <cover-view class="navText">南京</cover-view>
23 23
         </cover-view>
24
-      </cover-view>
24
+      </cover-view> -->
25 25
     </cover-view>
26 26
     <cover-view class="mainDetail flex-item">
27 27
       <cover-view class="detail flex-v">
28 28
         <cover-view class="top flex-h">
29 29
           <cover-view class="flex-item">
30
-            <cover-view class="name">银城颐居悦见山</cover-view>
31
-            <cover-view class="remark">老山风景区</cover-view>
32
-            <cover-view class="remark">项目自带商业</cover-view>
30
+            <cover-view class="name">{{actionBuilding.buildingName}}</cover-view>
31
+            <cover-view class="remark">{{actionBuilding.buildingTag[0].tagName || ''}}</cover-view>
32
+            <cover-view class="remark">{{actionBuilding.buildingTag[1].tagName || ''}}</cover-view>
33 33
           </cover-view>
34
-          <cover-view class="btn">
34
+          <cover-view class="btn" bindtap='toDaohang'>
35 35
             <cover-view class="centerLabel">
36
-              <cover-image class="btnImg" mode="widthFix" src="/assets/images/icon1.png"></cover-image>
36
+              <cover-image class="btnImg" mode="widthFix" src="/assets/images/daohang.png"></cover-image>
37 37
               <cover-view class="text">导航</cover-view>
38 38
             </cover-view>
39 39
           </cover-view>

+ 13
- 3
pages/map/testmap.wxss Dosyayı Görüntüle

@@ -46,14 +46,24 @@
46 46
   margin-left: 10px;
47 47
 }
48 48
 
49
+.layer .navItem button{
50
+  padding: 0;
51
+  line-height: 0;
52
+  color: #fff;
53
+  background: none;
54
+  border: none;
55
+  font-size: 20px;
56
+}
57
+
49 58
 .layer .nav .centerLabel {
50 59
   text-align: center;
51 60
   width: 100%;
52 61
 }
53 62
 
54 63
 .layer .navImg  {
55
-  max-width: 16px;
56
-  max-height: 16px;
64
+  /* max-width: 16px;
65
+  max-height: 16px; */
66
+  width: 14px;
57 67
   display: inline-block;
58 68
 }
59 69
 
@@ -63,7 +73,7 @@
63 73
   color: #666;
64 74
   width: 100%;
65 75
   display: block;
66
-  margin-top: -5rpx;
76
+  margin-top: -10rpx;
67 77
 }
68 78
 
69 79
 .layer .mainDetail {