upload project
This commit is contained in:
commit
06961cae04
422 changed files with 110626 additions and 0 deletions
|
|
@ -0,0 +1,558 @@
|
|||
// 🔔 通知设置页面逻辑
|
||||
const notificationManager = require('../../../utils/notification-manager.js');
|
||||
|
||||
Page({
|
||||
data: {
|
||||
// 系统信息
|
||||
statusBarHeight: 44,
|
||||
navBarHeight: 88,
|
||||
|
||||
// 通知设置
|
||||
notificationSettings: {
|
||||
enabled: true,
|
||||
message: {
|
||||
enabled: true,
|
||||
showPreview: true,
|
||||
sound: true,
|
||||
vibrate: true,
|
||||
groupByChat: true
|
||||
},
|
||||
group: {
|
||||
enabled: true,
|
||||
mentionOnly: false,
|
||||
sound: true,
|
||||
vibrate: true
|
||||
},
|
||||
friend: {
|
||||
enabled: true,
|
||||
sound: true
|
||||
},
|
||||
system: {
|
||||
enabled: true
|
||||
}
|
||||
},
|
||||
|
||||
// 免打扰设置
|
||||
doNotDisturb: {
|
||||
enabled: false,
|
||||
startTime: '22:00',
|
||||
endTime: '08:00',
|
||||
allowUrgent: true,
|
||||
allowMentions: true
|
||||
},
|
||||
|
||||
// 未读计数
|
||||
unreadCount: 0,
|
||||
|
||||
// 时间选择器
|
||||
showTimePicker: false,
|
||||
selectedTime: '22:00',
|
||||
timePickerType: 'start', // start, end
|
||||
|
||||
// 加载状态
|
||||
loading: false
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
|
||||
// 获取系统信息
|
||||
this.getSystemInfo();
|
||||
|
||||
// 加载通知设置
|
||||
this.loadNotificationSettings();
|
||||
|
||||
// 加载未读计数
|
||||
this.loadUnreadCount();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
|
||||
// 刷新未读计数
|
||||
this.loadUnreadCount();
|
||||
},
|
||||
|
||||
// 获取系统信息
|
||||
getSystemInfo() {
|
||||
try {
|
||||
const windowInfo = wx.getWindowInfo();
|
||||
this.setData({
|
||||
statusBarHeight: windowInfo.statusBarHeight || 44,
|
||||
navBarHeight: 88
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('获取系统信息失败:', error);
|
||||
this.setData({
|
||||
statusBarHeight: 44,
|
||||
navBarHeight: 88
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 加载通知设置
|
||||
loadNotificationSettings() {
|
||||
try {
|
||||
// 从通知管理器获取设置
|
||||
const settings = notificationManager.getStatus();
|
||||
|
||||
if (settings.notificationSettings) {
|
||||
this.setData({
|
||||
notificationSettings: {
|
||||
...this.data.notificationSettings,
|
||||
...settings.notificationSettings
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 加载免打扰设置
|
||||
const doNotDisturbSettings = wx.getStorageSync('doNotDisturbSettings');
|
||||
if (doNotDisturbSettings) {
|
||||
this.setData({
|
||||
doNotDisturb: {
|
||||
...this.data.doNotDisturb,
|
||||
...doNotDisturbSettings
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ 加载通知设置失败:', error);
|
||||
}
|
||||
},
|
||||
|
||||
// 加载未读计数
|
||||
loadUnreadCount() {
|
||||
try {
|
||||
const totalUnread = notificationManager.getTotalUnreadCount();
|
||||
this.setData({
|
||||
unreadCount: totalUnread
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('❌ 加载未读计数失败:', error);
|
||||
}
|
||||
},
|
||||
|
||||
// 🔔 ===== 通知设置变更 =====
|
||||
|
||||
// 通知总开关变更
|
||||
onNotificationEnabledChange(e) {
|
||||
const enabled = e.detail.value;
|
||||
|
||||
this.setData({
|
||||
'notificationSettings.enabled': enabled
|
||||
});
|
||||
|
||||
this.saveNotificationSettings();
|
||||
},
|
||||
|
||||
// 消息通知变更
|
||||
onMessageNotificationChange(e) {
|
||||
const enabled = e.detail.value;
|
||||
|
||||
this.setData({
|
||||
'notificationSettings.message.enabled': enabled
|
||||
});
|
||||
|
||||
this.saveNotificationSettings();
|
||||
},
|
||||
|
||||
// 消息预览变更
|
||||
onMessagePreviewChange(e) {
|
||||
const enabled = e.detail.value;
|
||||
|
||||
this.setData({
|
||||
'notificationSettings.message.showPreview': enabled
|
||||
});
|
||||
|
||||
this.saveNotificationSettings();
|
||||
},
|
||||
|
||||
// 消息提示音变更
|
||||
onMessageSoundChange(e) {
|
||||
const enabled = e.detail.value;
|
||||
|
||||
this.setData({
|
||||
'notificationSettings.message.sound': enabled
|
||||
});
|
||||
|
||||
this.saveNotificationSettings();
|
||||
},
|
||||
|
||||
// 消息震动变更
|
||||
onMessageVibrateChange(e) {
|
||||
const enabled = e.detail.value;
|
||||
|
||||
this.setData({
|
||||
'notificationSettings.message.vibrate': enabled
|
||||
});
|
||||
|
||||
this.saveNotificationSettings();
|
||||
},
|
||||
|
||||
// 消息分组变更
|
||||
onMessageGroupChange(e) {
|
||||
const enabled = e.detail.value;
|
||||
|
||||
this.setData({
|
||||
'notificationSettings.message.groupByChat': enabled
|
||||
});
|
||||
|
||||
this.saveNotificationSettings();
|
||||
},
|
||||
|
||||
// 群聊通知变更
|
||||
onGroupNotificationChange(e) {
|
||||
const enabled = e.detail.value;
|
||||
|
||||
this.setData({
|
||||
'notificationSettings.group.enabled': enabled
|
||||
});
|
||||
|
||||
this.saveNotificationSettings();
|
||||
},
|
||||
|
||||
// 群聊仅@提醒变更
|
||||
onGroupMentionOnlyChange(e) {
|
||||
const enabled = e.detail.value;
|
||||
|
||||
this.setData({
|
||||
'notificationSettings.group.mentionOnly': enabled
|
||||
});
|
||||
|
||||
this.saveNotificationSettings();
|
||||
},
|
||||
|
||||
// 群聊提示音变更
|
||||
onGroupSoundChange(e) {
|
||||
const enabled = e.detail.value;
|
||||
|
||||
this.setData({
|
||||
'notificationSettings.group.sound': enabled
|
||||
});
|
||||
|
||||
this.saveNotificationSettings();
|
||||
},
|
||||
|
||||
// 群聊震动变更
|
||||
onGroupVibrateChange(e) {
|
||||
const enabled = e.detail.value;
|
||||
|
||||
this.setData({
|
||||
'notificationSettings.group.vibrate': enabled
|
||||
});
|
||||
|
||||
this.saveNotificationSettings();
|
||||
},
|
||||
|
||||
// 好友通知变更
|
||||
onFriendNotificationChange(e) {
|
||||
const enabled = e.detail.value;
|
||||
|
||||
this.setData({
|
||||
'notificationSettings.friend.enabled': enabled
|
||||
});
|
||||
|
||||
this.saveNotificationSettings();
|
||||
},
|
||||
|
||||
// 好友提示音变更
|
||||
onFriendSoundChange(e) {
|
||||
const enabled = e.detail.value;
|
||||
|
||||
this.setData({
|
||||
'notificationSettings.friend.sound': enabled
|
||||
});
|
||||
|
||||
this.saveNotificationSettings();
|
||||
},
|
||||
|
||||
// 系统通知变更
|
||||
onSystemNotificationChange(e) {
|
||||
const enabled = e.detail.value;
|
||||
|
||||
this.setData({
|
||||
'notificationSettings.system.enabled': enabled
|
||||
});
|
||||
|
||||
this.saveNotificationSettings();
|
||||
},
|
||||
|
||||
// 🔕 ===== 免打扰设置 =====
|
||||
|
||||
// 免打扰模式变更
|
||||
onDoNotDisturbChange(e) {
|
||||
const enabled = e.detail.value;
|
||||
|
||||
this.setData({
|
||||
'doNotDisturb.enabled': enabled
|
||||
});
|
||||
|
||||
this.saveDoNotDisturbSettings();
|
||||
},
|
||||
|
||||
// 选择开始时间
|
||||
selectStartTime() {
|
||||
|
||||
this.setData({
|
||||
showTimePicker: true,
|
||||
selectedTime: this.data.doNotDisturb.startTime,
|
||||
timePickerType: 'start'
|
||||
});
|
||||
},
|
||||
|
||||
// 选择结束时间
|
||||
selectEndTime() {
|
||||
|
||||
this.setData({
|
||||
showTimePicker: true,
|
||||
selectedTime: this.data.doNotDisturb.endTime,
|
||||
timePickerType: 'end'
|
||||
});
|
||||
},
|
||||
|
||||
// 时间选择变更
|
||||
onTimeChange(e) {
|
||||
const time = e.detail.value;
|
||||
|
||||
if (this.data.timePickerType === 'start') {
|
||||
this.setData({
|
||||
'doNotDisturb.startTime': time,
|
||||
showTimePicker: false
|
||||
});
|
||||
} else {
|
||||
this.setData({
|
||||
'doNotDisturb.endTime': time,
|
||||
showTimePicker: false
|
||||
});
|
||||
}
|
||||
|
||||
this.saveDoNotDisturbSettings();
|
||||
},
|
||||
|
||||
// 取消时间选择
|
||||
onTimeCancel() {
|
||||
this.setData({
|
||||
showTimePicker: false
|
||||
});
|
||||
},
|
||||
|
||||
// 允许紧急通知变更
|
||||
onAllowUrgentChange(e) {
|
||||
const enabled = e.detail.value;
|
||||
|
||||
this.setData({
|
||||
'doNotDisturb.allowUrgent': enabled
|
||||
});
|
||||
|
||||
this.saveDoNotDisturbSettings();
|
||||
},
|
||||
|
||||
// 允许@提醒变更
|
||||
onAllowMentionsChange(e) {
|
||||
const enabled = e.detail.value;
|
||||
|
||||
this.setData({
|
||||
'doNotDisturb.allowMentions': enabled
|
||||
});
|
||||
|
||||
this.saveDoNotDisturbSettings();
|
||||
},
|
||||
|
||||
// 📋 ===== 通知管理 =====
|
||||
|
||||
// 查看通知历史
|
||||
viewNotificationHistory() {
|
||||
|
||||
wx.navigateTo({
|
||||
url: '/subpackages/settings/notification-settings/notification-settings'
|
||||
});
|
||||
},
|
||||
|
||||
// 清空通知历史
|
||||
clearNotificationHistory() {
|
||||
|
||||
wx.showModal({
|
||||
title: '清空通知历史',
|
||||
content: '确定要删除所有通知记录吗?此操作不可恢复。',
|
||||
confirmText: '清空',
|
||||
confirmColor: '#FF3B30',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
this.performClearHistory();
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 执行清空历史
|
||||
performClearHistory() {
|
||||
try {
|
||||
// 清空通知历史
|
||||
wx.removeStorageSync('notificationHistory');
|
||||
|
||||
// 重置未读计数
|
||||
notificationManager.reset();
|
||||
|
||||
this.setData({
|
||||
unreadCount: 0
|
||||
});
|
||||
|
||||
wx.showToast({
|
||||
title: '历史已清空',
|
||||
icon: 'success'
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ 清空通知历史失败:', error);
|
||||
wx.showToast({
|
||||
title: '清空失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 📱 ===== 订阅消息 =====
|
||||
|
||||
// 请求订阅消息权限
|
||||
async requestSubscribeMessage() {
|
||||
|
||||
try {
|
||||
const templateIds = [
|
||||
'template_id_1', // 新消息通知
|
||||
'template_id_2', // 好友请求通知
|
||||
'template_id_3' // 系统通知
|
||||
];
|
||||
|
||||
const result = await notificationManager.requestSubscribeMessage(templateIds);
|
||||
|
||||
if (result) {
|
||||
wx.showToast({
|
||||
title: '权限设置完成',
|
||||
icon: 'success'
|
||||
});
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: '权限设置失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ 请求订阅消息权限失败:', error);
|
||||
wx.showToast({
|
||||
title: '权限设置失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 查看订阅状态
|
||||
viewSubscribeStatus() {
|
||||
|
||||
wx.showToast({
|
||||
title: '功能开发中',
|
||||
icon: 'none'
|
||||
});
|
||||
},
|
||||
|
||||
// ⚙️ ===== 设置管理 =====
|
||||
|
||||
// 保存通知设置
|
||||
saveNotificationSettings() {
|
||||
try {
|
||||
// 更新通知管理器设置
|
||||
notificationManager.updateNotificationSettings(this.data.notificationSettings);
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ 保存通知设置失败:', error);
|
||||
}
|
||||
},
|
||||
|
||||
// 保存免打扰设置
|
||||
saveDoNotDisturbSettings() {
|
||||
try {
|
||||
wx.setStorageSync('doNotDisturbSettings', this.data.doNotDisturb);
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ 保存免打扰设置失败:', error);
|
||||
}
|
||||
},
|
||||
|
||||
// 重置设置
|
||||
resetSettings() {
|
||||
|
||||
wx.showModal({
|
||||
title: '重置通知设置',
|
||||
content: '确定要将所有通知设置恢复为默认值吗?',
|
||||
confirmText: '重置',
|
||||
confirmColor: '#FF3B30',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
this.performResetSettings();
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 执行重置设置
|
||||
performResetSettings() {
|
||||
try {
|
||||
// 重置为默认设置
|
||||
this.setData({
|
||||
notificationSettings: {
|
||||
enabled: true,
|
||||
message: {
|
||||
enabled: true,
|
||||
showPreview: true,
|
||||
sound: true,
|
||||
vibrate: true,
|
||||
groupByChat: true
|
||||
},
|
||||
group: {
|
||||
enabled: true,
|
||||
mentionOnly: false,
|
||||
sound: true,
|
||||
vibrate: true
|
||||
},
|
||||
friend: {
|
||||
enabled: true,
|
||||
sound: true
|
||||
},
|
||||
system: {
|
||||
enabled: true
|
||||
}
|
||||
},
|
||||
doNotDisturb: {
|
||||
enabled: false,
|
||||
startTime: '22:00',
|
||||
endTime: '08:00',
|
||||
allowUrgent: true,
|
||||
allowMentions: true
|
||||
}
|
||||
});
|
||||
|
||||
// 保存设置
|
||||
this.saveNotificationSettings();
|
||||
this.saveDoNotDisturbSettings();
|
||||
|
||||
wx.showToast({
|
||||
title: '设置已重置',
|
||||
icon: 'success'
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ 重置通知设置失败:', error);
|
||||
wx.showToast({
|
||||
title: '重置失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 🧭 ===== 页面导航 =====
|
||||
|
||||
// 返回上一页
|
||||
goBack() {
|
||||
wx.navigateBack();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"navigationStyle": "custom",
|
||||
"backgroundColor": "#F2F2F7",
|
||||
"backgroundTextStyle": "dark",
|
||||
"enablePullDownRefresh": false,
|
||||
"onReachBottomDistance": 50
|
||||
}
|
||||
|
|
@ -0,0 +1,312 @@
|
|||
<!-- 🔔 通知设置页面 -->
|
||||
<view class="notification-settings-container">
|
||||
<!-- 自定义导航栏 -->
|
||||
<view class="custom-navbar" style="padding-top: {{statusBarHeight}}px;">
|
||||
<view class="navbar-content" style="height: {{navBarHeight}}px;">
|
||||
<view class="navbar-left" bindtap="goBack">
|
||||
<text class="back-icon">‹</text>
|
||||
</view>
|
||||
|
||||
<view class="navbar-title">
|
||||
<text class="title-text">通知设置</text>
|
||||
</view>
|
||||
|
||||
<view class="navbar-right"></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 页面内容 -->
|
||||
<scroll-view class="page-content" scroll-y="true">
|
||||
<!-- 通知总开关 -->
|
||||
<view class="settings-section">
|
||||
<view class="section-header">
|
||||
<text class="section-title">通知总开关</text>
|
||||
</view>
|
||||
|
||||
<view class="setting-item">
|
||||
<view class="item-info">
|
||||
<text class="item-title">接收通知</text>
|
||||
<text class="item-desc">关闭后将不会收到任何通知</text>
|
||||
</view>
|
||||
<switch class="setting-switch"
|
||||
checked="{{notificationSettings.enabled}}"
|
||||
bindchange="onNotificationEnabledChange" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 消息通知 -->
|
||||
<view class="settings-section" wx:if="{{notificationSettings.enabled}}">
|
||||
<view class="section-header">
|
||||
<text class="section-title">消息通知</text>
|
||||
</view>
|
||||
|
||||
<view class="setting-item">
|
||||
<view class="item-info">
|
||||
<text class="item-title">新消息通知</text>
|
||||
<text class="item-desc">收到新消息时显示通知</text>
|
||||
</view>
|
||||
<switch class="setting-switch"
|
||||
checked="{{notificationSettings.message.enabled}}"
|
||||
bindchange="onMessageNotificationChange" />
|
||||
</view>
|
||||
|
||||
<view class="setting-item" wx:if="{{notificationSettings.message.enabled}}">
|
||||
<view class="item-info">
|
||||
<text class="item-title">消息预览</text>
|
||||
<text class="item-desc">在通知中显示消息内容</text>
|
||||
</view>
|
||||
<switch class="setting-switch"
|
||||
checked="{{notificationSettings.message.showPreview}}"
|
||||
bindchange="onMessagePreviewChange" />
|
||||
</view>
|
||||
|
||||
<view class="setting-item" wx:if="{{notificationSettings.message.enabled}}">
|
||||
<view class="item-info">
|
||||
<text class="item-title">消息提示音</text>
|
||||
<text class="item-desc">收到消息时播放提示音</text>
|
||||
</view>
|
||||
<switch class="setting-switch"
|
||||
checked="{{notificationSettings.message.sound}}"
|
||||
bindchange="onMessageSoundChange" />
|
||||
</view>
|
||||
|
||||
<view class="setting-item" wx:if="{{notificationSettings.message.enabled}}">
|
||||
<view class="item-info">
|
||||
<text class="item-title">消息震动</text>
|
||||
<text class="item-desc">收到消息时震动提醒</text>
|
||||
</view>
|
||||
<switch class="setting-switch"
|
||||
checked="{{notificationSettings.message.vibrate}}"
|
||||
bindchange="onMessageVibrateChange" />
|
||||
</view>
|
||||
|
||||
<view class="setting-item" wx:if="{{notificationSettings.message.enabled}}">
|
||||
<view class="item-info">
|
||||
<text class="item-title">按聊天分组</text>
|
||||
<text class="item-desc">将同一聊天的消息合并显示</text>
|
||||
</view>
|
||||
<switch class="setting-switch"
|
||||
checked="{{notificationSettings.message.groupByChat}}"
|
||||
bindchange="onMessageGroupChange" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 群聊通知 -->
|
||||
<view class="settings-section" wx:if="{{notificationSettings.enabled}}">
|
||||
<view class="section-header">
|
||||
<text class="section-title">群聊通知</text>
|
||||
</view>
|
||||
|
||||
<view class="setting-item">
|
||||
<view class="item-info">
|
||||
<text class="item-title">群聊消息</text>
|
||||
<text class="item-desc">收到群聊消息时显示通知</text>
|
||||
</view>
|
||||
<switch class="setting-switch"
|
||||
checked="{{notificationSettings.group.enabled}}"
|
||||
bindchange="onGroupNotificationChange" />
|
||||
</view>
|
||||
|
||||
<view class="setting-item" wx:if="{{notificationSettings.group.enabled}}">
|
||||
<view class="item-info">
|
||||
<text class="item-title">仅@我的消息</text>
|
||||
<text class="item-desc">只有@我的群聊消息才通知</text>
|
||||
</view>
|
||||
<switch class="setting-switch"
|
||||
checked="{{notificationSettings.group.mentionOnly}}"
|
||||
bindchange="onGroupMentionOnlyChange" />
|
||||
</view>
|
||||
|
||||
<view class="setting-item" wx:if="{{notificationSettings.group.enabled}}">
|
||||
<view class="item-info">
|
||||
<text class="item-title">群聊提示音</text>
|
||||
<text class="item-desc">收到群聊消息时播放提示音</text>
|
||||
</view>
|
||||
<switch class="setting-switch"
|
||||
checked="{{notificationSettings.group.sound}}"
|
||||
bindchange="onGroupSoundChange" />
|
||||
</view>
|
||||
|
||||
<view class="setting-item" wx:if="{{notificationSettings.group.enabled}}">
|
||||
<view class="item-info">
|
||||
<text class="item-title">群聊震动</text>
|
||||
<text class="item-desc">收到群聊消息时震动提醒</text>
|
||||
</view>
|
||||
<switch class="setting-switch"
|
||||
checked="{{notificationSettings.group.vibrate}}"
|
||||
bindchange="onGroupVibrateChange" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 好友通知 -->
|
||||
<view class="settings-section" wx:if="{{notificationSettings.enabled}}">
|
||||
<view class="section-header">
|
||||
<text class="section-title">好友通知</text>
|
||||
</view>
|
||||
|
||||
<view class="setting-item">
|
||||
<view class="item-info">
|
||||
<text class="item-title">好友请求</text>
|
||||
<text class="item-desc">收到好友请求时显示通知</text>
|
||||
</view>
|
||||
<switch class="setting-switch"
|
||||
checked="{{notificationSettings.friend.enabled}}"
|
||||
bindchange="onFriendNotificationChange" />
|
||||
</view>
|
||||
|
||||
<view class="setting-item" wx:if="{{notificationSettings.friend.enabled}}">
|
||||
<view class="item-info">
|
||||
<text class="item-title">好友提示音</text>
|
||||
<text class="item-desc">收到好友通知时播放提示音</text>
|
||||
</view>
|
||||
<switch class="setting-switch"
|
||||
checked="{{notificationSettings.friend.sound}}"
|
||||
bindchange="onFriendSoundChange" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 系统通知 -->
|
||||
<view class="settings-section" wx:if="{{notificationSettings.enabled}}">
|
||||
<view class="section-header">
|
||||
<text class="section-title">系统通知</text>
|
||||
</view>
|
||||
|
||||
<view class="setting-item">
|
||||
<view class="item-info">
|
||||
<text class="item-title">系统消息</text>
|
||||
<text class="item-desc">接收系统通知和公告</text>
|
||||
</view>
|
||||
<switch class="setting-switch"
|
||||
checked="{{notificationSettings.system.enabled}}"
|
||||
bindchange="onSystemNotificationChange" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 免打扰模式 -->
|
||||
<view class="settings-section" wx:if="{{notificationSettings.enabled}}">
|
||||
<view class="section-header">
|
||||
<text class="section-title">免打扰模式</text>
|
||||
</view>
|
||||
|
||||
<view class="setting-item">
|
||||
<view class="item-info">
|
||||
<text class="item-title">开启免打扰</text>
|
||||
<text class="item-desc">在指定时间段内不接收通知</text>
|
||||
</view>
|
||||
<switch class="setting-switch"
|
||||
checked="{{doNotDisturb.enabled}}"
|
||||
bindchange="onDoNotDisturbChange" />
|
||||
</view>
|
||||
|
||||
<view class="setting-item" wx:if="{{doNotDisturb.enabled}}">
|
||||
<view class="item-info">
|
||||
<text class="item-title">开始时间</text>
|
||||
<text class="item-desc">免打扰开始时间</text>
|
||||
</view>
|
||||
<view class="item-action" bindtap="selectStartTime">
|
||||
<text class="action-text">{{doNotDisturb.startTime}}</text>
|
||||
<text class="action-arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="setting-item" wx:if="{{doNotDisturb.enabled}}">
|
||||
<view class="item-info">
|
||||
<text class="item-title">结束时间</text>
|
||||
<text class="item-desc">免打扰结束时间</text>
|
||||
</view>
|
||||
<view class="item-action" bindtap="selectEndTime">
|
||||
<text class="action-text">{{doNotDisturb.endTime}}</text>
|
||||
<text class="action-arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="setting-item" wx:if="{{doNotDisturb.enabled}}">
|
||||
<view class="item-info">
|
||||
<text class="item-title">允许紧急通知</text>
|
||||
<text class="item-desc">免打扰期间仍接收紧急通知</text>
|
||||
</view>
|
||||
<switch class="setting-switch"
|
||||
checked="{{doNotDisturb.allowUrgent}}"
|
||||
bindchange="onAllowUrgentChange" />
|
||||
</view>
|
||||
|
||||
<view class="setting-item" wx:if="{{doNotDisturb.enabled}}">
|
||||
<view class="item-info">
|
||||
<text class="item-title">允许@提醒</text>
|
||||
<text class="item-desc">免打扰期间仍接收@提醒</text>
|
||||
</view>
|
||||
<switch class="setting-switch"
|
||||
checked="{{doNotDisturb.allowMentions}}"
|
||||
bindchange="onAllowMentionsChange" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 通知历史 -->
|
||||
<view class="settings-section">
|
||||
<view class="section-header">
|
||||
<text class="section-title">通知管理</text>
|
||||
</view>
|
||||
|
||||
<view class="setting-item" bindtap="viewNotificationHistory">
|
||||
<view class="item-info">
|
||||
<text class="item-title">通知历史</text>
|
||||
<text class="item-desc">查看最近的通知记录</text>
|
||||
</view>
|
||||
<view class="item-action">
|
||||
<text class="unread-badge" wx:if="{{unreadCount > 0}}">{{unreadCount}}</text>
|
||||
<text class="action-arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="setting-item" bindtap="clearNotificationHistory">
|
||||
<view class="item-info">
|
||||
<text class="item-title">清空通知历史</text>
|
||||
<text class="item-desc">删除所有通知记录</text>
|
||||
</view>
|
||||
<text class="action-arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 订阅消息 -->
|
||||
<view class="settings-section">
|
||||
<view class="section-header">
|
||||
<text class="section-title">订阅消息</text>
|
||||
</view>
|
||||
|
||||
<view class="setting-item" bindtap="requestSubscribeMessage">
|
||||
<view class="item-info">
|
||||
<text class="item-title">订阅消息权限</text>
|
||||
<text class="item-desc">允许应用发送订阅消息</text>
|
||||
</view>
|
||||
<text class="action-arrow">›</text>
|
||||
</view>
|
||||
|
||||
<view class="setting-item" bindtap="viewSubscribeStatus">
|
||||
<view class="item-info">
|
||||
<text class="item-title">订阅状态</text>
|
||||
<text class="item-desc">查看当前订阅消息状态</text>
|
||||
</view>
|
||||
<text class="action-arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 重置设置 -->
|
||||
<view class="settings-section">
|
||||
<view class="setting-item danger" bindtap="resetSettings">
|
||||
<view class="item-info">
|
||||
<text class="item-title danger">重置通知设置</text>
|
||||
<text class="item-desc">恢复所有通知设置为默认值</text>
|
||||
</view>
|
||||
<text class="action-arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<!-- 时间选择器 -->
|
||||
<picker wx:if="{{showTimePicker}}"
|
||||
mode="time"
|
||||
value="{{selectedTime}}"
|
||||
bindchange="onTimeChange"
|
||||
bindcancel="onTimeCancel">
|
||||
</picker>
|
||||
|
|
@ -0,0 +1,582 @@
|
|||
/* 🔔 通知设置页面样式 */
|
||||
|
||||
/* CSS变量定义 */
|
||||
page {
|
||||
--primary-color: #007AFF;
|
||||
--primary-light: #5AC8FA;
|
||||
--primary-dark: #0051D5;
|
||||
--success-color: #34C759;
|
||||
--danger-color: #FF3B30;
|
||||
--warning-color: #FF9500;
|
||||
--background-color: #F2F2F7;
|
||||
--surface-color: #FFFFFF;
|
||||
--text-primary: #000000;
|
||||
--text-secondary: #8E8E93;
|
||||
--text-tertiary: #C7C7CC;
|
||||
--border-color: #E5E5EA;
|
||||
--shadow-light: 0 1rpx 3rpx rgba(0, 0, 0, 0.1);
|
||||
--shadow-medium: 0 4rpx 12rpx rgba(0, 0, 0, 0.15);
|
||||
--radius-small: 8rpx;
|
||||
--radius-medium: 12rpx;
|
||||
--radius-large: 20rpx;
|
||||
}
|
||||
|
||||
/* 🌙 深色模式支持 */
|
||||
@media (prefers-color-scheme: dark) {
|
||||
page {
|
||||
--primary-color: #0A84FF;
|
||||
--primary-light: #64D2FF;
|
||||
--primary-dark: #0056CC;
|
||||
--success-color: #30D158;
|
||||
--danger-color: #FF453A;
|
||||
--warning-color: #FF9F0A;
|
||||
--background-color: #000000;
|
||||
--surface-color: #1C1C1E;
|
||||
--text-primary: #FFFFFF;
|
||||
--text-secondary: #8E8E93;
|
||||
--text-tertiary: #48484A;
|
||||
--border-color: #38383A;
|
||||
--shadow-light: 0 1rpx 3rpx rgba(0, 0, 0, 0.3);
|
||||
--shadow-medium: 0 4rpx 12rpx rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
}
|
||||
|
||||
.notification-settings-container {
|
||||
height: 100vh;
|
||||
background: var(--background-color);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* 🎨 自定义导航栏 */
|
||||
.custom-navbar {
|
||||
background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
|
||||
box-shadow: var(--shadow-medium);
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.navbar-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0 32rpx;
|
||||
}
|
||||
|
||||
.navbar-left, .navbar-right {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: var(--radius-medium);
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.navbar-left:active {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
transform: scale(0.95);
|
||||
}
|
||||
|
||||
.back-icon {
|
||||
font-size: 48rpx;
|
||||
color: white;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.navbar-title {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.title-text {
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* 🎨 页面内容 */
|
||||
.page-content {
|
||||
flex: 1;
|
||||
padding: 32rpx 0;
|
||||
}
|
||||
|
||||
/* 🎨 设置分组 */
|
||||
.settings-section {
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
padding: 0 32rpx 16rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 26rpx;
|
||||
font-weight: 600;
|
||||
color: var(--text-secondary);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1rpx;
|
||||
}
|
||||
|
||||
/* 🎨 设置项 */
|
||||
.setting-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 32rpx;
|
||||
background: var(--surface-color);
|
||||
border-bottom: 1rpx solid var(--border-color);
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.setting-item:first-child {
|
||||
border-top-left-radius: var(--radius-medium);
|
||||
border-top-right-radius: var(--radius-medium);
|
||||
}
|
||||
|
||||
.setting-item:last-child {
|
||||
border-bottom: none;
|
||||
border-bottom-left-radius: var(--radius-medium);
|
||||
border-bottom-right-radius: var(--radius-medium);
|
||||
}
|
||||
|
||||
.setting-item:active {
|
||||
background: var(--background-color);
|
||||
}
|
||||
|
||||
.setting-item.danger {
|
||||
background: rgba(255, 59, 48, 0.05);
|
||||
}
|
||||
|
||||
.setting-item.danger:active {
|
||||
background: rgba(255, 59, 48, 0.1);
|
||||
}
|
||||
|
||||
.item-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.item-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 500;
|
||||
color: var(--text-primary);
|
||||
display: block;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.item-title.danger {
|
||||
color: var(--danger-color);
|
||||
}
|
||||
|
||||
.item-desc {
|
||||
font-size: 26rpx;
|
||||
color: var(--text-secondary);
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.item-action {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.action-text {
|
||||
font-size: 30rpx;
|
||||
color: var(--primary-color);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.action-arrow {
|
||||
font-size: 32rpx;
|
||||
color: var(--text-tertiary);
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.unread-badge {
|
||||
min-width: 40rpx;
|
||||
height: 40rpx;
|
||||
border-radius: 20rpx;
|
||||
background: var(--danger-color);
|
||||
color: white;
|
||||
font-size: 24rpx;
|
||||
font-weight: 600;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0 8rpx;
|
||||
}
|
||||
|
||||
/* 🎨 开关控件 */
|
||||
.setting-switch {
|
||||
transform: scale(0.8);
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.setting-switch:active {
|
||||
transform: scale(0.75);
|
||||
}
|
||||
|
||||
/* 🎨 时间选择器样式 */
|
||||
.time-picker-container {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 9999;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
animation: fadeIn 0.3s ease-out;
|
||||
}
|
||||
|
||||
.time-picker-content {
|
||||
width: 100%;
|
||||
background: var(--surface-color);
|
||||
border-radius: var(--radius-large) var(--radius-large) 0 0;
|
||||
box-shadow: var(--shadow-medium);
|
||||
animation: slideUp 0.3s ease-out;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; }
|
||||
to { opacity: 1; }
|
||||
}
|
||||
|
||||
@keyframes slideUp {
|
||||
from {
|
||||
transform: translateY(100%);
|
||||
}
|
||||
to {
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.time-picker-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 32rpx;
|
||||
border-bottom: 1rpx solid var(--border-color);
|
||||
}
|
||||
|
||||
.time-picker-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.time-picker-btn {
|
||||
font-size: 30rpx;
|
||||
color: var(--primary-color);
|
||||
font-weight: 500;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.time-picker-btn:active {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.time-picker-btn.cancel {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.time-picker-body {
|
||||
padding: 32rpx;
|
||||
}
|
||||
|
||||
/* 🎨 状态指示器 */
|
||||
.status-indicator {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
width: 16rpx;
|
||||
height: 16rpx;
|
||||
border-radius: 8rpx;
|
||||
background: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.status-dot.active {
|
||||
background: var(--success-color);
|
||||
}
|
||||
|
||||
.status-dot.inactive {
|
||||
background: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.status-dot.error {
|
||||
background: var(--danger-color);
|
||||
}
|
||||
|
||||
.status-text {
|
||||
font-size: 26rpx;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
/* 🎨 通知预览 */
|
||||
.notification-preview {
|
||||
background: var(--surface-color);
|
||||
border: 1rpx solid var(--border-color);
|
||||
border-radius: var(--radius-medium);
|
||||
padding: 24rpx;
|
||||
margin: 24rpx 32rpx;
|
||||
box-shadow: var(--shadow-light);
|
||||
}
|
||||
|
||||
.preview-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.preview-icon {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
border-radius: 24rpx;
|
||||
background: var(--primary-color);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 24rpx;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.preview-title {
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.preview-time {
|
||||
font-size: 24rpx;
|
||||
color: var(--text-tertiary);
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.preview-content {
|
||||
font-size: 26rpx;
|
||||
color: var(--text-secondary);
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
/* 🎨 提示信息 */
|
||||
.tip-container {
|
||||
background: rgba(0, 122, 255, 0.1);
|
||||
border: 1rpx solid rgba(0, 122, 255, 0.3);
|
||||
border-radius: var(--radius-small);
|
||||
padding: 24rpx;
|
||||
margin: 24rpx 32rpx;
|
||||
}
|
||||
|
||||
.tip-text {
|
||||
font-size: 26rpx;
|
||||
color: var(--primary-color);
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.tip-icon {
|
||||
font-size: 28rpx;
|
||||
margin-right: 12rpx;
|
||||
}
|
||||
|
||||
/* 🎨 空状态 */
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 120rpx 40rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.empty-icon {
|
||||
font-size: 120rpx;
|
||||
margin-bottom: 24rpx;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 28rpx;
|
||||
color: var(--text-secondary);
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.empty-action {
|
||||
padding: 24rpx 48rpx;
|
||||
background: var(--primary-color);
|
||||
color: white;
|
||||
border-radius: var(--radius-medium);
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.empty-action:active {
|
||||
background: var(--primary-dark);
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
/* 🎨 加载状态 */
|
||||
.loading-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 80rpx;
|
||||
}
|
||||
|
||||
.loading-spinner {
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
border: 4rpx solid var(--border-color);
|
||||
border-top: 4rpx solid var(--primary-color);
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.loading-text {
|
||||
font-size: 28rpx;
|
||||
color: var(--text-secondary);
|
||||
margin-left: 24rpx;
|
||||
}
|
||||
|
||||
/* 📱 响应式设计 */
|
||||
@media screen and (max-width: 375px) {
|
||||
.page-content {
|
||||
padding: 24rpx 0;
|
||||
}
|
||||
|
||||
.settings-section {
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
padding: 0 24rpx 12rpx;
|
||||
}
|
||||
|
||||
.setting-item {
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.notification-preview,
|
||||
.tip-container {
|
||||
margin: 16rpx 24rpx;
|
||||
padding: 16rpx;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 414px) {
|
||||
.page-content {
|
||||
padding: 40rpx 0;
|
||||
}
|
||||
|
||||
.settings-section {
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
padding: 0 40rpx 20rpx;
|
||||
}
|
||||
|
||||
.setting-item {
|
||||
padding: 40rpx;
|
||||
}
|
||||
|
||||
.notification-preview,
|
||||
.tip-container {
|
||||
margin: 32rpx 40rpx;
|
||||
padding: 32rpx;
|
||||
}
|
||||
}
|
||||
|
||||
/* 🎨 动画效果 */
|
||||
.setting-item {
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.setting-item:hover {
|
||||
background: var(--background-color);
|
||||
}
|
||||
|
||||
.setting-switch {
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.action-text {
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.action-text:active {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
/* 🎨 特殊状态 */
|
||||
.setting-item.disabled {
|
||||
opacity: 0.5;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.setting-item.highlighted {
|
||||
background: rgba(0, 122, 255, 0.05);
|
||||
border-color: rgba(0, 122, 255, 0.3);
|
||||
}
|
||||
|
||||
.setting-item.warning {
|
||||
background: rgba(255, 149, 0, 0.05);
|
||||
}
|
||||
|
||||
.setting-item.warning .item-title {
|
||||
color: var(--warning-color);
|
||||
}
|
||||
|
||||
/* 🎨 分隔线 */
|
||||
.divider {
|
||||
height: 1rpx;
|
||||
background: var(--border-color);
|
||||
margin: 0 32rpx;
|
||||
}
|
||||
|
||||
.divider.thick {
|
||||
height: 16rpx;
|
||||
background: var(--background-color);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* 🎨 标签 */
|
||||
.tag {
|
||||
display: inline-block;
|
||||
padding: 8rpx 16rpx;
|
||||
border-radius: var(--radius-small);
|
||||
font-size: 24rpx;
|
||||
font-weight: 500;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.tag.primary {
|
||||
background: rgba(0, 122, 255, 0.1);
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
.tag.success {
|
||||
background: rgba(52, 199, 89, 0.1);
|
||||
color: var(--success-color);
|
||||
}
|
||||
|
||||
.tag.warning {
|
||||
background: rgba(255, 149, 0, 0.1);
|
||||
color: var(--warning-color);
|
||||
}
|
||||
|
||||
.tag.danger {
|
||||
background: rgba(255, 59, 48, 0.1);
|
||||
color: var(--danger-color);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue