refactor pages struct

This commit is contained in:
Timi
2026-01-28 14:11:54 +08:00
parent 8adc28ae9c
commit 965743be38
73 changed files with 234 additions and 176 deletions

View File

@ -0,0 +1,8 @@
{
"usingComponents": {
"calendar": "/components/calendar/index",
"t-navbar": "tdesign-miniprogram/navbar/navbar",
"journal-detail-popup": "/components/journal-detail-popup/index"
},
"navigationStyle": "custom"
}

View File

@ -0,0 +1,24 @@
/* pages/main/journal/date/index.less */
.container {
width: 100%;
height: 100vh;
position: fixed;
overflow: hidden;
background: var(--theme-bg);
.loading {
top: 50%;
left: 50%;
z-index: 1000;
position: fixed;
transform: translate(-50%, -50%);
.loading-text {
color: var(--theme-text-secondary);
padding: 24rpx 48rpx;
background: var(--theme-bg-card);
border-radius: 8rpx;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, .15);
}
}
}

View File

@ -0,0 +1,90 @@
// pages/main/journal/date/index.ts
import { Journal, JournalPageType } from "../../../../types/Journal";
import Time from "../../../../utils/Time";
import { JournalApi } from "../../../../api/JournalApi";
interface JournalDateData {
// 存储每个日期的日记 id 列表
isLoading: boolean;
journalMap: Record<string, number[]>;
popupIds: number[];
popupVisible: boolean;
}
Page({
data: <JournalDateData>{
isLoading: true,
journalMap: {},
popupIds: [],
popupVisible: false,
},
async onLoad() {
await this.loadJournals();
},
/** 加载所有日记 */
async loadJournals() {
this.setData({ isLoading: true });
try {
const pageResult = await JournalApi.getList({
index: 0,
size: 9007199254740992,
type: JournalPageType.PREVIEW
});
const list: Journal[] = pageResult.list || [];
// 按日期分组,只存储 id
const journalMap: Record<string, number[]> = {};
list.forEach((journal: any) => {
const dateKey = Time.toDate(journal.createdAt);
if (!journalMap[dateKey]) {
journalMap[dateKey] = [];
}
journalMap[dateKey].push(journal.id);
});
// 按 id 倒序排序每天的日记
Object.keys(journalMap).forEach(dateKey => {
journalMap[dateKey].sort((a, b) => b - a);
});
this.setData({
journalMap,
isLoading: false
});
} catch (err: any) {
wx.showToast({
title: err.message || "加载失败",
icon: "error"
});
this.setData({ isLoading: false });
}
},
/** 日期选择事件(来自 calendar 组件) */
onDateSelect(e: WechatMiniprogram.CustomEvent) {
const { date } = e.detail;
const journalIds = this.data.journalMap[date];
if (!journalIds || journalIds.length === 0) {
wx.showToast({
title: "该日期无日记",
icon: "none"
});
return;
}
// 调用接口获取详情
this.loadJournalsByIds(journalIds);
},
/** 根据 id 列表加载日记详情 */
async loadJournalsByIds(ids: number[]) {
this.setData({
popupIds: ids,
popupVisible: true
});
wx.hideLoading();
},
/** 关闭详情 */
closeDetail() {
this.setData({
popupVisible: false,
popupIds: []
});
}
});

View File

@ -0,0 +1,17 @@
<!--pages/main/journal/date/index.wxml-->
<t-navbar title="日期查找" placeholder left-arrow />
<view class="container">
<!-- 日历视图 -->
<calendar journal-map="{{journalMap}}" bind:dateselect="onDateSelect" />
<!-- 加载状态 -->
<view wx:if="{{isLoading}}" class="loading">
<view class="loading-text">加载中...</view>
</view>
</view>
<!-- 详情面板 -->
<journal-detail-popup
visible="{{popupVisible}}"
ids="{{popupIds}}"
mode="DATE"
bind:close="closeDetail"
/>

View File

@ -0,0 +1,12 @@
{
"component": true,
"usingComponents": {
"t-icon": "tdesign-miniprogram/icon/icon",
"t-input": "tdesign-miniprogram/input/input",
"t-radio": "tdesign-miniprogram/radio/radio",
"t-button": "tdesign-miniprogram/button/button",
"t-navbar": "tdesign-miniprogram/navbar/navbar",
"t-dialog": "tdesign-miniprogram/dialog/dialog",
"t-radio-group": "tdesign-miniprogram/radio-group/radio-group"
}
}

View File

@ -0,0 +1,172 @@
/* pages/main/journal/editor/index.wxss */
.container {
.content {
width: calc(100% - 64px);
padding: 0 32px 32px 32px;
display: flex;
align-items: center;
flex-direction: column;
.loading {
padding: 64px 0;
text-align: center;
color: var(--theme-text-secondary);
}
.label {
color: var(--theme-text-secondary);
}
.section {
width: 100%;
margin-top: 1.5rem;
&.type {
display: flex;
.radio {
background: transparent;
margin-right: 1em;
}
}
&.time {
display: flex;
.picker {
margin-right: .25rem;
}
}
&.media {
.gallery {
gap: 10rpx;
display: grid;
grid-template-columns: repeat(3, 1fr);
.item {
width: 200rpx;
height: 200rpx;
position: relative;
overflow: hidden;
background: var(--theme-bg-card);
box-shadow: 1px 1px 6px var(--theme-shadow-light);
border-radius: 2rpx;
&.add {
color: var(--theme-wx);
margin: 0;
font-size: 80rpx;
background: transparent;
&::after {
border-radius: 0;
}
}
.thumbnail {
width: 200rpx;
height: 200rpx;
display: block;
}
.video-container {
position: relative;
.play-icon {
top: 50%;
left: 50%;
color: rgba(255, 255, 255, .8);
z-index: 2;
position: absolute;
font-size: 128rpx;
transform: translate(-50%, -50%);
text-shadow: 4rpx 4rpx 0 rgba(0, 0, 0, .5);
pointer-events: none;
}
}
.delete {
top: 10rpx;
right: 10rpx;
color: rgba(255, 255, 255, .6);
z-index: 3;
position: absolute;
font-size: 45rpx;
&::after {
content: "";
top: 0;
width: 100%;
height: 100%;
z-index: -1;
position: absolute;
background: rgba(0, 0, 0, .6);
border-radius: 50%;
}
}
.new-badge {
top: 10rpx;
left: 10rpx;
color: var(--theme-wx);
z-index: 3;
display: flex;
position: absolute;
font-size: 45rpx;
text-shadow: 4rpx 4rpx 0 rgba(0, 0, 0, .5);
}
}
}
}
}
.uploading {
width: 100%;
margin-top: 1rem;
.progress {
margin-bottom: 8rpx;
}
.text {
color: var(--theme-text-secondary);
display: flex;
font-size: .8rem;
justify-content: space-between;
}
}
.ctrl {
width: 100%;
display: flex;
margin-top: 1rem;
align-items: center;
.clear,
.delete {
width: 200rpx;
}
.submit,
.save {
flex: 1;
margin-left: 12rpx;
}
}
}
}
.delete-dialog {
padding: 16rpx 0;
.tips {
color: var(--theme-text-secondary);
font-size: 28rpx;
line-height: 1.5;
margin-bottom: 24rpx;
}
}

