1002884655 4 years ago
parent
commit
e2f9e121da

+ 5
- 0
src/pages/HuiShengHuo/ActivityList/ActivityDetail/JoinIn/index.vue View File

32
 import { getCurrentInstance } from '@tarojs/taro'
32
 import { getCurrentInstance } from '@tarojs/taro'
33
 import { createNamespacedHelpers } from 'vuex'
33
 import { createNamespacedHelpers } from 'vuex'
34
 const { mapState: mapUserState, mapActions: mapUserActions, mapMutations: mapUserMutations } = createNamespacedHelpers('user')
34
 const { mapState: mapUserState, mapActions: mapUserActions, mapMutations: mapUserMutations } = createNamespacedHelpers('user')
35
+const { mapMutations: mapIndexMutations } = createNamespacedHelpers('index')
35
 export default {
36
 export default {
36
   name: 'LiJiBaoMing',
37
   name: 'LiJiBaoMing',
37
   data () {
38
   data () {
67
     ...mapUserMutations([
68
     ...mapUserMutations([
68
       'EditUserInfo' // 编辑用户信息
69
       'EditUserInfo' // 编辑用户信息
69
     ]),
70
     ]),
71
+    ...mapIndexMutations([
72
+      'EditActivityDetail'
73
+    ]),
70
     Init () {
74
     Init () {
71
     },
75
     },
72
     ToJoin () { // 去报名
76
     ToJoin () { // 去报名
77
         data: { data: { enrollName: this.Name, enrollPhone: this.Phone, enrollNum: this.Num } }
81
         data: { data: { enrollName: this.Name, enrollPhone: this.Phone, enrollNum: this.Num } }
78
       }).then((res) => {
82
       }).then((res) => {
79
         this.DataLock = false
83
         this.DataLock = false
84
+        this.EditActivityDetail({ name: 'status', value: 1 })
80
         wx.showToast({
85
         wx.showToast({
81
           title: '报名成功',
86
           title: '报名成功',
82
           icon: 'none',
87
           icon: 'none',

+ 31
- 32
src/pages/HuiShengHuo/ActivityList/ActivityDetail/index.vue View File

2
   <view class="page HuoDongXiangQing flex-v">
2
   <view class="page HuoDongXiangQing flex-v">
3
 
3
 
4
     <view class="flex-item">
4
     <view class="flex-item">
5
-      <view v-if="ActivityInfo !== null">
5
+      <view v-if="ActivityDetail !== null">
6
 
6
 
7
         <!-- 活动主要信息 -->
7
         <!-- 活动主要信息 -->
8
         <view class="MainInfo">
8
         <view class="MainInfo">
9
-          <text>{{ActivityInfo.name}}</text>
9
+          <text>{{ActivityDetail.name}}</text>
10
           <view class="SubInfo flex-h">
10
           <view class="SubInfo flex-h">
11
             <view class="flex-item">
11
             <view class="flex-item">
12
               <text class="iconfont iconxianshi"></text>
12
               <text class="iconfont iconxianshi"></text>
13
-              <text>{{ActivityInfo.pv || ''}}</text>
13
+              <text>{{ActivityDetail.pv || ''}}</text>
14
             </view>
14
             </view>
15
             <view class="Time">
15
             <view class="Time">
16
               <text class="iconfont iconshijian"></text>
16
               <text class="iconfont iconshijian"></text>
17
-              <text>{{ToolClass.DateFormat(new Date(ActivityInfo.createDate).getTime())}}</text>
17
+              <text>{{ToolClass.DateFormat(new Date(ActivityDetail.createDate).getTime())}}</text>
18
             </view>
18
             </view>
19
           </view>
19
           </view>
20
           <view class="Line flex-h">
20
           <view class="Line flex-h">
21
             <text>活动时间:</text>
21
             <text>活动时间:</text>
22
-            <text class="flex-item">{{ToolClass.DateFormat(new Date(ActivityInfo.startDate).getTime())}} 至 {{ToolClass.DateFormat(new Date(ActivityInfo.endDate).getTime())}}</text>
22
+            <text class="flex-item">{{ToolClass.DateFormat(new Date(ActivityDetail.startDate).getTime())}} 至 {{ToolClass.DateFormat(new Date(ActivityDetail.endDate).getTime())}}</text>
23
           </view>
23
           </view>
24
           <view class="Line flex-h">
24
           <view class="Line flex-h">
25
             <text>活动地址:</text>
25
             <text>活动地址:</text>
26
-            <text class="flex-item">{{ActivityInfo.address}}</text>
26
+            <text class="flex-item">{{ActivityDetail.address}}</text>
27
           </view>
27
           </view>
28
           <view class="Line flex-h">
28
           <view class="Line flex-h">
29
             <text>报名截止:</text>
29
             <text>报名截止:</text>
30
-            <text class="flex-item">{{ToolClass.DateFormat(new Date(ActivityInfo.enrollEnd).getTime())}}</text>
30
+            <text class="flex-item">{{ToolClass.DateFormat(new Date(ActivityDetail.enrollEnd).getTime())}}</text>
31
           </view>
31
           </view>
32
         </view>
32
         </view>
33
 
33
 
35
         <view class="DetailContainer">
35
         <view class="DetailContainer">
36
           <image mode="heightFix" src="https://cjgw.oss-cn-hangzhou.aliyuncs.com/ygcxxfb/image/huodongxiangqing.png"></image>
36
           <image mode="heightFix" src="https://cjgw.oss-cn-hangzhou.aliyuncs.com/ygcxxfb/image/huodongxiangqing.png"></image>
37
           <view class="Text">
37
           <view class="Text">
38
-            <!-- <rich-text :nodes="ActivityInfo.detail"></rich-text> -->
39
-            <Markdown :value="ActivityInfo.detail" />
38
+            <!-- <rich-text :nodes="ActivityDetail.detail"></rich-text> -->
39
+            <Markdown :value="ActivityDetail.detail" />
40
           </view>
40
           </view>
41
         </view>
41
         </view>
42
 
42
 
52
               </view>
52
               </view>
53
             </view>
53
             </view>
54
           </view>
54
           </view>
55
-          <text @tap="ToPostActivityVote" v-if="!ShowVoteRes && ActivityStatus">提交</text>
56
-          <button open-type="getPhoneNumber" class="GetPhoneBtn" v-if="!DataLock && ShowGetPhoneBtn && !ShowVoteRes && ActivityStatus" @getphonenumber="GetPhoneNumber">授权手机号</button>
55
+          <text @tap="ToPostActivityVote" v-if="!ShowVoteRes && (ActivityDetail.status - 0 !== 2)">提交</text>
56
+          <button open-type="getPhoneNumber" class="GetPhoneBtn" v-if="!DataLock && ShowGetPhoneBtn && !ShowVoteRes && (ActivityDetail.status - 0 !== 2)" @getphonenumber="GetPhoneNumber">授权手机号</button>
57
           <view class="ResList" v-if="ShowVoteRes">
57
           <view class="ResList" v-if="ShowVoteRes">
58
             <view v-for="(item, index) in VoteResList" :key="index">
58
             <view v-for="(item, index) in VoteResList" :key="index">
59
               <view class="Text flex-h">
59
               <view class="Text flex-h">
81
         <image class="centerLabel" mode="heightFix" src="https://cjgw.oss-cn-hangzhou.aliyuncs.com/ygcxxfb/image/fenxiang.png"></image>
81
         <image class="centerLabel" mode="heightFix" src="https://cjgw.oss-cn-hangzhou.aliyuncs.com/ygcxxfb/image/fenxiang.png"></image>
82
       </view>
82
       </view>
83
       <button open-type="share" class="ShareBottomBtn" :class="{'active': IsEnroll}">分享</button>
83
       <button open-type="share" class="ShareBottomBtn" :class="{'active': IsEnroll}">分享</button>
84
-      <image mode="heightFix" v-if="IsEnroll && !HasEnroll && ActivityStatus" src="https://cjgw.oss-cn-hangzhou.aliyuncs.com/ygcxxfb/image/lijibaomingbtn.png" @tap="ToJoin"></image>
85
-      <button open-type="getPhoneNumber" class="GetPhoneBottomBtn" v-if="!DataLock && ShowGetPhoneBtn && IsEnroll && !HasEnroll && ActivityStatus" @getphonenumber="GetPhoneNumber">授权手机号</button>
86
-      <text v-if="IsEnroll && HasEnroll && ActivityStatus">已报名</text>
87
-      <text v-if="!ActivityStatus">已过期</text>
84
+      <image mode="heightFix" v-if="IsEnroll && !HasEnroll && (ActivityDetail.status - 0 !== 2)" src="https://cjgw.oss-cn-hangzhou.aliyuncs.com/ygcxxfb/image/lijibaomingbtn.png" @tap="ToJoin"></image>
85
+      <button open-type="getPhoneNumber" class="GetPhoneBottomBtn" v-if="!DataLock && ShowGetPhoneBtn && IsEnroll && !HasEnroll && (ActivityDetail.status - 0 !== 2)" @getphonenumber="GetPhoneNumber">授权手机号</button>
86
+      <text v-if="IsEnroll && HasEnroll && (ActivityDetail.status - 0 !== 2)">已报名</text>
87
+      <text v-if="!(ActivityDetail.status - 0 !== 2)">已过期</text>
88
     </view>
88
     </view>
89
 
89
 
90
     <!-- 授权头像获取弹窗 -->
90
     <!-- 授权头像获取弹窗 -->
104
   data () {
104
   data () {
105
     return {
105
     return {
106
       From: null,
106
       From: null,
107
-      ActivityStatus: false,
108
       HasEnroll: false,
107
       HasEnroll: false,
109
       ShowVoteRes: false,
108
       ShowVoteRes: false,
110
       VoteResList: [],
109
       VoteResList: [],
111
       ShowGetPhoneBtn: false,
110
       ShowGetPhoneBtn: false,
112
       VoteIndex: null,
111
       VoteIndex: null,
113
       VoteList: [],
112
       VoteList: [],
114
-      ActivityInfo: null,
115
       IsVote: false,
113
       IsVote: false,
116
       IsEnroll: false,
114
       IsEnroll: false,
117
       CurrnetId: null,
115
       CurrnetId: null,
121
   computed: {
119
   computed: {
122
     ...mapUserState({
120
     ...mapUserState({
123
       UserInfo: x => x.UserInfo // 用户信息
121
       UserInfo: x => x.UserInfo // 用户信息
122
+    }),
123
+    ...mapIndexState({
124
+      ActivityDetail: x => x.ActivityDetail // 活动详情
124
     })
125
     })
125
   },
126
   },
126
   components: {
127
   components: {
128
   },
129
   },
129
   onShareAppMessage () {
130
   onShareAppMessage () {
130
     return {
131
     return {
131
-      title: this.ActivityInfo.shareTitle,
132
-      path: `/pages/HuiShengHuo/ActivityList/ActivityDetail/index?id=${this.ActivityInfo.activityId}&from=life`,
133
-      imageUrl: this.ActivityInfo.shareImg
132
+      title: this.ActivityDetail.shareTitle,
133
+      path: `/pages/HuiShengHuo/ActivityList/ActivityDetail/index?id=${this.ActivityDetail.activityId}&from=life`,
134
+      imageUrl: this.ActivityDetail.shareImg
134
     }
135
     }
135
   },
136
   },
136
   created () {
137
   created () {
162
     Init () {
163
     Init () {
163
       this.ShowGetPhoneBtn = this.UserInfo === null || this.UserInfo.Phone === undefined || this.UserInfo.Phone === null
164
       this.ShowGetPhoneBtn = this.UserInfo === null || this.UserInfo.Phone === undefined || this.UserInfo.Phone === null
164
       this.GetActivityDetail({ urlData: { id: this.CurrnetId } }).then((res) => {
165
       this.GetActivityDetail({ urlData: { id: this.CurrnetId } }).then((res) => {
165
-        this.ActivityInfo = res.data.data
166
-        this.IsEnroll = this.ActivityInfo.isEnroll
167
-        this.ActivityStatus = this.ActivityInfo.status - 0 !== 2
166
+        this.IsEnroll = this.ActivityDetail.isEnroll
168
         if (this.IsEnroll) {
167
         if (this.IsEnroll) {
169
-          this.HasEnroll = this.ActivityInfo.isSelfEnrolled
168
+          this.HasEnroll = this.ActivityDetail.isSelfEnrolled
170
         }
169
         }
171
-        if (this.ActivityInfo.isVote) {
172
-          this.VoteList = this.ActivityInfo.voteItemList.slice(0)
170
+        if (this.ActivityDetail.isVote) {
171
+          this.VoteList = this.ActivityDetail.voteItemList.slice(0)
173
           this.CreateVoteResList()
172
           this.CreateVoteResList()
174
-          this.ShowVoteRes = !!this.ActivityInfo.selfVoted
173
+          this.ShowVoteRes = !!this.ActivityDetail.selfVoted
175
         }
174
         }
176
-        this.IsVote = this.ActivityInfo.isVote
175
+        this.IsVote = this.ActivityDetail.isVote
177
       })
176
       })
178
     },
177
     },
179
     CreateVoteResList () { // 计算投票结果
178
     CreateVoteResList () { // 计算投票结果
183
         VoteTotal += item.voteNum - 0
182
         VoteTotal += item.voteNum - 0
184
       })
183
       })
185
       this.VoteList.map((item) => {
184
       this.VoteList.map((item) => {
186
-        this.VoteResList.push({ name: item.name, pec: Math.floor((item.voteNum / VoteTotal) * 100), total: VoteTotal, num: item.voteNum, selfVoted: this.ActivityInfo.selfVoted === item.itemId })
185
+        this.VoteResList.push({ name: item.name, pec: Math.floor((item.voteNum / VoteTotal) * 100), total: VoteTotal, num: item.voteNum, selfVoted: this.ActivityDetail.selfVoted === item.itemId })
187
       })
186
       })
188
     },
187
     },
189
     ToShare () {
188
     ToShare () {
196
       wx.switchTab({ url })
195
       wx.switchTab({ url })
197
     },
196
     },
198
     ToJoin () { // 报名
197
     ToJoin () { // 报名
199
-      wx.navigateTo({ url: `./JoinIn/index?id=${this.ActivityInfo.activityId}` })
198
+      wx.navigateTo({ url: `./JoinIn/index?id=${this.ActivityDetail.activityId}` })
200
     },
199
     },
201
     ToPostActivityVote () { // 活动投票
200
     ToPostActivityVote () { // 活动投票
202
       if (this.DataLock || this.VoteIndex === null) return
201
       if (this.DataLock || this.VoteIndex === null) return
203
       this.DataLock = true
202
       this.DataLock = true
204
       this.PostActivityVote({
203
       this.PostActivityVote({
205
-        urlData: { id: this.ActivityInfo.activityId },
204
+        urlData: { id: this.ActivityDetail.activityId },
206
         data: { data: { itemId: this.VoteList[this.VoteIndex].itemId } }
205
         data: { data: { itemId: this.VoteList[this.VoteIndex].itemId } }
207
       }).then(() => {
206
       }).then(() => {
208
         this.DataLock = false
207
         this.DataLock = false
211
           icon: 'none',
210
           icon: 'none',
212
           duration: 2000
211
           duration: 2000
213
         })
212
         })
214
-        this.ActivityInfo.selfVoted = this.VoteList[this.VoteIndex].itemId
213
+        this.ActivityDetail.selfVoted = this.VoteList[this.VoteIndex].itemId
215
         this.CreateVoteResList()
214
         this.CreateVoteResList()
216
         this.ShowVoteRes = true
215
         this.ShowVoteRes = true
217
       }).catch(() => {
216
       }).catch(() => {

+ 8
- 0
src/store/index/index.js View File

5
 export default {
5
 export default {
6
   namespaced: true,
6
   namespaced: true,
7
   state: {
7
   state: {
8
+    ActivityDetail: null, // 活动详情
8
     IndexBanner: [], // 首页banner
9
     IndexBanner: [], // 首页banner
9
     ActivityList: [], // 活动列表
10
     ActivityList: [], // 活动列表
10
     PhotoList: [], // 照片墙列表
11
     PhotoList: [], // 照片墙列表
76
     },
77
     },
77
     EmptyUserActivityList (state) { // 清空我的活动列表
78
     EmptyUserActivityList (state) { // 清空我的活动列表
78
       state.UserActivityList = []
79
       state.UserActivityList = []
80
+    },
81
+    UpdateActivityDetail (state, data) { // 更新活动详情
82
+      state.ActivityDetail = data || null
83
+    },
84
+    EditActivityDetail (state, data) { // 编辑活动详情
85
+      state.ActivityDetail = { ...state.ActivityDetail, [data.name]: data.value }
79
     }
86
     }
80
   },
87
   },
81
   actions: {
88
   actions: {
245
           method: Api.GetActivityDetail.method,
252
           method: Api.GetActivityDetail.method,
246
           ...payload,
253
           ...payload,
247
           success (res) {
254
           success (res) {
255
+            context.commit('UpdateActivityDetail', res.data.data)
248
             resolve(res)
256
             resolve(res)
249
           },
257
           },
250
           error (res) {
258
           error (res) {