zjxpcyc 6 лет назад
Родитель
Сommit
d677423ae2

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

@@ -61,6 +61,30 @@ const $api = {
61 61
       url: `${BaseAPIURl}wx/activity/:id`
62 62
     }
63 63
   },
64
+  appointment: {
65
+    getByUser: {
66
+      methods: 'GET',
67
+      url: `${BaseAPIURl}/wx/appointment/:openid`
68
+    },
69
+    save: {
70
+      methods: 'POST',
71
+      url: `${BaseAPIURl}/wx/appointment/:openid`
72
+    }
73
+  },
74
+  collection: {
75
+    getByUser: {
76
+      methods: 'GET',
77
+      url: `${BaseAPIURl}/wx/collection/:openid`
78
+    },
79
+    save: {
80
+      methods: 'POST',
81
+      url: `${BaseAPIURl}/wx/collection/:openid`
82
+    },
83
+    deleteById: {
84
+      methods: 'DELETE',
85
+      url: `${BaseAPIURl}/wx/collection/:openid`
86
+    }
87
+  }
64 88
 }
65 89
 
66 90
 const hasKey = (o, k) => Object.keys(o).indexOf(k) > -1

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

@@ -3,7 +3,7 @@
3 3
 const app = getApp()
4 4
 
5 5
 const page = require('../../utils/page.js');
6
-const HttpSever = require('../../utils/http.js').HttpSever;
6
+import fetch from '../../utils/http'
7 7
 const $api = require('../../config/api.js').$api;
8 8
 
9 9
 Page({
@@ -36,12 +36,47 @@ Page({
36 36
       this.setData({
37 37
         SubmitOff: false
38 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
-
39
+      if (this.data.FormData.AppointmentDate == '') {
40
+        wx.showToast({
41
+          title: '请选择预约时间',
42
+          icon: 'none'
43
+        })
44
+        return
45
+      }
46
+      if (this.data.FormData.Name == '') {
47
+        wx.showToast({
48
+          title: '请填写您的姓名',
49
+          icon: 'none'
50
+        })
51
+        return
52
+      }
53
+      if (this.data.FormData.PhoneNum == '') {
54
+        wx.showToast({
55
+          title: '请输入您的手机号',
56
+          icon: 'none'
57
+        })
58
+        return
59
+      }
60
+      fetch({
61
+        url: $api.appointment.save.url.replace(':openid', app.globalData.UserInfo.openid),
62
+        method: $api.appointment.save.method,
63
+        data: JSON.stringify({
64
+          buildingId: this.data.BuildingId,
65
+          appointmentDate: this.data.FormData.AppointmentDate,
66
+          customerName: this.data.FormData.Name,
67
+          phone: this.data.FormData.PhoneNum,
68
+          remark: this.data.FormData.Remark
69
+        })
70
+      }).then((data) => {
71
+        wx.showToast({
72
+          title: '预约成功!',
73
+          success: () => {
74
+            wx.navigateTo({
75
+              url: '/pages/EstateDetail/index?id=' + this.data.BuildingId
76
+            })
77
+          }
78
+        })
79
+      })
45 80
     }
46 81
   },
47 82
   FormInput(e) { // 表单输入数据绑定

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

@@ -8,7 +8,7 @@
8 8
       <image mode="widthFix" src="/assets/images/icon12.png" style="width: 22rpx;"></image>
9 9
     </view>
10 10
     <view class="flex-h">
11
-      <text>选择预约时间:</text>
11
+      <text><text>*</text>选择预约时间:</text>
12 12
       <view class="flex-item"></view>
13 13
       <text bindtap="SelectAppointmentDate">{{AppointmentDate === '' ? '请选择预约时间' : AppointmentDate}}</text>
14 14
       <image mode="widthFix" src="/assets/images/icon12.png" style="width: 22rpx;"></image>
@@ -28,7 +28,7 @@
28 28
       </view>
29 29
     </view>
30 30
     <view class="flex-h">
31
-      <text><text>*</text>备注:</text>
31
+      <text>备注:</text>
32 32
       <view class="flex-item">
33 33
         <input placeholder="请输入备注信息" data-name="Remark" bindinput="FormInput" />
34 34
       </view>

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

@@ -3,7 +3,7 @@
3 3
 const app = getApp()
4 4
 
5 5
 const page = require('../../utils/page.js');
6
-const HttpSever = require('../../utils/http.js').HttpSever;
6
+import fetch from '../../utils/http'
7 7
 const $api = require('../../config/api.js').$api;
8 8
 
9 9
 Page({
@@ -15,27 +15,34 @@ Page({
15 15
   onLoad: function (options) {
16 16
     const id = page.getCurrentPageOptions().id
17 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}
18
+
19
+    fetch({
20
+      url: $api.collection.getByUser.replace(':openid', app.globalData.UserInfo.openid),
21
+      method: $api.collection.getByUser.method
22
+    }).then((collects) => {
23
+      console.log(collects)
24
+      fetch({
25
+        url: $api.building.detail.url.replace(':id', id),
26
+        method: $api.building.detail.method,
27
+      }).then((data) => {
28
+        const dicts = app.globalData.Dict
29
+        const apart = data.data.buildingApartment.map(x => {
30
+          return {
31
+            ...x,
32
+            imgUrl: (x.buildingImgList[0] || {}).url,
33
+            marketStatus: (dicts.filter(d => d.id == x.marketStatus)[0] || {}).name
34
+          }
35
+        })
36
+        let propertyType = ''
37
+        data.data.propertyType.split(',').map(x => {
38
+          const f = dicts.filter(d => d.id == x)
39
+          if (f.length > 0) {
40
+            propertyType += (propertyType === '' ? '' : ',') + f[0].name
41
+          }
42
+        })
43
+        _that.setData({
44
+          EstateDetail: { ...data.data, propertyType: propertyType, buildingApartment: apart }
45
+        })
39 46
       })
40 47
     })
41 48
   },
@@ -49,6 +56,17 @@ Page({
49 56
       url: '/pages/AppointmentTime/index?id=' + this.data.EstateDetail.buildingId + '&name=' + this.data.EstateDetail.buildingName
50 57
     })
51 58
   },
59
+  MakeCollect() {
60
+    app.globalData.UserInfo.openid
61
+    fetch({
62
+      url: $api.collection.save.url.replace(':openid', app.globalData.UserInfo.openid) + '?buildingId=' + this.data.EstateDetail.buildingId,
63
+      method: $api.collection.save.method,
64
+    }).then((data) => {
65
+      wx.showToast({
66
+        title: '收藏成功!'
67
+      })
68
+    })
69
+  },
52 70
   OpenPhone() { // 电话咨询
53 71
     let _self = this
54 72
     wx.makePhoneCall({

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

@@ -79,7 +79,7 @@
79 79
     <view class="flex-item">
80 80
       <image mode="widthFix" wx:if="{{!EstateDetail.IsCollect}}" src="/assets/images/icon25.png" style="width: 34rpx;"></image>
81 81
       <image mode="widthFix" wx:if="{{EstateDetail.IsCollect}}" src="/assets/images/icon26.png" style="width: 34rpx;"></image>
82
-      <text>{{EstateDetail.IsCollect ? '已收藏' : '收藏楼盘'}}</text>
82
+      <text bindtap="MakeCollect">{{EstateDetail.IsCollect ? '已收藏' : '收藏楼盘'}}</text>
83 83
     </view>
84 84
     <view class="flex-item" bindtap="OpenPhone">
85 85
       <image mode="widthFix" src="/assets/images/icon24.png" style="width: 34rpx;"></image>

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

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