本次提交新增了用户反馈页面,在个人中心添加了反馈入口;优化了活动报名结果页、活动详情页、通知页面等多个页面的样式与逻辑,修复了部分交互问题,同时完善了全局登录状态管理与自定义tabbar的未读红点逻辑,升级了部分页面的skyline渲染配置。master
|
Before Width: | Height: | Size: 2.5 MiB After Width: | Height: | Size: 2.5 MiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 132 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.6 KiB |
|
After Width: | Height: | Size: 120 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
@ -0,0 +1,5 @@ |
|||||||
|
{ |
||||||
|
"navigationBarTitleText": "我要反馈", |
||||||
|
"navigationStyle": "default", |
||||||
|
"usingComponents": {} |
||||||
|
} |
||||||
@ -0,0 +1,26 @@ |
|||||||
|
page { |
||||||
|
background-color: rgba(255, 255, 255, 1); |
||||||
|
} |
||||||
|
.page { |
||||||
|
padding: 32rpx 30rpx; |
||||||
|
.tex { |
||||||
|
padding: 26rpx 32rpx 0; |
||||||
|
min-height: 320rpx; |
||||||
|
display: block; |
||||||
|
width: 100%; |
||||||
|
box-sizing: border-box; |
||||||
|
background-color: rgba(247, 248, 250, 1); |
||||||
|
border-radius: 16rpx; |
||||||
|
} |
||||||
|
.btn { |
||||||
|
margin-top: 48rpx; |
||||||
|
font-size: 32rpx; |
||||||
|
color: rgba(255, 255, 255, 1); |
||||||
|
height: 96rpx; |
||||||
|
display: flex; |
||||||
|
align-items: center; |
||||||
|
justify-content: center; |
||||||
|
background: linear-gradient(90deg, #9ddffd 0%, #4ab8fd 100%); |
||||||
|
border-radius: 16rpx 16rpx 16rpx 16rpx; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,8 @@ |
|||||||
|
const _app = getApp<IAppOption>(); |
||||||
|
|
||||||
|
Page({ |
||||||
|
data: {}, |
||||||
|
onLoad() {}, |
||||||
|
}); |
||||||
|
|
||||||
|
export {} |
||||||
@ -0,0 +1,9 @@ |
|||||||
|
<view class="page"> |
||||||
|
<textarea |
||||||
|
class="tex" |
||||||
|
placeholder-class="place-tex" |
||||||
|
placeholder="请描述具体问题,有助于我们更好的服务" |
||||||
|
auto-height="{{true}}" |
||||||
|
></textarea> |
||||||
|
<view class="btn">提交</view> |
||||||
|
</view> |
||||||
@ -1,9 +1,11 @@ |
|||||||
{ |
{ |
||||||
"navigationBarTitleText": "我的活动", |
"navigationBarTitleText": "我的活动", |
||||||
"navigationStyle": "default", |
"navigationStyle": "default", |
||||||
|
"enablePullDownRefresh": true, |
||||||
"usingComponents": { |
"usingComponents": { |
||||||
"van-tab": "@vant/weapp/tab/index", |
"van-tab": "@vant/weapp/tab/index", |
||||||
"van-tabs": "@vant/weapp/tabs/index", |
"van-tabs": "@vant/weapp/tabs/index", |
||||||
"van-icon": "@vant/weapp/icon/index" |
"van-icon": "@vant/weapp/icon/index", |
||||||
|
"pagination": "/components/pagination/index" |
||||||
} |
} |
||||||
} |
} |
||||||
|
|||||||
@ -1,8 +1,232 @@ |
|||||||
const _app = getApp<IAppOption>(); |
const app = getApp<IAppOption>() |
||||||
|
|
||||||
|
interface IActivityItem { |
||||||
|
id: number |
||||||
|
name: string |
||||||
|
mainImages: string[] |
||||||
|
startAt: string |
||||||
|
endAt: string |
||||||
|
status: string |
||||||
|
activityStatus: number |
||||||
|
activityStatusName: string |
||||||
|
checkinType: string |
||||||
|
regCount: number |
||||||
|
checkinCount: number |
||||||
|
isRegistered: boolean |
||||||
|
isChecked: boolean |
||||||
|
isReviewed: boolean |
||||||
|
location?: string |
||||||
|
} |
||||||
|
|
||||||
|
interface IPagination { |
||||||
|
page: number |
||||||
|
pageSize: number |
||||||
|
pages: number |
||||||
|
count: number |
||||||
|
} |
||||||
|
|
||||||
Page({ |
Page({ |
||||||
data: {}, |
data: { |
||||||
onLoad() {}, |
active: 0, |
||||||
}); |
imageUrl: app.globalData.imageUrl, |
||||||
|
Timestamp: app.globalData.Timestamp, |
||||||
|
|
||||||
|
// 我发布的
|
||||||
|
createdList: [] as IActivityItem[], |
||||||
|
createdPagination: { page: 1, pageSize: 10, pages: 0, count: 0 } as IPagination, |
||||||
|
createdLoading: false, |
||||||
|
|
||||||
|
// 我参与的
|
||||||
|
registeredList: [] as IActivityItem[], |
||||||
|
registeredPagination: { page: 1, pageSize: 10, pages: 0, count: 0 } as IPagination, |
||||||
|
registeredLoading: false, |
||||||
|
}, |
||||||
|
|
||||||
|
onLoad() { |
||||||
|
app.waitLogin({ type: 1 }).then(() => { |
||||||
|
this.fetchCreatedList() |
||||||
|
}) |
||||||
|
}, |
||||||
|
|
||||||
|
// 切换 tab
|
||||||
|
onChange(e: WechatMiniprogram.CustomEvent) { |
||||||
|
const active = e.detail.name || e.detail.index |
||||||
|
this.setData({ active }) |
||||||
|
|
||||||
|
if (active === 0 && this.data.createdList.length === 0) { |
||||||
|
this.fetchCreatedList() |
||||||
|
} else if (active === 1 && this.data.registeredList.length === 0) { |
||||||
|
this.fetchRegisteredList() |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
// 获取我发布的活动
|
||||||
|
async fetchCreatedList(isRefresh = false) { |
||||||
|
if (this.data.createdLoading) return |
||||||
|
|
||||||
|
const { createdPagination } = this.data |
||||||
|
const page = isRefresh ? 1 : createdPagination.page |
||||||
|
|
||||||
|
this.setData({ createdLoading: true }) |
||||||
|
|
||||||
|
try { |
||||||
|
const res = await wx.ajax({ |
||||||
|
url: '/me/my-activities', |
||||||
|
method: 'GET', |
||||||
|
data: { type: 'created', page, pageSize: createdPagination.pageSize }, |
||||||
|
}) |
||||||
|
|
||||||
|
if (res) { |
||||||
|
const newList = isRefresh ? res.list : [...this.data.createdList, ...res.list] |
||||||
|
this.setData({ |
||||||
|
createdList: newList, |
||||||
|
createdPagination: { |
||||||
|
page: res.pagination?.page || page, |
||||||
|
pageSize: res.pagination?.pageSize || createdPagination.pageSize, |
||||||
|
pages: res.pagination?.totalPages || 0, |
||||||
|
count: res.pagination?.total || 0, |
||||||
|
}, |
||||||
|
}) |
||||||
|
} |
||||||
|
} catch (err) { |
||||||
|
console.error('获取我发布的活动失败:', err) |
||||||
|
} finally { |
||||||
|
this.setData({ createdLoading: false }) |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
// 获取我参与的活动
|
||||||
|
async fetchRegisteredList(isRefresh = false) { |
||||||
|
if (this.data.registeredLoading) return |
||||||
|
|
||||||
|
const { registeredPagination } = this.data |
||||||
|
const page = isRefresh ? 1 : registeredPagination.page |
||||||
|
|
||||||
|
this.setData({ registeredLoading: true }) |
||||||
|
|
||||||
|
try { |
||||||
|
const res = await wx.ajax({ |
||||||
|
url: '/me/my-activities', |
||||||
|
method: 'GET', |
||||||
|
data: { type: 'registered', page, pageSize: registeredPagination.pageSize }, |
||||||
|
}) |
||||||
|
|
||||||
|
if (res) { |
||||||
|
const newList = isRefresh ? res.list : [...this.data.registeredList, ...res.list] |
||||||
|
this.setData({ |
||||||
|
registeredList: newList, |
||||||
|
registeredPagination: { |
||||||
|
page: res.pagination?.page || page, |
||||||
|
pageSize: res.pagination?.pageSize || registeredPagination.pageSize, |
||||||
|
pages: res.pagination?.totalPages || 0, |
||||||
|
count: res.pagination?.total || 0, |
||||||
|
}, |
||||||
|
}) |
||||||
|
} |
||||||
|
} catch (err) { |
||||||
|
console.error('获取我参与的活动失败:', err) |
||||||
|
} finally { |
||||||
|
this.setData({ registeredLoading: false }) |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
// 删除活动
|
||||||
|
async handleDelete(e: WechatMiniprogram.TouchEvent) { |
||||||
|
const { id } = e.currentTarget.dataset |
||||||
|
|
||||||
|
wx.showModal({ |
||||||
|
title: '提示', |
||||||
|
content: '确定要删除该活动吗?', |
||||||
|
success: async (res) => { |
||||||
|
if (res.confirm) { |
||||||
|
try { |
||||||
|
await wx.ajax({ |
||||||
|
url: `/activity/delete?id=${id}`, |
||||||
|
method: 'POST', |
||||||
|
}) |
||||||
|
wx.showToast({ title: '删除成功', icon: 'success' }) |
||||||
|
this.fetchCreatedList(true) |
||||||
|
} catch (err: any) { |
||||||
|
wx.showToast({ title: err?.message || '删除失败', icon: 'error' }) |
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
|
}) |
||||||
|
}, |
||||||
|
|
||||||
|
// 编辑活动
|
||||||
|
handleEdit(e: WechatMiniprogram.TouchEvent) { |
||||||
|
const { id } = e.currentTarget.dataset |
||||||
|
wx.navigateTo({ url: `/pages/actEdit/index?id=${id}` }) |
||||||
|
}, |
||||||
|
|
||||||
|
// 查看详情
|
||||||
|
handleDetail(e: WechatMiniprogram.TouchEvent) { |
||||||
|
const { id } = e.currentTarget.dataset |
||||||
|
wx.navigateTo({ url: `/pages/actDetail/index?id=${id}` }) |
||||||
|
}, |
||||||
|
|
||||||
|
// 取消活动
|
||||||
|
async handleCancel(e: WechatMiniprogram.TouchEvent) { |
||||||
|
const { id } = e.currentTarget.dataset |
||||||
|
|
||||||
|
wx.showModal({ |
||||||
|
title: '提示', |
||||||
|
content: '确定要取消该活动吗?取消后已报名用户将收到通知。', |
||||||
|
success: async (res) => { |
||||||
|
if (res.confirm) { |
||||||
|
try { |
||||||
|
await wx.ajax({ |
||||||
|
url: `/activity/cancel?id=${id}`, |
||||||
|
method: 'POST', |
||||||
|
}) |
||||||
|
wx.showToast({ title: '取消成功', icon: 'success' }) |
||||||
|
this.fetchCreatedList(true) |
||||||
|
} catch (err: any) { |
||||||
|
wx.showToast({ title: err?.message || '取消失败', icon: 'error' }) |
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
|
}) |
||||||
|
}, |
||||||
|
|
||||||
|
// 签到二维码
|
||||||
|
handleQrcode(e: WechatMiniprogram.TouchEvent) { |
||||||
|
const { id } = e.currentTarget.dataset |
||||||
|
wx.navigateTo({ url: `/pages/actQrcode/index?id=${id}` }) |
||||||
|
}, |
||||||
|
|
||||||
|
// 下拉刷新
|
||||||
|
onPullDownRefresh() { |
||||||
|
const { active } = this.data |
||||||
|
if (active === 0) { |
||||||
|
this.fetchCreatedList(true) |
||||||
|
} else { |
||||||
|
this.fetchRegisteredList(true) |
||||||
|
} |
||||||
|
wx.stopPullDownRefresh() |
||||||
|
}, |
||||||
|
|
||||||
|
// 上拉加载更多
|
||||||
|
onReachBottom() { |
||||||
|
const { active, createdPagination, registeredPagination } = this.data |
||||||
|
|
||||||
|
if (active === 0) { |
||||||
|
if (createdPagination.page < createdPagination.pages) { |
||||||
|
this.setData({ |
||||||
|
createdPagination: { ...createdPagination, page: createdPagination.page + 1 }, |
||||||
|
}) |
||||||
|
this.fetchCreatedList() |
||||||
|
} |
||||||
|
} else { |
||||||
|
if (registeredPagination.page < registeredPagination.pages) { |
||||||
|
this.setData({ |
||||||
|
registeredPagination: { ...registeredPagination, page: registeredPagination.page + 1 }, |
||||||
|
}) |
||||||
|
this.fetchRegisteredList() |
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
|
}) |
||||||
|
|
||||||
export {} |
export {} |
||||||
|
|||||||
@ -1,9 +1,12 @@ |
|||||||
{ |
{ |
||||||
"navigationBarTitleText": "通知", |
"navigationBarTitleText": "通知", |
||||||
"navigationStyle": "default", |
"navigationStyle": "default", |
||||||
|
"enablePullDownRefresh": true, |
||||||
"usingComponents": { |
"usingComponents": { |
||||||
"van-tab": "@vant/weapp/tab/index", |
"van-tab": "@vant/weapp/tab/index", |
||||||
"van-tabs": "@vant/weapp/tabs/index", |
"van-tabs": "@vant/weapp/tabs/index", |
||||||
"van-icon": "@vant/weapp/icon/index" |
"van-icon": "@vant/weapp/icon/index", |
||||||
|
"pagination": "/components/pagination/index", |
||||||
|
"mp-html": "mp-html" |
||||||
} |
} |
||||||
} |
} |
||||||
|
|||||||
@ -1,15 +1,225 @@ |
|||||||
const _app = getApp<IAppOption>() |
const app = getApp<IAppOption>() |
||||||
|
|
||||||
|
// 公告列表项
|
||||||
|
interface IAnnouncementItem { |
||||||
|
id: number |
||||||
|
title: string |
||||||
|
content: string |
||||||
|
displayPosition: number |
||||||
|
priority: number |
||||||
|
redDot: boolean |
||||||
|
jumpType: number |
||||||
|
jumpTarget: string |
||||||
|
buttonText: string |
||||||
|
startAt: string |
||||||
|
endAt: string |
||||||
|
createdAt: string |
||||||
|
isRead: boolean |
||||||
|
} |
||||||
|
|
||||||
|
// 通知列表项
|
||||||
|
interface INoticeItem { |
||||||
|
id: number |
||||||
|
taskId: number |
||||||
|
title: string |
||||||
|
subtitle: string |
||||||
|
subType: string |
||||||
|
subTypeName: string |
||||||
|
coverImage: string |
||||||
|
jumpType: number |
||||||
|
jumpTarget: string |
||||||
|
buttonText: string |
||||||
|
isRead: boolean |
||||||
|
scheduleAt: string |
||||||
|
} |
||||||
|
|
||||||
|
interface IPagination { |
||||||
|
page: number |
||||||
|
pageSize: number |
||||||
|
pages: number |
||||||
|
count: number |
||||||
|
} |
||||||
|
|
||||||
Page({ |
Page({ |
||||||
data: { |
data: { |
||||||
active: 2, |
active: 0, |
||||||
|
imageUrl: app.globalData.imageUrl, |
||||||
|
Timestamp: app.globalData.Timestamp, |
||||||
|
|
||||||
|
// 公告
|
||||||
|
announcementList: [] as IAnnouncementItem[], |
||||||
|
announcementPagination: { page: 1, pageSize: 20, pages: 0, count: 0 } as IPagination, |
||||||
|
announcementLoading: false, |
||||||
|
|
||||||
|
// 重要通知
|
||||||
|
importantList: [] as INoticeItem[], |
||||||
|
importantPagination: { page: 1, pageSize: 20, pages: 0, count: 0 } as IPagination, |
||||||
|
importantLoading: false, |
||||||
|
|
||||||
|
// 活动通知
|
||||||
|
activityList: [] as INoticeItem[], |
||||||
|
activityPagination: { page: 1, pageSize: 20, pages: 0, count: 0 } as IPagination, |
||||||
|
activityLoading: false, |
||||||
}, |
}, |
||||||
onLoad() {}, |
|
||||||
handleDetail() { |
onLoad() { |
||||||
|
app.waitLogin({ type: 1 }).then(() => { |
||||||
|
this.fetchAnnouncementList() |
||||||
|
}) |
||||||
|
}, |
||||||
|
|
||||||
|
onShow() { |
||||||
|
// 刷新 tabbar 红点
|
||||||
|
const tabBar = this.getTabBar() |
||||||
|
if (tabBar && typeof tabBar.fetchUnreadCount === 'function') { |
||||||
|
tabBar.fetchUnreadCount() |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
// 切换 tab
|
||||||
|
onChange(e: WechatMiniprogram.CustomEvent) { |
||||||
|
const active = e.detail.index ?? 0 |
||||||
|
this.setData({ active }) |
||||||
|
|
||||||
|
if (active === 0 && this.data.announcementList.length === 0) { |
||||||
|
this.fetchAnnouncementList() |
||||||
|
} else if (active === 1 && this.data.importantList.length === 0) { |
||||||
|
this.fetchNoticeList('important') |
||||||
|
} else if (active === 2 && this.data.activityList.length === 0) { |
||||||
|
this.fetchNoticeList('activity') |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
// 获取公告列表(专用接口)
|
||||||
|
async fetchAnnouncementList(isRefresh = false) { |
||||||
|
if (this.data.announcementLoading) return |
||||||
|
|
||||||
|
const { announcementPagination } = this.data |
||||||
|
const page = isRefresh ? 1 : announcementPagination.page |
||||||
|
|
||||||
|
this.setData({ announcementLoading: true }) |
||||||
|
|
||||||
|
try { |
||||||
|
const res = await wx.ajax({ |
||||||
|
url: '/notification/announcement-list', |
||||||
|
method: 'GET', |
||||||
|
data: { page, pageSize: announcementPagination.pageSize }, |
||||||
|
}) |
||||||
|
|
||||||
|
if (res) { |
||||||
|
const newList = isRefresh ? res.list : [...this.data.announcementList, ...res.list] |
||||||
|
this.setData({ |
||||||
|
announcementList: newList, |
||||||
|
announcementPagination: { |
||||||
|
page: res.pagination?.page || page, |
||||||
|
pageSize: res.pagination?.pageSize || announcementPagination.pageSize, |
||||||
|
pages: res.pagination?.totalPages || 0, |
||||||
|
count: res.pagination?.total || 0, |
||||||
|
}, |
||||||
|
}) |
||||||
|
} |
||||||
|
} catch (err) { |
||||||
|
console.error('获取公告列表失败:', err) |
||||||
|
} finally { |
||||||
|
this.setData({ announcementLoading: false }) |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
// 获取通知列表(重要通知/活动通知)
|
||||||
|
async fetchNoticeList(type: 'important' | 'activity', isRefresh = false) { |
||||||
|
const loadingKey = `${type}Loading` as const |
||||||
|
const listKey = `${type}List` as const |
||||||
|
const paginationKey = `${type}Pagination` as const |
||||||
|
|
||||||
|
if (this.data[loadingKey]) return |
||||||
|
|
||||||
|
const pagination = this.data[paginationKey] |
||||||
|
const page = isRefresh ? 1 : pagination.page |
||||||
|
|
||||||
|
this.setData({ [loadingKey]: true } as any) |
||||||
|
|
||||||
|
try { |
||||||
|
const res = await wx.ajax({ |
||||||
|
url: '/notification/list', |
||||||
|
method: 'GET', |
||||||
|
data: { type, page, pageSize: pagination.pageSize }, |
||||||
|
}) |
||||||
|
|
||||||
|
if (res) { |
||||||
|
const newList = isRefresh ? res.list : [...this.data[listKey], ...res.list] |
||||||
|
this.setData({ |
||||||
|
[listKey]: newList, |
||||||
|
[paginationKey]: { |
||||||
|
page: res.pagination?.page || page, |
||||||
|
pageSize: res.pagination?.pageSize || pagination.pageSize, |
||||||
|
pages: res.pagination?.totalPages || 0, |
||||||
|
count: res.pagination?.total || 0, |
||||||
|
}, |
||||||
|
} as any) |
||||||
|
} |
||||||
|
} catch (err) { |
||||||
|
console.error('获取通知列表失败:', err) |
||||||
|
} finally { |
||||||
|
this.setData({ [loadingKey]: false } as any) |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
// 查看公告详情
|
||||||
|
handleAnnouncementDetail(e: WechatMiniprogram.TouchEvent) { |
||||||
|
const { id } = e.currentTarget.dataset |
||||||
wx.navigateTo({ |
wx.navigateTo({ |
||||||
url: '/pages/noticeDetail/index', |
url: `/pages/noticeDetail/index?id=${id}&type=announcement`, |
||||||
}) |
}) |
||||||
}, |
}, |
||||||
|
|
||||||
|
// 查看通知详情
|
||||||
|
handleNoticeDetail(e: WechatMiniprogram.TouchEvent) { |
||||||
|
const { taskId } = e.currentTarget.dataset |
||||||
|
wx.navigateTo({ |
||||||
|
url: `/pages/noticeDetail/index?taskId=${taskId}&type=notice`, |
||||||
|
}) |
||||||
|
}, |
||||||
|
|
||||||
|
// 下拉刷新
|
||||||
|
onPullDownRefresh() { |
||||||
|
const { active } = this.data |
||||||
|
if (active === 0) { |
||||||
|
this.fetchAnnouncementList(true) |
||||||
|
} else if (active === 1) { |
||||||
|
this.fetchNoticeList('important', true) |
||||||
|
} else if (active === 2) { |
||||||
|
this.fetchNoticeList('activity', true) |
||||||
|
} |
||||||
|
wx.stopPullDownRefresh() |
||||||
|
}, |
||||||
|
|
||||||
|
// 上拉加载更多
|
||||||
|
onReachBottom() { |
||||||
|
const { active, announcementPagination, importantPagination, activityPagination } = this.data |
||||||
|
|
||||||
|
if (active === 0) { |
||||||
|
if (announcementPagination.page < announcementPagination.pages) { |
||||||
|
this.setData({ |
||||||
|
announcementPagination: { ...announcementPagination, page: announcementPagination.page + 1 }, |
||||||
|
}) |
||||||
|
this.fetchAnnouncementList() |
||||||
|
} |
||||||
|
} else if (active === 1) { |
||||||
|
if (importantPagination.page < importantPagination.pages) { |
||||||
|
this.setData({ |
||||||
|
importantPagination: { ...importantPagination, page: importantPagination.page + 1 }, |
||||||
|
}) |
||||||
|
this.fetchNoticeList('important') |
||||||
|
} |
||||||
|
} else if (active === 2) { |
||||||
|
if (activityPagination.page < activityPagination.pages) { |
||||||
|
this.setData({ |
||||||
|
activityPagination: { ...activityPagination, page: activityPagination.page + 1 }, |
||||||
|
}) |
||||||
|
this.fetchNoticeList('activity') |
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
}) |
}) |
||||||
|
|
||||||
export {} |
export {} |
||||||
@ -1,8 +1,119 @@ |
|||||||
const _app = getApp<IAppOption>(); |
const app = getApp<IAppOption>() |
||||||
|
|
||||||
|
// 分类名称映射
|
||||||
|
const categoryNameMap: Record<string, string> = { |
||||||
|
announcement: '公告', |
||||||
|
important: '重要通知', |
||||||
|
activity: '活动通知', |
||||||
|
agent: '智能体通知', |
||||||
|
} |
||||||
|
|
||||||
Page({ |
Page({ |
||||||
data: {}, |
data: { |
||||||
onLoad() {}, |
imageUrl: app.globalData.imageUrl, |
||||||
}); |
Timestamp: app.globalData.Timestamp, |
||||||
|
type: '', // announcement | notice
|
||||||
|
id: 0, |
||||||
|
taskId: 0, |
||||||
|
detail: null as any, |
||||||
|
categoryName: '', |
||||||
|
}, |
||||||
|
|
||||||
|
onLoad(options: { id?: string, taskId?: string, type?: string }) { |
||||||
|
const type = options.type || 'notice' |
||||||
|
const id = Number(options.id || 0) |
||||||
|
const taskId = Number(options.taskId || 0) |
||||||
|
|
||||||
|
if (type === 'announcement' && !id) { |
||||||
|
wx.showToast({ title: '参数错误', icon: 'error' }) |
||||||
|
setTimeout(() => wx.navigateBack(), 1500) |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
if (type === 'notice' && !taskId) { |
||||||
|
wx.showToast({ title: '参数错误', icon: 'error' }) |
||||||
|
setTimeout(() => wx.navigateBack(), 1500) |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
this.setData({ type, id, taskId }) |
||||||
|
|
||||||
|
app.waitLogin({ type: 1 }).then(() => { |
||||||
|
if (type === 'announcement') { |
||||||
|
this.fetchAnnouncementDetail() |
||||||
|
} else { |
||||||
|
this.fetchNoticeDetail() |
||||||
|
} |
||||||
|
}) |
||||||
|
}, |
||||||
|
|
||||||
|
// 获取公告详情(专用接口)
|
||||||
|
async fetchAnnouncementDetail() { |
||||||
|
try { |
||||||
|
const res = await wx.ajax({ |
||||||
|
url: '/notification/announcement-detail', |
||||||
|
method: 'GET', |
||||||
|
data: { id: this.data.id }, |
||||||
|
}) |
||||||
|
|
||||||
|
if (res) { |
||||||
|
this.setData({ |
||||||
|
detail: res, |
||||||
|
categoryName: '公告', |
||||||
|
}) |
||||||
|
} |
||||||
|
} catch (err) { |
||||||
|
console.error('获取公告详情失败:', err) |
||||||
|
wx.showToast({ title: '获取详情失败', icon: 'error' }) |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
// 获取通知详情
|
||||||
|
async fetchNoticeDetail() { |
||||||
|
try { |
||||||
|
const res = await wx.ajax({ |
||||||
|
url: '/notification/detail', |
||||||
|
method: 'GET', |
||||||
|
data: { taskId: this.data.taskId }, |
||||||
|
}) |
||||||
|
|
||||||
|
if (res) { |
||||||
|
this.setData({ |
||||||
|
detail: res, |
||||||
|
categoryName: categoryNameMap[res.category] || '通知', |
||||||
|
}) |
||||||
|
} |
||||||
|
} catch (err) { |
||||||
|
console.error('获取通知详情失败:', err) |
||||||
|
wx.showToast({ title: '获取详情失败', icon: 'error' }) |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
// 跳转
|
||||||
|
handleJump() { |
||||||
|
const { detail } = this.data |
||||||
|
if (!detail || detail.jumpType === 0) return |
||||||
|
|
||||||
|
if (detail.jumpType === 1) { |
||||||
|
// 不跳转
|
||||||
|
|
||||||
|
} else if (detail.jumpType === 2) { |
||||||
|
// 跳转活动
|
||||||
|
wx.navigateTo({ url: `/pages/actDetail/index?id=${detail.jumpTarget}` }) |
||||||
|
} else if (detail.jumpType === 3) { |
||||||
|
// 跳转小程序页面
|
||||||
|
wx.navigateTo({ url: detail.jumpTarget }) |
||||||
|
} else if (detail.jumpType === 4) { |
||||||
|
// 跳转H5链接
|
||||||
|
wx.navigateTo({ |
||||||
|
url: `/pages/webview/index?url=${encodeURIComponent(detail.jumpTarget)}`, |
||||||
|
}) |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
handleBack() { |
||||||
|
wx.navigateBack() |
||||||
|
}, |
||||||
|
}) |
||||||
|
|
||||||
export {} |
export {} |
||||||
@ -1,38 +1,23 @@ |
|||||||
<view class="page"> |
<view class="page" wx:if="{{detail}}"> |
||||||
<view class="info"> |
<view class="info"> |
||||||
<view class="row"> |
<view class="row"> |
||||||
<view class="type"> |
<view class="type"> |
||||||
<image class="icon" src="{{imageUrl}}icon23.png?t={{Timestamp}}"></image> |
<image class="icon" src="{{imageUrl}}icon23.png?t={{Timestamp}}"></image> |
||||||
<view class="content">通知</view> |
<view class="content">{{categoryName}}</view> |
||||||
</view> |
</view> |
||||||
<view class="status status1">已发布</view> |
|
||||||
</view> |
|
||||||
<view class="title">关于开展校园歌手大赛的通知</view> |
|
||||||
<view class="tag-wrap"> |
|
||||||
<view class="tag tag1">校园活动</view> |
|
||||||
</view> |
</view> |
||||||
|
<view class="title">{{detail.title}}</view> |
||||||
<view class="stat"> |
<view class="stat"> |
||||||
<view class="date"> |
<view class="date"> |
||||||
<image class="icon" src="{{imageUrl}}icon24.png?t={{Timestamp}}"></image> |
<image class="icon" src="{{imageUrl}}icon24.png?t={{Timestamp}}"></image> |
||||||
<view class="content">2026-05-20 14:30:00</view> |
<view class="content">{{type === 'announcement' ? detail.createdAt : detail.scheduleAt}}</view> |
||||||
</view> |
|
||||||
<view class="user"> |
|
||||||
<image class="icon" src="{{imageUrl}}icon25.png?t={{Timestamp}}"></image> |
|
||||||
<view class="content">浏览人数:128</view> |
|
||||||
</view> |
</view> |
||||||
</view> |
</view> |
||||||
</view> |
</view> |
||||||
<view class="mp-html"> |
<view class="mp-html"> |
||||||
<mp-html content="{{content}}"></mp-html> |
<mp-html content="{{type === 'announcement' ? detail.content : detail.richContent}}"></mp-html> |
||||||
</view> |
|
||||||
<view class="tip"> |
|
||||||
<image class="icon" src="{{imageUrl}}icon26.png?t={{Timestamp}}"></image> |
|
||||||
<view class="wrap"> |
|
||||||
<view class="w-title">温馨提示</view> |
|
||||||
<view class="w-content">未尽事宜,请联系校团委文艺部,联系电话:0755-12345678。</view> |
|
||||||
</view> |
|
||||||
</view> |
</view> |
||||||
<view class="footer"> |
<view class="footer" wx:if="{{detail.jumpType !== 1 && detail.buttonText}}"> |
||||||
<view class="btn">查看活动详情</view> |
<view class="btn" bind:tap="handleJump">{{detail.buttonText}}</view> |
||||||
</view> |
</view> |
||||||
</view> |
</view> |
||||||