View File

@ -0,0 +1,606 @@
// pages/main/journal/editor/index.ts
import Events from "../../../../utils/Events";
import Time from "../../../../utils/Time";
import Toolkit from "../../../../utils/Toolkit";
import config from "../../../../config/index";
import { Location, MediaItem, MediaItemType, WechatMediaItem } from "../../../../types/UI";
import { JournalType } from "../../../../types/Journal";
import { MediaAttachType, PreviewImageMetadata } from "../../../../types/Attachment";
import IOSize, { Unit } from "../../../../utils/IOSize";
import { JournalApi } from "../../../../api/JournalApi";
interface JournalEditorData {
/** 模式create 或 edit */
mode: "create" | "edit";
/** 日记 ID编辑模式 */
id?: number;
/** 想法 */
idea: string;
/** 日期 */
date: string;
/** 时间 */
time: string;
/** 类型 */
type: JournalType;
/** 媒体列表(创建模式:新选择的媒体;编辑模式:现有附件) */
mediaList: (MediaItem | WechatMediaItem)[];
/** 新媒体列表(仅编辑模式使用) */
newMediaList: WechatMediaItem[];
/** 位置 */
location?: Location;
/** 是否授权定位 */
isAuthLocation: boolean;
/** 是否正在加载(编辑模式) */
isLoading: boolean;
/** 是否正在保存/提交 */
isSaving: boolean;
/** 已上传大小 */
uploaded: string;
/** 总大小 */
uploadTotal: string;
/** 上传速度 */
uploadSpeed: string;
/** 上传进度 */
uploadProgress: number;
/** 媒体类型枚举 */
mediaItemTypeEnum: any;
/** 删除对话框可见性 */
deleteDialogVisible: boolean;
/** 删除确认文本 */
deleteConfirmText: string;
}
Page({
data: <JournalEditorData>{
mode: "create",
id: undefined,
idea: "",
date: "2025-06-28",
time: "16:00",
type: JournalType.NORMAL,
mediaList: [],
newMediaList: [],
location: undefined,
isSaving: false,
isLoading: false,
uploaded: "0",
uploadTotal: "0 MB",
uploadSpeed: "0 MB / s",
uploadProgress: 0,
mediaItemTypeEnum: {
...MediaItemType
},
isAuthLocation: false,
deleteDialogVisible: false,
deleteConfirmText: ""
},
async onLoad(options: any) {
// 授权定位
const setting = await wx.getSetting();
wx.setStorageSync("isAuthLocation", setting.authSetting["scope.userLocation"] || false);
let isAuthLocation = JSON.parse(wx.getStorageSync("isAuthLocation"));
this.setData({ isAuthLocation });
if (!isAuthLocation) {
wx.authorize({
scope: "scope.userLocation"
}).then(() => {
isAuthLocation = true;
this.setData({ isAuthLocation });
});
}
// 判断模式:有 ID 是编辑,无 ID 是创建
const id = options.id ? parseInt(options.id) : undefined;
if (id) {
// 编辑模式
this.setData({
mode: "edit",
id,
isLoading: true
});
await this.loadJournalDetail(id);
} else {
// 创建模式
this.setData({
mode: "create",
isLoading: false
});
// 设置当前时间
const unixTime = new Date().getTime();
this.setData({
date: Time.toDate(unixTime),
time: Time.toTime(unixTime)
});
// 获取默认定位
this.getDefaultLocation();
}
},
/** 获取默认定位(创建模式) */
getDefaultLocation() {
wx.getLocation({
type: "gcj02"
}).then(resp => {
this.setData({
location: {
lat: resp.latitude,
lng: resp.longitude
}
});
const argLoc = `location=${this.data.location!.lat},${this.data.location!.lng}`;
const argKey = "key=WW5BZ-J4LCM-UIT6I-65MXY-Z5HDT-VRFFU";
wx.request({
url: `https://apis.map.qq.com/ws/geocoder/v1/?${argLoc}&${argKey}`,
success: res => {
if (res.statusCode === 200) {
this.setData({
location: {
lat: this.data.location!.lat,
lng: this.data.location!.lng,
text: (res.data as any).result?.formatted_addresses?.recommend
}
});
}
}
});
}).catch(() => {
// 忽略定位失败
});
},
/** 加载日记详情(编辑模式) */
async loadJournalDetail(id: number) {
try {
const journal = await JournalApi.getDetail(id);
const items = journal.items || [];
const thumbItems = items.filter((item) => item.attachType === MediaAttachType.THUMB);
const mediaList: MediaItem[] = thumbItems.map((thumbItem) => {
const metadata = (typeof thumbItem.metadata === "string" ? JSON.parse(thumbItem.metadata) : thumbItem.metadata) as PreviewImageMetadata;
const thumbURL = `${config.url}/attachment/read/${thumbItem.mongoId}`;
const sourceURL = `${config.url}/attachment/read/${metadata.sourceMongoId}`;
const isVideo = metadata.sourceMimeType?.startsWith("video/");
return {
type: isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
thumbURL,
sourceURL,
size: thumbItem.size || 0,
attachmentId: thumbItem.id
} as MediaItem;
});
this.setData({
idea: journal.idea || "",
date: Time.toDate(journal.createdAt),
time: Time.toTime(journal.createdAt),
type: journal.type,
location: journal.location ? {
lat: journal.lat,
lng: journal.lng,
text: journal.location
} : undefined,
mediaList,
isLoading: false
});
wx.hideLoading();
} catch (err: any) {
wx.hideLoading();
wx.showToast({
title: err.message || "加载失败",
icon: "error"
});
setTimeout(() => {
wx.navigateBack();
}, 1500);
}
},
/** 改变类型 */
onChangeType(e: any) {
const { value } = e.detail;
this.setData({ type: value });
},
/** 选择位置 */
async chooseLocation() {
try {
const location = await wx.chooseLocation({});
this.setData({
location: {
lat: location.latitude,
lng: location.longitude,
text: location.name
}
});
} catch (err) {
// 用户取消选择
}
},
/** 新增附件 */
addMedia() {
const that = this;
wx.chooseMedia({
mediaType: ["mix"],
sourceType: ["album", "camera"],
camera: "back",
success(res) {
wx.showLoading({
title: "加载中..",
mask: true
});
const tempFiles = res.tempFiles;
const newMedia = tempFiles.map(item => {
return {
type: (<any>MediaItemType)[item.fileType.toUpperCase()],
path: item.tempFilePath,
thumbPath: item.thumbTempFilePath,
size: item.size,
duration: item.duration,
raw: item
} as WechatMediaItem;
});
if (that.data.mode === "create") {
// 创建模式:直接添加到 mediaList
that.setData({
mediaList: [...that.data.mediaList, ...newMedia]
});
} else {
// 编辑模式:添加到 newMediaList
that.setData({
newMediaList: [...that.data.newMediaList, ...newMedia]
});
}
wx.hideLoading();
}
});
},
/** 清空媒体(仅创建模式) */
clearMedia() {
wx.showModal({
title: "提示",
content: "确认清空已选照片或视频吗?",
confirmText: "清空",
confirmColor: "#E64340",
cancelText: "取消",
success: res => {
if (res.confirm) {
this.setData({
mediaList: []
});
}
}
});
},
/** 预览附件 */
preview(e: WechatMiniprogram.BaseEvent) {
const isNewMedia = e.currentTarget.dataset.newMedia;
const index = e.currentTarget.dataset.index;
if (this.data.mode === "create") {
// 创建模式:只有 mediaList
const sources = (this.data.mediaList as WechatMediaItem[]).map(item => ({
url: item.path,
type: item.type.toLowerCase()
}));
const total = sources.length;
const startIndex = Math.max(0, index - 25);
const endIndex = Math.min(total, startIndex + 50);
const newCurrentIndex = index - startIndex;
wx.previewMedia({
current: newCurrentIndex,
sources: sources.slice(startIndex, endIndex) as WechatMiniprogram.MediaSource[]
});
} else {
// 编辑模式mediaList + newMediaList
const sources = (this.data.mediaList as MediaItem[]).map(item => ({
url: item.sourceURL,
type: item.type
}));
const newSources = this.data.newMediaList.map(item => ({
url: item.path,
type: item.type
}));
const allSources = [...sources, ...newSources];
const itemIndex = isNewMedia ? this.data.mediaList.length + index : index;
const total = allSources.length;
const startIndex = Math.max(0, itemIndex - 25);
const endIndex = Math.min(total, startIndex + 50);
const newCurrentIndex = itemIndex - startIndex;
wx.previewMedia({
current: newCurrentIndex,
sources: allSources.slice(startIndex, endIndex) as WechatMiniprogram.MediaSource[]
});
}
},
/** 删除附件 */
deleteMedia(e: WechatMiniprogram.BaseEvent) {
const isNewMedia = e.currentTarget.dataset.newMedia;
const index = e.currentTarget.dataset.index;
if (this.data.mode === "create") {
// 创建模式:从 mediaList 删除
const mediaList = [...this.data.mediaList];
mediaList.splice(index, 1);
this.setData({ mediaList });
} else {
// 编辑模式:根据标识删除
if (isNewMedia) {
const newMediaList = [...this.data.newMediaList];
newMediaList.splice(index, 1);
this.setData({ newMediaList });
} else {
const mediaList = [...this.data.mediaList];
mediaList.splice(index, 1);
this.setData({ mediaList });
}
}
},
/** 取消 */
cancel() {
if (this.data.mode === "create") {
wx.switchTab({
url: "/pages/main/tabs/journal/index"
});
} else {
wx.navigateBack();
}
},
/** 删除记录(仅编辑模式) */
deleteJournal() {
this.setData({
deleteDialogVisible: true,
deleteConfirmText: ""
});
},
/** 取消删除 */
cancelDelete() {
this.setData({
deleteDialogVisible: false,
deleteConfirmText: ""
});
},
/** 确认删除 */
confirmDelete() {
const inputText = this.data.deleteConfirmText.trim();
if (inputText !== "确认删除") {
wx.showToast({
title: "输入不匹配",
icon: "error"
});
return;
}
this.setData({
deleteDialogVisible: false
});
this.executeDelete();
},
/** 执行删除 */
async executeDelete() {
try {
await JournalApi.delete(this.data.id!);
Events.emit("JOURNAL_REFRESH");
Events.emit("JOURNAL_LIST_REFRESH");
wx.showToast({
title: "删除成功",
icon: "success"
});
setTimeout(() => {
wx.navigateBack();
}, 1000);
} catch (error) {
console.error("删除日记失败:", error);
}
},
/** 提交/保存 */
submit() {
if (this.data.mode === "create") {
this.createJournal();
} else {
this.updateJournal();
}
},
/** 创建日记 */
async createJournal() {
const handleFail = () => {
wx.showToast({ title: "上传失败", icon: "error" });
this.setData({
isSaving: false
});
};
this.setData({
isSaving: true
});
try {
// 获取 openId
const getOpenId = new Promise<string>((resolve, reject) => {
wx.login({
success: async (res) => {
if (res.code) {
try {
const openId = await JournalApi.getOpenId(res.code);
resolve(openId);
} catch (error) {
reject(new Error("获取 openId 失败"));
}
} else {
reject(new Error("获取登录凭证失败"));
}
},
fail: () => reject(new Error("登录失败"))
});
});
// 文件上传
const uploadFiles = this.uploadMediaFiles(this.data.mediaList as WechatMediaItem[]);
// 并行执行获取 openId 和文件上传
const [openId, tempFileIds] = await Promise.all([getOpenId, uploadFiles]);
await JournalApi.create({
idea: this.data.idea,
type: this.data.type,
lat: this.data.location?.lat,
lng: this.data.location?.lng,
location: this.data.location?.text,
pusher: openId,
createdAt: Date.parse(`${this.data.date} ${this.data.time}`),
tempFileIds
});
Events.emit("JOURNAL_REFRESH");
wx.showToast({ title: "提交成功", icon: "success" });
this.setData({
idea: "",
mediaList: [],
isSaving: false,
uploaded: "0",
uploadTotal: "0 MB",
uploadProgress: 0
});
await Toolkit.sleep(1000);
wx.switchTab({
url: "/pages/main/tabs/journal/index"
});
} catch (error) {
console.error("创建日记失败:", error);
handleFail();
}
},
/** 更新日记 */
async updateJournal() {
const handleFail = () => {
wx.showToast({ title: "保存失败", icon: "error" });
this.setData({
isSaving: false
});
};
this.setData({
isSaving: true
});
try {
// 收集保留的附件 ID缩略图 ID
const attachmentIds = (this.data.mediaList as MediaItem[]).map(item => item.attachmentId);
// 上传新媒体文件
const tempFileIds = await this.uploadMediaFiles(this.data.newMediaList);
await JournalApi.update({
id: this.data.id!,
idea: this.data.idea,
type: this.data.type,
lat: this.data.location?.lat,
lng: this.data.location?.lng,
location: this.data.location?.text,
createdAt: new Date(`${this.data.date}T${this.data.time}:00`).getTime(),
attachmentIds,
tempFileIds
});
Events.emit("JOURNAL_REFRESH");
Events.emit("JOURNAL_LIST_REFRESH");
wx.showToast({ title: "保存成功", icon: "success" });
this.setData({
isSaving: false,
uploaded: "0",
uploadTotal: "0 MB",
uploadProgress: 0
});
await Toolkit.sleep(1000);
wx.navigateBack();
} catch (error) {
console.error("更新日记失败:", error);
handleFail();
}
},
/** 上传媒体文件 */
uploadMediaFiles(mediaList: WechatMediaItem[]): Promise<string[]> {
return new Promise<string[]>((resolve, reject) => {
if (mediaList.length === 0) {
resolve([]);
return;
}
wx.showLoading({ title: "正在上传..", mask: true });
// 计算总大小
const sizePromises = mediaList.map(item => {
return new Promise<number>((sizeResolve, sizeReject) => {
wx.getFileSystemManager().getFileInfo({
filePath: item.path,
success: (res) => sizeResolve(res.size),
fail: (err) => sizeReject(err)
});
});
});
Promise.all(sizePromises).then(fileSizes => {
const totalSize = fileSizes.reduce((acc, size) => acc + size, 0);
const uploadTasks: WechatMiniprogram.UploadTask[] = [];
let uploadedSize = 0;
let lastUploadedSize = 0;
this.setData({
uploadTotal: IOSize.format(totalSize, 2, Unit.MB)
});
// 计算上传速度
const speedUpdateInterval = setInterval(() => {
const chunkSize = uploadedSize - lastUploadedSize;
this.setData({
uploadSpeed: `${IOSize.format(chunkSize)} / s`
});
lastUploadedSize = uploadedSize;
}, 1000);
// 上传文件
const uploadPromises = mediaList.map(item => {
return new Promise<string>((uploadResolve, uploadReject) => {
const task = wx.uploadFile({
url: `${config.url}/temp/file/upload`,
filePath: item.path,
name: "file",
success: (resp) => {
const result = JSON.parse(resp.data);
if (result && result.code === 20000) {
uploadResolve(result.data[0].id);
} else {
uploadReject(new Error(`文件上传失败: ${result?.message || "未知错误"}`));
}
},
fail: (err) => uploadReject(new Error(`文件上传失败: ${err.errMsg}`))
});
// 监听上传进度
let prevProgress = 0;
task.onProgressUpdate((res) => {
const fileUploaded = (res.totalBytesExpectedToSend * res.progress) / 100;
const delta = fileUploaded - prevProgress;
uploadedSize += delta;
prevProgress = fileUploaded;
// 更新进度条
this.setData({
uploaded: IOSize.formatWithoutUnit(uploadedSize, 2, Unit.MB),
uploadProgress: Math.round((uploadedSize / totalSize) * 10000) / 100
});
});
uploadTasks.push(task);
});
});
Promise.all(uploadPromises).then((tempFileIds) => {
// 清除定时器
clearInterval(speedUpdateInterval);
uploadTasks.forEach(task => task.offProgressUpdate());
this.setData({
uploadProgress: 100,
uploadSpeed: "0 MB / s"
});
resolve(tempFileIds);
}).catch((e: Error) => {
// 取消所有上传任务
uploadTasks.forEach(task => task.abort());
clearInterval(speedUpdateInterval);
reject(e);
});
}).catch(reject);
});
}
});

