wangfei 6 年之前
父節點
當前提交
1e536948cd
共有 3 個檔案被更改,包括 27 行新增13 行删除
  1. 6
    6
      config/api.js
  2. 21
    6
      pages/EstateDetail/index.js
  3. 0
    1
      utils/http.js

+ 6
- 6
config/api.js 查看文件

37
       url: `${BaseAPIURl}wx/building/list`
37
       url: `${BaseAPIURl}wx/building/list`
38
     },
38
     },
39
     detail: {
39
     detail: {
40
-      methods: 'GET',
40
+      method: 'GET',
41
       url: `${BaseAPIURl}/wx/buildingSelectId/:id`
41
       url: `${BaseAPIURl}/wx/buildingSelectId/:id`
42
     }
42
     }
43
   },
43
   },
63
   },
63
   },
64
   appointment: {
64
   appointment: {
65
     getByUser: {
65
     getByUser: {
66
-      methods: 'GET',
66
+      method: 'GET',
67
       url: `${BaseAPIURl}/wx/appointment/:openid`
67
       url: `${BaseAPIURl}/wx/appointment/:openid`
68
     },
68
     },
69
     save: {
69
     save: {
70
-      methods: 'POST',
70
+      method: 'POST',
71
       url: `${BaseAPIURl}/wx/appointment/:openid`
71
       url: `${BaseAPIURl}/wx/appointment/:openid`
72
     }
72
     }
73
   },
73
   },
74
   collection: {
74
   collection: {
75
     getByUser: {
75
     getByUser: {
76
-      methods: 'GET',
76
+      method: 'GET',
77
       url: `${BaseAPIURl}/wx/collection/:openid`
77
       url: `${BaseAPIURl}/wx/collection/:openid`
78
     },
78
     },
79
     save: {
79
     save: {
80
-      methods: 'POST',
80
+      method: 'POST',
81
       url: `${BaseAPIURl}/wx/collection/:openid`
81
       url: `${BaseAPIURl}/wx/collection/:openid`
82
     },
82
     },
83
     deleteById: {
83
     deleteById: {
84
-      methods: 'DELETE',
84
+      method: 'DELETE',
85
       url: `${BaseAPIURl}/wx/collection/:openid`
85
       url: `${BaseAPIURl}/wx/collection/:openid`
86
     }
86
     }
87
   }
87
   }

+ 21
- 6
pages/EstateDetail/index.js 查看文件

17
     const _that = this
17
     const _that = this
18
 
18
 
19
     fetch({
19
     fetch({
20
-      url: $api.collection.getByUser.replace(':openid', app.globalData.UserInfo.openid),
21
-      method: $api.collection.getByUser.method
20
+      url: $api.collection.getByUser.url.replace(':openid', app.globalData.UserInfo.openid),
21
+      method: $api.collection.getByUser.method,
22
+      data: {
23
+        pageNum: 1,
24
+        pageSize: 100
25
+      }
22
     }).then((collects) => {
26
     }).then((collects) => {
23
-      console.log(collects)
27
+      _that.setData({
28
+        Collects: collects.data.records
29
+      })
24
       fetch({
30
       fetch({
25
         url: $api.building.detail.url.replace(':id', id),
31
         url: $api.building.detail.url.replace(':id', id),
26
         method: $api.building.detail.method,
32
         method: $api.building.detail.method,
41
           }
47
           }
42
         })
48
         })
43
         _that.setData({
49
         _that.setData({
44
-          EstateDetail: { ...data.data, propertyType: propertyType, buildingApartment: apart }
50
+          EstateDetail: { 
51
+            ...data.data, 
52
+            propertyType: propertyType, 
53
+            buildingApartment: apart, 
54
+            IsCollect: (_that.data.Collects.filter(x => x.buildingId == data.data.buildingId).length>0? true:false)
55
+            }
45
         })
56
         })
46
       })
57
       })
47
     })
58
     })
49
   data: {
60
   data: {
50
     UserInfo: app.globalData.UserInfo,
61
     UserInfo: app.globalData.UserInfo,
51
     ScreenBottomHeight: app.globalData.ScreenBottomHeight,
62
     ScreenBottomHeight: app.globalData.ScreenBottomHeight,
52
-    EstateDetail: {}
63
+    EstateDetail: {},
64
+    Collects: []
53
   },
65
   },
54
   MakeAnAppointment() { // 预约看房
66
   MakeAnAppointment() { // 预约看房
55
     wx.navigateTo({
67
     wx.navigateTo({
57
     })
69
     })
58
   },
70
   },
59
   MakeCollect() {
71
   MakeCollect() {
60
-    app.globalData.UserInfo.openid
72
+    const _that = this
61
     fetch({
73
     fetch({
62
       url: $api.collection.save.url.replace(':openid', app.globalData.UserInfo.openid) + '?buildingId=' + this.data.EstateDetail.buildingId,
74
       url: $api.collection.save.url.replace(':openid', app.globalData.UserInfo.openid) + '?buildingId=' + this.data.EstateDetail.buildingId,
63
       method: $api.collection.save.method,
75
       method: $api.collection.save.method,
65
       wx.showToast({
77
       wx.showToast({
66
         title: '收藏成功!'
78
         title: '收藏成功!'
67
       })
79
       })
80
+      _that.setData({
81
+        EstateDetail: { ..._that.data.EstateDetail, IsCollect:true}
82
+      })
68
     })
83
     })
69
   },
84
   },
70
   OpenPhone() { // 电话咨询
85
   OpenPhone() { // 电话咨询

+ 0
- 1
utils/http.js 查看文件

7
       method: config.method,
7
       method: config.method,
8
       data: config.data,
8
       data: config.data,
9
       success(res) {
9
       success(res) {
10
-        console.log(res, apiCode)
11
         if (res.statusCode && res.statusCode === apiCode.success) {
10
         if (res.statusCode && res.statusCode === apiCode.success) {
12
           resolve(res.data)
11
           resolve(res.data)
13
         } else {
12
         } else {