zjxpcyc il y a 6 ans
Parent
révision
ed98a043ed

+ 17
- 1
config/api.js Voir le fichier

@@ -18,6 +18,10 @@ const $api = {
18 18
       method: 'PUT',
19 19
       url: `${BaseAPIURl}wx/user`
20 20
     },
21
+    signUpList: { // 报名过的活动
22
+      method: 'GET',
23
+      url: `${BaseAPIURl}wx/activity/byuser/:openid`
24
+    },
21 25
     appointment: {
22 26
       method: 'GET',
23 27
       url: `${BaseAPIURl}wx/appointment/:openid`
@@ -75,6 +79,10 @@ const $api = {
75 79
     detail: { // 活动详情
76 80
       method: 'GET',
77 81
       url: `${BaseAPIURl}wx/activity/:id`
82
+    },
83
+    signUp: { // 活动报名
84
+      method: 'POST',
85
+      url: `${BaseAPIURl}wx/signUpActivity/:openid`
78 86
     }
79 87
   },
80 88
   appointment: {
@@ -105,8 +113,16 @@ const $api = {
105 113
     list: { // 评论列表
106 114
       methods: 'GET',
107 115
       url: `${BaseAPIURl}/wx/comment/list`
116
+    },
117
+    add: { // 添加评论
118
+      method: 'POST',
119
+      url: `${BaseAPIURl}comment/add`
108 120
     }
109
-  }
121
+  },
122
+  uploadImage: { // 图片上传
123
+    method: 'POST',
124
+    url: `${BaseAPIURl}uploadImage`
125
+  },
110 126
 }
111 127
 
112 128
 const hasKey = (o, k) => Object.keys(o).indexOf(k) > -1

+ 80
- 14
pages/ActivityDetail/comment.js Voir le fichier

@@ -1,6 +1,9 @@
1 1
 //index.js
2 2
 //获取应用实例
3
+import fetch from '../../utils/http'
4
+
3 5
 const app = getApp()
6
+const $api = require('../../config/api.js').$api
4 7
 