View File

@ -0,0 +1,243 @@
<!--pages/main/journal/editor/index.wxml-->
<t-navbar title="{{mode === 'create' ? '新纪录' : '编辑记录'}}" placeholder>
<text slot="left" bindtap="cancel">取消</text>
</t-navbar>
<scroll-view
class="container"
type="custom"
scroll-y
show-scrollbar="{{false}}"
scroll-into-view="{{intoView}}"
>
<view class="content">
<view wx:if="{{isLoading}}" class="loading">
<text>加载中...</text>
</view>
<block wx:else>
<view class="section">
<textarea
class="idea"
placeholder="这一刻的想法..."
model:value="{{idea}}"
/>
</view>
<view class="section type">
<text class="label">类型:</text>
<t-radio-group bind:change="onChangeType" default-value="{{type}}" borderless t-class="box">
<t-radio class="radio" block="{{false}}" label="日常" value="NORMAL" />
<t-radio class="radio" block="{{false}}" label="专拍" value="PORTFOLIO" />
</t-radio-group>
</view>
<view class="section time">
<text class="label">时间:</text>
<picker class="picker" mode="date" model:value="{{date}}">
<view class="picker">
{{date}}
</view>
</picker>
<picker class="picker" mode="time" model:value="{{time}}">
<view class="picker">
{{time}}
</view>
</picker>
</view>
<view class="section location">
<text class="label">位置:</text>
<text wx:if="{{location}}" bind:tap="chooseLocation">{{location.text}}</text>
<text wx:else bind:tap="chooseLocation">选择位置..</text>
</view>
<view class="section media">
<view class="gallery">
<!-- 创建模式mediaList 显示新选择的媒体 -->
<block wx:if="{{mode === 'create'}}">
<block wx:for="{{mediaList}}" wx:key="index">
<view class="item">
<!-- 图片 -->
<image
wx:if="{{item.type === mediaItemTypeEnum.IMAGE}}"
src="{{item.path}}"
class="thumbnail"
mode="aspectFill"
bindtap="preview"
data-index="{{index}}"
data-new-media="{{true}}"
></image>
<!-- 视频 -->
<view wx:if="{{item.type === mediaItemTypeEnum.VIDEO}}" class="video-container">
<image
src="{{item.thumbPath}}"
class="thumbnail"
mode="aspectFill"
bindtap="preview"
data-index="{{index}}"
data-new-media="{{true}}"
></image>
<t-icon class="play-icon" name="play" />
</view>
<!-- 删除 -->
<t-icon
class="delete"
name="close"
bindtap="deleteMedia"
data-index="{{index}}"
data-new-media="{{true}}"
/>
</view>
</block>
</block>
<!-- 编辑模式mediaList 显示现有附件newMediaList 显示新添加的附件 -->
<block wx:else>
<!-- 现有附件 -->
<block wx:for="{{mediaList}}" wx:key="attachmentId">
<view class="item">
<!-- 图片 -->
<image
wx:if="{{item.type === mediaItemTypeEnum.IMAGE}}"
src="{{item.thumbURL}}"
class="thumbnail"
mode="aspectFill"
bindtap="preview"
data-index="{{index}}"
data-new-media="{{false}}"
></image>
<!-- 视频 -->
<view wx:if="{{item.type === mediaItemTypeEnum.VIDEO}}" class="video-container">
<image
src="{{item.thumbURL}}"
class="thumbnail"
mode="aspectFill"
bindtap="preview"
data-index="{{index}}"
data-new-media="{{false}}"
></image>
<t-icon class="play-icon" name="play" />
</view>
<!-- 删除 -->
<t-icon
class="delete"
name="close"
bindtap="deleteMedia"
data-index="{{index}}"
data-new-media="{{false}}"
/>
</view>
</block>
<!-- 新选择附件 -->
<block wx:for="{{newMediaList}}" wx:key="index">
<view class="item new-item">
<!-- 图片 -->
<image
wx:if="{{item.type === mediaItemTypeEnum.IMAGE}}"
src="{{item.path}}"
class="thumbnail"
mode="aspectFill"
bindtap="preview"
data-index="{{index}}"
data-new-media="{{true}}"
></image>
<!-- 视频 -->
<view wx:if="{{item.type === mediaItemTypeEnum.VIDEO}}" class="video-container">
<image
src="{{item.thumbPath}}"
class="thumbnail"
mode="aspectFill"
bindtap="preview"
data-index="{{index}}"
data-new-media="{{true}}"
></image>
<t-icon class="play-icon" name="play" />
</view>
<!-- 新增标识 -->
<t-icon class="new-badge" name="add" />
<!-- 删除 -->
<t-icon
class="delete"
name="close"
bindtap="deleteMedia"
data-index="{{index}}"
data-new-media="{{true}}"
/>
</view>
</block>
</block>
<!-- 添加按钮 -->
<t-button
class="item add"
theme="primary"
plain="true"
disabled="{{isSaving}}"
bind:tap="addMedia"
>
<t-icon name="add" />
</t-button>
</view>
</view>
<view wx:if="{{isSaving}}" class="uploading">
<progress
class="progress"
percent="{{uploadProgress}}"
stroke-width="6"
/>
<view class="text">
<view>{{uploaded}} / {{uploadTotal}}</view>
<view>{{uploadSpeed}}</view>
</view>
</view>
<!-- 控制按钮 -->
<view class="ctrl">
<!-- 创建模式 -->
<block wx:if="{{mode === 'create'}}">
<t-button
class="clear"
theme="danger"
variant="outline"
disabled="{{isSaving}}"
bind:tap="clearMedia"
disabled="{{mediaList.length === 0}}"
>清空已选</t-button>
<t-button
class="submit"
theme="primary"
bind:tap="submit"
disabled="{{(!idea && mediaList.length === 0) || isSaving}}"
>提交</t-button>
</block>
<!-- 编辑模式 -->
<block wx:else>
<t-button
class="delete"
theme="danger"
bind:tap="deleteJournal"
disabled="{{isSaving}}"
>删除记录</t-button>
<t-button
class="save"
theme="primary"
bind:tap="submit"
disabled="{{(!idea && mediaList.length === 0 && newMediaList.length === 0) || isSaving}}"
>保存</t-button>
</block>
</view>
</block>
</view>
</scroll-view>
<!-- 删除对话框(仅编辑模式) -->
<t-dialog
wx:if="{{mode === 'edit'}}"
visible="{{deleteDialogVisible}}"
title="删除记录"
confirm-btn="{{ {content: '删除', variant: 'text', theme: 'danger'} }}"
cancel-btn="取消"
bind:confirm="confirmDelete"
bind:cancel="cancelDelete"
>
<view slot="content" class="delete-dialog">
<view class="tips">
<text>此记录的照片和视频也会同步删除,删除后无法恢复,请输入 "</text>
<text style="color: var(--theme-error)">确认删除</text>
<text>" 以继续</text>
</view>
<t-input model:value="{{deleteConfirmText}}" placeholder="请输入:确认删除" />
</view>
</t-dialog>

View File

@ -1,12 +0,0 @@
{
"component": true,
"usingComponents": {
"t-cell": "tdesign-miniprogram/cell/cell",
"t-icon": "tdesign-miniprogram/icon/icon",
"t-navbar": "tdesign-miniprogram/navbar/navbar",
"t-indexes": "tdesign-miniprogram/indexes/indexes",
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group",
"t-indexes-anchor": "tdesign-miniprogram/indexes-anchor/indexes-anchor"
},
"styleIsolation": "shared"
}

View File

@ -1,130 +0,0 @@
.more-menu {
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 999;
position: fixed;
background: var(--theme-bg-overlay);
.content {
z-index: 1000;
position: fixed;
background: var(--theme-bg-menu);
box-shadow: 0 0 12px var(--theme-shadow-medium);
border-radius: 8rpx;
}
}
.journal-list {
width: 100vw;
.content {
.date {
font-weight: bold;
}
.text,
.items {
position: relative;
font-size: 14px;
}
> .text {
color: var(--theme-text-primary);
width: calc(100% - 32px - 2rem);
padding: 8px 16px;
margin: .5rem 1rem 1rem 1rem;
position: relative;
background: var(--theme-bg-journal);
box-shadow: 0 2px 10px var(--theme-shadow-medium);
border-radius: 2px;
// 纸张纹理效果
&::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background:
linear-gradient(90deg,
var(--theme-texture-light) 0%,
var(--theme-texture-bright) 50%,
var(--theme-texture-light) 100%),
linear-gradient(var(--theme-texture-line) 1px, transparent 1px),
linear-gradient(90deg, var(--theme-texture-line) 1px, transparent 1px);
pointer-events: none;
background-size: 100% 100%, 10px 10px, 10px 10px;
}
.location {
gap: 6rpx;
display: flex;
margin-top: 16rpx;
align-items: center;
justify-content: flex-end;
.icon {
color: var(--theme-wx);
}
.text {
color: var(--theme-text-secondary);
}
}
}
.items {
gap: .25rem;
display: flex;
padding-bottom: 2rem;
align-items: flex-start;
.column {
flex: 1;
display: flex;
flex-direction: column;
.item {
overflow: hidden;
background: var(--theme-bg-card);
margin-bottom: .25rem;
&.thumbnail {
width: 100%;
display: block;
}
&.video {
height: auto;
position: relative;
&::after {
content: "";
top: 50%;
left: 53%;
width: 0;
height: 0;
position: absolute;
transform: translate(-50%, -50%);
border-top: 16px solid transparent;
border-left: 24px solid var(--theme-video-play);
border-bottom: 16px solid transparent;
pointer-events: none;
}
}
}
}
}
}
.start {
color: var(--theme-text-secondary);
padding: 1rem 0;
font-size: 12px;
text-align: center;
}
}

