Pārlūkot izejas kodu

fix: resolve API naming conflict for activity guide endpoints and WXML :class compatibility

Rename getActivityList/getActivityDetail to getGuideActivityList/getGuideActivityDetail in api.js to avoid conflict with activity center endpoints. Fix guide/activities/detail.vue to use renamed imports. Refactor activity/index.vue to pre-compute WXML-compatible display properties instead of calling methods in :class bindings.
User 2 mēneši atpakaļ
vecāks
revīzija
55f46ac806

+ 25 - 2
cfc-frontend/pages/activity/index.vue

@@ -62,8 +62,8 @@
               <text class="card-meta">{{ act.startTime }}</text>
               <text class="card-meta" v-if="act.location">📍 {{ act.location }}</text>
               <view class="card-bottom">
-                <text class="card-status" :class="getStatusClass(act)">
-                  {{ getStatusText(act) }}
+                <text class="card-status" :class="'status-' + (act._cls || 'upcoming')">
+                  {{ act._txt || '待开始' }}
                 </text>
                 <text class="card-price" v-if="act.price > 0">¥{{ formatPrice(act.price) }}</text>
                 <text class="card-price free" v-else>免费</text>
@@ -343,6 +343,9 @@ export default {
             }
             records = filtered
           }
+          for (var di = 0; di < records.length; di++) {
+            self.decorateActivity(records[di])
+          }
           if (refresh) {
             self.myActivities = records
           } else {
@@ -519,6 +522,26 @@ export default {
     formatPrice: function(price) {
       return (price / 100).toFixed(2)
     },
+    // Pre-compute display properties for WXML compatibility (no method calls in :class)
+    decorateActivity: function(act) {
+      if (act.status) {
+        act._cls = act.status
+        var map = { pending: '待审核', approved: '报名成功', rejected: '已拒绝', cancelled: '已取消', checked_in: '已签到' }
+        act._txt = map[act.status] || act.status
+      } else {
+        if (act.endTime) {
+          var endTime = new Date(act.endTime.replace(/-/g, '/'))
+          if (endTime < new Date()) {
+            act._cls = 'ended'
+            act._txt = '已结束'
+            return act
+          }
+        }
+        act._cls = 'upcoming'
+        act._txt = '待开始'
+      }
+      return act
+    },
     onCheckin: function(act) {
       var self = this
       var childId = uni.getStorageSync('currentChildId')

+ 2 - 2
cfc-frontend/pages/guide/activities/detail.vue

@@ -124,7 +124,7 @@
 </template>
 
 <script>
-import { getActivityDetail, createActivity, updateActivity, publishActivity } from '../../../utils/api.js'
+import { getGuideActivityDetail, createActivity, updateActivity, publishActivity } from '../../../utils/api.js'
 
 export default {
   data() {
@@ -169,7 +169,7 @@ export default {
     loadDetail() {
       var self = this
       self.loading = true
-      getActivityDetail(self.activityId).then(function(res) {
+      getGuideActivityDetail(self.activityId).then(function(res) {
         self.loading = false
         if (res.code === 200 && res.data) {
           self.form = res.data

+ 2 - 2
cfc-frontend/utils/api.js

@@ -632,11 +632,11 @@ export const deleteTrainingPlan = (planId) => {
 }
 
 // ===== 活动管理 =====
-export const getActivityList = (status) => {
+export const getGuideActivityList = (status) => {
   return request('/api/guide/activities/list', 'POST', status ? { status } : {})
 }
 
-export const getActivityDetail = (activityId) => {
+export const getGuideActivityDetail = (activityId) => {
   return request('/api/guide/activities/detail', 'POST', { activityId })
 }