Explorar el Código

fix(miniapp): 修复活动中心管理 tab 空白及结束活动假实现

E2E Test Bot hace 1 semana
padre
commit
d7331ae7e0
Se han modificado 1 ficheros con 48 adiciones y 7 borrados
  1. 48 7
      cfc-frontend/pages/activity/index.vue

+ 48 - 7
cfc-frontend/pages/activity/index.vue

@@ -281,6 +281,7 @@
                   <text class="manage-action-small" v-if="act.status === 'draft'" @click.stop="doPublish(act.id)">{{ isAdmin ? '发布' : '提交审核' }}</text>
                   <text class="manage-action-small" v-if="act.status === 'rejected'" @click.stop="doPublish(act.id)">重新提交</text>
                   <text class="manage-action-small" v-if="act.status === 'published'" @click.stop="doEnd(act.id)">结束</text>
+                  <text class="manage-action-small" v-if="act.status === 'published'" @click.stop="doWithdraw(act.id)">撤回</text>
                 </view>
               </view>
             </view>
@@ -301,7 +302,7 @@
 </template>
 
 <script>
-import { getActivityList, getMyActivityRegistrations, activityCheckin, cancelActivityRegistration, adminListMyActivities, adminPublishActivity, submitActivityForReview, reportAppEnter} from '@/utils/api.js'
+import { getActivityList, getMyActivityRegistrations, activityCheckin, cancelActivityRegistration, adminListMyActivities, adminPublishActivity, adminEndActivity, adminWithdrawActivity, submitActivityForReview, reportAppEnter} from '@/utils/api.js'
 import config from '@/config.js'
 import { parseDate } from '../../utils/format.js'
 
@@ -309,7 +310,15 @@ export default {
   computed: {
     isAdmin: function() {
       var userInfo = uni.getStorageSync('userInfo')
-      return userInfo && (userInfo.role === 'admin' || userInfo.role === 'activity_admin' || (userInfo.roles && userInfo.roles.indexOf('activity_admin') >= 0))
+      if (!userInfo) return false
+      if (userInfo.role === 'admin' || userInfo.role === 'activity_admin' || userInfo.role === 'activity_manager') return true
+      if (userInfo.roles && userInfo.roles.length) {
+        for (var i = 0; i < userInfo.roles.length; i++) {
+          var r = userInfo.roles[i]
+          if (r === 'activity_admin' || r === 'activity_manager' || r === 'admin') return true
+        }
+      }
+      return false
     },
     isActivityProvider: function() {
       var userInfo = uni.getStorageSync('userInfo')
@@ -424,7 +433,7 @@ export default {
             var s = records[i].status
             if (s === 'published') published++
             else if (s === 'draft') draft++
-            else if (s === 'ended' || s === 'cancelled') ended++
+            else if (s === 'ended' || s === 'cancelled' || s === 'withdrawn') ended++
           }
           self.manageStats = { total: total, published: published, draft: draft, ended: ended }
         } else {
@@ -450,6 +459,7 @@ export default {
         rejected: '已驳回',
         published: '进行中',
         ended: '已结束',
+        withdrawn: '已撤回',
         cancelled: '已取消'
       }
       return map[status] || status
@@ -501,11 +511,42 @@ export default {
         success: function(res) {
           if (res.confirm) {
             uni.showLoading({ title: '操作中...' })
-            setTimeout(function() {
+            adminEndActivity(id).then(function(r) {
               uni.hideLoading()
-              uni.showToast({ title: '操作成功', icon: 'success' })
-              self.loadManageData()
-            }, 500)
+              if (r && r.code === 200) {
+                uni.showToast({ title: '已结束', icon: 'success' })
+                self.loadManageData()
+              } else {
+                uni.showToast({ title: (r && r.message) || '操作失败', icon: 'none' })
+              }
+            }).catch(function() {
+              uni.hideLoading()
+              uni.showToast({ title: '网络异常', icon: 'none' })
+            })
+          }
+        }
+      })
+    },
+    doWithdraw: function(id) {
+      var self = this
+      uni.showModal({
+        title: '提示',
+        content: '确认撤回此活动吗?撤回后不再对外展示,可重新编辑。',
+        success: function(res) {
+          if (res.confirm) {
+            uni.showLoading({ title: '操作中...' })
+            adminWithdrawActivity(id).then(function(r) {
+              uni.hideLoading()
+              if (r && r.code === 200) {
+                uni.showToast({ title: '已撤回', icon: 'success' })
+                self.loadManageData()
+              } else {
+                uni.showToast({ title: (r && r.message) || '操作失败', icon: 'none' })
+              }
+            }).catch(function() {
+              uni.hideLoading()
+              uni.showToast({ title: '网络异常', icon: 'none' })
+            })
           }
         }
       })