View File

@ -1,244 +0,0 @@
// pages/journal/index.ts
import Time from "../../../utils/Time";
import config from "../../../config/index"
import Events from "../../../utils/Events";
import Toolkit from "../../../utils/Toolkit";
import { Journal, JournalPage, JournalPageType } from "../../../types/Journal";
import { OrderType } from "../../../types/Model";
import { PreviewImageMetadata } from "../../../types/Attachment";
import { MediaItem, MediaItemType } from "../../../types/UI";
import { JournalApi } from "../../../api/JournalApi";
interface JournalData {
page: JournalPage;
list: Journal[];
dateFilterMin: number;
dateFilterMax: number;
dateFilterAllows: number[];
dateFilterVisible: boolean;
isFetching: boolean;
isFinished: boolean;
stickyOffset: number;
isShowMoreMenu: boolean;
menuTop: number;
menuLeft: number;
}
Page({
data: <JournalData>{
page: {
index: 0,
size: 8,
type: JournalPageType.NORMAL,
likeMap: {
type: "NORMAL"
},
orderMap: {
createdAt: OrderType.DESC
}
},
list: [],
dateFilterMin: new Date("2025/06/28 16:00:00").getTime(),
dateFilterMax: new Date(2026, 1, 15).getTime(),
dateFilterAllows: [
new Date(2025, 11, 15).getTime(),
new Date(2025, 11, 20).getTime(),
new Date(2025, 11, 10).getTime(),
],
dateFilterVisible: false,
isFetching: false,
isFinished: false,
stickyOffset: 0,
isShowMoreMenu: false,
menuTop: 0,
menuLeft: 0
},
onLoad() {
Events.reset("JOURNAL_REFRESH", () => {
this.setData({
page: {
index: 0,
size: 8,
type: JournalPageType.NORMAL,
equalsExample: {
type: "NORMAL"
},
orderMap: {
createdAt: OrderType.DESC
}
},
list: [],
isFetching: false,
isFinished: false
});
this.fetch();
});
this.setData({
list: []
})
this.fetch();
},
onReady() {
this.getCustomNavbarHeight();
},
onHide() {
this.setData({
isShowMoreMenu: false
})
},
onReachBottom() {
this.fetch();
},
getCustomNavbarHeight() {
const query = wx.createSelectorQuery();
query.select(".custom-navbar").boundingClientRect();
query.exec((res) => {
const { height = 0 } = res[0] || {};
this.setData({ stickyOffset: height });
});
},
toggleMoreMenu() {
if (!this.data.isShowMoreMenu) {
// 打开菜单时计算位置
const query = wx.createSelectorQuery();
query.select(".more").boundingClientRect();
query.exec((res) => {
if (res[0]) {
const { top, left, height } = res[0];
this.setData({
isShowMoreMenu: true,
menuTop: top + height + 16, // 按钮下方 8px
menuLeft: left
});
}
});
} else {
// 关闭菜单
this.setData({
isShowMoreMenu: false
});
}
},
/** 阻止事件冒泡 */
stopPropagation() {
// 空函数,仅用于阻止事件冒泡
},
toCreater() {
wx.navigateTo({
"url": "/pages/main/journal-editor/index?from=journal"
})
},
toSearch() {
wx.navigateTo({
url: "/pages/main/journal-search/index"
})
},
toMap() {
wx.navigateTo({
url: "/pages/main/journal-map/index"
})
},
toDate() {
wx.navigateTo({
url: "/pages/main/journal-date/index"
})
},
async fetch() {
if (this.data.isFetching || this.data.isFinished) {
return;
}
this.setData({
isFetching: true
});
try {
const pageResult = await JournalApi.getList(this.data.page);
const list = pageResult.list;
if (!list || list.length === 0) {
this.setData({
isFinished: true,
isFetching: false
});
return;
}
list.forEach(journal => {
const mediaItems = journal.items!.filter((item) => item.attachType === "THUMB").map((thumbItem, index) => {
const metadata = (typeof thumbItem.metadata === "string" ? JSON.parse(thumbItem.metadata) : thumbItem.metadata) as PreviewImageMetadata;
const thumbURL = `${config.url}/attachment/read/${thumbItem.mongoId}`;
const sourceURL = `${config.url}/attachment/read/${metadata.sourceMongoId}`;
const isVideo = metadata.sourceMimeType?.startsWith("video/");
return {
type: isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
thumbURL,
sourceURL,
size: thumbItem.size || 0,
attachmentId: thumbItem.id,
width: metadata.width,
height: metadata.height,
originalIndex: index
} as MediaItem;
});
journal.date = Time.toDate(journal.createdAt);
journal.time = Time.toTime(journal.createdAt);
journal.datetime = Time.toPassedDateTime(journal.createdAt);
journal.mediaItems = mediaItems;
journal.columnedItems = Toolkit.splitItemsIntoColumns(mediaItems, 3, (item) => {
if (item.width && item.height && 0 < item.width) {
return item.height / item.width;
}
return 1;
})
});
this.setData({
page: {
index: this.data.page.index + 1,
size: 8,
type: JournalPageType.NORMAL,
equalsExample: {
type: "NORMAL"
},
orderMap: {
createdAt: OrderType.DESC
}
},
list: this.data.list.concat(list),
isFinished: list.length < this.data.page.size,
isFetching: false
});
} catch (error) {
console.error("加载日记失败:", error);
this.setData({ isFetching: false });
}
},
preview(e: WechatMiniprogram.BaseEvent) {
const { journalIndex, itemIndex } = e.currentTarget.dataset;
const journal = this.data.list[journalIndex];
const items = journal.mediaItems!;
const total = items.length;
const startIndex = Math.max(0, itemIndex - 25);
const endIndex = Math.min(total, startIndex + 50);
const newCurrentIndex = itemIndex - startIndex;
const sources = items.slice(startIndex, endIndex).map((item) => {
return {
url: item.sourceURL,
type: item.type === MediaItemType.IMAGE ? "image" : "video"
}
}) as any;
wx.previewMedia({
current: newCurrentIndex,
sources
})
},
openLocation(e: WechatMiniprogram.BaseEvent) {
const { journalIndex } = e.currentTarget.dataset;
const journal = this.data.list[journalIndex] as Journal;
if (journal.lat && journal.lng) {
wx.openLocation({
latitude: journal.lat,
longitude: journal.lng,
});
}
},
});

