zjxpcyc 6 anos atrás
pai
commit
654f865abc

+ 2
- 4
app.js Ver arquivo

@@ -13,9 +13,7 @@ App({
13 13
             url: $api.user.getCode.url + '?code=' + res.code,
14 14
             method: $api.user.getCode.method
15 15
           }).then((res) => {
16
-            if (res.code === 200) {
17
-              _self.globalData.UserInfo = res.data
18
-            }
16
+            _self.globalData.UserInfo = res.data
19 17
           })
20 18
         } else {
21 19
           console.log('登录失败!' + res.errMsg)
@@ -64,7 +62,7 @@ App({
64 62
       phone: '',
65 63
       idNum: '',
66 64
       remark: '',
67
-      openid: '',
65
+      openid: '1',
68 66
       avatar: '',
69 67
     },
70 68
     ScreenBottomHeight: 0,

+ 4
- 0
config/api.js Ver arquivo

@@ -21,6 +21,10 @@ const $api = {
21 21
     appointment: {
22 22
       method: 'GET',
23 23
       url: `${BaseAPIURl}wx/appointment/:openid`
24
+    },    
25
+    delAppointment: {
26
+      method: 'DELETE',
27
+      url: `${BaseAPIURl}wx/appointment/of/:id`
24 28
     }
25 29
   },
26 30
   dict: {

+ 46
- 63
pages/AppointmentHistory/index.js Ver arquivo

@@ -12,67 +12,25 @@ create(store, {
12 12
     })
13 13
   },
14 14
   onLoad () {
15
-    
15
+    const userInfo = app.globalData.UserInfo
16
+
17
+    fetch({
18
+      ...getApi('user.appointment', { openid: userInfo.openid }),
19
+      query: { pageNum: 1, pageSize: 10 },
20
+    }).then(({ data }) => {
21
+      const list = data.records || []
22
+
23
+      this.setData({ list })
24
+    }).catch((err) => {
25
+      wx.showToast({
26
+        title: '获取列表失败',
27
+        icon: 'error',
28
+      })
29
+    })
16 30
   },
17 31
   data: {
18
-    UserInfo: app.globalData.UserInfo, // 用户信息
19
-    List: [{
20
-      Name: '示例姓名',
21
-      PhoneNum: '18267901393',
22
-      CaseName: '示例项目名称',
23
-      AppointmentDate: '2019-02-02',
24
-      Remark: '几点睡觉都会涉及到很多技术'
25
-    }, {
26
-      Name: '示例姓名',
27
-      PhoneNum: '18267901393',
28
-      CaseName: '示例项目名称',
29
-      AppointmentDate: '2019-02-02',
30
-      Remark: '几点睡觉都会涉及到很多技术'
31
-    }, {
32
-      Name: '示例姓名',
33
-      PhoneNum: '18267901393',
34
-      CaseName: '示例项目名称',
35
-      AppointmentDate: '2019-02-02',
36
-      Remark: '几点睡觉都会涉及到很多技术'
37
-    }, {
38
-      Name: '示例姓名',
39
-      PhoneNum: '18267901393',
40
-      CaseName: '示例项目名称',
41
-      AppointmentDate: '2019-02-02',
42
-      Remark: '几点睡觉都会涉及到很多技术'
43
-    }, {
44
-      Name: '示例姓名',
45
-      PhoneNum: '18267901393',
46
-      CaseName: '示例项目名称',
47
-      AppointmentDate: '2019-02-02',
48
-      Remark: '几点睡觉都会涉及到很多技术'
49
-    }, {
50
-      Name: '示例姓名',
51
-      PhoneNum: '18267901393',
52
-      CaseName: '示例项目名称',
53
-      AppointmentDate: '2019-02-02',
54
-      Remark: '几点睡觉都会涉及到很多技术'
55
-    }, {
56
-      Name: '示例姓名',
57
-      PhoneNum: '18267901393',
58
-      CaseName: '示例项目名称',
59
-      AppointmentDate: '2019-02-02',
60
-      Remark: '几点睡觉都会涉及到很多技术'
61
-    }, {
62
-      Name: '示例姓名',
63
-      PhoneNum: '18267901393',
64
-      CaseName: '示例项目名称',
65
-      AppointmentDate: '2019-02-02',
66
-      Remark: '几点睡觉都会涉及到很多技术'
67
-    }, {
68
-      Name: '示例姓名',
69
-      PhoneNum: '18267901393',
70
-      CaseName: '示例项目名称',
71
-      AppointmentDate: '2019-02-02',
72
-      Remark: '几点睡觉都会涉及到很多技术'
73
-    }],
32
+    list: [],
74 33
     DeleteIndex: null,
75
-    DeleteOff: true
76 34
   },
77 35
   ShowDeleteItem(e) { // 长按显示删除
78 36
     this.setData({
@@ -85,10 +43,35 @@ create(store, {
85 43
     })
86 44
   },
87 45
   DeleteItem() { // 确认删除逻辑
88
-    if (this.data.DeleteOff) {
89
-      this.setData({
90
-        DeleteOff: false
91
-      })
92
-    }
46
+    const delId = this.data.DeleteIndex
47
+    this.ResetDeleteIndex()
48
+
49
+    const _self = this
50
+
51
+    wx.showModal({
52
+      title: '确认',
53
+      content: '确认要删除当前记录?',
54
+      success(res) {
55
+        if (res.confirm) {
56
+          
57
+          fetch({
58
+            ...getApi('user.delAppointment', { id: delId }),
59
+          }).then(() => {
60
+            const list = _self.data.list.filter(x => x.appointmentId !== delId)
61
+
62
+            _self.setData({ list })
63
+          }).catch((err) => {
64
+            wx.showToast({
65
+              title: '删除失败',
66
+              icon: 'error',
67
+            })
68
+          })
69
+
70
+
71
+        } else if (res.cancel) {
72
+          console.log('用户点击取消')
73
+        }
74
+      }
75
+    })
93 76
   }
94 77
 })

+ 9
- 9
pages/AppointmentHistory/index.wxml Ver arquivo

@@ -1,29 +1,29 @@
1 1
 <!--index.wxml-->
2 2
 <view class="MainPage" bindtouchmove="ResetDeleteIndex">
3 3
   <view class="list">
4
-    <view wx:for="{{List}}" wx:for-item="item" wx:for-index="idx" wx:key="key">
4
+    <view wx:for="{{list}}" wx:for-item="item" wx:key="item.appointmentId" bindtap="ResetDeleteIndex">
5 5
       <view class="line flex-h">
6
-        <text>{{item.Name}}</text>
7
-        <text class="flex-item">{{item.PhoneNum}}</text>
6
+        <text>{{item.customerName}}</text>
7
+        <text class="flex-item">{{item.phone}}</text>
8 8
       </view>
9 9
       <view class="line flex-h">
10 10
         <text>预约项目:</text>
11
-        <text class="flex-item">{{item.CaseName}}</text>
11
+        <text class="flex-item">{{item.buildingName}}</text>
12 12
       </view>
13 13
       <view class="line flex-h">
14 14
         <text>预约时间:</text>
15
-        <text class="flex-item">{{item.AppointmentDate}}</text>
15
+        <text class="flex-item">{{item.appointmentDate}}</text>
16 16
       </view>
17 17
       <view class="line">
18 18
         <text>备注信息:</text>
19
-        <text style="line-height: 35rpx;">{{item.Remark}}</text>
19
+        <text style="line-height: 35rpx;">{{item.remark}}</text>
20 20
       </view>
21
-      <view class="delete" hidden="{{DeleteIndex !== idx}}">
22
-        <view class="centerLabel" data-index="{{idx}}" bindtap="DeleteItem">
21
+      <view class="delete" hidden="{{DeleteIndex !== item.appointmentId}}">
22
+        <view class="centerLabel" data-index="{{item.appointmentId}}" bindtap="DeleteItem">
23 23
           <image mode="widthFix" src="/assets/images/icon27.png" class="centerLabel"></image>
24 24
         </view>
25 25
       </view>
26
-      <view class="layer" data-index="{{idx}}" bindlongpress="ShowDeleteItem"></view>
26
+      <view class="layer" data-index="{{item.appointmentId}}" bindlongpress="ShowDeleteItem"></view>
27 27
     </view>
28 28
   </view>
29 29
 </view>

+ 9
- 4
pages/MyCollectEstateList/index.js Ver arquivo

@@ -1,15 +1,20 @@
1
-//index.js
2
-//获取应用实例
1
+import store from '../../store'
2
+import create from '../../utils/create'
3
+import fetch from '../../utils/http'
4
+import { get as getApi } from '../../config/api'
5
+
3 6
 const app = getApp()
4 7
 
5
-Page({
8
+create(store, {
6 9
   onShow() {
7 10
     wx.setNavigationBarTitle({
8 11
       title: '收藏的楼盘'
9 12
     })
13
+  },
14
+  onLoad () {
15
+
10 16
   },
11 17
   data: {
12
-    UserInfo: app.globalData.UserInfo, // 用户信息
13 18
     List: [{
14 19
       Img: '/assets/images/img5.jpg',
15 20
       Name: '示例楼盘名称',

+ 2
- 6
pages/UserCenter/UserInfo/index.js Ver arquivo

@@ -15,19 +15,15 @@ create(store, {
15 15
     })
16 16
   },
17 17
   SaveUserInfo() { // 提交表单数据
18
-    wx.showLoading({ title: '数据更新, 请稍后...', mask: true })
19
-
20 18
     fetch({ ...getApi('user.update'), data: this.data.UserInfo }).then(() => {
21 19
       // 同步到 globalData
22
-      this.globalData.UserInfo = { ...this.data.UserInfo }
20
+      app.globalData.UserInfo = { ...this.data.UserInfo }
23 21
 
24
-      wx.hideLoading()
25 22
       wx.showToast({
26 23
         title: '更新成功',
27 24
         icon: 'success',
28 25
       })
29
-    }).catch(() => {
30
-      wx.hideLoading()
26
+    }).catch((err) => {
31 27
       wx.showToast({
32 28
         title: '更新失败',
33 29
         icon: 'error',

+ 23
- 2
utils/http.js Ver arquivo

@@ -1,19 +1,40 @@
1 1
 import { apiCode } from '../config/code'
2 2
 
3
+function isArray (arg) {
4
+  return Object.prototype.toString.call(arg) === '[object Array]';
5
+}
6
+
3 7
 export default (config = {}) => {
4 8
   return new Promise((resolve, reject) => {
9
+    wx.showLoading({ title: '数据处理中, 请稍后...', mask: true })
10
+
11
+    let { query, url } = config
12
+
13
+    // query 只支持 url rfc 定义的内容
14
+    if (query) {
15
+      const searchStr = Object.keys(query).map((key) => {
16
+        const val = query[key]
17
+        return !isArray(val) ? `${key}=${val}` : val.map(it => `${key}=${it}`).join('&')
18
+      }).join('&')
19
+
20
+      const sign = url.indexOf('?') > -1 ? '&' : '?'
21
+      url = `${url}${sign}${searchStr}`
22
+    }
23
+
5 24
     wx.request({
6
-      url: config.url,
25
+      url: url,
7 26
       method: config.method,
8 27
       data: config.data,
9 28
       success(res) {
10
-        if (res.statusCode && res.statusCode === apiCode.success) {
29
+        wx.hideLoading()
30
+        if (res.statusCode === apiCode.success && res.data.code === apiCode.success) {
11 31
           resolve(res.data)
12 32
         } else {
13 33
           reject(res.data.message + "失败")
14 34
         }
15 35
       },
16 36
       error(msg) {
37
+        wx.hideLoading()
17 38
         reject(msg)
18 39
       }
19 40
     })