wangfei 6 lat temu
rodzic
commit
1e536948cd
3 zmienionych plików z 27 dodań i 13 usunięć
  1. 6
    6
      config/api.js
  2. 21
    6
      pages/EstateDetail/index.js
  3. 0
    1
      utils/http.js

+ 6
- 6
config/api.js Wyświetl plik

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

+ 21
- 6
pages/EstateDetail/index.js Wyświetl plik

@@ -17,10 +17,16 @@ Page({
17 17
     const _that = this
18 18
 
19 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 26
     }).then((collects) => {
23
-      console.log(collects)
27
+      _that.setData({
28
+        Collects: collects.data.records
29
+      })
24 30
       fetch({
25 31
         url: $api.building.detail.url.replace(':id', id),
26 32
         method: $api.building.detail.method,
@@ -41,7 +47,12 @@ Page({
41 47
           }
42 48
         })
43 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,7 +60,8 @@ Page({
49 60
   data: {
50 61
     UserInfo: app.globalData.UserInfo,
51 62
     ScreenBottomHeight: app.globalData.ScreenBottomHeight,
52
-    EstateDetail: {}
63
+    EstateDetail: {},
64
+    Collects: []
53 65
   },
54 66
   MakeAnAppointment() { // 预约看房
55 67
     wx.navigateTo({
@@ -57,7 +69,7 @@ Page({
57 69
     })
58 70
   },
59 71
   MakeCollect() {
60
-    app.globalData.UserInfo.openid
72
+    const _that = this
61 73
     fetch({
62 74
       url: $api.collection.save.url.replace(':openid', app.globalData.UserInfo.openid) + '?buildingId=' + this.data.EstateDetail.buildingId,
63 75
       method: $api.collection.save.method,
@@ -65,6 +77,9 @@ Page({
65 77
       wx.showToast({
66 78
         title: '收藏成功!'
67 79
       })
80
+      _that.setData({
81
+        EstateDetail: { ..._that.data.EstateDetail, IsCollect:true}
82
+      })
68 83
     })
69 84
   },
70 85
   OpenPhone() { // 电话咨询

+ 0
- 1
utils/http.js Wyświetl plik

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