qingcheng-xiaochengxu/pages/projectModule/projectNotice/projectNotice.js

53 lines
1.2 KiB
JavaScript
Raw Normal View History

2025-05-19 01:17:46 +00:00
const { baseUrl } = require('../../../request');
Page({
data: {
title: '',
createTime: '',
content: '',
id: null
},
onLoad(options) {
// 1. 获取跳转传来的 id
const id = options.id;
this.setData({ id });
// 2. 拉取通知详情
this.fetchNotificationDetail(id);
},
fetchNotificationDetail(id) {
const token = wx.getStorageSync('token');
wx.request({
url: baseUrl + '/projectNotification/mini/query/id', // 用你的实际接口
method: 'POST',
header: {
Authorization: token
},
data: { id },
success: (res) => {
if (res.data.code === 1) {
const detail = res.data.data || {};
this.setData({
title: detail.notificationTitle || '',
createTime: detail.createTime || '',
content: detail.notificationContent || ''
});
} else {
wx.showToast({
title: res.data.message || '获取通知失败',
icon: 'none'
});
}
},
fail: () => {
wx.showToast({
title: '网络错误',
icon: 'none'
});
}
});
}
});