wangfei 6 лет назад
Родитель
Сommit
77feee7e33

+ 12
- 1
app.js Просмотреть файл

1
 //app.js
1
 //app.js
2
 
2
 
3
+const HttpSever = require('./utils/http.js').HttpSever;
4
+const $api = require('./config/api.js').$api;
5
+
3
 App({
6
 App({
4
   onLaunch: function() {
7
   onLaunch: function() {
5
     let _self = this
8
     let _self = this
10
         }
13
         }
11
       }
14
       }
12
     })
15
     })
16
+
17
+    HttpSever.Ajax({
18
+      url: $api.dict.list.url,
19
+      method: $api.dict.list.method,
20
+    }).then((data) => {
21
+      _self.globalData.Dict = data.data
22
+    })
13
   },
23
   },
14
   globalData: {
24
   globalData: {
15
     UserInfo: {
25
     UserInfo: {
17
       UserName: '用户名',
27
       UserName: '用户名',
18
       UserPhone: '18267901393'
28
       UserPhone: '18267901393'
19
     },
29
     },
20
-    ScreenBottomHeight: 0
30
+    ScreenBottomHeight: 0,
31
+    Dict: []
21
   }
32
   }
22
 })
33
 })

+ 10
- 0
config/api.js Просмотреть файл

11
       url: `${BaseAPIURl}/wx/info/:appid`
11
       url: `${BaseAPIURl}/wx/info/:appid`
12
     },
12
     },
13
   },
13
   },
14
+  dict: {
15
+    list: {
16
+      methods: 'GET',
17
+      url: `${BaseAPIURl}/dict`
18
+    }
19
+  },
14
   banner: {
20
   banner: {
15
     list: {
21
     list: {
16
       methods: 'GET',
22
       methods: 'GET',
22
       methods: 'GET',
28
       methods: 'GET',
23
       url: `${BaseAPIURl}/wx/building/list`
29
       url: `${BaseAPIURl}/wx/building/list`
24
     },
30
     },
31
+    detail: {
32
+      methods: 'GET',
33
+      url: `${BaseAPIURl}/wx/buildingSelectId/:id`
34
+    }
25
   },
35
   },
