Initial commit

This commit is contained in:
admin
2025-12-09 14:31:16 +08:00
parent c34b63b8da
commit b8648c2861
82 changed files with 1896 additions and 46 deletions

View File

@@ -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' })

View File

@@ -6,7 +6,10 @@
<view class="title-sub">致力成就</view>
<view class="title-main">终身教育伟大事业</view>
</view>
<view class="bell-btn">🔔</view>
<view class="bell-btn" bindtap="handleNotificationClick">
<image class="notification-icon" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiNmZmZmZmYiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIj48cGF0aCBkPSJNMjEgMTVhMiAyIDAgMCAxLTIgMkg3bC00IDRWNWEyIDIgMCAwIDEgMi0yaDE0YTIgMiAwIDAgMSAyIDJ6Ij48L3BhdGg+PC9zdmc+" />
<view class="badge" wx:if="{{unreadCount > 0}}">{{unreadCount > 99 ? '99+' : unreadCount}}</view>
</view>
</view>
<!-- Search Bar -->

View File

@@ -54,10 +54,9 @@
.bell-btn {
background-color: rgba(255, 255, 255, 0.2);
backdrop-filter: blur(4px);
padding: 16rpx;
padding: 0;
border-radius: 50%;
color: var(--text-white);
font-size: 32rpx;
width: 72rpx;
height: 72rpx;
display: flex;
@@ -65,6 +64,25 @@
justify-content: center;
box-sizing: border-box;
border: 1rpx solid rgba(255, 255, 255, 0.3);
position: relative;
}
.notification-icon {
width: 40rpx;
height: 40rpx;
}
.badge {
position: absolute;
top: -6rpx;
right: -6rpx;
background-color: #ff4d4f;
color: white;
font-size: 20rpx;
padding: 4rpx 10rpx;
border-radius: 20rpx;
line-height: 1;
border: 2rpx solid #fff;
}
.search-bar {