许成详 преди 6 години
родител
ревизия
275135e68f

+ 16
- 0
config/api.js Целия файл

@@ -17,6 +17,10 @@ const $api = {
17 17
     update: {
18 18
       method: 'PUT',
19 19
       url: `${BaseAPIURl}wx/user`
20
+    },
21
+    signUpList: { // 报名过的活动
22
+      method: 'GET',
23
+      url: `${BaseAPIURl}wx/activity/byuser/:openid`
20 24
     }
21 25
   },
22 26
   dict: {
@@ -59,6 +63,10 @@ const $api = {
59 63
     detail: { // 活动详情
60 64
       method: 'GET',
61 65
       url: `${BaseAPIURl}wx/activity/:id`
66
+    },
67
+    signUp: { // 活动报名
68
+      method: 'POST',
69
+      url: `${BaseAPIURl}wx/signUpActivity/:openid`
62 70
     }
63 71
   },
64 72
   appointment: {
@@ -89,7 +97,15 @@ const $api = {
89 97
     list: { // 评论列表
90 98
       methods: 'GET',
91 99
       url: `${BaseAPIURl}/wx/comment/list`
100
+    },
101
+    add: { // 添加评论
102
+      method: 'POST',
103
+      url: `${BaseAPIURl}/comment/add`
92 104
     }
105
+  },
106
+  uploadImage: { // 图片上传
107
+    method: 'POST',
108
+    url: `${BaseAPIURl}uploadImage`
93 109
   }
94 110
 }
95 111
 

+ 79
- 14
pages/ActivityDetail/comment.js Целия файл

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

+ 3
- 1
pages/ActivityDetail/comment.json Целия файл

@@ -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 Целия файл

@@ -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>

+ 74
- 15
pages/ActivityDetail/index.js Целия файл

@@ -6,7 +6,15 @@ const app = getApp()
6 6
 const $api = require('../../config/api.js').$api
7 7
 
8 8
 Page({
9
-  onShow() {},
9
+  onShow() {
10
+    if (this.data.Type === 1) {
11
+      this.GetProjectDetail()
12
+    } else {
13
+      this.GetActivityDetail()
14
+      this.GetCommentList()
15
+      this.GetSignUpList()
16
+    }
17
+  },
10 18
   onLoad(e) {
11 19
     this.setData({
12 20
       Id: e.id,
@@ -28,9 +36,10 @@ Page({
28 36
     Type: null,
29 37
     ShowPopup: false,
30 38
     FormData: {
31
-      Name: '',
32
-      PhoneNum: '',
33
-      IdCard: ''
39
+      customerName: '',
40
+      phone: '',
41
+      idNum: '',
42
+      activityId: ''
34 43
     },
35 44
     SubmitOff: true,
36 45
     ActivityDetail: {
@@ -42,12 +51,15 @@ Page({
42 51
     CommentList: []
43 52
   },
44 53
   onReady() {
45
-    if (this.data.Type === 1) {
46
-      this.GetProjectDetail()
47
-    } else {
48
-      this.GetActivityDetail()
49
-      this.GetCommentList()
50
-    }
54
+
55
+  },
56
+  GetSignUpList() {
57
+    fetch({
58
+      url: $api.user.signUpList.url.replace(':openid', app.globalData.UserInfo.openid) + '?pageNum=1&pageSize=10000',
59
+      method: $api.user.signUpList.method
60
+    }).then((res) => {
61
+      console.log(res)
62
+    })
51 63
   },
52 64
   AddComment() { // 添加评论
53 65
     wx.navigateTo({
@@ -63,9 +75,10 @@ Page({
63 75
     this.setData({
64 76
       ShowPopup: false,
65 77
       FormData: {
66
-        Name: '',
67
-        PhoneNum: '',
68
-        IdCard: ''
78
+        customerName: '',
79
+        phone: '',
80
+        idNum: '',
81
+        activityId: this.data.FormData.activityId
69 82
       }
70 83
     })
71 84
   },
@@ -78,11 +91,57 @@ Page({
78 91
     })
79 92
   },
80 93
   Submit() { // 提交报名信息
94
+    if (this.data.FormData.customerName === '') {
95
+      wx.showToast({
96
+        title: '姓名不能为空!',
97
+        icon: 'none'
98
+      })
99
+      return false
100
+    }
101
+    if (this.data.FormData.phone === '') {
102
+      wx.showToast({
103
+        title: '手机号不能为空!',
104
+        icon: 'none'
105
+      })
106
+      return false
107
+    }
108
+    if (this.data.FormData.idNum === '') {
109
+      wx.showToast({
110
+        title: '身份证号不能为空!',
111
+        icon: 'none'
112
+      })
113
+      return false
114
+    }
81 115
     if (this.data.SubmitOff) {
82 116
       this.setData({
83 117
         SubmitOff: false
84 118
       })
85
-
119
+      fetch({
120
+        url: $api.activity.signUp.url.replace(':openid', app.globalData.UserInfo.openid),
121
+        method: $api.activity.signUp.method,
122
+        data: {
123
+          ...this.data.FormData
124
+        }
125
+      }).then((res) => {
126
+        // console.log(res)
127
+        if (res.code === 200) {
128
+          wx.showToast({
129
+            title: '报名成功!',
130
+            icon: 'success'
131
+          })
132
+          this.setData({
133
+            ShowPopup: false
134
+          })
135
+        } else {
136
+          wx.showToast({
137
+            title: res.message,
138
+            icon: 'none'
139
+          })
140
+          this.setData({
141
+            SubmitOff: true
142
+          })
143
+        }
144
+      })
86 145
     }
87 146
   },
88 147
   GetCommentList() { // 获取评论列表
@@ -91,7 +150,7 @@ Page({
91 150
       method: $api.comment.list.method
92 151
     }).then((res) => {
93 152
       if (res.code === 200) {
94
-        console.log(res.data.records)
153
+        // console.log(res.data.records)
95 154
         let CommentList = []
96 155
         res.data.records.map((item, index) => {
97 156
           CommentList.push({

+ 3
- 3
pages/ActivityDetail/index.wxml Целия файл

@@ -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>

+ 1
- 1
pages/components/Concessions/index.js Целия файл

@@ -92,7 +92,7 @@ Component({
92 92
       })
93 93
     },
94 94
     CutNav(e) { // 切换nav
95
-      if (e.target.dataset.index !== undefined) {
95
+      if (e.target.dataset.index !== undefined && e.target.dataset.index !== this.data.NavActiveIndex) {
96 96
         this.setData({
97 97
           NavActiveIndex: e.target.dataset.index
98 98
         })

+ 7
- 2
pages/components/Estate/index.wxml Целия файл

@@ -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 Целия файл

@@ -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
+}