修改bug
This commit is contained in:
@@ -90,17 +90,14 @@
|
||||
<!-- 招募要求 -->
|
||||
<view class="section">
|
||||
<view class="section-title">招募要求</view>
|
||||
<view class="section-content">
|
||||
{{activityConent.requirements}}
|
||||
</view>
|
||||
<view class="section-content" v-html="formatRichText(activityConent.requirements)"></view>
|
||||
</view>
|
||||
|
||||
<!-- 活动详情 -->
|
||||
<view class="section" style="margin-bottom: 40rpx;">
|
||||
<view class="section-title">活动详情</view>
|
||||
<view class="section-content rich-content">
|
||||
<view v-html="activityConent.content"></view>
|
||||
<view></view>
|
||||
<view v-html="formatRichText(activityConent.content)"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -170,7 +167,7 @@
|
||||
报名
|
||||
</button>
|
||||
|
||||
<!-- 已报名状态显示取消报名按钮(活动已结束则隐藏) -->
|
||||
<!-- 已报名状态显示取消报名按钮 -->
|
||||
<button
|
||||
v-if="hasSigned && !isActivityEnded && activeTab === 'detail'"
|
||||
class="action-btn cancel-btn"
|
||||
@@ -246,10 +243,7 @@ const liveRecords = ref([])
|
||||
|
||||
// 判断活动是否已结束
|
||||
const isActivityEnded = computed(() => {
|
||||
// 优先使用列表页传入的statusText
|
||||
if (statusTextFromParam.value === '已结束') return true
|
||||
// 其次使用后端详情接口返回的状态字段
|
||||
// if (activityConent.value.statusText === '已结束') return true
|
||||
// 报名截止时间已过
|
||||
if (activityConent.value.applyDeadline && moment().isAfter(moment(activityConent.value.applyDeadline))) return true
|
||||
// 活动结束时间已过
|
||||
@@ -269,9 +263,6 @@ const isActivityEndedByTime = computed(() => {
|
||||
return moment().isAfter(moment(activityConent.value.endTime))
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
// ========方法=====
|
||||
// 时间格式化函数
|
||||
const formatTime = (timeStr) => {
|
||||
@@ -279,13 +270,27 @@ const formatTime = (timeStr) => {
|
||||
return moment(timeStr).format('YYYY-MM-DD HH:mm')
|
||||
}
|
||||
|
||||
// 富文本处理:给 img 注入内联样式
|
||||
const formatRichText = (html) => {
|
||||
if (!html) return ''
|
||||
return html.replace(/<img\b([^>]*)>/gi, (match, attrs) => {
|
||||
// 去掉尾部自闭合斜杠,避免 style 追加到斜杠之后
|
||||
const inner = attrs.replace(/\/\s*$/, '')
|
||||
const imgStyle = 'max-width:100%;height:auto;display:block;'
|
||||
if (/style\s*=/i.test(inner)) {
|
||||
// 已有 style,在 style 值开头注入
|
||||
return `<img${inner.replace(/(style\s*=\s*["'])/i, `$1${imgStyle}`)}>`
|
||||
}
|
||||
return `<img${inner} style="${imgStyle}">`
|
||||
})
|
||||
}
|
||||
|
||||
// ---接收参数---
|
||||
const statusTextFromParam = ref('') // 从列表页传入的活动状态文本
|
||||
onLoad((option) =>{
|
||||
navTitle.value = option?.title
|
||||
curActivityId.value = option?.id
|
||||
statusTextFromParam.value = option?.statusText || ''
|
||||
// 处理applied参数
|
||||
hasSigned.value = option?.applied === 'true'
|
||||
// console.log('hasSigned.value',hasSigned.value)
|
||||
// 2. 初始化数据
|
||||
|
||||
Reference in New Issue
Block a user