5 8
 Page({
6 9
   onShow() {
@@ -8,30 +11,58 @@ Page({
8 11
       title: '添加评论'
9 12
     })
10 13
   },
14
+  onLoad(e) {
15
+    this.setData({
16
+      Id: e.id,
17
+      FormData: {
18
+        ...this.data.FormData,
19
+        mainId: e.id,
20
+        customerId: app.globalData.UserInfo.customerId
21
+      }
22
+    })
23
+    console.log(this.data.FormData.customerId)
24
+  },
11 25
   data: {
26
+    Id: '',
12 27
     UserInfo: app.globalData.UserInfo,
13 28
     SubmitOff: true,
14 29
     FormData: {
15
-      Comment: '',
16
-      ImgList: []
30
+      customerId: '',
31
+      commentType: 'activity',
32
+      mainId: '',
33
+      parentId: '',
34
+      commentContent: '',
35
+      imgArray: []
17 36
     }
18 37
   },
19 38
   AddImage() { // 添加图片
20 39
     let _self = this
21 40
     wx.chooseImage({
22
-      count: 4 - _self.data.FormData.ImgList.length,
41
+      count: 4 - _self.data.FormData.imgArray.length,
23 42
       sizeType: ['original', 'compressed'],
24 43
       sourceType: ['album', 'camera'],
25 44
       success(res) {
26
-        let aArr = _self.data.FormData.ImgList.slice(0)
27
-        res.tempFilePaths.map((item) => {
28
-          aArr.push(item)
29
-        })
30
-        _self.setData({
31
-          FormData: {
32
-            ..._self.data.FormData,
33
-            ImgList: aArr
34
-          }
45
+        const tempFilePaths = res.tempFilePaths || []
46
+        let aArr = _self.data.FormData.imgArray.slice(0)
47
+        let num = 0
48
+        tempFilePaths.map((item, index) => {
49
+          wx.uploadFile({
50
+            url: $api.uploadImage.url,
51
+            filePath: item,
52
+            name: 'uploadFiles',
53
+            success(resr) {
54
+              num += 1
55
+              aArr.push(JSON.parse(resr.data).data[0])
56
+              if (num === tempFilePaths.length) {
57
+                _self.setData({
58
+                  FormData: {
59
+                    ..._self.data.FormData,
60
+                    imgArray: aArr
61
+                  }
62
+                })
63
+              }
64
+            }
65
+          })
35 66
         })
36 67
       }
37 68
     })
@@ -45,20 +76,55 @@ Page({
45 76
     })
46 77
   },
47 78
   DeleteItem(e) { // 删除img
48
-    let aArr = this.data.FormData.ImgList.slice(0)
79
+    let aArr = this.data.FormData.imgArray.slice(0)
49 80
     aArr.splice(e.target.dataset.index, 1)
50 81
     this.setData({
51 82
       FormData: {
52 83
         ...this.data.FormData,
53
-        ImgList: aArr
84
+        imgArray: aArr
54 85
       }
55 86
     })
56 87
   },
57 88
   SubmitForm() { // 发布
89
+    if (this.data.FormData.commentContent === '') {
90
+      // Toast('评论内容不能为空!')
91
+      wx.showToast({
92
+        title: '评论内容不能为空!',
93
+        icon: 'none',
94
+      })
95
+      return false
96
+    }
58 97
     if (this.data.SubmitOff) {
59 98
       this.setData({
60 99
         SubmitOff: false
61 100
       })
101
+      fetch({
102
+        url: $api.comment.add.url,
103
+        method: $api.comment.add.method,
104
+        data: {
105
+          ...this.data.FormData
106
+        }
107
+      }).then((res) => {
108
+        if (res.code === 200) {
109
+          wx.showToast({
110
+            title: '添加评论成功!',
111
+            icon: 'success',
112
+          })
113
+          setTimeout(() => {
114
+            wx.navigateBack({
115
+              delta: 1
116
+            })
117
+          }, 500)
118
+        } else {
119
+          wx.showToast({
120
+            title: res.message,
121
+            icon: 'none',
122
+          })
123
+          this.setData({
124
+            SubmitOff: true
125
+          })
126
+        }
127
+      })
62 128
     }
63 129
   }
64 130
 })

+ 3
- 1
pages/ActivityDetail/comment.json Voir le fichier

@@ -1,3 +1,5 @@
1 1
 {
2
-  "usingComponents": {}
2
+  "usingComponents": {
3
+    "van-toast": "/dist/toast/index"
4
+  }
3 5
 }

+ 3
- 3
pages/ActivityDetail/comment.wxml Voir le fichier

@@ -1,16 +1,16 @@
1 1
 <!--index.wxml-->
2 2
 <view class="MainPage">
3 3
   <view class="textarea">
4
-    <textarea placeholder="请输入评论" bindinput="FormInput" data-name="Comment"></textarea>
4
+    <textarea placeholder="请输入评论" bindinput="FormInput" data-name="commentContent"></textarea>
5 5
   </view>
6 6
   <view class="photos">
7 7
     <view class="flex-h">
8 8
       <view class="flex-item">
9
-        <view class="item" wx:for="{{FormData.ImgList}}" wx:for-index="idx" wx:for-item="item" wx:key="key">
9
+        <view class="item" wx:for="{{FormData.imgArray}}" wx:for-index="idx" wx:for-item="item" wx:key="key">
10 10
           <image mode="aspectFit" src="{{item}}" class="centerLabel contain"></image>
11 11
           <text data-index="{{idx}}" bindtap="DeleteItem"></text>
12 12
         </view>
13
-        <view class="addBtn" wx:if="{{FormData.ImgList.length < 4}}" bindtap="AddImage">
13
+        <view class="addBtn" wx:if="{{FormData.imgArray.length < 4}}" bindtap="AddImage">
14 14
           <view class="centerLabel">
15 15
             <image mode="widthFix" src="/assets/images/icon35.png"></image>
16 16
             <text>相机/相册</text>

+ 136
- 25
pages/ActivityDetail/index.js Voir le fichier

@@ -6,11 +6,24 @@ const app = getApp()
6 6
 const $api = require('../../config/api.js').$api
7 7
 
8 8
 Page({
9
-  onShow() {},
9
+  onShow() {
10
+    this.PageReset()
11
+    if (this.data.Type === 1) {
12
+      this.GetProjectDetail()
13
+    } else {
14
+      this.GetActivityDetail()
15
+      this.GetCommentList()
16
+      this.GetSignUpList()
17
+    }
18
+  },
10 19
   onLoad(e) {
11 20
     this.setData({
12 21
       Id: e.id,
13
-      Type: e.type - 0
22
+      Type: e.type - 0,
23
+      FormData: {
24
+        ...this.data.FormData,
25
+        activityId: e.id
26
+      }
14 27
     })
15 28
     if (e.type - 0 === 1) {
16 29
       wx.setNavigationBarTitle({
@@ -23,49 +36,91 @@ Page({
23 36
     }
24 37
   },
25 38
   data: {
39
+    HasSignUp: false,
26 40
     UserInfo: app.globalData.UserInfo,
27 41
     Id: null,
28 42
     Type: null,
29 43
     ShowPopup: false,
30 44
     FormData: {
31
-      Name: '',
32
-      PhoneNum: '',
33
-      IdCard: ''
45
+      customerName: '',
46
+      phone: '',
47
+      idNum: '',
48
+      activityId: ''
34 49
     },
35 50
     SubmitOff: true,
36 51
     ActivityDetail: {
37
-      Title: '示例标题',
38
-      Publisher: '示例发布人',
39
-      CreateDate: '2019-02-02',
52
+      Title: '',
53
+      Publisher: '',
54
+      CreateDate: '',
40 55
       Content: ''
41 56
     },
42 57
     CommentList: []
43 58
   },
44 59
   onReady() {
45
-    if (this.data.Type === 1) {
46
-      this.GetProjectDetail()
47
-    } else {
48
-      this.GetActivityDetail()
49
-      this.GetCommentList()
50
-    }
60
+
51 61
   },
52
-  AddComment() { // 添加评论
53
-    wx.navigateTo({
54
-      url: '/pages/ActivityDetail/comment?id=' + this.data.Id
62
+  PageReset() {
63
+    this.setData({
64
+      ActivityDetail: {
65
+        Title: '',
66
+        Publisher: '',
67
+        CreateDate: '',
68
+        Content: ''
69
+      },
70
+      CommentList: [],
71
+      SubmitOff: true,
72
+      ShowPopup: false
55 73
     })
56 74
   },
57
-  ShowSignUpPopup() { // 打开报名弹窗
58
-    this.setData({
59
-      ShowPopup: true
75
+  GetSignUpList() { // 获取报名情况
76
+    fetch({
77
+      url: $api.user.signUpList.url.replace(':openid', app.globalData.UserInfo.openid) + '?pageNum=1&pageSize=10000',
78
+      method: $api.user.signUpList.method
79
+    }).then((res) => {
80
+      if (res.code === 200) {
81
+        res.data.records.map((item) => {
82
+          if (item.activityId === this.data.FormData.activityId) {
83
+            this.setData({
84
+              HasSignUp: true
85
+            })
86
+            return
87
+          }
88
+        })
89
+      }
60 90
     })
61 91
   },
92
+  AddComment() { // 添加评论
93
+    if (app.globalData.UserInfo.avatar === '' && app.globalData.UserInfo.name === '') {
94
+      wx.navigateTo({
95
+        url: '/pages/index/index?index=3'
96
+      })
97
+    } else {
98
+      wx.navigateTo({
99
+        url: '/pages/ActivityDetail/comment?id=' + this.data.Id
100
+      })
101
+    }
102
+  },
103
+  ShowSignUpPopup() { // 打开报名弹窗
104
+    if (app.globalData.UserInfo.avatar === '' && app.globalData.UserInfo.name === '') {
105
+      wx.navigateTo({
106
+        url: '/pages/index/index?index=3'
107
+      })
108
+    } else {
109
+      if (!this.data.HasSignUp) {
110
+        this.setData({
111
+          ShowPopup: true
112
+        })
113
+      }
114
+    }
115
+  },
62 116
   ClosePopup() { // 关闭报名弹窗
63 117
     this.setData({
64 118
       ShowPopup: false,
65 119
       FormData: {
66
-        Name: '',
67
-        PhoneNum: '',
68
-        IdCard: ''
120
+        customerName: '',
121
+        phone: '',
122
+        idNum: '',
123
+        activityId: this.data.FormData.activityId
69 124
       }
70 125
     })
71 126
   },
@@ -78,11 +133,57 @@ Page({
78 133
     })
79 134
   },
80 135
   Submit() { // 提交报名信息
136
+    if (this.data.FormData.customerName === '') {
137
+      wx.showToast({
138
+        title: '姓名不能为空!',
139
+        icon: 'none'
140
+      })
141
+      return false
142
+    }
143
+    if (this.data.FormData.phone === '') {
144
+      wx.showToast({
145
+        title: '手机号不能为空!',
146
+        icon: 'none'
147
+      })
148
+      return false
149
+    }
150
+    if (this.data.FormData.idNum === '') {
151
+      wx.showToast({
152
+        title: '身份证号不能为空!',
153
+        icon: 'none'
154
+      })
155
+      return false
156
+    }
81 157
     if (this.data.SubmitOff) {
82 158
       this.setData({
83 159
         SubmitOff: false
84 160
       })
85
-
161
+      fetch({
162
+        url: $api.activity.signUp.url.replace(':openid', app.globalData.UserInfo.openid),
163
+        method: $api.activity.signUp.method,
164
+        data: {
165
+          ...this.data.FormData
166
+        }
167
+      }).then((res) => {
168
+        // console.log(res)
169
+        if (res.code === 200) {
170
+          wx.showToast({
171
+            title: '报名成功!',
172
+            icon: 'success'
173
+          })
174
+          this.setData({
175
+            ShowPopup: false
176
+          })
177
+        } else {
178
+          wx.showToast({
179
+            title: res.message,
180
+            icon: 'none'
181
+          })
182
+          this.setData({
183
+            SubmitOff: true
184
+          })
185
+        }
186
+      })
86 187
     }
87 188
   },
88 189
   GetCommentList() { // 获取评论列表
@@ -91,7 +192,7 @@ Page({
91 192
       method: $api.comment.list.method
92 193
     }).then((res) => {
93 194
       if (res.code === 200) {
94
-        console.log(res.data.records)
195
+        // console.log(res.data.records)
95 196
         let CommentList = []
96 197
         res.data.records.map((item, index) => {
97 198
           CommentList.push({
@@ -101,6 +202,7 @@ Page({
101 202
             Content: item.commentContent,
102 203
             ImgList: item.commentImgList,
103 204
             LikeNum: '0',
205
+            ParentId: item.parentId,
104 206
             Childs: []
105 207
           })
106 208
           let aChild = []
@@ -115,6 +217,15 @@ Page({
115 217
           })
116 218
           CommentList[index].Childs = aChild
117 219
         })
220
+        let aArr = []
221
+        CommentList.map((item, index) => {
222
+          if (item.ParentId !== '') {
223
+            aArr.unshift(index)
224
+          }
225
+        })
226
+        aArr.map((item) => {
227
+          CommentList.splice(item - 0, 1)
228
+        })
118 229
         this.setData({
119 230
           CommentList: CommentList
120 231
         })

+ 4
- 4
pages/ActivityDetail/index.wxml Voir le fichier

@@ -92,7 +92,7 @@
92 92
   </view>
93 93
   <view class="SignUp" hidden="{{Type !== 2}}">
94 94
     <view>
95
-      <text bindtap="ShowSignUpPopup">我要报名</text>
95
+      <text bindtap="ShowSignUpPopup">{{HasSignUp ? '已报名' : '我要报名'}}</text>
96 96
     </view>
97 97
   </view>
98 98
 
@@ -105,15 +105,15 @@
105 105
           <text>填写报名信息</text>
106 106
           <view class="line flex-h">
107 107
             <image mode="widthFix" src="/assets/images/icon32.png" style="width: 28rpx;"></image>
108
-            <input class="flex-item" type="text" placeholder="姓名" bindinput="FormInput" data-name="Name"></input>
108
+            <input class="flex-item" type="text" placeholder="姓名" bindinput="FormInput" data-name="customerName"></input>
109 109
           </view>
110 110
           <view class="line flex-h">
111 111
             <image mode="widthFix" src="/assets/images/icon34.png" style="width: 22rpx;"></image>
112
-            <input type="number" class="flex-item" placeholder="手机号码" bindinput="FormInput" data-name="PhoneNum"></input>
112
+            <input type="number" class="flex-item" placeholder="手机号码" bindinput="FormInput" data-name="phone"></input>
113 113
           </view>
114 114
           <view class="line flex-h">
115 115
             <image mode="widthFix" src="/assets/images/icon33.png" style="width: 30rpx;"></image>
116
-            <input type="idcard" class="flex-item" placeholder="身份证号" bindinput="FormInput" data-name="IdCard"></input>
116
+            <input type="idcard" class="flex-item" placeholder="身份证号" bindinput="FormInput" data-name="idNum"></input>
117 117
           </view>
118 118
           <view class="btn">
119 119
             <text bindtap="Submit">提交报名信息</text>

+ 7
- 0
pages/AppointmentTime/index.js Voir le fichier

@@ -15,6 +15,13 @@ Page({
15 15
       BuildingId: page.getCurrentPageOptions().id,
16 16
       BuildingName: page.getCurrentPageOptions().name
17 17
     })
18
+    this.setData({
19
+      FormData: {
20
+        Name: app.globalData.UserInfo.customerName,
21
+        PhoneNum: app.globalData.UserInfo.phone,
22
+      }
23
+    })
24
+    
18 25
   },
19 26
   data: {
20 27
     UserInfo: app.globalData.UserInfo, // 用户信息

+ 2
- 0
pages/SelfServiceTool/Cyclopedia/index.js Voir le fichier

@@ -1,6 +1,8 @@
1 1
 //index.js
2 2
 //获取应用实例
3 3
 const app = getApp()
4
+import fetch from '../../../utils/http'
5
+const $api = require('../../../config/api.js').$api;
4 6
 
5 7
 Page({
6 8
   onShow() {

+ 11
- 3
pages/components/Concessions/index.js Voir le fichier

@@ -21,17 +21,25 @@ Component({
21 21
     ListB: [],
22 22
     PostDataA: {
23 23
       PageNum: 1,
24
-      PageSize: 15
24
+      PageSize: 10000
25 25
     },
26 26
     PostDataB: {
27 27
       PageNum: 1,
28
-      PageSize: 15
28
+      PageSize: 10000
29 29
     }
30 30
   },
31 31
   lifetimes: {},
32 32
   ready: function() {
33 33
     this.GetProjectList()
34 34
     this.GetActivityList()
35
+    let _self = this
36
+    wx.getSystemInfo({
37
+      success(res) {
38
+        _self.setData({
39
+          WindowHeight: res.windowHeight
40
+        })
41
+      }
42
+    })
35 43
   },
36 44
   pageLifetimes: {
37 45
     show: function() {},
@@ -92,7 +100,7 @@ Component({
92 100
       })
93 101
     },
94 102
     CutNav(e) { // 切换nav
95
-      if (e.target.dataset.index !== undefined) {
103
+      if (e.target.dataset.index !== undefined && e.target.dataset.index !== this.data.NavActiveIndex) {
96 104
         this.setData({
97 105
           NavActiveIndex: e.target.dataset.index
98 106
         })

+ 8
- 0
pages/components/Concessions/index.wxss Voir le fichier

@@ -1,6 +1,14 @@
1 1
 /**index.wxss**/
2 2
 @import '../../../app.wxss';
3 3
 
4
+.SubContainer {
5
+  min-height: 100%;
6
+  overflow-y: scroll;
7
+  -webkit-overflow-scrolling: touch;
8
+  transform: translateZ(0);
9
+  -webkit-transform: translateZ(0);
10
+}
11
+
4 12
 .nav {
5 13
   width: 100%;
6 14
   position: relative;

+ 1
- 1
pages/components/ConcessionsListItem/index.wxml Voir le fichier

@@ -1,7 +1,7 @@
1 1
 <!--index.wxml-->
2 2
 <view class="component flex-h">
3 3
   <view class="img">
4
-    <image mode="widthFix" src="{{Params.Img}}" class="centerLabel cover"></image>
4
+    <image mode="aspectFill" src="{{Params.Img}}" class="centerLabel cover"></image>
5 5
   </view>
6 6
   <view class="flex-item">
7 7
     <text class="title">{{Params.Title}}</text>

+ 7
- 2
pages/components/Estate/index.wxml Voir le fichier

@@ -1,9 +1,14 @@
1 1
 <!--index.wxml-->
2 2
 <view class="SubContainer">
3 3
   <view class="map">
4
-    <image mode="widthFix" src="/assets/images/img4.jpg" class="centerLabel cover bg"></image>
4
+    <movable-area style="height: 100%; width: 100%; background: #eee;position:absolute;left:0;top:0;">
5
+      <movable-view scale="{{true}}" scale-min="1" scale-max="2.5" x="{{x}}" y="{{y}}" direction="all">
6
+        <image mode="aspectFit" src="/assets/images/img4.jpg" class="centerLabel contian bg"></image>
7
+      </movable-view>
8
+    </movable-area>
9
+    <!-- <image mode="widthFix" src="/assets/images/img4.jpg" class="centerLabel cover bg"></image>
5 10
     <image mode="widthFix" src="/assets/images/icon15.png" class="AddIcon"></image>
6
-    <image mode="widthFix" src="/assets/images/icon14.png" class="SubtractIcon"></image>
11
+    <image mode="widthFix" src="/assets/images/icon14.png" class="SubtractIcon"></image> -->
7 12
   </view>
8 13
   <view class="EstateList">
9 14
     <text>附近楼盘</text>

+ 12
- 0
pages/components/Estate/index.wxss Voir le fichier

@@ -145,3 +145,15 @@
145 145
   font-size: 17rpx;
146 146
   line-height: 30rpx;
147 147
 }
148
+
149
+movable-view {
150
+  position: relative;
151
+  overflow: hidden;
152
+  min-height: 100%; 
153
+  min-width: 100%;
154
+}
155
+
156
+movable-view image {
157
+  width: 100%;
158
+  height: 100%;
159
+}

+ 5
- 0
pages/index/index.js Voir le fichier

@@ -4,6 +4,11 @@ import create from '../../utils/create'
4 4
 const app = getApp()
5 5
 
6 6
 create(store, {
7
+  onLoad(e) {
8
+    this.setData({
9
+      NavActiveIndex: e.index || 0
10
+    })
11
+  },
7 12
   data: {
8 13
     NavList: [{ // navlist数据
9 14
       value: '首页',

+ 4
- 0
pages/index/index.wxss Voir le fichier

@@ -17,6 +17,10 @@
17 17
   -webkit-transform: translateZ(0);
18 18
 }
19 19
 
20
+.CutContent > view > view {
21
+  min-height: 100%;
22
+}
23
+
20 24
 .foot {
21 25
   background: #fff;
22 26
   position: relative;

BIN
wxmini.zip Voir le fichier