26
   dynamic: {
36
   dynamic: {
27
     list: {
37
     list: {

+ 16
- 33
pages/AppointmentTime/index.js Просмотреть файл

2
 //获取应用实例
2
 //获取应用实例
3
 const app = getApp()
3
 const app = getApp()
4
 
4
 
5
+const page = require('../../utils/page.js');
6
+const HttpSever = require('../../utils/http.js').HttpSever;
7
+const $api = require('../../config/api.js').$api;
8
+
5
 Page({
9
 Page({
6
   onShow() {
10
   onShow() {
7
     wx.setNavigationBarTitle({
11
     wx.setNavigationBarTitle({
8
       title: '填写预约信息'
12
       title: '填写预约信息'
9
     })
13
     })
14
+    this.setData({
15
+      BuildingId: page.getCurrentPageOptions().id,
16
+      BuildingName: page.getCurrentPageOptions().name
17
+    })
10
   },
18
   },
11
   data: {
19
   data: {
12
     UserInfo: app.globalData.UserInfo, // 用户信息
20
     UserInfo: app.globalData.UserInfo, // 用户信息
13
     SubmitOff: true, // 提交判重开关
21
     SubmitOff: true, // 提交判重开关
22
+    BuildingId: '',
23
+    BuildingName: '',
14
     FormData: { // 提交表单数据
24
     FormData: { // 提交表单数据
15
-      EstateId: '', // 楼盘id
16
       AppointmentDate: '', // 预约时间戳
25
       AppointmentDate: '', // 预约时间戳
17
       Name: '', // 姓名
26
       Name: '', // 姓名
18
       PhoneNum: '', // 手机号
27
       PhoneNum: '', // 手机号
19
       Remark: '' // 备注
28
       Remark: '' // 备注
20
     },
29
     },
21
     AppointmentDate: '', // 预约时间
30
     AppointmentDate: '', // 预约时间
22
-    EstateName: '', // 楼盘名称
23
-    EstateList: [{ // 楼盘列表数据
24
-      value: '示例楼盘A',
25
-      id: '1'
26
-    }, {
27
-      value: '示例楼盘B',
28
-      id: '2'
29
-    }, {
30
-      value: '示例楼盘C',
31
-      id: '3'
32
-    }],
33
-    TriggerSelectEstate: false, // 显隐楼盘选择器
34
     MinDate: new Date().getTime(),
31
     MinDate: new Date().getTime(),
35
     TriggerSelectAppointmentDate: false // 显隐预约时间选择器
32
     TriggerSelectAppointmentDate: false // 显隐预约时间选择器
36
   },
33
   },
39
       this.setData({
36
       this.setData({
40
         SubmitOff: false
37
         SubmitOff: false
41
       })
38
       })
39
+      if (this.FormData)
40
+      HttpSever.Ajax({
41
+        url: $api.building.detail.url.replace(':id', id),
42
+        method: $api.building.detail.method,
43
+      }).then((data) => {})
44
+
42
     }
45
     }
43
   },
46
   },
44
   FormInput(e) { // 表单输入数据绑定
47
   FormInput(e) { // 表单输入数据绑定
73
       MinDate: new Date().getTime(),
76
       MinDate: new Date().getTime(),
74
       TriggerSelectAppointmentDate: true
77
       TriggerSelectAppointmentDate: true
75
     })
78
     })
76
-  },
77
-  SelectEstateConfirm(e) { // 确认选择楼盘
78
-    this.setData({
79
-      FormData: {
80
-        ...this.data.FormData,
81
-        EstateId: e.detail.value.id
82
-      },
83
-      EstateName: e.detail.value.value,
84
-      TriggerSelectEstate: false
85
-    })
86
-  },
87
-  SelectEstateCancel() { // 取消选择楼盘
88
-    this.setData({
89
-      TriggerSelectEstate: false
90
-    })
91
-  },
92
-  SelectEstate() { // 打开楼盘选择器
93
-    this.setData({
94
-      TriggerSelectEstate: true
95
-    })
96
   }
79
   }
97
 })
80
 })

+ 1
- 6
pages/AppointmentTime/index.wxml Просмотреть файл

4
     <view class="flex-h">
4
     <view class="flex-h">
5
       <text><text>*</text>具体楼盘:</text>
5
       <text><text>*</text>具体楼盘:</text>
6
       <view class="flex-item"></view>
6
       <view class="flex-item"></view>
7
-      <text bindtap="SelectEstate">{{EstateName === '' ? '请选择楼盘' : EstateName}}</text>
7
+      <text>{{BuildingName}}</text>
8
       <image mode="widthFix" src="/assets/images/icon12.png" style="width: 22rpx;"></image>
8
       <image mode="widthFix" src="/assets/images/icon12.png" style="width: 22rpx;"></image>
9
     </view>
9
     </view>
10
     <view class="flex-h">
10
     <view class="flex-h">
38
   <view class="btn" bindtap="MakeAnAppointment">
38
   <view class="btn" bindtap="MakeAnAppointment">
39
     <text>预约</text>
39
     <text>预约</text>
40
   </view>
40
   </view>
41
-  <view class="popup" hidden="{{!TriggerSelectEstate}}">
42
-    <view>
43
-      <van-picker show-toolbar columns="{{ EstateList }}" value-key="value" bind:cancel="SelectEstateCancel" bind:confirm="SelectEstateConfirm" />
44
-    </view>
45
-  </view>
46
   <view class="popup" hidden="{{!TriggerSelectAppointmentDate}}">
41
   <view class="popup" hidden="{{!TriggerSelectAppointmentDate}}">
47
     <view>
42
     <view>
48
       <van-datetime-picker min-date="{{MinDate}}" type="datetime" bind:cancel="SelectAppointmentDateCancel" bind:confirm="SelectAppointmentDateConfirm" />
