123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- noticeDetail: {}
- },
- onLoad: function (options) {
- const app = getApp();
- debugger
- if (options.noticeData) {
- const parsedNotice = JSON.parse(decodeURIComponent(options.noticeData));
- // 确保数据格式正确,映射字段到正确的显示名称
- const processedNotice = {
- ...parsedNotice,
- title: parsedNotice.title || parsedNotice.noticetitle || '',
- content: parsedNotice.roption || parsedNotice.noticecontent || ''
- };
-
- // 替换可能存在的占位符
- // if (processedNotice.content) {
- // const userInfo = app.globalData.userInfo || {};
- // processedNotice.content = processedNotice.content
- // .replace(/\[用户姓名\]/g, userInfo.name || '用户');
- // }
-
- this.setData({
- noticeDetail: processedNotice
- });
- return;
- }
-
- // 如果只传入了id,则从全局notices中获取
- if (options.id) {
- const noticeDetail = app.globalData.notices.find(notice => notice.id === options.id);
- const processedNotice = {
- ...noticeDetail,
- title: noticeDetail.title || noticeDetail.noticetitle || '',
- content: noticeDetail.roption || noticeDetail.noticecontent || ''
- };
- this.setData({
- noticeDetail: processedNotice
- });
- }
- },
- /**
- * 返回上一页
- */
- goBack: function() {
- wx.navigateBack();
- },
- })
|