View File

@ -1,56 +0,0 @@
<view class="custom-navbar">
<t-navbar title="我们的记录">
<view slot="left" class="more" bind:tap="toggleMoreMenu">
<t-icon name="view-list" size="24px" />
</view>
</t-navbar>
</view>
<view wx:if="{{isShowMoreMenu}}" class="more-menu" catchtap="toggleMoreMenu">
<t-cell-group
class="content"
theme="card"
style="top: {{menuTop}}px; left: {{menuLeft}}px;"
catchtap="stopPropagation"
>
<t-cell title="新纪录" leftIcon="add" bind:tap="toCreater" />
<t-cell title="按列表查找" leftIcon="view-list" bind:tap="toSearch" />
<t-cell title="按日期查找" leftIcon="calendar-1" bind:tap="toDate" />
<t-cell title="按地图查找" leftIcon="location" bind:tap="toMap" />
</t-cell-group>
</view>
<t-indexes
class="journal-list"
bind:scroll="onScroll"
sticky-offset="{{stickyOffset}}"
>
<view class="content" wx:for="{{list}}" wx:for-item="journal" wx:for-index="journalIndex" wx:key="index">
<t-indexes-anchor class="date" index="{{journal.datetime}}" />
<view wx:if="{{journal.idea || journal.location}}" class="text">
<text class="idea">{{journal.idea}}</text>
<view
wx:if="{{journal.location}}"
class="location"
bind:tap="openLocation"
data-journal-index="{{journalIndex}}"
>
<t-icon class="icon" name="location-filled" />
<text class="text">{{journal.location}}</text>
</view>
</view>
<view wx:if="{{journal.columnedItems}}" class="items">
<view wx:for="{{journal.columnedItems}}" wx:for-item="column" wx:for-index="columnIndex" wx:key="columnIndex" class="column">
<block wx:for="{{column}}" wx:for-item="item" wx:for-index="itemIndex" wx:key="attachmentId">
<image
class="item thumbnail {{item.type}}"
src="{{item.thumbURL}}"
mode="widthFix"
bindtap="preview"
data-item-index="{{item.originalIndex}}"
data-journal-index="{{journalIndex}}"
></image>
</block>
</view>
</view>
</view>
<view wx:if="{{isFinished}}" class="start">已回到最初的起点</view>
</t-indexes>

