主要更新uniapp相关功能
This commit is contained in:
1 parent
aa92ca40a2
commit
5b4dbb2b46
65 files changed
+8532
-1921
No files matched your search
@@ -8,9 +8,11 @@
|
||||
<view class="content-block">
|
||||
<view class="content-header">
|
||||
<text class="info-label">日程内容</text>
|
||||
<view class="status-tag" :class="item.completed ? 'done' : 'pending'">
|
||||
<text>{{ item.completed ? '已完成' : '待办' }}</text>
|
||||
</view>
|
||||
<u-tag
|
||||
:text="item.completed ? '已完成' : '待办'"
|
||||
:type="item.completed ? 'success' : 'primary'"
|
||||
size="mini"
|
||||
/>
|
||||
</view>
|
||||
<text class="content-text">{{ item.content || '无内容' }}</text>
|
||||
</view>
|
||||
@@ -23,11 +25,14 @@
|
||||
<view class="info-row channel-row">
|
||||
<text class="info-label">提醒渠道</text>
|
||||
<view class="channel-tags">
|
||||
<text
|
||||
<u-tag
|
||||
v-for="channel in item.remindChannels"
|
||||
:key="channel"
|
||||
class="channel-tag"
|
||||
>{{ getRemindChannelLabel(channel) }}</text>
|
||||
:text="getRemindChannelLabel(channel)"
|
||||
type="primary"
|
||||
size="mini"
|
||||
plain
|
||||
/>
|
||||
<text v-if="!item.remindChannels?.length" class="info-value muted">未设置</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -45,17 +50,20 @@
|
||||
</template>
|
||||
|
||||
<view v-if="item" class="footer">
|
||||
<view class="btn-complete" @tap="onToggleComplete">
|
||||
<FaIcon :name="item.completed ? 'rotate-left' : 'check'" :color="item.completed ? '#606266' : '#3c9cff'" :size="16" />
|
||||
<text>{{ item.completed ? '标为待办' : '标记完成' }}</text>
|
||||
<view class="footer-btn">
|
||||
<u-button
|
||||
:type="item.completed ? 'info' : 'primary'"
|
||||
:icon="item.completed ? 'reload' : 'checkmark'"
|
||||
:text="item.completed ? '标为待办' : '标记完成'"
|
||||
:plain="item.completed"
|
||||
@click="onToggleComplete"
|
||||
/>
|
||||
</view>
|
||||
<view v-if="!item.completed" class="btn-edit" @tap="openEdit">
|
||||
<FaIcon name="pen-to-square" color="#3c9cff" :size="16" />
|
||||
<text>编辑</text>
|
||||
<view v-if="!item.completed" class="footer-btn">
|
||||
<u-button type="primary" plain icon="edit-pen" text="编辑" @click="openEdit" />
|
||||
</view>
|
||||
<view class="btn-delete" @tap="onDelete">
|
||||
<FaIcon name="trash-can" color="#f56c6c" :size="16" />
|
||||
<text>删除</text>
|
||||
<view class="footer-btn">
|
||||
<u-button type="error" plain icon="trash" text="删除" @click="onDelete" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -116,11 +124,13 @@ function openEdit() {
|
||||
|
||||
async function onToggleComplete() {
|
||||
if (!item.value) return
|
||||
const wasCompleted = item.value.completed
|
||||
try {
|
||||
const updated = await toggleScheduleComplete(item.value.id)
|
||||
item.value = updated
|
||||
await toggleScheduleComplete(item.value.id)
|
||||
// toggle 接口只返回 is_finished,需重新拉取完整详情
|
||||
await loadDetail()
|
||||
uni.showToast({
|
||||
title: updated.completed ? '已标记完成' : '已标为待办',
|
||||
title: wasCompleted ? '已标为待办' : '已标记完成',
|
||||
icon: 'none'
|
||||
})
|
||||
} catch (e) {
|
||||
@@ -180,23 +190,6 @@ function onDelete() {
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
.status-tag {
|
||||
padding: 4rpx 12rpx;
|
||||
border-radius: $radius-sm;
|
||||
font-size: 22rpx;
|
||||
font-weight: 500;
|
||||
|
||||
&.pending {
|
||||
background: $color-primary-bg;
|
||||
color: $color-primary;
|
||||
}
|
||||
|
||||
&.done {
|
||||
background: #f0f9eb;
|
||||
color: #67c23a;
|
||||
}
|
||||
}
|
||||
|
||||
.content-text {
|
||||
display: block;
|
||||
font-size: 30rpx;
|
||||
@@ -244,14 +237,6 @@ function onDelete() {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.channel-tag {
|
||||
font-size: 24rpx;
|
||||
color: $color-primary;
|
||||
background: $color-primary-bg;
|
||||
padding: 6rpx 16rpx;
|
||||
border-radius: $radius-sm;
|
||||
}
|
||||
|
||||
.meta-row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -277,35 +262,8 @@ function onDelete() {
|
||||
box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
.btn-complete,
|
||||
.btn-edit,
|
||||
.btn-delete {
|
||||
.footer-btn {
|
||||
flex: 1;
|
||||
height: 88rpx;
|
||||
border-radius: $radius-md;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.btn-complete {
|
||||
background: $color-primary-bg;
|
||||
color: $color-primary;
|
||||
}
|
||||
|
||||
.btn-edit {
|
||||
background: $color-bg-page;
|
||||
color: $color-primary;
|
||||
border: 1rpx solid $color-primary-bg;
|
||||
}
|
||||
|
||||
.btn-delete {
|
||||
background: $color-bg-page;
|
||||
color: #f56c6c;
|
||||
border: 1rpx solid #fde2e2;
|
||||
}
|
||||
|
||||
.state-box {
|
||||
|
||||
@@ -8,16 +8,15 @@
|
||||
<view class="form-card" :class="{ 'is-disabled': isCompleted }">
|
||||
<view class="field">
|
||||
<text class="field-label">日程内容 <text class="required">*</text></text>
|
||||
<textarea
|
||||
class="field-textarea content-textarea"
|
||||
<u-textarea
|
||||
v-model="form.content"
|
||||
placeholder="输入日程内容,支持多行"
|
||||
placeholder-class="placeholder"
|
||||
maxlength="1000"
|
||||
:show-confirm-bar="false"
|
||||
:maxlength="1000"
|
||||
count
|
||||
height="120"
|
||||
border="none"
|
||||
:disabled="isCompleted"
|
||||
/>
|
||||
<text class="char-count">{{ form.content.length }}/1000</text>
|
||||
</view>
|
||||
|
||||
<view class="field">
|
||||
@@ -44,15 +43,16 @@
|
||||
<text class="field-label">提醒渠道</text>
|
||||
<text class="field-hint">可多选,接入接口后按渠道下发提醒</text>
|
||||
<view class="channel-grid">
|
||||
<view
|
||||
<u-tag
|
||||
v-for="channel in channelOptions"
|
||||
:key="channel.value"
|
||||
class="channel-chip"
|
||||
:class="{ active: form.remindChannels.includes(channel.value) }"
|
||||
@tap="!isCompleted && toggleChannel(channel.value)"
|
||||
>
|
||||
<text>{{ channel.label }}</text>
|
||||
</view>
|
||||
:text="channel.label"
|
||||
:name="channel.value"
|
||||
:type="isChannelActive(channel.value) ? 'primary' : 'info'"
|
||||
:plain="!isChannelActive(channel.value)"
|
||||
size="medium"
|
||||
@click="onChannelTap"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -68,41 +68,39 @@
|
||||
|
||||
<view class="field">
|
||||
<text class="field-label">重复提醒间隔(分钟)</text>
|
||||
<view class="number-input">
|
||||
<button class="number-btn" @tap="form.repeatIntervalMinutes = Math.max(0, form.repeatIntervalMinutes - 1)" :disabled="isCompleted">−</button>
|
||||
<input
|
||||
v-model.number="form.repeatIntervalMinutes"
|
||||
type="number"
|
||||
class="number-field"
|
||||
:disabled="isCompleted"
|
||||
@blur="form.repeatIntervalMinutes = Math.max(0, Math.min(1440, form.repeatIntervalMinutes))"
|
||||
/>
|
||||
<button class="number-btn" @tap="form.repeatIntervalMinutes = Math.min(1440, form.repeatIntervalMinutes + 1)" :disabled="isCompleted">+</button>
|
||||
</view>
|
||||
<u-number-box
|
||||
v-model="form.repeatIntervalMinutes"
|
||||
:min="0"
|
||||
:max="1440"
|
||||
integer
|
||||
:disabled="isCompleted"
|
||||
/>
|
||||
<text class="form-tip">0表示不重复,仅发送一次</text>
|
||||
</view>
|
||||
|
||||
<view class="field">
|
||||
<text class="field-label">最多提醒次数</text>
|
||||
<view class="number-input">
|
||||
<button class="number-btn" @tap="form.maxSendCount = Math.max(1, form.maxSendCount - 1)" :disabled="isCompleted">−</button>
|
||||
<input
|
||||
v-model.number="form.maxSendCount"
|
||||
type="number"
|
||||
class="number-field"
|
||||
:disabled="isCompleted"
|
||||
@blur="form.maxSendCount = Math.max(1, Math.min(100, form.maxSendCount))"
|
||||
/>
|
||||
<button class="number-btn" @tap="form.maxSendCount = Math.min(100, form.maxSendCount + 1)" :disabled="isCompleted">+</button>
|
||||
</view>
|
||||
<u-number-box
|
||||
v-model="form.maxSendCount"
|
||||
:min="1"
|
||||
:max="100"
|
||||
integer
|
||||
:disabled="isCompleted"
|
||||
/>
|
||||
<text class="form-tip">最多发送的提醒次数</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="!isCompleted" class="footer">
|
||||
<view class="btn-primary full" :class="{ disabled: saving }" @tap="onSave">
|
||||
{{ saving ? '保存中...' : '保存' }}
|
||||
</view>
|
||||
<u-button
|
||||
type="primary"
|
||||
color="#2563eb"
|
||||
shape="circle"
|
||||
:loading="saving"
|
||||
loading-text="保存中..."
|
||||
text="保存"
|
||||
@click="onSave"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -177,12 +175,18 @@ async function loadSchedule(id) {
|
||||
}
|
||||
}
|
||||
|
||||
function toggleChannel(value) {
|
||||
const index = form.remindChannels.indexOf(value)
|
||||
/** 渠道是否已选中 */
|
||||
function isChannelActive(value) {
|
||||
return form.remindChannels.includes(value)
|
||||
}
|
||||
|
||||
function onChannelTap(name) {
|
||||
if (isCompleted.value) return
|
||||
const index = form.remindChannels.indexOf(name)
|
||||
if (index >= 0) {
|
||||
form.remindChannels.splice(index, 1)
|
||||
} else {
|
||||
form.remindChannels.push(value)
|
||||
form.remindChannels.push(name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,29 +319,6 @@ async function saveData(datetime) {
|
||||
color: #f56c6c;
|
||||
}
|
||||
|
||||
.field-textarea {
|
||||
width: 100%;
|
||||
font-size: 30rpx;
|
||||
color: $color-text;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.content-textarea {
|
||||
height: 240rpx;
|
||||
}
|
||||
|
||||
.placeholder {
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.char-count {
|
||||
display: block;
|
||||
text-align: right;
|
||||
font-size: 22rpx;
|
||||
color: $color-text-muted;
|
||||
margin-top: 12rpx;
|
||||
}
|
||||
|
||||
.picker-value {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -356,69 +337,6 @@ async function saveData(datetime) {
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.channel-chip {
|
||||
padding: 14rpx 28rpx;
|
||||
border-radius: $radius-full;
|
||||
font-size: 26rpx;
|
||||
color: $color-text-secondary;
|
||||
background: $color-bg-page;
|
||||
border: 1rpx solid transparent;
|
||||
|
||||
&.active {
|
||||
color: $color-primary;
|
||||
background: $color-primary-bg;
|
||||
border-color: $color-primary;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
.number-input {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
.number-btn {
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
border-radius: $radius-md;
|
||||
background: $color-bg-page;
|
||||
border: 1rpx solid $color-divider;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 28rpx;
|
||||
color: $color-text;
|
||||
flex-shrink: 0;
|
||||
|
||||
&:active:not(:disabled) {
|
||||
background: $color-primary-bg;
|
||||
color: $color-primary;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
.number-field {
|
||||
flex: 1;
|
||||
height: 60rpx;
|
||||
padding: 0 16rpx;
|
||||
background: $color-bg-page;
|
||||
border: 1rpx solid $color-divider;
|
||||
border-radius: $radius-md;
|
||||
font-size: 28rpx;
|
||||
color: $color-text;
|
||||
text-align: center;
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
.form-tip {
|
||||
display: block;
|
||||
font-size: 22rpx;
|
||||
@@ -439,29 +357,4 @@ async function saveData(datetime) {
|
||||
border-top: 1rpx solid $color-border;
|
||||
box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
flex: 1;
|
||||
height: 88rpx;
|
||||
border-radius: $radius-md;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
background: $color-primary;
|
||||
color: #fff;
|
||||
|
||||
&:active {
|
||||
background: $color-primary-dark;
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
&.full {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,47 +1,133 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<view class="toolbar">
|
||||
<view class="search-bar">
|
||||
<FaIcon name="magnifying-glass" color="#909399" :size="16" />
|
||||
<input
|
||||
class="search-input"
|
||||
v-model="keyword"
|
||||
type="text"
|
||||
placeholder="搜索日程内容"
|
||||
placeholder-class="search-placeholder"
|
||||
confirm-type="search"
|
||||
@confirm="loadSchedules"
|
||||
<scroll-view class="body" scroll-y :show-scrollbar="false">
|
||||
<view class="body-inner">
|
||||
<!-- 本周概览横幅 -->
|
||||
<view class="hero-banner">
|
||||
<view class="hero-info">
|
||||
<view class="hero-title-row">
|
||||
<text class="hero-title">本周日程</text>
|
||||
<text class="hero-unit">(项)</text>
|
||||
<text class="hero-count">{{ weekCount }}</text>
|
||||
</view>
|
||||
<text class="hero-sub">{{ heroRangeLabel }}</text>
|
||||
</view>
|
||||
<view class="hero-icon">
|
||||
<FaIcon name="calendar-check" color="#ffffff" :size="26" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 可收缩日历 -->
|
||||
<view class="cal-card">
|
||||
<view v-if="expanded" class="cal-head">
|
||||
<text class="cal-title">{{ monthLabel }}</text>
|
||||
<view class="cal-head-right">
|
||||
<view class="cal-nav" @tap="shiftMonth(-1)">
|
||||
<FaIcon name="chevron-left" color="#475569" :size="13" />
|
||||
</view>
|
||||
<view class="cal-today-btn" @tap="goToday">
|
||||
<text>今天</text>
|
||||
</view>
|
||||
<view class="cal-nav" @tap="shiftMonth(1)">
|
||||
<FaIcon name="chevron-right" color="#475569" :size="13" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="cal-week">
|
||||
<text v-for="w in WEEK_LABELS" :key="w" class="cal-week-item">{{ w }}</text>
|
||||
</view>
|
||||
|
||||
<view class="cal-grid">
|
||||
<view
|
||||
v-for="cell in gridCells"
|
||||
:key="cell.key"
|
||||
class="cal-cell"
|
||||
@tap="pickDay(cell)"
|
||||
>
|
||||
<view
|
||||
class="cal-day"
|
||||
:class="{
|
||||
dim: !cell.inMonth,
|
||||
today: cell.isToday && cell.key !== selectedKey,
|
||||
selected: cell.key === selectedKey
|
||||
}"
|
||||
>{{ cell.day }}</view>
|
||||
<view class="cal-dots">
|
||||
<view
|
||||
v-for="n in dotCount(cell.key)"
|
||||
:key="n"
|
||||
class="cal-dot"
|
||||
:class="{ on: cell.key === selectedKey }"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="cal-toggle" @tap="expanded = !expanded">
|
||||
<text>{{ expanded ? '收起' : '展开' }}</text>
|
||||
<FaIcon :name="expanded ? 'chevron-up' : 'chevron-down'" color="#94a3b8" :size="11" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 选中日期的日程 -->
|
||||
<view class="day-head">
|
||||
<text class="day-title">{{ selectedLabel }}</text>
|
||||
<text class="day-count">{{ dayItems.length }} 项</text>
|
||||
</view>
|
||||
|
||||
<u-empty
|
||||
v-if="!loading && dayItems.length === 0"
|
||||
mode="list"
|
||||
:icon-size="72"
|
||||
text="当天暂无日程"
|
||||
/>
|
||||
<view v-if="keyword" class="search-clear" @tap="clearSearch">
|
||||
<FaIcon name="circle-xmark" color="#c0c4cc" :size="16" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="tabs">
|
||||
<view
|
||||
v-for="tab in tabs"
|
||||
:key="tab.value"
|
||||
class="tab"
|
||||
:class="{ active: status === tab.value }"
|
||||
@tap="changeStatus(tab.value)"
|
||||
>{{ tab.label }}</view>
|
||||
</view>
|
||||
</view>
|
||||
v-for="item in dayItems"
|
||||
:key="item.id"
|
||||
class="sched-card"
|
||||
:class="{ done: item.completed }"
|
||||
>
|
||||
<view class="sched-main" @tap="openDetail(item.id)">
|
||||
<view class="sched-left">
|
||||
<text class="sched-day">{{ dayLabel(item.datetime) }}</text>
|
||||
<text class="sched-time">{{ timeText(item.datetime) }}</text>
|
||||
</view>
|
||||
<view class="sched-sep" />
|
||||
<view class="sched-right">
|
||||
<view class="sched-title-row">
|
||||
<text class="sched-content">{{ item.content || item.title }}</text>
|
||||
<view class="status-chip" :class="item.completed ? 'done' : 'pending'">
|
||||
<text>{{ item.completed ? '已完成' : '待办' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="item.remindChannels.length" class="sched-meta">
|
||||
<FaIcon name="bell" color="#94a3b8" :size="11" />
|
||||
<text>{{ getRemindMinutesLabel(item.remindMinutes) }}</text>
|
||||
<text v-if="item.repeatIntervalMinutes > 0">· 每 {{ item.repeatIntervalMinutes }} 分钟</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<scroll-view class="list-scroll" scroll-y :show-scrollbar="false">
|
||||
<view v-if="loading" class="state-box">
|
||||
<text class="state-text">加载中...</text>
|
||||
</view>
|
||||
<view v-else-if="groupedList.length === 0" class="state-box">
|
||||
<FaIcon name="calendar-days" color="#c0c4cc" :size="40" />
|
||||
<text class="state-text">{{ keyword ? '未找到相关日程' : '暂无日程,点击右下角新建' }}</text>
|
||||
</view>
|
||||
<view v-else class="schedule-list">
|
||||
<view v-for="group in groupedList" :key="group.key" class="group">
|
||||
<text class="group-title">{{ group.label }}</text>
|
||||
<view class="action-row">
|
||||
<view class="action-btn" @tap="onToggleComplete(item)">
|
||||
<FaIcon :name="item.completed ? 'rotate-left' : 'check'" color="#8a94ad" :size="12" />
|
||||
<text>{{ item.completed ? '标为待办' : '标记完成' }}</text>
|
||||
</view>
|
||||
<view class="action-btn" @tap="openEdit(item.id)">
|
||||
<FaIcon name="pen" color="#8a94ad" :size="12" />
|
||||
<text>编辑</text>
|
||||
</view>
|
||||
<view class="action-btn danger" @tap="onDelete(item)">
|
||||
<FaIcon name="trash" color="#f56c6c" :size="12" />
|
||||
<text>删除</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="bottom-space" />
|
||||
</view>
|
||||
<view class="bottom-space" />
|
||||
</scroll-view>
|
||||
|
||||
<view class="fab" @tap="createSchedule">
|
||||
@@ -53,38 +139,153 @@
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { fetchSchedules, toggleScheduleComplete, getScheduleSummary, getRemindChannelLabel, getRemindMinutesLabel } from '@/api/schedule.js'
|
||||
import { formatDate, dayLabel, isToday, startOfDay } from '@/utils/date.js'
|
||||
import {
|
||||
fetchSchedules,
|
||||
deleteSchedule,
|
||||
toggleScheduleComplete,
|
||||
getRemindMinutesLabel
|
||||
} from '@/api/schedule.js'
|
||||
import { pad, startOfDay, isToday, isTomorrow, dayLabel } from '@/utils/date.js'
|
||||
import { isLoggedIn } from '@/utils/auth.js'
|
||||
|
||||
const keyword = ref('')
|
||||
const status = ref('all')
|
||||
/** 周一为一周第一天 */
|
||||
const WEEK_LABELS = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
|
||||
|
||||
const schedules = ref([])
|
||||
const loading = ref(false)
|
||||
/** 默认收缩,仅显示选中日所在周的一行 */
|
||||
const expanded = ref(false)
|
||||
const monthCursor = ref(new Date(new Date().getFullYear(), new Date().getMonth(), 1))
|
||||
const selectedDate = ref(startOfDay(new Date()))
|
||||
|
||||
const tabs = [
|
||||
{ value: 'all', label: '全部' },
|
||||
{ value: 'pending', label: '待办' },
|
||||
{ value: 'done', label: '已完成' }
|
||||
]
|
||||
function dateKey(value) {
|
||||
const d = value instanceof Date ? value : new Date(value)
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
|
||||
}
|
||||
|
||||
const groupedList = computed(() => {
|
||||
const map = new Map()
|
||||
schedules.value.forEach(item => {
|
||||
const key = startOfDay(item.datetime).getTime()
|
||||
if (!map.has(key)) {
|
||||
map.set(key, {
|
||||
key,
|
||||
label: dayLabel(item.datetime),
|
||||
isToday: isToday(item.datetime),
|
||||
items: []
|
||||
})
|
||||
}
|
||||
map.get(key).items.push(item)
|
||||
})
|
||||
return [...map.values()].sort((a, b) => a.key - b.key)
|
||||
const monthLabel = computed(
|
||||
() => `${monthCursor.value.getFullYear()}年${monthCursor.value.getMonth() + 1}月`
|
||||
)
|
||||
|
||||
const selectedKey = computed(() => dateKey(selectedDate.value))
|
||||
|
||||
/** 选中日所在周(周一~周日)的 7 个单元格 */
|
||||
const weekCells = computed(() => {
|
||||
const base = selectedDate.value
|
||||
const offset = (base.getDay() + 6) % 7
|
||||
const cells = []
|
||||
for (let i = 0; i < 7; i++) {
|
||||
const d = new Date(base.getFullYear(), base.getMonth(), base.getDate() - offset + i)
|
||||
cells.push({
|
||||
key: dateKey(d),
|
||||
date: d,
|
||||
day: d.getDate(),
|
||||
inMonth: true,
|
||||
isToday: isToday(d)
|
||||
})
|
||||
}
|
||||
return cells
|
||||
})
|
||||
|
||||
/** 月历 6×7 单元格,含上下月补齐日期 */
|
||||
const monthCells = computed(() => {
|
||||
const year = monthCursor.value.getFullYear()
|
||||
const month = monthCursor.value.getMonth()
|
||||
const offset = (new Date(year, month, 1).getDay() + 6) % 7
|
||||
const start = new Date(year, month, 1 - offset)
|
||||
const cells = []
|
||||
for (let i = 0; i < 42; i++) {
|
||||
const d = new Date(start.getFullYear(), start.getMonth(), start.getDate() + i)
|
||||
cells.push({
|
||||
key: dateKey(d),
|
||||
date: d,
|
||||
day: d.getDate(),
|
||||
inMonth: d.getMonth() === month,
|
||||
isToday: isToday(d)
|
||||
})
|
||||
}
|
||||
return cells
|
||||
})
|
||||
|
||||
const gridCells = computed(() => (expanded.value ? monthCells.value : weekCells.value))
|
||||
|
||||
/** 日程按日期聚合,key 为 YYYY-MM-DD */
|
||||
const dayMap = computed(() => {
|
||||
const map = {}
|
||||
schedules.value.forEach((item) => {
|
||||
if (!item.datetime) return
|
||||
const key = dateKey(new Date(item.datetime))
|
||||
if (!map[key]) map[key] = []
|
||||
map[key].push(item)
|
||||
})
|
||||
return map
|
||||
})
|
||||
|
||||
/** 选中日期的日程,按时间升序 */
|
||||
const dayItems = computed(() => {
|
||||
const list = dayMap.value[selectedKey.value] || []
|
||||
return list.slice().sort((a, b) => a.datetime - b.datetime)
|
||||
})
|
||||
|
||||
/** 本周(周一~周日)范围与日程数 */
|
||||
const weekRange = computed(() => {
|
||||
const now = startOfDay(new Date())
|
||||
const offset = (now.getDay() + 6) % 7
|
||||
const start = new Date(now.getFullYear(), now.getMonth(), now.getDate() - offset)
|
||||
const end = new Date(start.getFullYear(), start.getMonth(), start.getDate() + 7)
|
||||
return { start, end }
|
||||
})
|
||||
|
||||
const weekCount = computed(() => {
|
||||
const { start, end } = weekRange.value
|
||||
return schedules.value.filter((item) => {
|
||||
if (!item.datetime) return false
|
||||
const d = new Date(item.datetime)
|
||||
return d >= start && d < end
|
||||
}).length
|
||||
})
|
||||
|
||||
const heroRangeLabel = computed(() => {
|
||||
const { start, end } = weekRange.value
|
||||
const last = new Date(end.getFullYear(), end.getMonth(), end.getDate() - 1)
|
||||
return `${start.getMonth() + 1}月${start.getDate()}日 - ${last.getMonth() + 1}月${last.getDate()}日`
|
||||
})
|
||||
|
||||
const selectedLabel = computed(() => {
|
||||
const d = selectedDate.value
|
||||
const week = `周${WEEK_LABELS[(d.getDay() + 6) % 7].slice(1)}`
|
||||
if (isToday(d)) return `今天 ${d.getMonth() + 1}月${d.getDate()}日`
|
||||
if (isTomorrow(d)) return `明天 ${d.getMonth() + 1}月${d.getDate()}日`
|
||||
return `${d.getMonth() + 1}月${d.getDate()}日 ${week}`
|
||||
})
|
||||
|
||||
function dotCount(key) {
|
||||
return Math.min(3, (dayMap.value[key] || []).length)
|
||||
}
|
||||
|
||||
function timeText(timestamp) {
|
||||
const d = new Date(timestamp)
|
||||
return `${pad(d.getHours())}:${pad(d.getMinutes())}`
|
||||
}
|
||||
|
||||
function shiftMonth(step) {
|
||||
const cur = monthCursor.value
|
||||
monthCursor.value = new Date(cur.getFullYear(), cur.getMonth() + step, 1)
|
||||
}
|
||||
|
||||
function goToday() {
|
||||
const now = new Date()
|
||||
monthCursor.value = new Date(now.getFullYear(), now.getMonth(), 1)
|
||||
selectedDate.value = startOfDay(now)
|
||||
}
|
||||
|
||||
function pickDay(cell) {
|
||||
selectedDate.value = startOfDay(cell.date)
|
||||
monthCursor.value = new Date(cell.date.getFullYear(), cell.date.getMonth(), 1)
|
||||
// 月历里选完日期后自动收回周栏
|
||||
if (expanded.value) expanded.value = false
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
@@ -100,10 +301,8 @@ onShow(() => {
|
||||
async function loadSchedules() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await fetchSchedules({
|
||||
keyword: keyword.value,
|
||||
status: status.value
|
||||
})
|
||||
// 后端暂不支持按日期区间过滤,取最近一页在端上按月/按天聚合
|
||||
const res = await fetchSchedules({ pageSize: 100 })
|
||||
schedules.value = res.list
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
@@ -112,16 +311,6 @@ async function loadSchedules() {
|
||||
}
|
||||
}
|
||||
|
||||
function clearSearch() {
|
||||
keyword.value = ''
|
||||
loadSchedules()
|
||||
}
|
||||
|
||||
function changeStatus(value) {
|
||||
status.value = value
|
||||
loadSchedules()
|
||||
}
|
||||
|
||||
function createSchedule() {
|
||||
uni.navigateTo({ url: '/pages/tools/schedule/edit' })
|
||||
}
|
||||
@@ -146,175 +335,356 @@ async function onToggleComplete(item) {
|
||||
uni.showToast({ title: '操作失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
|
||||
function onDelete(item) {
|
||||
uni.showModal({
|
||||
title: '删除日程',
|
||||
content: '删除后该日程及其提醒将一并移除,确定继续吗?',
|
||||
confirmText: '删除',
|
||||
cancelText: '取消',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return
|
||||
try {
|
||||
await deleteSchedule(item.id)
|
||||
uni.showToast({ title: '已删除', icon: 'none' })
|
||||
await loadSchedules()
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '删除失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '@/src/styles/page-common.scss';
|
||||
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
height: 100vh;
|
||||
background: $color-bg-page;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
flex-shrink: 0;
|
||||
.body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.body-inner {
|
||||
padding: 20rpx $page-padding-x 0;
|
||||
background: $color-card;
|
||||
box-shadow: $shadow-header;
|
||||
}
|
||||
|
||||
.search-bar {
|
||||
/* ---------- 本周概览横幅 ---------- */
|
||||
.hero-banner {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
height: 72rpx;
|
||||
padding: 0 24rpx;
|
||||
background: $color-bg-page;
|
||||
border-radius: $radius-full;
|
||||
justify-content: space-between;
|
||||
padding: 28rpx 32rpx;
|
||||
border-radius: $radius-lg;
|
||||
background: $hero-gradient;
|
||||
box-shadow: 0 10rpx 28rpx rgba(37, 99, 235, 0.28);
|
||||
}
|
||||
|
||||
.search-input {
|
||||
flex: 1;
|
||||
height: 72rpx;
|
||||
font-size: 28rpx;
|
||||
.hero-info {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.hero-title-row {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 8rpx;
|
||||
}
|
||||
|
||||
.hero-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.hero-unit {
|
||||
font-size: 24rpx;
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
}
|
||||
|
||||
.hero-count {
|
||||
margin-left: 8rpx;
|
||||
font-size: 44rpx;
|
||||
font-weight: 700;
|
||||
color: #ffffff;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.hero-sub {
|
||||
display: block;
|
||||
margin-top: 8rpx;
|
||||
font-size: 23rpx;
|
||||
color: rgba(255, 255, 255, 0.75);
|
||||
}
|
||||
|
||||
.hero-icon {
|
||||
width: 84rpx;
|
||||
height: 84rpx;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.16);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* ---------- 可收缩日历 ---------- */
|
||||
.cal-card {
|
||||
margin-top: 20rpx;
|
||||
padding: 16rpx 16rpx 8rpx;
|
||||
background: $color-card;
|
||||
border-radius: $radius-lg;
|
||||
box-shadow: $shadow-card;
|
||||
}
|
||||
|
||||
.cal-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 4rpx 8rpx 12rpx;
|
||||
}
|
||||
|
||||
.cal-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
color: $color-text;
|
||||
}
|
||||
|
||||
.search-placeholder {
|
||||
color: $color-text-muted;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.search-clear {
|
||||
.cal-head-right {
|
||||
display: flex;
|
||||
padding: 8rpx;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.tabs {
|
||||
display: flex;
|
||||
gap: 16rpx;
|
||||
padding: 20rpx 0 24rpx;
|
||||
}
|
||||
|
||||
.tab {
|
||||
padding: 10rpx 28rpx;
|
||||
border-radius: $radius-full;
|
||||
font-size: 26rpx;
|
||||
color: $color-text-secondary;
|
||||
.cal-nav {
|
||||
width: 52rpx;
|
||||
height: 52rpx;
|
||||
border-radius: 50%;
|
||||
background: $color-bg-page;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&.active {
|
||||
color: $color-primary;
|
||||
&:active {
|
||||
background: $color-primary-bg;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
.list-scroll {
|
||||
.cal-today-btn {
|
||||
height: 52rpx;
|
||||
padding: 0 20rpx;
|
||||
border-radius: $radius-full;
|
||||
background: $color-primary-bg;
|
||||
color: $color-primary;
|
||||
font-size: 24rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
&:active {
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
|
||||
.cal-week {
|
||||
display: flex;
|
||||
padding: 4rpx 0 8rpx;
|
||||
}
|
||||
|
||||
.cal-week-item {
|
||||
flex: 1;
|
||||
height: 0;
|
||||
text-align: center;
|
||||
font-size: 23rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.schedule-list {
|
||||
padding: 24rpx $page-padding-x 0;
|
||||
.cal-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.group {
|
||||
margin-bottom: 28rpx;
|
||||
.cal-cell {
|
||||
flex: 0 0 14.2857%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 6rpx 0;
|
||||
}
|
||||
|
||||
.group-title {
|
||||
display: block;
|
||||
font-size: 26rpx;
|
||||
.cal-day {
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 27rpx;
|
||||
color: $color-text;
|
||||
box-sizing: border-box;
|
||||
|
||||
&.dim {
|
||||
color: $color-text-muted;
|
||||
opacity: 0.55;
|
||||
}
|
||||
|
||||
&.today {
|
||||
color: $color-primary;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
&.selected {
|
||||
background: $color-primary;
|
||||
color: #ffffff;
|
||||
font-weight: 600;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.cal-dots {
|
||||
height: 12rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4rpx;
|
||||
}
|
||||
|
||||
.cal-dot {
|
||||
width: 8rpx;
|
||||
height: 8rpx;
|
||||
border-radius: 50%;
|
||||
background: $color-primary;
|
||||
|
||||
&.on {
|
||||
background: #ffffff;
|
||||
}
|
||||
}
|
||||
|
||||
.cal-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8rpx;
|
||||
padding: 14rpx 0 10rpx;
|
||||
font-size: 24rpx;
|
||||
color: $color-text-muted;
|
||||
|
||||
&:active {
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- 当日日程 ---------- */
|
||||
.day-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin: 28rpx 0 16rpx;
|
||||
}
|
||||
|
||||
.day-title {
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
color: $color-text-secondary;
|
||||
margin-bottom: 16rpx;
|
||||
padding-left: 4rpx;
|
||||
color: $color-text;
|
||||
}
|
||||
|
||||
.schedule-card {
|
||||
.day-count {
|
||||
font-size: 24rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.sched-card {
|
||||
@include card;
|
||||
margin-bottom: 16rpx;
|
||||
overflow: hidden;
|
||||
|
||||
&.done .schedule-title {
|
||||
&.done .sched-content {
|
||||
text-decoration: line-through;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
}
|
||||
|
||||
.schedule-main {
|
||||
padding: 24rpx 24rpx 16rpx;
|
||||
.sched-main {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
padding: 24rpx 8rpx;
|
||||
|
||||
&:active {
|
||||
background: $color-bg-page;
|
||||
}
|
||||
}
|
||||
|
||||
.schedule-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
width: 12rpx;
|
||||
height: 12rpx;
|
||||
border-radius: 50%;
|
||||
.sched-left {
|
||||
width: 128rpx;
|
||||
flex-shrink: 0;
|
||||
|
||||
&.pending {
|
||||
background: $color-primary;
|
||||
}
|
||||
|
||||
&.done {
|
||||
background: #67c23a;
|
||||
}
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6rpx;
|
||||
}
|
||||
|
||||
.schedule-title {
|
||||
flex: 1;
|
||||
font-size: 30rpx;
|
||||
.sched-day {
|
||||
font-size: 22rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.sched-time {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: $color-text;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.schedule-meta {
|
||||
.sched-sep {
|
||||
width: 1rpx;
|
||||
margin: 4rpx 20rpx;
|
||||
background: $color-divider;
|
||||
}
|
||||
|
||||
.sched-right {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.sched-title-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.sched-content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 28rpx;
|
||||
line-height: 1.5;
|
||||
color: $color-text;
|
||||
word-break: break-all;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.status-chip {
|
||||
@include chip;
|
||||
flex-shrink: 0;
|
||||
|
||||
&.done {
|
||||
background: #ecfdf5;
|
||||
color: $color-success;
|
||||
}
|
||||
}
|
||||
|
||||
.sched-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 8rpx;
|
||||
font-size: 24rpx;
|
||||
color: $color-text-muted;
|
||||
padding-left: 24rpx;
|
||||
margin-top: 8rpx;
|
||||
}
|
||||
|
||||
.channel-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 10rpx;
|
||||
padding-left: 24rpx;
|
||||
margin-top: 12rpx;
|
||||
}
|
||||
|
||||
.channel-mini {
|
||||
font-size: 22rpx;
|
||||
color: $color-primary;
|
||||
background: $color-primary-bg;
|
||||
padding: 4rpx 12rpx;
|
||||
border-radius: $radius-sm;
|
||||
}
|
||||
|
||||
.remind-text {
|
||||
font-size: 22rpx;
|
||||
margin-top: 10rpx;
|
||||
font-size: 23rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
@@ -329,61 +699,39 @@ async function onToggleComplete(item) {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8rpx;
|
||||
padding: 20rpx 0;
|
||||
padding: 18rpx 0;
|
||||
font-size: 24rpx;
|
||||
color: $color-text-muted;
|
||||
|
||||
& + & {
|
||||
border-left: 1rpx solid $color-divider;
|
||||
}
|
||||
|
||||
&.danger {
|
||||
color: #f56c6c;
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
color: #c0c4cc;
|
||||
}
|
||||
color: $color-text-secondary;
|
||||
|
||||
&:active {
|
||||
background: $color-bg-page;
|
||||
}
|
||||
}
|
||||
|
||||
.state-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 160rpx 48rpx;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.state-text {
|
||||
font-size: 26rpx;
|
||||
color: $color-text-muted;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.fab {
|
||||
position: fixed;
|
||||
right: 40rpx;
|
||||
bottom: calc(40rpx + env(safe-area-inset-bottom));
|
||||
width: 104rpx;
|
||||
height: 104rpx;
|
||||
border-radius: 50%;
|
||||
background: $color-primary;
|
||||
box-shadow: 0 8rpx 24rpx rgba(60, 156, 255, 0.35);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&:active {
|
||||
background: $color-primary-dark;
|
||||
&.danger {
|
||||
color: #f56c6c;
|
||||
}
|
||||
}
|
||||
|
||||
.bottom-space {
|
||||
height: 160rpx;
|
||||
}
|
||||
|
||||
.fab {
|
||||
position: fixed;
|
||||
right: 40rpx;
|
||||
bottom: calc(60rpx + env(safe-area-inset-bottom));
|
||||
width: 104rpx;
|
||||
height: 104rpx;
|
||||
border-radius: 50%;
|
||||
background: $color-primary;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: 0 10rpx 28rpx rgba(37, 99, 235, 0.35);
|
||||
z-index: 20;
|
||||
|
||||
&:active {
|
||||
opacity: 0.9;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,441 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<!-- 本周概览 -->
|
||||
<view class="hero-card">
|
||||
<view class="hero-left">
|
||||
<text class="hero-sub">查看每周日程提醒</text>
|
||||
<view class="hero-num-row">
|
||||
<text class="hero-label">本周日程(条)</text>
|
||||
<text class="hero-num">{{ weekItems.length }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="hero-illus">
|
||||
<FaIcon name="bell" color="#ffffff" :size="26" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 周历条 -->
|
||||
<view class="week-card">
|
||||
<view
|
||||
v-for="d in weekDays"
|
||||
:key="d.key"
|
||||
class="week-item"
|
||||
@tap="pickWeekDay(d)"
|
||||
>
|
||||
<text class="week-name">{{ d.name }}</text>
|
||||
<view
|
||||
class="week-date"
|
||||
:class="{ today: d.isToday, selected: d.key === selectedKey }"
|
||||
>{{ d.day }}</view>
|
||||
<view class="week-dot" :class="{ show: d.count > 0 }" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 我的日程 -->
|
||||
<view class="section-head">
|
||||
<text class="section-title">我的日程({{ shownItems.length }})</text>
|
||||
<view class="range-tabs">
|
||||
<text class="range-tab" :class="{ active: range === 'day' }" @tap="showToday">今日</text>
|
||||
<text class="range-sep">|</text>
|
||||
<text class="range-tab" :class="{ active: range === 'week' }" @tap="range = 'week'">本周</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<u-empty
|
||||
v-if="!loading && shownItems.length === 0"
|
||||
mode="list"
|
||||
:icon-size="72"
|
||||
:text="range === 'week' ? '本周暂无日程提醒' : '当天暂无日程提醒'"
|
||||
/>
|
||||
<view v-else class="rem-list">
|
||||
<view v-for="item in shownItems" :key="item.id" class="rem-card" @tap="openDetail(item.id)">
|
||||
<view class="rem-time">
|
||||
<text class="rem-day">{{ shortDayLabel(item.datetime) }}</text>
|
||||
<text class="rem-clock">{{ timeText(item.datetime) }}</text>
|
||||
</view>
|
||||
<view class="rem-body">
|
||||
<text class="rem-title">{{ item.content || item.title }}</text>
|
||||
<view class="rem-meta">
|
||||
<FaIcon name="clock" color="#94a3b8" :size="11" />
|
||||
<text class="rem-meta-text">{{ fullTime(item.datetime) }}</text>
|
||||
</view>
|
||||
<view class="rem-meta">
|
||||
<FaIcon name="bell" color="#94a3b8" :size="11" />
|
||||
<text class="rem-meta-text">{{ remindLine(item) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="bottom-space" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { fetchSchedules, getRemindChannelLabel, getRemindMinutesLabel } from '@/api/schedule.js'
|
||||
import { pad, startOfDay, isToday } from '@/utils/date.js'
|
||||
import { isLoggedIn } from '@/utils/auth.js'
|
||||
|
||||
/** 周一为一周第一天 */
|
||||
const WEEK_LABELS = ['一', '二', '三', '四', '五', '六', '日']
|
||||
|
||||
const schedules = ref([])
|
||||
const loading = ref(false)
|
||||
const range = ref('day')
|
||||
const selectedDate = ref(startOfDay(new Date()))
|
||||
|
||||
function dateKey(value) {
|
||||
const d = value instanceof Date ? value : new Date(value)
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
|
||||
}
|
||||
|
||||
function startOfWeek(base = new Date()) {
|
||||
const d = startOfDay(base)
|
||||
const offset = (d.getDay() + 6) % 7
|
||||
return new Date(d.getFullYear(), d.getMonth(), d.getDate() - offset)
|
||||
}
|
||||
|
||||
const weekStart = computed(() => startOfWeek(selectedDate.value))
|
||||
const selectedKey = computed(() => dateKey(selectedDate.value))
|
||||
|
||||
/** 只保留已设置提醒渠道的日程 */
|
||||
const reminders = computed(() =>
|
||||
schedules.value.filter((item) => item.remindChannels && item.remindChannels.length > 0)
|
||||
)
|
||||
|
||||
/** 提醒按日期聚合,key 为 YYYY-MM-DD */
|
||||
const reminderMap = computed(() => {
|
||||
const map = {}
|
||||
reminders.value.forEach((item) => {
|
||||
if (!item.datetime) return
|
||||
const key = dateKey(new Date(item.datetime))
|
||||
if (!map[key]) map[key] = []
|
||||
map[key].push(item)
|
||||
})
|
||||
return map
|
||||
})
|
||||
|
||||
const weekDays = computed(() => {
|
||||
const base = weekStart.value
|
||||
return Array.from({ length: 7 }, (_, i) => {
|
||||
const d = new Date(base.getFullYear(), base.getMonth(), base.getDate() + i)
|
||||
const key = dateKey(d)
|
||||
return {
|
||||
key,
|
||||
date: d,
|
||||
name: '周' + WEEK_LABELS[i],
|
||||
day: d.getDate(),
|
||||
isToday: isToday(d),
|
||||
count: (reminderMap.value[key] || []).length
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
/** 本周(周一~周日)的提醒,按时间升序 */
|
||||
const weekItems = computed(() => {
|
||||
const base = weekStart.value
|
||||
const startTs = base.getTime()
|
||||
const endTs = startTs + 7 * 24 * 60 * 60 * 1000
|
||||
return reminders.value
|
||||
.filter((item) => item.datetime >= startTs && item.datetime < endTs)
|
||||
.sort((a, b) => a.datetime - b.datetime)
|
||||
})
|
||||
|
||||
const shownItems = computed(() => {
|
||||
if (range.value === 'week') return weekItems.value
|
||||
return (reminderMap.value[selectedKey.value] || [])
|
||||
.slice()
|
||||
.sort((a, b) => a.datetime - b.datetime)
|
||||
})
|
||||
|
||||
function timeText(timestamp) {
|
||||
const d = new Date(timestamp)
|
||||
return `${pad(d.getHours())}:${pad(d.getMinutes())}`
|
||||
}
|
||||
|
||||
function fullTime(timestamp) {
|
||||
const d = new Date(timestamp)
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${timeText(timestamp)}`
|
||||
}
|
||||
|
||||
function shortDayLabel(timestamp) {
|
||||
if (isToday(timestamp)) return '今天'
|
||||
const d = new Date(timestamp)
|
||||
return '周' + WEEK_LABELS[(d.getDay() + 6) % 7]
|
||||
}
|
||||
|
||||
function remindLine(item) {
|
||||
const channels = (item.remindChannels || [])
|
||||
.map((ch) => getRemindChannelLabel(ch))
|
||||
.join('、')
|
||||
const parts = [getRemindMinutesLabel(item.remindMinutes)]
|
||||
if (channels) parts.push(channels)
|
||||
return parts.join(' · ')
|
||||
}
|
||||
|
||||
function pickWeekDay(d) {
|
||||
selectedDate.value = startOfDay(d.date)
|
||||
range.value = 'day'
|
||||
}
|
||||
|
||||
function showToday() {
|
||||
selectedDate.value = startOfDay(new Date())
|
||||
range.value = 'day'
|
||||
}
|
||||
|
||||
function openDetail(id) {
|
||||
uni.navigateTo({ url: `/pages/tools/schedule/detail?id=${id}` })
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
return
|
||||
}
|
||||
loadReminders()
|
||||
})
|
||||
|
||||
async function loadReminders() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await fetchSchedules({ pageSize: 100 })
|
||||
schedules.value = res.list
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '@/src/styles/page-common.scss';
|
||||
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
padding: 24rpx $page-padding-x 0;
|
||||
background: $color-bg-page;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* ---------- 本周概览 ---------- */
|
||||
.hero-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 32rpx;
|
||||
border-radius: $radius-lg;
|
||||
background: linear-gradient(135deg, #1e3a8a, #2563eb);
|
||||
box-shadow: 0 12rpx 30rpx rgba(37, 99, 235, 0.28);
|
||||
}
|
||||
|
||||
.hero-left {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.hero-sub {
|
||||
font-size: 24rpx;
|
||||
color: rgba(255, 255, 255, 0.78);
|
||||
}
|
||||
|
||||
.hero-num-row {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 16rpx;
|
||||
margin-top: 12rpx;
|
||||
}
|
||||
|
||||
.hero-label {
|
||||
font-size: 28rpx;
|
||||
color: #ffffff;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.hero-num {
|
||||
font-size: 56rpx;
|
||||
font-weight: 700;
|
||||
color: #ffffff;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.hero-illus {
|
||||
flex-shrink: 0;
|
||||
width: 96rpx;
|
||||
height: 96rpx;
|
||||
border-radius: 28rpx;
|
||||
background: rgba(255, 255, 255, 0.18);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
/* ---------- 周历条 ---------- */
|
||||
.week-card {
|
||||
display: flex;
|
||||
margin-top: 20rpx;
|
||||
padding: 20rpx 8rpx 16rpx;
|
||||
background: $color-card;
|
||||
border-radius: $radius-lg;
|
||||
box-shadow: $shadow-card;
|
||||
}
|
||||
|
||||
.week-item {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 8rpx;
|
||||
}
|
||||
|
||||
.week-name {
|
||||
font-size: 22rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.week-date {
|
||||
width: 56rpx;
|
||||
height: 56rpx;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 26rpx;
|
||||
color: $color-text;
|
||||
|
||||
&.today {
|
||||
color: $color-primary;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
&.selected {
|
||||
background: $color-primary;
|
||||
color: #ffffff;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.week-dot {
|
||||
width: 8rpx;
|
||||
height: 8rpx;
|
||||
border-radius: 50%;
|
||||
background: transparent;
|
||||
|
||||
&.show {
|
||||
background: $color-primary;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- 我的日程 ---------- */
|
||||
.section-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin: 32rpx 0 16rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
color: $color-text;
|
||||
}
|
||||
|
||||
.range-tabs {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14rpx;
|
||||
}
|
||||
|
||||
.range-tab {
|
||||
font-size: 26rpx;
|
||||
color: $color-text-muted;
|
||||
|
||||
&.active {
|
||||
color: $color-primary;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.range-sep {
|
||||
font-size: 22rpx;
|
||||
color: $color-border;
|
||||
}
|
||||
|
||||
.rem-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.rem-card {
|
||||
@include card;
|
||||
display: flex;
|
||||
gap: 24rpx;
|
||||
padding: 26rpx 24rpx;
|
||||
margin-bottom: 16rpx;
|
||||
|
||||
&:active {
|
||||
background: $color-bg-page;
|
||||
}
|
||||
}
|
||||
|
||||
.rem-time {
|
||||
flex-shrink: 0;
|
||||
width: 110rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6rpx;
|
||||
}
|
||||
|
||||
.rem-day {
|
||||
font-size: 24rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.rem-clock {
|
||||
font-size: 32rpx;
|
||||
font-weight: 700;
|
||||
color: $color-text;
|
||||
}
|
||||
|
||||
.rem-body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10rpx;
|
||||
border-left: 1rpx solid $color-divider;
|
||||
padding-left: 24rpx;
|
||||
}
|
||||
|
||||
.rem-title {
|
||||
font-size: 29rpx;
|
||||
font-weight: 600;
|
||||
color: $color-text;
|
||||
word-break: break-all;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.rem-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10rpx;
|
||||
}
|
||||
|
||||
.rem-meta-text {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 23rpx;
|
||||
color: $color-text-muted;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.bottom-space {
|
||||
height: 60rpx;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user