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