View File

@ -0,0 +1,7 @@
{
"usingComponents": {
"t-navbar": "tdesign-miniprogram/navbar/navbar",
"journal-detail-popup": "/components/journal-detail-popup/index"
},
"navigationStyle": "custom"
}

View File

@ -0,0 +1,100 @@
/* pages/main/journal/map/index.less */
.container {
width: 100%;
height: 100vh;
position: fixed;
overflow: hidden;
.map {
width: 100%;
height: 100%;
.location {
width: fit-content;
background: var(--theme-bg-card);
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, .15);
border-radius: 6rpx;
.content {
display: flex;
padding: 8rpx 16rpx 8rpx 8rpx;
align-items: flex-start;
.thumb {
width: 72rpx;
height: 72rpx;
position: relative;
flex-shrink: 0;
margin-right: 12rpx;
overflow: hidden;
border-radius: 6rpx;
.img {
width: 100%;
height: 100%;
}
.badge {
top: 4rpx;
right: 4rpx;
color: #fff;
padding: 2rpx 6rpx;
position: absolute;
font-size: 20rpx;
background: rgba(0, 0, 0, .7);
border-radius: 8rpx;
}
}
.text {
flex: 1;
display: flex;
overflow: hidden;
flex-direction: column;
.value {
color: var(--theme-text-primary);
width: calc(var(--title-length) * 30rpx);
overflow: hidden;
font-size: 30rpx;
white-space: nowrap;
text-overflow: ellipsis;
margin-bottom: 4rpx;
}
.date-count {
display: flex;
.date {
color: var(--theme-text-secondary);
font-size: 24rpx;
margin-right: 16rpx;
}
.count {
color: var(--theme-wx);
font-size: 24rpx;
font-weight: 600;
}
}
}
}
}
}
.loading {
top: 50%;
left: 50%;
z-index: 1000;
position: fixed;
transform: translate(-50%, -50%);
.loading-text {
color: #666;
padding: 24rpx 48rpx;
background: #FFF;
border-radius: 8rpx;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, .15);
}
}
}

View File

