Initial commit
This commit is contained in:
@@ -12,7 +12,11 @@ Page({
|
||||
canIUseOpenData: wx.canIUse('open-data.type.userAvatarUrl') && wx.canIUse('open-data.type.userNickName'), // 如需尝试获取用户信息可改为false
|
||||
selectedCategory: 'all',
|
||||
showcases: [],
|
||||
categoryStats: {}
|
||||
categoryStats: {},
|
||||
unreadCount: 0
|
||||
},
|
||||
onShow() {
|
||||
this.fetchUnreadCount();
|
||||
},
|
||||
onLoad() {
|
||||
if (wx.getUserProfile) {
|
||||
@@ -30,6 +34,26 @@ Page({
|
||||
this.setData({ selectedCategory: type });
|
||||
this.fetchData(type);
|
||||
},
|
||||
fetchUnreadCount() {
|
||||
// Only fetch if logged in
|
||||
const app = getApp()
|
||||
if (!app.globalData.token) return;
|
||||
|
||||
console.log('Fetching unread count...');
|
||||
const { request } = require('../../utils/request')
|
||||
request({ url: '/notifications/unread_count/' })
|
||||
.then(res => {
|
||||
if (res && typeof res.count === 'number') {
|
||||
this.setData({ unreadCount: res.count })
|
||||
}
|
||||
})
|
||||
.catch(err => console.error('Fetch unread count error:', err))
|
||||
},
|
||||
handleNotificationClick() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/message/index'
|
||||
})
|
||||
},
|
||||
fetchBanners() {
|
||||
const { request } = require('../../utils/request')
|
||||
request({ url: '/banners/?is_active=true' })
|
||||
|
||||
Reference in New Issue
Block a user