|
|
@@ -137,7 +137,7 @@
|
|
|
<text class="tag-chip" v-for="(t, ti) in tagList(act.tags)" :key="ti">{{ t }}</text>
|
|
|
</view>
|
|
|
<text class="card-meta">开始 {{ formatActivityTime(act.startTime) }}{{ act.endTime ? ' 结束 ' + formatActivityTime(act.endTime) : '' }}</text>
|
|
|
- <text class="card-desc" v-if="act.intro || act.description">{{ act.intro || act.description }}</text>
|
|
|
+ <text class="card-desc" v-if="act.intro || act.description">{{ plainText(act.intro || act.description) }}</text>
|
|
|
<text class="card-meta" v-if="act.location">📍 {{ act.location }}</text>
|
|
|
<view class="card-bottom">
|
|
|
<text class="card-status" :class="'status-' + (act.displayStatus || 'open')">
|
|
|
@@ -392,7 +392,7 @@ export default {
|
|
|
if (this._onLoadFired) {
|
|
|
this._onLoadFired = false // 首次进入:onLoad 已加载,跳过避免双发
|
|
|
} else {
|
|
|
- // 切 Tab/从子页返回:刷新权限态(同步部分不发请求)+ 当前 tab 数据
|
|
|
+ // 从子页面(如活动详情)返回:刷新当前 tab(loadData 统一重置第一页,避免旧数据被追加导致翻倍)
|
|
|
this.resolveManagePermission()
|
|
|
this.loadData()
|
|
|
}
|
|
|
@@ -401,6 +401,25 @@ export default {
|
|
|
tagList: function(tags) {
|
|
|
return String(tags || '').split(/[,,、]/).map(function(t) { return t.trim() }).filter(function(t) { return !!t })
|
|
|
},
|
|
|
+ // 富文本(HTML)→ 纯文本摘要:去掉 style/script 标签与 HTML 标签、解码 HTML 实体( ' 等)、压缩空白
|
|
|
+ plainText: function(html) {
|
|
|
+ if (!html) return ''
|
|
|
+ var s = String(html)
|
|
|
+ .replace(/<style[\s\S]*?<\/style>/gi, ' ')
|
|
|
+ .replace(/<script[\s\S]*?<\/script>/gi, ' ')
|
|
|
+ .replace(/<[^>]+>/g, ' ')
|
|
|
+ .replace(/ /gi, ' ')
|
|
|
+ .replace(/</gi, '<')
|
|
|
+ .replace(/>/gi, '>')
|
|
|
+ .replace(/&/gi, '&')
|
|
|
+ .replace(/"/gi, '"')
|
|
|
+ s = s
|
|
|
+ .replace(/&#x([0-9a-fA-F]+);/g, function(all, hex) { return String.fromCharCode(parseInt(hex, 16)) })
|
|
|
+ .replace(/&#(\d+);/g, function(all, dec) { return String.fromCharCode(parseInt(dec, 10)) })
|
|
|
+ .replace(/\s+/g, ' ')
|
|
|
+ .trim()
|
|
|
+ return s
|
|
|
+ },
|
|
|
// 活动管理权限判定:与后端 ActivityController.hasActivityManageRole 对齐。
|
|
|
// 后台角色(admin / activity_admin / activity_manager)→ 可直接发布;
|
|
|
// 其余账号查服务商入驻状态,vendorType=activity_provider 且审核通过 → 可管理(只能提交审核)。
|
|
|
@@ -681,11 +700,14 @@ export default {
|
|
|
this.minePage = 1
|
|
|
this.myActivities = []
|
|
|
}
|
|
|
+ // 请求序号:返回期间若已发起新请求(onShow/下拉刷新重置),旧响应直接丢弃,防止旧分页追加导致列表翻倍
|
|
|
+ var seq = (this._mineReqSeq || 0) + 1
|
|
|
+ this._mineReqSeq = seq
|
|
|
this.mineLoading = true
|
|
|
var memberId = uni.getStorageSync('currentChildId')
|
|
|
if (!memberId) {
|
|
|
this.mineLoading = false
|
|
|
- return
|
|
|
+ return Promise.resolve()
|
|
|
}
|
|
|
var params = {
|
|
|
memberId: memberId,
|
|
|
@@ -695,7 +717,9 @@ export default {
|
|
|
if (this.currentMineFilter && this.currentMineFilter !== 'upcoming') {
|
|
|
params.status = this.currentMineFilter
|
|
|
}
|
|
|
- getMyActivityRegistrations(params).then(function(res) {
|
|
|
+ // 返回 Promise:onRefresh 的 .finally 依赖它来复位 isRefreshing(不返回会导致 undefined.finally 抛错,下拉刷新卡死)
|
|
|
+ return getMyActivityRegistrations(params).then(function(res) {
|
|
|
+ if (seq !== self._mineReqSeq) return
|
|
|
self.mineLoading = false
|
|
|
if (res && res.code === 200 && res.data) {
|
|
|
var records = res.data.records || []
|
|
|
@@ -728,7 +752,7 @@ export default {
|
|
|
self.hasMore = records.length >= self.pageSize
|
|
|
}
|
|
|
}).catch(function() {
|
|
|
- self.mineLoading = false
|
|
|
+ if (seq === self._mineReqSeq) self.mineLoading = false
|
|
|
})
|
|
|
},
|
|
|
loadDiscoverActivities: function(refresh) {
|
|
|
@@ -737,6 +761,9 @@ export default {
|
|
|
this.discoverPage = 1
|
|
|
this.discoverActivities = []
|
|
|
}
|
|
|
+ // 请求序号:过期响应直接丢弃,防止旧分页在刷新后追加导致列表翻倍
|
|
|
+ var seq = (this._discoverReqSeq || 0) + 1
|
|
|
+ this._discoverReqSeq = seq
|
|
|
this.discoverLoading = true
|
|
|
var params = {
|
|
|
page: this.discoverPage,
|
|
|
@@ -745,7 +772,9 @@ export default {
|
|
|
if (this.currentDimension) {
|
|
|
params.dimensionCode = this.currentDimension
|
|
|
}
|
|
|
- getActivityList(params).then(function(res) {
|
|
|
+ // 返回 Promise:onRefresh 的 .finally 依赖它复位 isRefreshing
|
|
|
+ return getActivityList(params).then(function(res) {
|
|
|
+ if (seq !== self._discoverReqSeq) return
|
|
|
self.discoverLoading = false
|
|
|
if (res && res.code === 200 && res.data) {
|
|
|
var list = Array.isArray(res.data) ? res.data : (res.data.records || [])
|
|
|
@@ -757,7 +786,7 @@ export default {
|
|
|
self.hasMore = list.length >= self.pageSize
|
|
|
}
|
|
|
}).catch(function() {
|
|
|
- self.discoverLoading = false
|
|
|
+ if (seq === self._discoverReqSeq) self.discoverLoading = false
|
|
|
})
|
|
|
},
|
|
|
loadHistoryActivities: function(refresh) {
|
|
|
@@ -766,18 +795,23 @@ export default {
|
|
|
this.historyPage = 1
|
|
|
this.historyActivities = []
|
|
|
}
|
|
|
+ // 请求序号:过期响应直接丢弃,防止旧分页在刷新后追加导致列表翻倍
|
|
|
+ var seq = (this._historyReqSeq || 0) + 1
|
|
|
+ this._historyReqSeq = seq
|
|
|
this.historyLoading = true
|
|
|
var memberId = uni.getStorageSync('currentChildId')
|
|
|
if (!memberId) {
|
|
|
this.historyLoading = false
|
|
|
- return
|
|
|
+ return Promise.resolve()
|
|
|
}
|
|
|
var params = {
|
|
|
memberId: memberId,
|
|
|
page: this.historyPage,
|
|
|
size: this.pageSize
|
|
|
}
|
|
|
- getMyActivityRegistrations(params).then(function(res) {
|
|
|
+ // 返回 Promise:onRefresh 的 .finally 依赖它复位 isRefreshing
|
|
|
+ return getMyActivityRegistrations(params).then(function(res) {
|
|
|
+ if (seq !== self._historyReqSeq) return
|
|
|
self.historyLoading = false
|
|
|
if (res && res.code === 200 && res.data) {
|
|
|
var records = res.data.records || []
|
|
|
@@ -802,7 +836,7 @@ export default {
|
|
|
self.hasMore = records.length >= self.pageSize
|
|
|
}
|
|
|
}).catch(function() {
|
|
|
- self.historyLoading = false
|
|
|
+ if (seq === self._historyReqSeq) self.historyLoading = false
|
|
|
})
|
|
|
},
|
|
|
// 报名记录 → 卡片所需字段:/api/activity/my-registrations 返回的是
|