活动时间改为年月日到年月日
This commit is contained in:
parent
b7fe6a9066
commit
54b9aaf9f6
|
|
@ -1,29 +1,37 @@
|
|||
<template>
|
||||
<view class="page">
|
||||
<custom-navbar title="寺庙活动" />
|
||||
<view class="header" :style="{ backgroundColor: CommonEnum.BASE_COLOR }">
|
||||
<custom-navbar ref="customNavbar" title="寺庙活动" />
|
||||
<view :style="{ backgroundColor: CommonEnum.BASE_COLOR }" class="header">
|
||||
<!-- 状态展示 -->
|
||||
<status-display v-if="loading" type="loading" loading-text="加载中..." />
|
||||
<status-display v-if="loading" loading-text="加载中..." type="loading" />
|
||||
|
||||
<!-- 错误状态 -->
|
||||
<status-display v-if="error" type="error" :error-text="error" @retry="loadPageData" />
|
||||
<status-display
|
||||
v-if="error"
|
||||
:error-text="error"
|
||||
type="error"
|
||||
@retry="loadPageData"
|
||||
/>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<status-display
|
||||
v-if="!loading && !error && activityList.length === 0"
|
||||
type="empty"
|
||||
empty-text="暂无活动"
|
||||
type="empty"
|
||||
/>
|
||||
|
||||
<!-- 活动卡片列表 -->
|
||||
<view class="activity-list" v-if="!loading && !error && activityList.length > 0">
|
||||
<view
|
||||
v-if="!loading && !error && activityList.length > 0"
|
||||
class="activity-list"
|
||||
>
|
||||
<activity-card
|
||||
v-for="activity in activityList"
|
||||
:key="activity.id"
|
||||
:activity="activity"
|
||||
:show-title="true"
|
||||
@card-click="handleCardClick"
|
||||
@register="handleRegister"
|
||||
@card-click="handleCardClick"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -31,208 +39,210 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import CommonEnum from '../../enum/common'
|
||||
import { ACTIVITY_STATUS, ACTIVITY_TYPE } from '../../enum/activity'
|
||||
import StatusDisplay from '../../components/status-display/status-display.vue'
|
||||
import ActivityCard from '../../components/activity-card/activity-card.vue'
|
||||
import activityApi from '../../api/activity/activity.js'
|
||||
import activityFormatter from '../../utils/activity-data-formatter.js'
|
||||
import CommonEnum from "../../enum/common";
|
||||
import StatusDisplay from "../../components/status-display/status-display.vue";
|
||||
import ActivityCard from "../../components/activity-card/activity-card.vue";
|
||||
import activityApi from "../../api/activity/activity.js";
|
||||
import activityFormatter from "../../utils/activity-data-formatter.js";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
StatusDisplay,
|
||||
ActivityCard,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
CommonEnum,
|
||||
loading: false,
|
||||
error: '',
|
||||
activityList: [],
|
||||
// 分页参数
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
hasMore: true,
|
||||
export default {
|
||||
components: {
|
||||
StatusDisplay,
|
||||
ActivityCard,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
CommonEnum,
|
||||
loading: false,
|
||||
error: "",
|
||||
activityList: [],
|
||||
// 分页参数
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
hasMore: true,
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
// 页面加载时获取数据
|
||||
this.loadPageData();
|
||||
},
|
||||
// 下拉刷新
|
||||
onPullDownRefresh() {
|
||||
this.refreshData();
|
||||
},
|
||||
// 上拉加载更多
|
||||
onReachBottom() {
|
||||
if (this.hasMore && !this.loading) {
|
||||
this.loadMoreData();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 加载页面数据
|
||||
async loadPageData() {
|
||||
this.loading = true;
|
||||
this.error = "";
|
||||
|
||||
try {
|
||||
const response = await activityApi.getActivityList({
|
||||
pageNum: this.pageNum,
|
||||
pageSize: this.pageSize,
|
||||
});
|
||||
|
||||
if (response.code === 200 && response.data) {
|
||||
// 格式化数据
|
||||
const formattedData = activityFormatter.formatActivityList(
|
||||
response.data,
|
||||
);
|
||||
this.activityList = formattedData;
|
||||
|
||||
// 判断是否还有更多数据
|
||||
this.hasMore = response.data.length >= this.pageSize;
|
||||
} else {
|
||||
this.error = response.msg || "获取活动列表失败";
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("获取活动列表失败:", error);
|
||||
this.error = "网络错误,请稍后重试";
|
||||
} finally {
|
||||
this.loading = false;
|
||||
uni.stopPullDownRefresh();
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
// 页面加载时获取数据
|
||||
this.loadPageData()
|
||||
|
||||
// 刷新数据
|
||||
async refreshData() {
|
||||
this.pageNum = 1;
|
||||
this.hasMore = true;
|
||||
await this.loadPageData();
|
||||
},
|
||||
// 下拉刷新
|
||||
onPullDownRefresh() {
|
||||
this.refreshData()
|
||||
},
|
||||
// 上拉加载更多
|
||||
onReachBottom() {
|
||||
if (this.hasMore && !this.loading) {
|
||||
this.loadMoreData()
|
||||
|
||||
// 加载更多数据
|
||||
async loadMoreData() {
|
||||
if (!this.hasMore || this.loading) return;
|
||||
|
||||
this.loading = true;
|
||||
try {
|
||||
const nextPage = this.pageNum + 1;
|
||||
const response = await activityApi.getActivityList({
|
||||
pageNum: nextPage,
|
||||
pageSize: this.pageSize,
|
||||
});
|
||||
|
||||
if (response.code === 200 && response.data) {
|
||||
const formattedData = activityFormatter.formatActivityList(
|
||||
response.data,
|
||||
);
|
||||
this.activityList = [...this.activityList, ...formattedData];
|
||||
this.pageNum = nextPage;
|
||||
this.hasMore = response.data.length >= this.pageSize;
|
||||
} else {
|
||||
this.hasMore = false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("加载更多活动失败:", error);
|
||||
this.hasMore = false;
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 加载页面数据
|
||||
async loadPageData() {
|
||||
this.loading = true
|
||||
this.error = ''
|
||||
|
||||
try {
|
||||
const response = await activityApi.getActivityList({
|
||||
pageNum: this.pageNum,
|
||||
pageSize: this.pageSize,
|
||||
})
|
||||
// 处理卡片点击
|
||||
handleCardClick(activity) {
|
||||
console.log("点击活动卡片:", activity);
|
||||
// 跳转到活动详情页
|
||||
uni.navigateTo({
|
||||
url: `/pages/activity/activityDetail?actId=${activity.id}`,
|
||||
});
|
||||
},
|
||||
|
||||
if (response.code === 200 && response.data) {
|
||||
// 格式化数据
|
||||
const formattedData = activityFormatter.formatActivityList(response.data)
|
||||
this.activityList = formattedData
|
||||
// 处理报名
|
||||
async handleRegister(activity) {
|
||||
console.log("报名活动:", activity);
|
||||
|
||||
// 判断是否还有更多数据
|
||||
this.hasMore = response.data.length >= this.pageSize
|
||||
} else {
|
||||
this.error = response.msg || '获取活动列表失败'
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取活动列表失败:', error)
|
||||
this.error = '网络错误,请稍后重试'
|
||||
} finally {
|
||||
this.loading = false
|
||||
uni.stopPullDownRefresh()
|
||||
}
|
||||
},
|
||||
|
||||
// 刷新数据
|
||||
async refreshData() {
|
||||
this.pageNum = 1
|
||||
this.hasMore = true
|
||||
await this.loadPageData()
|
||||
},
|
||||
|
||||
// 加载更多数据
|
||||
async loadMoreData() {
|
||||
if (!this.hasMore || this.loading) return
|
||||
|
||||
this.loading = true
|
||||
try {
|
||||
const nextPage = this.pageNum + 1
|
||||
const response = await activityApi.getActivityList({
|
||||
pageNum: nextPage,
|
||||
pageSize: this.pageSize,
|
||||
})
|
||||
|
||||
if (response.code === 200 && response.data) {
|
||||
const formattedData = activityFormatter.formatActivityList(response.data)
|
||||
this.activityList = [...this.activityList, ...formattedData]
|
||||
this.pageNum = nextPage
|
||||
this.hasMore = response.data.length >= this.pageSize
|
||||
} else {
|
||||
this.hasMore = false
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载更多活动失败:', error)
|
||||
this.hasMore = false
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
// 处理卡片点击
|
||||
handleCardClick(activity) {
|
||||
console.log('点击活动卡片:', activity)
|
||||
// 跳转到活动详情页
|
||||
uni.navigateTo({
|
||||
url: `/pages/activity/activityDetail?actId=${activity.id}`,
|
||||
})
|
||||
},
|
||||
|
||||
// 处理报名
|
||||
async handleRegister(activity) {
|
||||
console.log('报名活动:', activity)
|
||||
|
||||
// 检查用户是否登录
|
||||
const userInfo = uni.getStorageSync('userInfo')
|
||||
if (!userInfo) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '请先登录后再报名活动',
|
||||
confirmText: '去登录',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
// 跳转到登录页
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/login',
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 确认报名
|
||||
// 检查用户是否登录
|
||||
const userInfo = uni.getStorageSync("userInfo");
|
||||
if (!userInfo) {
|
||||
uni.showModal({
|
||||
title: '确认报名',
|
||||
content: `确定要报名参加"${activity.name}"活动吗?`,
|
||||
success: async res => {
|
||||
title: "提示",
|
||||
content: "请先登录后再报名活动",
|
||||
confirmText: "去登录",
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
const response = await activityApi.registerActivity({
|
||||
activityId: activity.id,
|
||||
userId: userInfo.id,
|
||||
userName: userInfo.userName || userInfo.nickName,
|
||||
phone: userInfo.phone,
|
||||
})
|
||||
|
||||
if (response.code === 200) {
|
||||
uni.showToast({
|
||||
title: '报名成功',
|
||||
icon: 'success',
|
||||
})
|
||||
|
||||
// 刷新活动列表以更新报名状态
|
||||
this.refreshData()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: response.msg || '报名失败',
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('报名失败:', error)
|
||||
uni.showToast({
|
||||
title: '报名失败,请稍后重试',
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
// 跳转到登录页
|
||||
uni.navigateTo({
|
||||
url: "/pages/login/login",
|
||||
});
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 确认报名
|
||||
uni.showModal({
|
||||
title: "确认报名",
|
||||
content: `确定要报名参加"${activity.name}"活动吗?`,
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
const response = await activityApi.registerActivity({
|
||||
activityId: activity.id,
|
||||
userId: userInfo.id,
|
||||
userName: userInfo.userName || userInfo.nickName,
|
||||
phone: userInfo.phone,
|
||||
});
|
||||
|
||||
if (response.code === 200) {
|
||||
uni.showToast({
|
||||
title: "报名成功",
|
||||
icon: "success",
|
||||
});
|
||||
|
||||
// 刷新活动列表以更新报名状态
|
||||
this.refreshData();
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: response.msg || "报名失败",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("报名失败:", error);
|
||||
uni.showToast({
|
||||
title: "报名失败,请稍后重试",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background: #faf8f3;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
}
|
||||
page {
|
||||
background: #faf8f3;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.header {
|
||||
width: 100%;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
padding: 0 34rpx;
|
||||
padding-bottom: 40rpx;
|
||||
}
|
||||
.header {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
padding: 0 34rpx 40rpx 34rpx;
|
||||
}
|
||||
|
||||
.activity-list {
|
||||
margin-top: 40rpx;
|
||||
width: 100%;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
}
|
||||
.activity-list {
|
||||
margin-top: 34rpx;
|
||||
width: 100%;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
//border: red 1rpx solid;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -1,12 +1,17 @@
|
|||
<template>
|
||||
<view class="page">
|
||||
<custom-navbar title="活动详情" />
|
||||
<view class="header" :style="{ backgroundColor: CommonEnum.BASE_COLOR }">
|
||||
<custom-navbar ref="customNavbar" title="活动详情" />
|
||||
<view :style="{ backgroundColor: CommonEnum.BASE_COLOR }" class="header">
|
||||
<!-- 状态展示 -->
|
||||
<status-display v-if="loading" type="loading" loading-text="加载中..." />
|
||||
<status-display v-if="loading" loading-text="加载中..." type="loading" />
|
||||
|
||||
<!-- 错误状态 -->
|
||||
<status-display v-if="error" type="error" :error-text="error" @retry="loadPageData" />
|
||||
<status-display
|
||||
v-if="error"
|
||||
:error-text="error"
|
||||
type="error"
|
||||
@retry="loadPageData"
|
||||
/>
|
||||
|
||||
<!-- 活动详情内容 -->
|
||||
<view v-if="!loading && !error && activityData" class="activity-detail">
|
||||
|
|
@ -15,8 +20,12 @@
|
|||
<view class="title-section">
|
||||
<text class="main-title">{{ activityData.title }}</text>
|
||||
<view class="meta-info">
|
||||
<text class="date">{{ formatDate(activityData.createTime) }}</text>
|
||||
<text class="read-count">阅读{{ activityData.readNum || 0 }}</text>
|
||||
<text class="date">{{
|
||||
formatDate(activityData.createTime)
|
||||
}}</text>
|
||||
<text class="read-count"
|
||||
>阅读{{ activityData.readNum || 0 }}</text
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -24,10 +33,10 @@
|
|||
<!-- 活动信息卡片 -->
|
||||
<activity-card
|
||||
:activity="formattedActivity"
|
||||
:show-title="false"
|
||||
:show-register-button="false"
|
||||
@card-click="handleCardClick"
|
||||
:show-title="false"
|
||||
@register="handleRegister"
|
||||
@card-click="handleCardClick"
|
||||
/>
|
||||
|
||||
<!-- 参与统计 -->
|
||||
|
|
@ -38,28 +47,41 @@
|
|||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-label">已报名:</text>
|
||||
<text class="stat-value">{{ activityData.currentBooking || 0 }}</text>
|
||||
<text class="stat-value">{{
|
||||
activityData.currentBooking || 0
|
||||
}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 活动描述 -->
|
||||
<view class="activity-description" v-if="activityData.content">
|
||||
<view v-if="activityData.content" class="activity-description">
|
||||
<view class="description-title">
|
||||
<text class="title-text">活动详情</text>
|
||||
</view>
|
||||
<view class="description-content">
|
||||
<rich-text :nodes="activityData.content" class="content-html"></rich-text>
|
||||
<rich-text
|
||||
:nodes="activityData.content"
|
||||
class="content-html"
|
||||
></rich-text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<view class="bottom-actions">
|
||||
<view class="action-button phone-button" @click="handlePhoneCall">
|
||||
<image class="button-icon" :src="CommonEnum.PHONE" mode="aspectFit"></image>
|
||||
<image
|
||||
:src="CommonEnum.PHONE"
|
||||
class="button-icon"
|
||||
mode="aspectFit"
|
||||
></image>
|
||||
<text class="button-text">电话</text>
|
||||
</view>
|
||||
<view class="action-button location-button" @click="handleLocation">
|
||||
<image class="button-icon" :src="CommonEnum.ADDRESS" mode="aspectFit"></image>
|
||||
<image
|
||||
:src="CommonEnum.ADDRESS"
|
||||
class="button-icon"
|
||||
mode="aspectFit"
|
||||
></image>
|
||||
<text class="button-text">地址</text>
|
||||
</view>
|
||||
<view class="action-button register-button" @click="handleRegister">
|
||||
|
|
@ -72,398 +94,398 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import CustomNavbar from '../../components/custom-navbar/custom-navbar.vue'
|
||||
import CommonEnum from '../../enum/common'
|
||||
import StatusDisplay from '../../components/status-display/status-display.vue'
|
||||
import ActivityCard from '../../components/activity-card/activity-card.vue'
|
||||
import activityApi from '../../api/activity/activity.js'
|
||||
import activityFormatter from '../../utils/activity-data-formatter.js'
|
||||
import CustomNavbar from "../../components/custom-navbar/custom-navbar.vue";
|
||||
import CommonEnum from "../../enum/common";
|
||||
import StatusDisplay from "../../components/status-display/status-display.vue";
|
||||
import ActivityCard from "../../components/activity-card/activity-card.vue";
|
||||
import activityApi from "../../api/activity/activity.js";
|
||||
import activityFormatter from "../../utils/activity-data-formatter.js";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
CustomNavbar,
|
||||
StatusDisplay,
|
||||
ActivityCard,
|
||||
export default {
|
||||
components: {
|
||||
CustomNavbar,
|
||||
StatusDisplay,
|
||||
ActivityCard,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
CommonEnum,
|
||||
loading: false,
|
||||
error: "",
|
||||
activityData: null,
|
||||
actId: "",
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
// 格式化后的活动数据
|
||||
formattedActivity() {
|
||||
if (!this.activityData) return null;
|
||||
return activityFormatter.formatActivityDetail(this.activityData);
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
CommonEnum,
|
||||
loading: false,
|
||||
error: '',
|
||||
activityData: null,
|
||||
actId: '',
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// 格式化后的活动数据
|
||||
formattedActivity() {
|
||||
if (!this.activityData) return null
|
||||
return activityFormatter.formatActivityDetail(this.activityData)
|
||||
},
|
||||
},
|
||||
onLoad(options) {
|
||||
// 获取传入的活动ID
|
||||
if (options.actId) {
|
||||
this.actId = options.actId
|
||||
this.loadPageData()
|
||||
} else {
|
||||
this.error = '缺少活动ID参数'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 加载页面数据
|
||||
async loadPageData() {
|
||||
if (!this.actId) return
|
||||
},
|
||||
onLoad(options) {
|
||||
// 获取传入的活动ID
|
||||
if (options.actId) {
|
||||
this.actId = options.actId;
|
||||
this.loadPageData();
|
||||
} else {
|
||||
this.error = "缺少活动ID参数";
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 加载页面数据
|
||||
async loadPageData() {
|
||||
if (!this.actId) return;
|
||||
|
||||
this.loading = true
|
||||
this.error = ''
|
||||
this.loading = true;
|
||||
this.error = "";
|
||||
|
||||
try {
|
||||
const response = await activityApi.getActivityDetail(this.actId)
|
||||
try {
|
||||
const response = await activityApi.getActivityDetail(this.actId);
|
||||
|
||||
if (response.code === 200 && response.data) {
|
||||
this.activityData = response.data
|
||||
} else {
|
||||
this.error = response.msg || '获取活动详情失败'
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取活动详情失败:', error)
|
||||
this.error = '网络错误,请稍后重试'
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
// 格式化日期
|
||||
formatDate(dateString) {
|
||||
if (!dateString) return ''
|
||||
|
||||
try {
|
||||
// 将 "yyyy-MM-dd HH:mm:ss" 格式转换为 "yyyy-MM-ddTHH:mm:ss" 格式以兼容iOS
|
||||
const iosCompatibleDate = dateString.replace(' ', 'T')
|
||||
const date = new Date(iosCompatibleDate)
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
const hours = String(date.getHours()).padStart(2, '0')
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0')
|
||||
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}`
|
||||
} catch (error) {
|
||||
console.error('格式化日期失败:', error)
|
||||
return dateString
|
||||
}
|
||||
},
|
||||
|
||||
// 处理卡片点击
|
||||
handleCardClick(activity) {
|
||||
console.log('点击活动卡片:', activity)
|
||||
// 在详情页中点击卡片不执行任何操作
|
||||
},
|
||||
|
||||
// 处理报名
|
||||
async handleRegister() {
|
||||
if (!this.activityData) return
|
||||
|
||||
console.log('报名活动:', this.activityData)
|
||||
|
||||
// 检查用户是否登录
|
||||
const userInfo = uni.getStorageSync('userInfo')
|
||||
if (!userInfo) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '请先登录后再报名活动',
|
||||
confirmText: '去登录',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
// 跳转到登录页
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/login',
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 确认报名
|
||||
uni.showModal({
|
||||
title: '确认报名',
|
||||
content: `确定要报名参加"${this.activityData.title}"活动吗?`,
|
||||
success: async res => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
const response = await activityApi.registerActivity({
|
||||
activityId: this.activityData.id,
|
||||
userId: userInfo.id,
|
||||
userName: userInfo.userName || userInfo.nickName,
|
||||
phone: userInfo.phone,
|
||||
})
|
||||
|
||||
if (response.code === 200) {
|
||||
uni.showToast({
|
||||
title: '报名成功',
|
||||
icon: 'success',
|
||||
})
|
||||
|
||||
// 刷新活动详情以更新报名状态
|
||||
this.loadPageData()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: response.msg || '报名失败',
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('报名失败:', error)
|
||||
uni.showToast({
|
||||
title: '报名失败,请稍后重试',
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
|
||||
// 处理电话拨打
|
||||
handlePhoneCall() {
|
||||
if (!this.activityData || !this.activityData.phone) {
|
||||
uni.showToast({
|
||||
title: '暂无联系电话',
|
||||
icon: 'none',
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
uni.showModal({
|
||||
title: '拨打电话',
|
||||
content: `确定要拨打 ${this.activityData.phone} 吗?`,
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
uni.makePhoneCall({
|
||||
phoneNumber: this.activityData.phone,
|
||||
fail: err => {
|
||||
console.error('拨打电话失败:', err)
|
||||
uni.showToast({
|
||||
title: '拨打电话失败',
|
||||
icon: 'none',
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
|
||||
// 处理地址查看
|
||||
handleLocation() {
|
||||
if (!this.activityData || !this.activityData.address) {
|
||||
uni.showToast({
|
||||
title: '暂无地址信息',
|
||||
icon: 'none',
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 如果有经纬度信息,打开地图
|
||||
if (this.activityData.lon && this.activityData.lat) {
|
||||
uni.openLocation({
|
||||
latitude: this.activityData.lat,
|
||||
longitude: this.activityData.lon,
|
||||
name: this.activityData.title,
|
||||
address: this.activityData.address,
|
||||
fail: err => {
|
||||
console.error('打开地图失败:', err)
|
||||
// 如果打开地图失败,显示地址信息
|
||||
this.showAddressInfo()
|
||||
},
|
||||
})
|
||||
if (response.code === 200 && response.data) {
|
||||
this.activityData = response.data;
|
||||
} else {
|
||||
// 没有经纬度信息,显示地址详情
|
||||
this.showAddressInfo()
|
||||
this.error = response.msg || "获取活动详情失败";
|
||||
}
|
||||
},
|
||||
|
||||
// 显示地址信息
|
||||
showAddressInfo() {
|
||||
uni.showModal({
|
||||
title: '活动地址',
|
||||
content: this.activityData.address,
|
||||
showCancel: false,
|
||||
confirmText: '知道了',
|
||||
})
|
||||
},
|
||||
} catch (error) {
|
||||
console.error("获取活动详情失败:", error);
|
||||
this.error = "网络错误,请稍后重试";
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
// 格式化日期
|
||||
formatDate(dateString) {
|
||||
if (!dateString) return "";
|
||||
|
||||
try {
|
||||
// 将 "yyyy-MM-dd HH:mm:ss" 格式转换为 "yyyy-MM-ddTHH:mm:ss" 格式以兼容iOS
|
||||
const iosCompatibleDate = dateString.replace(" ", "T");
|
||||
const date = new Date(iosCompatibleDate);
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, "0");
|
||||
const day = String(date.getDate()).padStart(2, "0");
|
||||
const hours = String(date.getHours()).padStart(2, "0");
|
||||
const minutes = String(date.getMinutes()).padStart(2, "0");
|
||||
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}`;
|
||||
} catch (error) {
|
||||
console.error("格式化日期失败:", error);
|
||||
return dateString;
|
||||
}
|
||||
},
|
||||
|
||||
// 处理卡片点击
|
||||
handleCardClick(activity) {
|
||||
console.log("点击活动卡片:", activity);
|
||||
// 在详情页中点击卡片不执行任何操作
|
||||
},
|
||||
|
||||
// 处理报名
|
||||
async handleRegister() {
|
||||
if (!this.activityData) return;
|
||||
|
||||
console.log("报名活动:", this.activityData);
|
||||
|
||||
// 检查用户是否登录
|
||||
const userInfo = uni.getStorageSync("userInfo");
|
||||
if (!userInfo) {
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "请先登录后再报名活动",
|
||||
confirmText: "去登录",
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
// 跳转到登录页
|
||||
uni.navigateTo({
|
||||
url: "/pages/login/login",
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 确认报名
|
||||
uni.showModal({
|
||||
title: "确认报名",
|
||||
content: `确定要报名参加"${this.activityData.title}"活动吗?`,
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
const response = await activityApi.registerActivity({
|
||||
activityId: this.activityData.id,
|
||||
userId: userInfo.id,
|
||||
userName: userInfo.userName || userInfo.nickName,
|
||||
phone: userInfo.phone,
|
||||
});
|
||||
|
||||
if (response.code === 200) {
|
||||
uni.showToast({
|
||||
title: "报名成功",
|
||||
icon: "success",
|
||||
});
|
||||
|
||||
// 刷新活动详情以更新报名状态
|
||||
this.loadPageData();
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: response.msg || "报名失败",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("报名失败:", error);
|
||||
uni.showToast({
|
||||
title: "报名失败,请稍后重试",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
// 处理电话拨打
|
||||
handlePhoneCall() {
|
||||
if (!this.activityData || !this.activityData.phone) {
|
||||
uni.showToast({
|
||||
title: "暂无联系电话",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
uni.showModal({
|
||||
title: "拨打电话",
|
||||
content: `确定要拨打 ${this.activityData.phone} 吗?`,
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.makePhoneCall({
|
||||
phoneNumber: this.activityData.phone,
|
||||
fail: (err) => {
|
||||
console.error("拨打电话失败:", err);
|
||||
uni.showToast({
|
||||
title: "拨打电话失败",
|
||||
icon: "none",
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
// 处理地址查看
|
||||
handleLocation() {
|
||||
if (!this.activityData || !this.activityData.address) {
|
||||
uni.showToast({
|
||||
title: "暂无地址信息",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果有经纬度信息,打开地图
|
||||
if (this.activityData.lon && this.activityData.lat) {
|
||||
uni.openLocation({
|
||||
latitude: this.activityData.lat,
|
||||
longitude: this.activityData.lon,
|
||||
name: this.activityData.title,
|
||||
address: this.activityData.address,
|
||||
fail: (err) => {
|
||||
console.error("打开地图失败:", err);
|
||||
// 如果打开地图失败,显示地址信息
|
||||
this.showAddressInfo();
|
||||
},
|
||||
});
|
||||
} else {
|
||||
// 没有经纬度信息,显示地址详情
|
||||
this.showAddressInfo();
|
||||
}
|
||||
},
|
||||
|
||||
// 显示地址信息
|
||||
showAddressInfo() {
|
||||
uni.showModal({
|
||||
title: "活动地址",
|
||||
content: this.activityData.address,
|
||||
showCancel: false,
|
||||
confirmText: "知道了",
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background: #faf8f3;
|
||||
}
|
||||
page {
|
||||
background: #faf8f3;
|
||||
}
|
||||
|
||||
.header {
|
||||
width: 100%;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
padding: 0 15rpx;
|
||||
padding-bottom: 200rpx; /* 为固定底部按钮留出空间 */
|
||||
}
|
||||
.header {
|
||||
width: 100%;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
padding: 0 15rpx;
|
||||
padding-bottom: 200rpx; /* 为固定底部按钮留出空间 */
|
||||
}
|
||||
|
||||
.activity-detail {
|
||||
width: 100%;
|
||||
}
|
||||
.activity-detail {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.activity-header {
|
||||
width: 100%;
|
||||
padding: 30rpx 0 20rpx 24rpx;
|
||||
.activity-header {
|
||||
width: 100%;
|
||||
padding: 30rpx 0 20rpx 24rpx;
|
||||
|
||||
.title-section {
|
||||
.main-title {
|
||||
font-size: 44rpx;
|
||||
font-weight: 500;
|
||||
color: #3d3d3d;
|
||||
line-height: 60rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.meta-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 30rpx;
|
||||
|
||||
.date {
|
||||
font-weight: 400;
|
||||
font-size: 24rpx;
|
||||
color: #808080;
|
||||
}
|
||||
|
||||
.read-count {
|
||||
font-weight: 400;
|
||||
font-size: 24rpx;
|
||||
color: #808080;
|
||||
}
|
||||
}
|
||||
.title-section {
|
||||
.main-title {
|
||||
font-size: 44rpx;
|
||||
font-weight: 500;
|
||||
color: #3d3d3d;
|
||||
line-height: 60rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.participation-stats {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
border-radius: 16rpx;
|
||||
padding: 30rpx;
|
||||
margin-bottom: 30rpx;
|
||||
|
||||
.stat-item {
|
||||
.meta-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 0;
|
||||
gap: 30rpx;
|
||||
|
||||
&:last-child {
|
||||
margin-left: 50rpx;
|
||||
.date {
|
||||
font-weight: 400;
|
||||
font-size: 24rpx;
|
||||
color: #808080;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 30rpx;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 30rpx;
|
||||
color: #e74c3c;
|
||||
font-weight: bold;
|
||||
.read-count {
|
||||
font-weight: 400;
|
||||
font-size: 24rpx;
|
||||
color: #808080;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.activity-description {
|
||||
width: 100%;
|
||||
border-radius: 16rpx;
|
||||
padding: 30rpx;
|
||||
margin-bottom: 30rpx;
|
||||
.participation-stats {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
border-radius: 16rpx;
|
||||
padding: 30rpx;
|
||||
margin-bottom: 30rpx;
|
||||
|
||||
.description-title {
|
||||
margin-bottom: 20rpx;
|
||||
|
||||
.title-text {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
|
||||
.description-content {
|
||||
.content-html {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
line-height: 1.6;
|
||||
text-align: justify;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.bottom-actions {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
.stat-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
height: 62px;
|
||||
padding: 30rpx 40rpx;
|
||||
background: #fff;
|
||||
border-top: 1rpx solid #f0f0f0;
|
||||
border-radius: 20rpx 20rpx 0 0;
|
||||
margin-bottom: 12rpx;
|
||||
margin-bottom: 0;
|
||||
|
||||
.action-button {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 12rpx;
|
||||
&:last-child {
|
||||
margin-left: 50rpx;
|
||||
}
|
||||
|
||||
&.phone-button,
|
||||
&.location-button {
|
||||
flex: 1;
|
||||
min-height: 120rpx;
|
||||
background: transparent;
|
||||
.stat-label {
|
||||
font-size: 30rpx;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.button-icon {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
margin-bottom: 12rpx;
|
||||
filter: brightness(0) saturate(100%) invert(27%) sepia(51%) saturate(2878%)
|
||||
hue-rotate(346deg) brightness(104%) contrast(97%);
|
||||
}
|
||||
.stat-value {
|
||||
font-size: 30rpx;
|
||||
color: #e74c3c;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.button-text {
|
||||
font-size: 26rpx;
|
||||
color: #522510;
|
||||
font-weight: 400;
|
||||
}
|
||||
.activity-description {
|
||||
width: 100%;
|
||||
border-radius: 16rpx;
|
||||
padding: 30rpx;
|
||||
margin-bottom: 30rpx;
|
||||
|
||||
.description-title {
|
||||
margin-bottom: 20rpx;
|
||||
|
||||
.title-text {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
|
||||
.description-content {
|
||||
.content-html {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
line-height: 1.6;
|
||||
text-align: justify;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.bottom-actions {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
height: 62px;
|
||||
padding: 30rpx 40rpx;
|
||||
background: #fff;
|
||||
border-top: 1rpx solid #f0f0f0;
|
||||
border-radius: 20rpx 20rpx 0 0;
|
||||
margin-bottom: 12rpx;
|
||||
|
||||
.action-button {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 12rpx;
|
||||
|
||||
&.phone-button,
|
||||
&.location-button {
|
||||
flex: 1;
|
||||
min-height: 120rpx;
|
||||
background: transparent;
|
||||
|
||||
.button-icon {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
margin-bottom: 12rpx;
|
||||
filter: brightness(0) saturate(100%) invert(27%) sepia(51%)
|
||||
saturate(2878%) hue-rotate(346deg) brightness(104%) contrast(97%);
|
||||
}
|
||||
|
||||
&.register-button {
|
||||
flex: 4;
|
||||
background: #a24242;
|
||||
border-radius: 60rpx;
|
||||
padding: 0 40rpx;
|
||||
width: 227px;
|
||||
height: 38px;
|
||||
.button-text {
|
||||
font-size: 26rpx;
|
||||
color: #522510;
|
||||
font-weight: 400;
|
||||
}
|
||||
}
|
||||
|
||||
.button-text {
|
||||
font-size: 32rpx;
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
}
|
||||
&.register-button {
|
||||
flex: 4;
|
||||
background: #a24242;
|
||||
border-radius: 60rpx;
|
||||
padding: 0 40rpx;
|
||||
width: 227px;
|
||||
height: 38px;
|
||||
|
||||
.button-text {
|
||||
font-size: 32rpx;
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ACTIVITY_STATUS, ACTIVITY_TYPE } from '../enum/activity'
|
||||
import { ACTIVITY_STATUS, ACTIVITY_TYPE } from "../enum/activity";
|
||||
|
||||
/**
|
||||
* 活动数据格式化工具
|
||||
|
|
@ -11,10 +11,10 @@ export default {
|
|||
*/
|
||||
formatActivityList(apiData) {
|
||||
if (!Array.isArray(apiData)) {
|
||||
return []
|
||||
return [];
|
||||
}
|
||||
|
||||
return apiData.map(item => this.formatActivityItem(item))
|
||||
return apiData.map((item) => this.formatActivityItem(item));
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -23,16 +23,20 @@ export default {
|
|||
* @returns {Object} 格式化后的活动数据
|
||||
*/
|
||||
formatActivityItem(item) {
|
||||
if (!item) return null
|
||||
if (!item) return null;
|
||||
|
||||
return {
|
||||
id: item.id || '',
|
||||
name: item.title || '未命名活动',
|
||||
theme: item.content ? `活动主题: ${item.content}` : '',
|
||||
id: item.id || "",
|
||||
name: item.title || "未命名活动",
|
||||
theme: item.content ? `活动主题: ${item.content}` : "",
|
||||
type: this.getActivityType(item.type),
|
||||
status: this.getActivityStatus(item.status, item.actStartTime, item.actEndTime),
|
||||
status: this.getActivityStatus(
|
||||
item.status,
|
||||
item.actStartTime,
|
||||
item.actEndTime,
|
||||
),
|
||||
time: this.formatActivityTime(item.actStartTime, item.actEndTime),
|
||||
location: item.address || '',
|
||||
location: item.address || "",
|
||||
backgroundImage: item.imgUrl || this.getDefaultImageByType(item.type),
|
||||
// 额外信息
|
||||
templeId: item.templeId,
|
||||
|
|
@ -42,7 +46,7 @@ export default {
|
|||
phone: item.phone,
|
||||
lon: item.lon,
|
||||
lat: item.lat,
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -51,17 +55,22 @@ export default {
|
|||
* @returns {Object} 格式化后的活动详情数据
|
||||
*/
|
||||
formatActivityDetail(apiData) {
|
||||
if (!apiData) return null
|
||||
if (!apiData) return null;
|
||||
|
||||
return {
|
||||
id: apiData.id || '',
|
||||
name: apiData.title || '未命名活动',
|
||||
id: apiData.id || "",
|
||||
name: apiData.title || "未命名活动",
|
||||
|
||||
type: this.getActivityType(apiData.type),
|
||||
status: this.getActivityStatus(apiData.status, apiData.actStartTime, apiData.actEndTime),
|
||||
status: this.getActivityStatus(
|
||||
apiData.status,
|
||||
apiData.actStartTime,
|
||||
apiData.actEndTime,
|
||||
),
|
||||
time: this.formatActivityTime(apiData.actStartTime, apiData.actEndTime),
|
||||
location: apiData.address || '',
|
||||
backgroundImage: apiData.imgUrl || this.getDefaultImageByType(apiData.type),
|
||||
location: apiData.address || "",
|
||||
backgroundImage:
|
||||
apiData.imgUrl || this.getDefaultImageByType(apiData.type),
|
||||
// 详情页额外信息
|
||||
templeId: apiData.templeId,
|
||||
currentBooking: apiData.currentBooking || 0,
|
||||
|
|
@ -73,7 +82,7 @@ export default {
|
|||
content: apiData.content,
|
||||
createTime: apiData.createTime,
|
||||
updateTime: apiData.updateTime,
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -82,21 +91,21 @@ export default {
|
|||
* @returns {string} 纯文本内容
|
||||
*/
|
||||
extractTextFromHtml(htmlContent) {
|
||||
if (!htmlContent) return ''
|
||||
if (!htmlContent) return "";
|
||||
|
||||
try {
|
||||
// 简单的HTML标签移除
|
||||
return htmlContent
|
||||
.replace(/<[^>]*>/g, '') // 移除HTML标签
|
||||
.replace(/ /g, ' ') // 替换空格实体
|
||||
.replace(/&/g, '&') // 替换&实体
|
||||
.replace(/</g, '<') // 替换<实体
|
||||
.replace(/>/g, '>') // 替换>实体
|
||||
.replace(/<[^>]*>/g, "") // 移除HTML标签
|
||||
.replace(/ /g, " ") // 替换空格实体
|
||||
.replace(/&/g, "&") // 替换&实体
|
||||
.replace(/</g, "<") // 替换<实体
|
||||
.replace(/>/g, ">") // 替换>实体
|
||||
.replace(/"/g, '"') // 替换"实体
|
||||
.trim()
|
||||
.trim();
|
||||
} catch (error) {
|
||||
console.error('提取HTML文本失败:', error)
|
||||
return htmlContent
|
||||
console.error("提取HTML文本失败:", error);
|
||||
return htmlContent;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -106,7 +115,7 @@ export default {
|
|||
* @returns {string} 标准化的活动类型
|
||||
*/
|
||||
getActivityType(type) {
|
||||
if (!type) return ACTIVITY_TYPE.PRAYER
|
||||
if (!type) return ACTIVITY_TYPE.PRAYER;
|
||||
|
||||
const typeMap = {
|
||||
1: ACTIVITY_TYPE.PRAYER, // 祈福活动
|
||||
|
|
@ -114,9 +123,9 @@ export default {
|
|||
3: ACTIVITY_TYPE.MEDITATION, // 禅修活动
|
||||
4: ACTIVITY_TYPE.DONATION, // 捐赠活动
|
||||
5: ACTIVITY_TYPE.VOLUNTEER, // 义工活动
|
||||
}
|
||||
};
|
||||
|
||||
return typeMap[type] || ACTIVITY_TYPE.PRAYER
|
||||
return typeMap[type] || ACTIVITY_TYPE.PRAYER;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -127,22 +136,22 @@ export default {
|
|||
* @returns {string} 标准化的活动状态
|
||||
*/
|
||||
getActivityStatus(status, startTime, endTime) {
|
||||
if (!status || status === '0') {
|
||||
return ACTIVITY_STATUS.FINISHED
|
||||
if (!status || status === "0") {
|
||||
return ACTIVITY_STATUS.FINISHED;
|
||||
}
|
||||
|
||||
// 如果有时间信息,根据时间判断状态
|
||||
if (startTime && endTime) {
|
||||
const now = new Date()
|
||||
const start = this.parseDateForIOS(startTime)
|
||||
const end = this.parseDateForIOS(endTime)
|
||||
const now = new Date();
|
||||
const start = this.parseDateForIOS(startTime);
|
||||
const end = this.parseDateForIOS(endTime);
|
||||
|
||||
if (now < start) {
|
||||
return ACTIVITY_STATUS.REGISTERING
|
||||
return ACTIVITY_STATUS.REGISTERING;
|
||||
} else if (now >= start && now <= end) {
|
||||
return ACTIVITY_STATUS.ONGOING
|
||||
return ACTIVITY_STATUS.ONGOING;
|
||||
} else {
|
||||
return ACTIVITY_STATUS.FINISHED
|
||||
return ACTIVITY_STATUS.FINISHED;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -151,9 +160,9 @@ export default {
|
|||
1: ACTIVITY_STATUS.REGISTERING,
|
||||
2: ACTIVITY_STATUS.ONGOING,
|
||||
3: ACTIVITY_STATUS.FINISHED,
|
||||
}
|
||||
};
|
||||
|
||||
return statusMap[status] || ACTIVITY_STATUS.REGISTERING
|
||||
return statusMap[status] || ACTIVITY_STATUS.REGISTERING;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -162,15 +171,15 @@ export default {
|
|||
* @returns {Date} 解析后的日期对象
|
||||
*/
|
||||
parseDateForIOS(dateString) {
|
||||
if (!dateString) return new Date()
|
||||
if (!dateString) return new Date();
|
||||
|
||||
try {
|
||||
// 将 "yyyy-MM-dd HH:mm:ss" 格式转换为 "yyyy-MM-ddTHH:mm:ss" 格式以兼容iOS
|
||||
const iosCompatibleDate = dateString.replace(' ', 'T')
|
||||
return new Date(iosCompatibleDate)
|
||||
const iosCompatibleDate = dateString.replace(" ", "T");
|
||||
return new Date(iosCompatibleDate);
|
||||
} catch (error) {
|
||||
console.error('解析日期失败:', error)
|
||||
return new Date()
|
||||
console.error("解析日期失败:", error);
|
||||
return new Date();
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -181,38 +190,46 @@ export default {
|
|||
* @returns {string} 格式化后的时间字符串
|
||||
*/
|
||||
formatActivityTime(startTime, endTime) {
|
||||
if (!startTime) return ''
|
||||
if (!startTime) return "";
|
||||
|
||||
try {
|
||||
const start = this.parseDateForIOS(startTime)
|
||||
const end = endTime ? this.parseDateForIOS(endTime) : null
|
||||
const start = this.parseDateForIOS(startTime);
|
||||
const end = endTime ? this.parseDateForIOS(endTime) : null;
|
||||
|
||||
// 格式化日期
|
||||
const formatDate = date => {
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
|
||||
const weekday = weekdays[date.getDay()]
|
||||
const hours = String(date.getHours()).padStart(2, '0')
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0')
|
||||
const formatDate = (date) => {
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, "0");
|
||||
const day = String(date.getDate()).padStart(2, "0");
|
||||
// const weekdays = [
|
||||
// "周日",
|
||||
// "周一",
|
||||
// "周二",
|
||||
// "周三",
|
||||
// "周四",
|
||||
// "周五",
|
||||
// "周六",
|
||||
// ];
|
||||
// const weekday = weekdays[date.getDay()];
|
||||
// const hours = String(date.getHours()).padStart(2, "0");
|
||||
// const minutes = String(date.getMinutes()).padStart(2, "0");
|
||||
//${weekday} ${hours}:${minutes}
|
||||
|
||||
return `${year}年${month}月${day}日 ${weekday} ${hours}:${minutes}`
|
||||
}
|
||||
return `${year}年${month}月${day}日`;
|
||||
};
|
||||
|
||||
let timeStr = formatDate(start)
|
||||
let timeStr = formatDate(start);
|
||||
|
||||
// 如果有结束时间,添加结束时间
|
||||
if (end && end.getTime() !== start.getTime()) {
|
||||
const endHours = String(end.getHours()).padStart(2, '0')
|
||||
const endMinutes = String(end.getMinutes()).padStart(2, '0')
|
||||
timeStr += `~${endHours}:${endMinutes}`
|
||||
timeStr += "至";
|
||||
timeStr += formatDate(end);
|
||||
}
|
||||
|
||||
return timeStr
|
||||
return timeStr;
|
||||
} catch (error) {
|
||||
console.error('格式化时间失败:', error)
|
||||
return startTime
|
||||
console.error("格式化时间失败:", error);
|
||||
return startTime;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -223,14 +240,14 @@ export default {
|
|||
*/
|
||||
getDefaultImageByType(type) {
|
||||
const typeMap = {
|
||||
1: '/static/image/a1.png', // 祈福活动
|
||||
2: '/static/image/a2.png', // 法会活动
|
||||
3: '/static/image/a3.png', // 禅修活动
|
||||
4: '/static/image/a4.png', // 捐赠活动
|
||||
5: '/static/image/a5.png', // 义工活动
|
||||
}
|
||||
1: "/static/image/a1.png", // 祈福活动
|
||||
2: "/static/image/a2.png", // 法会活动
|
||||
3: "/static/image/a3.png", // 禅修活动
|
||||
4: "/static/image/a4.png", // 捐赠活动
|
||||
5: "/static/image/a5.png", // 义工活动
|
||||
};
|
||||
|
||||
return typeMap[type] || '/static/image/a1.png'
|
||||
return typeMap[type] || "/static/image/a1.png";
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -239,6 +256,6 @@ export default {
|
|||
* @returns {boolean} 是否有效
|
||||
*/
|
||||
isValidActivity(activity) {
|
||||
return activity && activity.id && activity.title && activity.status !== '0'
|
||||
return activity && activity.id && activity.title && activity.status !== "0";
|
||||
},
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user