43
       <van-datetime-picker min-date="{{MinDate}}" type="datetime" bind:cancel="SelectAppointmentDateCancel" bind:confirm="SelectAppointmentDateConfirm" />

+ 33
- 30
pages/EstateDetail/index.js Просмотреть файл

2
 //获取应用实例
2
 //获取应用实例
3
 const app = getApp()
3
 const app = getApp()
4
 
4
 
5
+const page = require('../../utils/page.js');
6
+const HttpSever = require('../../utils/http.js').HttpSever;
7
+const $api = require('../../config/api.js').$api;
8
+
5
 Page({
9
 Page({
6
   onShow() {
10
   onShow() {
7
     wx.setNavigationBarTitle({
11
     wx.setNavigationBarTitle({
8
       title: '楼盘详情'
12
       title: '楼盘详情'
9
     })
13
     })
10
   },
14
   },
15
+  onLoad: function (options) {
16
+    const id = page.getCurrentPageOptions().id
17
+    const _that = this
18
+    HttpSever.Ajax({
19
+      url: $api.building.detail.url.replace(':id', id),
20
+      method: $api.building.detail.method,
21
+    }).then((data) => {
22
+      const dicts = app.globalData.Dict
23
+      const apart = data.data.buildingApartment.map(x => {
24
+        return {
25
+          ...x,
26
+          imgUrl: (x.buildingImgList[0] || {}).url,
27
+          marketStatus: (dicts.filter(d => d.id == x.marketStatus)[0] || {}).name
28
+        }
29
+      })
30
+      let propertyType = ''
31
+      data.data.propertyType.split(',').map(x => {
32
+        const f = dicts.filter(d => d.id == x)
33
+        if (f.length > 0) {
34
+          propertyType += (propertyType === '' ? '' : ',') + f[0].name
35
+        }
36
+      })
37
+      _that.setData({
38
+        EstateDetail: { ...data.data, propertyType: propertyType, buildingApartment: apart}
39
+      })
40
+    })
41
+  },
11
   data: {
42
   data: {
12
     UserInfo: app.globalData.UserInfo,
43
     UserInfo: app.globalData.UserInfo,
13
     ScreenBottomHeight: app.globalData.ScreenBottomHeight,
44
     ScreenBottomHeight: app.globalData.ScreenBottomHeight,
14
-    EstateDetail: {
15
-      Name: '楼盘名称', // 楼盘名称
16
-      Price: '14000', // 均价
17
-      Remark: '备注', // 备注
18
-      ImgList: ['/assets/images/img5.jpg', '/assets/images/img5.jpg', '/assets/images/img5.jpg', '/assets/images/img5.jpg'], // banner
19
-      OpenDate: '2016-02-02', // 开盘日期
20
-      Address: '江苏省南京市某某路xx号', // 项目地址
21
-      Type: '叠墅', // 物业类型
22
-      News: '即将开放', // 最新动态
23
-      IsCollect: false, // 是否已收藏
24
-      PhoneNum: '', // 联系电话
25
-      Id: '', // 楼盘id
26
-      RoomTypeList: [{
27
-        Img: '/assets/images/img1.jpg',
28
-        Type: '商住',
29
-        AreaNum: '33',
30
-        State: '在售'
31
-      }, {
32
-        Img: '/assets/images/img1.jpg',
33
-        Type: '商住',
34
-        AreaNum: '33',
35
-        State: '在售'
36
-      }, {
37
-        Img: '/assets/images/img1.jpg',
38
-        Type: '商住',
39
-        AreaNum: '33',
40
-        State: '在售'
41
-      }] // 户型
42
-    }
45
+    EstateDetail: {}
43
   },
46
   },
44
   MakeAnAppointment() { // 预约看房
47
   MakeAnAppointment() { // 预约看房
45
     wx.navigateTo({
48
     wx.navigateTo({
46
-      url: '/pages/AppointmentTime/index?id='
49
+      url: '/pages/AppointmentTime/index?id=' + this.data.EstateDetail.buildingId + '&name=' + this.data.EstateDetail.buildingName
47
     })
50
     })
48
   },
51
   },
49
   OpenPhone() { // 电话咨询
52
   OpenPhone() { // 电话咨询

+ 15
- 15
pages/EstateDetail/index.wxml Просмотреть файл

7
       <view class="banner">
7
       <view class="banner">
8
         <view class="imgContent">
8
         <view class="imgContent">
9
           <swiper autoplay="{{true}}" indicator-dots="{{true}}" indicator-color="#83837d" indicator-active-color="#e23838">
9
           <swiper autoplay="{{true}}" indicator-dots="{{true}}" indicator-color="#83837d" indicator-active-color="#e23838">
10
-            <block wx:for="{{EstateDetail.ImgList}}" wx:for-item="item" wx:for-index="index" wx:key="key">
10
+            <block wx:for="{{EstateDetail.buildingImg}}" wx:for-item="item" wx:for-index="index" wx:key="key">
11
               <swiper-item>
11
               <swiper-item>
12
                 <view class="swiper-item">
12
                 <view class="swiper-item">
13
-                  <image mode="aspectFill" src="{{item}}" class="centerLabel cover"></image>
13
+                  <image mode="aspectFill" src="{{item.url}}" class="centerLabel cover"></image>
14
                 </view>
14
                 </view>
15
               </swiper-item>
15
               </swiper-item>
16
             </block>
16
             </block>
19
         <view class="remark">
19
         <view class="remark">
20
           <view class="centerLabel">
20
           <view class="centerLabel">
21
             <view class="flex-h">
21
             <view class="flex-h">
22
-              <text class="name flex-item">{{EstateDetail.Name}}</text>
23
-              <text class="price">均价:{{EstateDetail.Price}}元/m²</text>
22
+              <text class="name flex-item">{{EstateDetail.buildingName}}</text>
23
+              <text class="price">均价:{{EstateDetail.price}}</text>
24
             </view>
24
             </view>
25
-            <text>{{EstateDetail.Remark}}</text>
25
+            <text>别名:{{EstateDetail.name}}</text>
26
           </view>
26
           </view>
27
         </view>
27
         </view>
28
       </view>
28
       </view>
33
         <view class="list">
33
         <view class="list">
34
           <view class="flex-h">
34
           <view class="flex-h">
35
             <text>开盘时间</text>
35
             <text>开盘时间</text>
36
-            <text class="flex-item">{{EstateDetail.OpenDate}}</text>
36
+            <text class="flex-item">{{EstateDetail.openingDate}}</text>
37
           </view>
37
           </view>
38
           <view class="flex-h">
38
           <view class="flex-h">
39
             <text>项目地址</text>
39
             <text>项目地址</text>
40
-            <text class="flex-item">{{EstateDetail.Address}}</text>
40
+            <text class="flex-item">{{EstateDetail.address}}</text>
41
           </view>
41
           </view>
42
           <view class="flex-h">
42
           <view class="flex-h">
43
             <text>物业类型</text>
43
             <text>物业类型</text>
44
-            <text class="flex-item">{{EstateDetail.Type}}</text>
44
+            <text class="flex-item">{{EstateDetail.propertyType}}</text>
45
           </view>
45
           </view>
46
           <view class="flex-h">
46
           <view class="flex-h">
47
             <text>最新动态</text>
47
             <text>最新动态</text>
48
-            <text class="flex-item">{{EstateDetail.News}}</text>
48
+            <text class="flex-item">{{EstateDetail.dynamic}}</text>
49
           </view>
49
           </view>
50
         </view>
50
         </view>
51
       </view>
51
       </view>
52
 
52
 
53
       <!-- 户型 -->
53
       <!-- 户型 -->
54
       <view class="roomType subContent">
54
       <view class="roomType subContent">
55
-        <text class="title">户型({{EstateDetail.RoomTypeList.length}})</text>
55
+        <text class="title">户型({{EstateDetail.buildingApartment.length}})</text>
56
         <view class="list">
56
         <view class="list">
57
-          <view class="item" wx:for="{{EstateDetail.RoomTypeList}}" wx:for-item="item" wx:for-index="idx" wx:key="key">
57
+          <view class="item" wx:for="{{EstateDetail.buildingApartment}}" wx:for-item="item" wx:for-index="idx" wx:key="key">
58
             <view class="img">
58
             <view class="img">
59
-              <image mode="aspectFill" src="{{item.Img}}" class="centerLabel cover"></image>
59
+              <image mode="aspectFill" src="{{item.imgUrl}}" class="centerLabel cover"></image>
60
             </view>
60
             </view>
61
             <view class="info">
61
             <view class="info">
62
-              <text>{{item.Type}}</text>
63
-              <text>{{item.AreaNum}}m²</text>
62
+              <text>{{item.apartmentName}}</text>
63
+              <text>{{item.remark}}</text>
64
             </view>
64
             </view>
65
-            <text>{{item.State}}</text>
65
+            <text>{{item.marketStatus}}</text>
66
           </view>
66
           </view>
67
         </view>
67
         </view>
68
       </view>
68
       </view>

+ 6
- 25
pages/components/Estate/index.js Просмотреть файл

9
   properties: {},
9
   properties: {},
10
   data: {
10
   data: {
11
     UserInfo: app.globalData.UserInfo,
11
     UserInfo: app.globalData.UserInfo,
12
-    EstateList: [{
13
-      Name: '示例数据',
14
-      Address: '江北 白马路',
15
-      Distance: '21',
16
-      Price: '1.8',
17
-      Img: '/assets/images/img1.jpg'
18
-    }, {
19
-      Name: '示例数据',
20
-      Address: '江北 白马路',
21
-      Distance: '21',
22
-      Price: '1.8',
23
-      Img: '/assets/images/img1.jpg'
24
-    }, {
25
-      Name: '示例数据',
26
-      Address: '江北 白马路',
27
-      Distance: '21',
28
-      Price: '1.8',
29
-      Img: '/assets/images/img1.jpg'
30
-    }]
12
+    EstateList: []
31
   },
13
   },
32
   lifetimes: {},
14
   lifetimes: {},
33
   ready: function() {
15
   ready: function() {
51
     show: function() {},
33
     show: function() {},
52
   },
34
   },
53
   methods: {
35
   methods: {
54
-    ListTap() { // 跳转楼盘详情
36
+    ListTap(e) { // 跳转楼盘详情
55
       wx.navigateTo({
37
       wx.navigateTo({
56
-        url: '/pages/EstateDetail/index?id='
38
+        url: '/pages/EstateDetail/index?id=' + e.currentTarget.dataset.id
57
       })
39
       })
58
     },
40
     },
59
     GetGreatCircleDistance(lat1, lng1, lat2, lng2) {
41
     GetGreatCircleDistance(lat1, lng1, lat2, lng2) {
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)))
51
       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
52
       s = s * EARTH_RADIUS
71
       s = Math.round(s * 10000) / 10000.0
53
       s = Math.round(s * 10000) / 10000.0
72
-      console.log(s)
73
-      return s
54
+      return s/100
74
     },
55
     },
75
     ShowLocation() {
56
     ShowLocation() {
76
       const _that = this
57
       const _that = this
77
       wx.getLocation({
58
       wx.getLocation({
78
         type: 'wgs84',
59
         type: 'wgs84',
79
         success(res) {
60
         success(res) {
80
-          console.log(res)
81
           HttpSever.Ajax({
61
           HttpSever.Ajax({
82
             url: $api.building.list.url,
62
             url: $api.building.list.url,
83
             method: $api.building.list.method,
63
             method: $api.building.list.method,
85
             const eslist = data.data.map(x => {
65
             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))
66
               const distance = parseInt(_that.GetGreatCircleDistance(res.latitude, res.longitude, x.coordinate.split(',')[0], x.coordinate.split(',')[1] || res.longitude))
87
               return {
67
               return {
68
+                buildingId: x.buildingId,
88
                 buildingName: x.buildingName,
69
                 buildingName: x.buildingName,
89
                 price: x.price,
70
                 price: x.price,
90
                 address: x.address,
71
                 address: x.address,
91
                 buildingImg: (x.buildingImg[0] || {}).url,
72
                 buildingImg: (x.buildingImg[0] || {}).url,
92
-                distance: distance / 1000
73
+                distance: distance / 10
93
               }
74
               }
94
             })
75
             })
95
             _that.setData({
76
             _that.setData({

+ 1
- 1
pages/components/Estate/index.wxml Просмотреть файл

8
   <view class="EstateList">
8
   <view class="EstateList">
9
     <text>附近楼盘</text>
9
     <text>附近楼盘</text>
10
     <view class="list">
10
     <view class="list">
11
-      <view wx:for="{{EstateList}}" wx:for-item="item" wx:for-index="index" wx:key="key" bindtap="ListTap">
11
+      <view wx:for="{{EstateList}}" wx:for-item="item" wx:for-index="index" wx:key="key" data-id="{{item.buildingId}}" bindtap="ListTap">
12
         <image mode="aspectFill" src="{{item.buildingImg}}" class="centerLabel cover"></image>
12
         <image mode="aspectFill" src="{{item.buildingImg}}" class="centerLabel cover"></image>
13
         <text class="price">均价:{{item.price}}</text>
13
         <text class="price">均价:{{item.price}}</text>
14
         <text class="name">{{item.buildingName}}</text>
14
         <text class="name">{{item.buildingName}}</text>

+ 0
- 3
utils/http.js Просмотреть файл

17
         data: {
17
         data: {
18
           ...config.data
18
           ...config.data
19
         },
19
         },
20
-        header: {
21
-          'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
22
-        },
23
         success(res) {
20
         success(res) {
24
           if (res.statusCode && res.statusCode === apiCode.common.successCode) {
21
           if (res.statusCode && res.statusCode === apiCode.common.successCode) {
25
             resolve(res.data)
22
             resolve(res.data)

+ 39
- 0
utils/page.js Просмотреть файл

1
+/*获取当前页url*/
2
+function getCurrentPageUrl() {
3
+  var pages = getCurrentPages()    //获取加载的页面
4
+  var currentPage = pages[pages.length - 1]    //获取当前页面的对象
5
+  var url = currentPage.route    //当前页面url
6
+  return url
7
+}
8
+
9
+/*获取当前页参数*/
10
+function getCurrentPageOptions() {
11
+  var pages = getCurrentPages()    //获取加载的页面
12
+  var currentPage = pages[pages.length - 1]    //获取当前页面的对象
13
+  var options = currentPage.options    //当前页面所有参数
14
+  return options
15
+}
16
+
17
+/*获取当前页带参数的url*/
18
+function getCurrentPageUrlWithArgs() {
19
+  var pages = getCurrentPages()    //获取加载的页面
20
+  var currentPage = pages[pages.length - 1]    //获取当前页面的对象
21
+  var url = currentPage.route    //当前页面url
22
+  var options = currentPage.options    //如果要获取url中所带的参数可以查看options
23
+
24
+  //拼接url的参数
25
+  var urlWithArgs = url + '?'
26
+  for (var key in options) {
27
+    var value = options[key]
28
+    urlWithArgs += key + '=' + value + '&'
29
+  }
30
+  urlWithArgs = urlWithArgs.substring(0, urlWithArgs.length - 1)
31
+
32
+  return urlWithArgs
33
+} 
34
+
35
+module.exports = {
36
+  getCurrentPageUrl: getCurrentPageUrl,
37
+  getCurrentPageUrlWithArgs: getCurrentPageUrlWithArgs,
38
+  getCurrentPageOptions: getCurrentPageOptions
39
+}