@ -0,0 +1,170 @@
// pages/main/journal/map/index.ts
import config from "../../../../config/index";
import Time from "../../../../utils/Time";
import { JournalPageType } from "../../../../types/Journal";
import Toolkit from "../../../../utils/Toolkit";
import { MapMarker } from "../../../../types/UI";
import { JournalApi } from "../../../../api/JournalApi";
interface LocationMarker {
locationKey: string; // 位置键 "lat,lng"
lat: number;
lng: number;
location?: string;
journalIds: number[]; // 该位置的所有日记 ID
count: number; // 日记数量
date: string;
previewThumb?: string; // 预览缩略图
}
interface JournalMapData {
centerLat: number;
centerLng: number;
scale: number;
markers: MapMarker[];
locations: LocationMarker[]; // 位置标记列表
customCalloutMarkerIds: string[]; // 改为 string[] 以支持 locationKey
includePoints: Array<{ latitude: number; longitude: number }>; // 缩放视野以包含所有点
popupIds: number[];
popupVisible: boolean;
isLoading: boolean;
}
Page({
data: <JournalMapData>{
centerLat: 39.908823,
centerLng: 116.397470,
scale: 13,
markers: [],
locations: [],
customCalloutMarkerIds: [],
includePoints: [],
selectedLocation: null,
popupIds: [],
popupVisible: false,
isLoading: true,
},
async onLoad() {
await this.loadJournals();
},
/** 加载所有记录 */
async loadJournals() {
this.setData({ isLoading: true });
try {
const result = await JournalApi.getList({
index: 0,
size: 9007199254740992,
type: JournalPageType.PREVIEW
});
const list = result.list || [];
// 过滤有位置信息的记录,并按位置分组
const locationMap = new Map<string, LocationMarker>();
list.filter((journal: any) => journal.lat && journal.lng).forEach((journal: any) => {
// 保留 6 位小数作为位置键,约等于 0.1 米精度
const lat = Number(journal.lat.toFixed(6));
const lng = Number(journal.lng.toFixed(6));
const locationKey = `${lat},${lng}`;
if (!locationMap.has(locationKey)) {
const thumbItem = journal.items.find((item: any) => item.attachType === "THUMB");
locationMap.set(locationKey, {
locationKey,
lat,
lng,
location: journal.location,
journalIds: [],
count: 0,
date: Time.toPassedDate(journal.createdAt),
previewThumb: thumbItem ? `${config.url}/attachment/read/${thumbItem.mongoId}` : undefined
});
}
const marker = locationMap.get(locationKey)!;
marker.journalIds.push(journal.id);
marker.count++;
// 如果还没有预览图,尝试从当前日记获取
if (!marker.previewThumb) {
const thumbItem = journal.items.find((item: any) => item.attachType === "THUMB");
if (thumbItem) {
marker.previewThumb = `${config.url}/attachment/read/${thumbItem.mongoId}`;
}
}
});
const locations = Array.from(locationMap.values());
if (locations.length === 0) {
wx.showToast({
title: "暂无位置记录",
icon: "none"
});
this.setData({ isLoading: false });
return;
}
// 生成地图标记
const markers: MapMarker[] = locations.map((location, index) => ({
id: index,
latitude: location.lat,
longitude: location.lng,
width: 24,
height: 30,
customCallout: {
anchorY: -2,
// 随机错位避免近距离重叠
anchorX: Toolkit.random(-10, 10),
display: "ALWAYS"
}
}));
// 所有标记的 locationKey 列表
const customCalloutMarkerIds = locations.map(l => l.locationKey);
// 计算中心点(所有标记的平均位置)
const centerLat = locations.reduce((sum, l) => sum + l.lat, 0) / locations.length;
const centerLng = locations.reduce((sum, l) => sum + l.lng, 0) / locations.length;
// 缩放视野以包含所有标记点
const includePoints = locations.map((l) => ({
latitude: l.lat,
longitude: l.lng
}));
this.setData({
locations,
markers,
customCalloutMarkerIds,
centerLat,
centerLng,
includePoints,
isLoading: false
});
} catch (err: any) {
wx.showToast({
title: err.message || "加载失败",
icon: "error"
});
this.setData({ isLoading: false });
}
},
/** 标记点击事件 */
onMarkerTap(e: any) {
const markerId = e.detail.markerId || e.markerId;
this.loadLocationDetail(markerId);
},
/** 气泡点击事件 */
onCalloutTap(e: any) {
const markerId = e.detail.markerId || e.markerId;
this.loadLocationDetail(markerId);
},
/** 加载位置详情(该位置的所有日记) */
async loadLocationDetail(markerId: number) {
const location = this.data.locations[markerId];
if (!location) {
return;
}
this.setData({
popupIds: location.journalIds,
popupVisible: true
});
},
/** 关闭详情 */
async closeDetail() {
this.setData({
popupVisible: false,
selectedLocation: null
});
},
});

View File

@ -0,0 +1,50 @@
<!--pages/main/journal/map/index.wxml-->
<t-navbar title="地图查找" left-arrow placeholder />
<view class="container">
<map
id="journal-map"
class="map"
latitude="{{centerLat}}"
longitude="{{centerLng}}"
scale="{{scale}}"
markers="{{markers}}"
include-points="{{includePoints}}"
bindmarkertap="onMarkerTap"
bindcallouttap="onCalloutTap"
>
<cover-view slot="callout">
<cover-view
class="location"
wx:for="{{locations}}"
wx:key="locationKey"
wx:for-index="locationIndex"
marker-id="{{locationIndex}}"
style="{{'--title-length: ' + item.location.length}}"
>
<cover-view class="content">
<cover-view wx:if="{{item.previewThumb}}" class="thumb">
<cover-image class="img" src="{{item.previewThumb}}" />
<cover-view wx:if="{{1 < item.count}}" class="badge">{{item.count}}</cover-view>
</cover-view>
<cover-view class="text">
<cover-view wx:if="{{item.location}}" class="value">{{item.location}}</cover-view>
<cover-view class="date-count">
<cover-view class="date">{{item.date}}</cover-view>
<cover-view wx:if="{{1 < item.count}}" class="count">{{item.count}} 条日记</cover-view>
</cover-view>
</cover-view>
</cover-view>
</cover-view>
</cover-view>
</map>
<view wx:if="{{isLoading}}" class="loading">
<view class="loading-text">加载中...</view>
</view>
</view>
<!-- 详情面板 -->
<journal-detail-popup
visible="{{popupVisible}}"
ids="{{popupIds}}"
mode="LOCATION"
bind:close="closeDetail"
/>

View File

@ -0,0 +1,7 @@
{
"usingComponents": {
"t-navbar": "tdesign-miniprogram/navbar/navbar",
"journal-list": "/components/journal-list/index"
},
"navigationBarTitleText": "按列表查找"
}

View File

@ -0,0 +1,21 @@
page {
height: 100vh;
background: var(--td-bg-color-page);
}
.page-container {
width: 100%;
height: 100%;
display: flex;
overflow: hidden;
flex-direction: column;
.navbar {
flex-shrink: 0;
}
.content {
flex: 1;
overflow: hidden;
}
}

View File

@ -0,0 +1,19 @@
// pages/main/journal/search/index.ts
import Events from "../../../../utils/Events";
Page({
onLoad() {
Events.reset("JOURNAL_LIST_REFRESH", () => {
const listRef = this.selectComponent('#listRef');
if (listRef) {
listRef.reSearch();
}
});
},
onNavigateItem(e: WechatMiniprogram.CustomEvent) {
const { id } = e.detail;
wx.navigateTo({
url: `/pages/main/journal/editor/index?id=${id}`
});
}
});

View File

@ -0,0 +1,13 @@
<view class="page-container">
<view class="navbar">
<t-navbar title="列表查找" left-arrow placeholder />
</view>
<view class="content">
<journal-list
id="listRef"
searchable="{{true}}"
mode="navigate"
bind:navigate="onNavigateItem"
/>
</view>
</view>