From 068be2757aa2d51e3f6604dae54287683160ad0e Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期一, 19 一月 2026 17:29:48 +0800
Subject: [PATCH] 2026.1.19
---
pages/mNotice/notice/notice.js | 153 +++++++++++++++++++++++++++++++++++---------------
1 files changed, 107 insertions(+), 46 deletions(-)
diff --git a/pages/mNotice/notice/notice.js b/pages/mNotice/notice/notice.js
index 32cc542..2d66107 100644
--- a/pages/mNotice/notice/notice.js
+++ b/pages/mNotice/notice/notice.js
@@ -1,42 +1,47 @@
// pages/notice/notice.js
-const notificationservice = require("../../../service/notificationservice")
-const moment = require('../../../utils/moment.min')
-const util = require("../../../utils/util.js")
-const app = getApp()
+const notificationservice = require('../../../service/notificationservice');
+const moment = require('../../../utils/moment.min');
+const util = require('../../../utils/util.js');
+const app = getApp();
Page({
-
/**
* 椤甸潰鐨勫垵濮嬫暟鎹�
*/
data: {
currentTab: 0,
- tabList: [{
- "name": "宸ヤ綔閫氱煡"
+ tabList: [
+ {
+ name: '宸ヤ綔閫氱煡',
},
{
- "name": "棰勮璀︾ず"
+ name: '椋庨櫓棰勮',
},
{
- "name": "绯荤粺閫氱煡"
- }
+ name: '绯荤粺閫氱煡',
+ },
],
- pageList: [
- [],
- [],
- []
- ]
+ unReadList: [0, 0, 0],
+ pageList: [[], [], []],
+
+ showNoticeDetail: false,
+ showTitle: '',
+ showContent: '',
+ confirmBtn: { content: '鐭ラ亾浜�', variant: 'base' },
},
//璁$畻swiper楂樺害鏂规硶锛堝湪鍒囨崲鐨勬椂鍊欒皟鐢級
tabsHeight(element) {
let that = this;
let query = wx.createSelectorQuery(); //蹇呴』瑕佸厛鍒涘缓涓�涓煡璇�
- query.select(element).boundingClientRect(function (rect) {
- that.setData({
- pageheight: rect.height + 'px'
- });
- }).exec();
+ query
+ .select(element)
+ .boundingClientRect(function (rect) {
+ that.setData({
+ pageheight: rect.height + 'px',
+ });
+ })
+ .exec();
},
swichNav: function (e) {
var that = this;
@@ -45,16 +50,17 @@
} else {
that.setData({
currentTab: e.target.dataset.current,
- navScrollLeft: e.target.dataset.current >= 4 ? ((e.target.dataset.current) * 60) : 0 //鍒ゆ柇褰撳墠閫変腑鐨勪釜鏁版槸鍚︽槸绗�5涓�
- })
- that.tabsHeight('.page'+e.target.dataset.current); //鏌ヨ鍝竴涓厓绱�
+ navScrollLeft:
+ e.target.dataset.current >= 4 ? e.target.dataset.current * 60 : 0, //鍒ゆ柇褰撳墠閫変腑鐨勪釜鏁版槸鍚︽槸绗�5涓�
+ });
+ that.tabsHeight('.page' + e.target.dataset.current); //鏌ヨ鍝竴涓厓绱�
}
},
bindChange: function (e) {
var that = this;
that.setData({
currentTab: e.detail.current,
- navScrollLeft: e.detail.current >= 4 ? ((e.detail.current) * 60) : 0 //鍒ゆ柇褰撳墠閫変腑鐨勪釜鏁版槸鍚︽槸绗�5涓�
+ navScrollLeft: e.detail.current >= 4 ? e.detail.current * 60 : 0, //鍒ゆ柇褰撳墠閫変腑鐨勪釜鏁版槸鍚︽槸绗�5涓�
});
// that.tabsHeight('.page'+e.target.dataset.current); //鏌ヨ鍝竴涓厓绱�
},
@@ -64,36 +70,91 @@
*/
onLoad: function (options) {
this.tabsHeight('.page0');
- this.getNotice()
+ this.getNotice();
},
- onReachBottom () {
+ onReachBottom() {
if (this.cPage && this.tPage) {
if (this.cPage < this.tPage) {
- this.getNotice(this.cPage + 1)
+ this.getNotice(this.cPage + 1);
}
}
},
getNotice(cPage = 1) {
- var that = this
- notificationservice.getNotification(app.globalData.accessToken.userId, cPage, {
- onHead(header) {
- that.cPage = parseInt(header.currentPage)
- that.tPage = parseInt(header.totalPage)
- console.log(`cPage:${that.cPage}, tPage:${that.tPage}`);
+ var that = this;
+ notificationservice.getNotification(
+ app.globalData.accessToken.userId,
+ cPage,
+ {
+ onHead(header) {
+ that.cPage = parseInt(header.currentPage);
+ that.tPage = parseInt(header.totalPage);
+ console.log(`cPage:${that.cPage}, tPage:${that.tPage}`);
+ },
+ success(res) {
+ const { pageList, unReadList } = that.data;
+ res.forEach(r => {
+ r.updateTime = moment(r.updateTime).format('YYYY骞碝M鏈圖D鏃�');
+ switch (r.typeId) {
+ // 绯荤粺閫氱煡
+ case '1':
+ if (!r.hasRead) unReadList[2]++;
+ pageList[2].push(r);
+ break;
+ // 宸ヤ綔閫氱煡
+ case '2':
+ if (!r.hasRead) unReadList[0]++;
+ pageList[0].push(r);
+ break;
+ // 棰勮璀︾ず
+ case '3':
+ if (!r.hasRead) unReadList[1]++;
+ pageList[1].push(r);
+ break;
+ default:
+ if (!r.hasRead) unReadList[2]++;
+ pageList[2].push(r);
+ break;
+ }
+ });
+ that.setData({ pageList, unReadList });
+ that.tabsHeight('.page0'); //鍒锋柊楂樺害
+ },
},
- success(res) {
- res.forEach(r => {
- r.updateTime = moment(r.updateTime).format('YYYY骞碝M鏈圖D鏃�')
- });
- let notices = that.data.pageList[0].concat(res)
- that.setData({
- ['pageList[0]']: notices
- })
-
- that.tabsHeight('.page0'); //鍒锋柊楂樺害
- }
- }, 5)
+ 30,
+ );
},
-})
\ No newline at end of file
+
+ showDialog(e) {
+ const { index } = e.currentTarget.dataset;
+ const notice = this.data.pageList[index[0]][index[1]];
+ this.setData({
+ showNoticeDetail: true,
+ showTitle: notice.title,
+ showContent: notice.content,
+ });
+ if (!notice.hasRead) {
+ var that = this;
+ const { unReadList } = this.data;
+ notificationservice.updateReadState(
+ app.globalData.accessToken.userId,
+ [{ noticeId: notice.id, hasRead: true, hasSigned: true }],
+ {
+ success() {
+ notice.hasRead = true;
+ unReadList[index[0]]--;
+ that.setData({
+ [`pageList[${index[0]}][${index[1]}]`]: notice,
+ unReadList,
+ });
+ },
+ },
+ );
+ }
+ },
+
+ closeDialog() {
+ this.setData({ showNoticeDetail: false });
+ },
+});
--
Gitblit v1.9.3