Compare commits

...

26 Commits

Author SHA1 Message Date
980d0e1431 update 1.5.1 2025-12-10 19:00:44 +08:00
1905d1cd5a fix dark mode 2025-12-10 19:00:25 +08:00
18c6a41549 fix location icon 2025-12-10 17:17:57 +08:00
920b3c87e8 fix map callout 2025-12-10 16:59:22 +08:00
1e54782600 add journal-detail-panel 2025-12-10 16:45:29 +08:00
a5fb1d752b fix title 2025-12-10 15:52:56 +08:00
79bc51bc56 fix delete btn style 2025-12-10 15:47:22 +08:00
b6be7c50e8 fix delete journal 2025-12-10 15:38:10 +08:00
fd533cb92d fix thumb size 2025-12-10 15:36:24 +08:00
16335821e2 fix journal list type 2025-12-10 15:31:50 +08:00
d07fa0ef88 fix journal list sort 2025-12-10 15:28:49 +08:00
432cc85663 fix map scale 2025-12-10 15:13:20 +08:00
71cbf554d4 animate popup 2025-12-10 15:08:01 +08:00
69bf186f0e adaptation dark mode 2025-12-10 15:02:17 +08:00
ad755c7d0e fix calendar layout style 2025-12-10 14:20:21 +08:00
4f1942f3f0 hidden other month day 2025-12-10 14:11:01 +08:00
b4f25929df fix journal detail sort 2025-12-10 14:08:24 +08:00
3305e4a508 fix map scale 2025-12-10 13:55:29 +08:00
aa6b00a87d bigger detail popup 2025-12-10 13:46:51 +08:00
ea0186447a fix thumb margin 2025-12-10 13:46:27 +08:00
c3d1276a24 remove search-list 2025-12-10 13:28:22 +08:00
58c55f3672 add journal-date 2025-12-10 13:27:34 +08:00
630c7fefcb add journal-map 2025-12-10 00:54:52 +08:00
a38ed44fd1 update creater style 2025-12-09 18:12:02 +08:00
19b6206695 add editor 2025-12-09 18:02:23 +08:00
6dc4d71718 better layout 2025-12-08 20:47:59 +08:00
49 changed files with 2503 additions and 185 deletions

View File

@ -4,6 +4,9 @@
"pages/main/journal/index",
"pages/main/journal-creater/index",
"pages/main/journal-search/index",
"pages/main/journal-editor/index",
"pages/main/journal-map/index",
"pages/main/journal-date/index",
"pages/main/portfolio/index",
"pages/main/travel/index",
"pages/main/about/index",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 517 B

View File

@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"t-icon": "tdesign-miniprogram/icon/icon"
}
}

View File

@ -0,0 +1,114 @@
/* components/calendar/index.less */
.calendar {
flex: 1;
height: 100%;
display: flex;
overflow: hidden;
flex-direction: column;
.year {
color: var(--theme-text-secondary);
display: flex;
padding: 16rpx 32rpx;
background: transparent;
align-items: center;
margin-bottom: 24rpx;
justify-content: space-between;
.btn {
width: 64rpx;
height: 64rpx;
display: flex;
align-items: center;
border-radius: 12rpx;
justify-content: center;
&:active {
opacity: .7;
}
}
.text {
color: var(--theme-text);
font-size: 32rpx;
font-weight: 600;
}
}
.weekdays {
display: grid;
padding: 0 32rpx;
margin-bottom: 16rpx;
grid-template-columns: repeat(7, 1fr);
.weekday {
color: var(--theme-text-secondary);
padding: 16rpx 0;
font-size: 24rpx;
text-align: center;
}
}
.months {
flex: 1;
height: 0;
padding-bottom: 256rpx;
.month {
padding: 0 32rpx;
.title {
color: var(--theme-text);
font-size: 28rpx;
margin-top: 32rpx;
font-weight: 600;
}
.days {
display: grid;
grid-gap: 8rpx;
grid-template-columns: repeat(7, 1fr);
.day {
display: flex;
position: relative;
background: transparent;
align-items: center;
aspect-ratio: 1;
border-radius: 12rpx;
flex-direction: column;
justify-content: center;
.number {
color: var(--theme-text);
font-size: 28rpx;
}
.dot {
width: 8rpx;
height: 8rpx;
border-radius: 50%;
background: var(--theme-primary);
}
&.other-month {
visibility: hidden;
}
&.has-journal {
background: var(--theme-bg-journal);
.number {
color: var(--theme-wx);
font-weight: bold;
}
&:active {
opacity: .7;
}
}
}
}
}
}
}

View File

@ -0,0 +1,210 @@
// components/calendar/index.ts
interface DayInfo {
date: string; // YYYY-MM-DD
year: number;
month: number;
day: number;
isCurrentMonth: boolean;
hasJournal: boolean;
isToday: boolean;
}
interface MonthInfo {
year: number;
month: number;
days: DayInfo[];
}
interface CalendarData {
currentYear: number;
months: MonthInfo[];
scrollIntoView: string; // 滚动到的元素 id
}
Component({
properties: {
// 日记数据key 为日期 YYYY-MM-DDvalue 为日记 id 数组
journalMap: {
type: Object,
value: {}
}
},
data: <CalendarData>{
currentYear: 0,
months: [],
scrollIntoView: ''
},
lifetimes: {
attached() {
this.initCalendar();
}
},
observers: {
'journalMap.**'(journalMap: Record<string, number[]>) {
// 日记数据更新时重新生成所有月份的日期
if (this.data.months.length > 0) {
this.updateAllMonthsDays(journalMap);
}
}
},
methods: {
/** 初始化日历 */
initCalendar() {
const now = new Date();
const currentYear = now.getFullYear();
const currentMonth = now.getMonth() + 1;
this.setData({
currentYear,
months: this.generateYearMonths(currentYear)
});
// 滚动到当前月份
this.scrollToMonth(currentMonth);
},
/** 生成指定年份的 12 个月 */
generateYearMonths(year: number): MonthInfo[] {
const months: MonthInfo[] = [];
const today = new Date();
const todayStr = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`;
for (let month = 1; month <= 12; month++) {
months.push({
year,
month,
days: this.generateDaysForMonth(year, month, this.data.journalMap || {}, todayStr)
});
}
return months;
},
/** 更新所有月份的日期数据 */
updateAllMonthsDays(journalMap: Record<string, number[]>) {
const { months } = this.data;
const today = new Date();
const todayStr = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`;
const updatedMonths = months.map(monthInfo => ({
...monthInfo,
days: this.generateDaysForMonth(monthInfo.year, monthInfo.month, journalMap, todayStr)
}));
this.setData({ months: updatedMonths });
},
/** 生成指定月份的日期数据 */
generateDaysForMonth(year: number, month: number, journalMap: Record<string, number[]>, todayStr: string): DayInfo[] {
const days: DayInfo[] = [];
// 当前月第一天
const firstDay = new Date(year, month - 1, 1);
const firstDayWeek = firstDay.getDay();
// 当前月最后一天
const lastDay = new Date(year, month, 0);
const lastDate = lastDay.getDate();
// 上个月需要显示的日期
const prevMonthLastDay = new Date(year, month - 1, 0);
const prevMonthLastDate = prevMonthLastDay.getDate();
for (let i = firstDayWeek - 1; i >= 0; i--) {
const day = prevMonthLastDate - i;
const prevMonth = month === 1 ? 12 : month - 1;
const prevYear = month === 1 ? year - 1 : year;
const dateKey = `${prevYear}-${String(prevMonth).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
days.push({
date: dateKey,
year: prevYear,
month: prevMonth,
day,
isCurrentMonth: false,
hasJournal: !!journalMap[dateKey],
isToday: dateKey === todayStr
});
}
// 当前月的日期
for (let day = 1; day <= lastDate; day++) {
const dateKey = `${year}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
days.push({
date: dateKey,
year,
month,
day,
isCurrentMonth: true,
hasJournal: !!journalMap[dateKey],
isToday: dateKey === todayStr
});
}
// 下个月需要显示的日期(补齐到 35 个格子6 行)
const remainingDays = 35 - days.length;
for (let day = 1; day <= remainingDays; day++) {
const nextMonth = month === 12 ? 1 : month + 1;
const nextYear = month === 12 ? year + 1 : year;
const dateKey = `${nextYear}-${String(nextMonth).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
days.push({
date: dateKey,
year: nextYear,
month: nextMonth,
day,
isCurrentMonth: false,
hasJournal: !!journalMap[dateKey],
isToday: dateKey === todayStr
});
}
return days;
},
/** 切换年份 */
changeYear(delta: number) {
const newYear = this.data.currentYear + delta;
this.setData({
currentYear: newYear,
months: this.generateYearMonths(newYear)
});
// 滚动到第一个月
this.scrollToMonth(1);
},
/** 上一年 */
prevYear() {
this.changeYear(-1);
},
/** 下一年 */
nextYear() {
this.changeYear(1);
},
/** 滚动到指定月份 */
scrollToMonth(month: number) {
// 先清空,然后设置,触发滚动
this.setData({ scrollIntoView: '' });
wx.nextTick(() => {
this.setData({ scrollIntoView: `month-${month}` });
});
},
/** 点击日期 */
onDayTap(e: WechatMiniprogram.BaseEvent) {
const { date, year, month, day } = e.currentTarget.dataset;
// 触发自定义事件,传递选中的日期信息
this.triggerEvent('dateselect', {
date,
year,
month,
day
});
}
}
});

View File

@ -0,0 +1,46 @@
<!-- components/calendar/index.wxml -->
<view class="calendar">
<!-- 年份切换器 -->
<view class="year">
<t-icon class="btn" name="chevron-left" size="40rpx" catchtap="prevYear" />
<text class="text">{{currentYear}} 年</text>
<t-icon class="btn" name="chevron-right" size="40rpx" catchtap="nextYear" />
</view>
<!-- 星期标题 -->
<view class="weekdays">
<view class="weekday">日</view>
<view class="weekday">一</view>
<view class="weekday">二</view>
<view class="weekday">三</view>
<view class="weekday">四</view>
<view class="weekday">五</view>
<view class="weekday">六</view>
</view>
<!-- 月份列表 -->
<scroll-view class="months" scroll-y enhanced show-scrollbar="{{false}}" scroll-into-view="{{scrollIntoView}}" scroll-with-animation>
<block wx:for="{{months}}" wx:key="month">
<view class="month" id="month-{{item.month}}">
<!-- 月份标题 -->
<view class="title">{{item.month}} 月</view>
<!-- 日期网格 -->
<view class="days">
<block wx:for="{{item.days}}" wx:key="date" wx:for-item="day">
<view
class="day {{day.isCurrentMonth ? '' : 'other-month'}} {{day.hasJournal ? 'has-journal' : ''}} {{day.isToday ? 'today' : ''}}"
catchtap="onDayTap"
data-date="{{day.date}}"
data-year="{{day.year}}"
data-month="{{day.month}}"
data-day="{{day.day}}"
>
<view class="number">{{day.day}}</view>
<view wx:if="{{day.hasJournal}}" class="dot"></view>
</view>
</block>
</view>
</view>
</block>
</scroll-view>
</view>

View File

@ -0,0 +1,7 @@
{
"component": true,
"usingComponents": {
"t-icon": "tdesign-miniprogram/icon/icon",
"t-popup": "tdesign-miniprogram/popup/popup"
}
}

View File

@ -0,0 +1,166 @@
/* components/journal-detail-panel/index.less */
.detail-panel {
width: 100%;
height: 70vh;
display: flex;
border-radius: 16rpx 16rpx 0 0;
flex-direction: column;
.detail-content {
flex: 1;
display: flex;
overflow: hidden;
flex-direction: column;
.header {
display: flex;
padding: 32rpx 32rpx 0 32rpx;
flex-shrink: 0;
margin-bottom: 24rpx;
align-items: flex-start;
justify-content: space-between;
.info {
flex: 1;
display: flex;
flex-direction: column;
.title {
display: flex;
font-size: 32rpx;
font-weight: 600;
align-items: center;
margin-bottom: 8rpx;
.icon {
color: var(--theme-wx);
font-size: 48rpx;
margin-right: 8rpx;
}
}
}
.actions {
gap: 16rpx;
display: flex;
flex-shrink: 0;
align-items: center;
.indicator {
color: var(--theme-wx);
padding: 4rpx 12rpx;
font-size: 24rpx;
font-weight: 600;
border-radius: 12rpx;
background: var(--theme-bg-journal);
}
}
}
.journals-swiper {
flex: 1;
height: 100%;
.swiper-item-wrapper {
height: 100%;
.journal-item {
height: 100%;
display: flex;
flex-direction: column;
.journal-header {
gap: 16rpx;
display: flex;
padding: 0 32rpx;
flex-wrap: wrap;
flex-shrink: 0;
margin-bottom: 16rpx;
align-items: baseline;
.location {
gap: 8rpx;
display: flex;
font-size: 24rpx;
flex-basis: 100%;
align-items: center;
.icon {
color: var(--theme-wx);
font-size: 32rpx;
}
.text {
font-size: 24rpx;
}
}
.date {
flex: 1;
font-size: 28rpx;
font-weight: 600;
}
.time {
font-size: 24rpx;
}
}
.idea {
display: block;
padding: 0 32rpx;
font-size: 28rpx;
line-height: 1.6;
flex-shrink: 0;
margin-bottom: 16rpx;
}
.items-scroll {
flex: 1;
height: 100%;
.items {
padding: 0 32rpx 128rpx 32rpx;
.wrapper {
column-gap: 8rpx;
column-count: 3;
padding-bottom: 128rpx;
.item {
overflow: hidden;
background: var(--theme-bg-card);
break-inside: avoid;
margin-bottom: 8rpx;
&.thumbnail {
width: 100%;
display: block;
}
&.video {
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;
}
}
}
}
}
}
}
}
}
}
}

View File

@ -0,0 +1,116 @@
// components/journal-detail-panel/index.ts
interface JournalInfo {
id: number;
date: string;
time: string;
lat?: number;
lng?: number;
location?: string;
idea?: string;
items: Array<{
type: number;
thumbURL: string;
sourceURL: string;
mongoId: string;
}>;
}
interface JournalDetailPanelData {
currentJournalIndex: number;
}
Component({
properties: {
// 是否显示
visible: {
type: Boolean,
value: false
},
// 标题(如 "2024 年 1 月 1 日" 或位置名称)
title: {
type: String,
value: ""
},
// 日记列表
journals: {
type: Array,
value: []
},
// 是否显示标题位置图标
showLocationIcon: {
type: Boolean,
value: false
},
// 是否显示每条日记的日期
showJournalDate: {
type: Boolean,
value: true
},
// 是否显示每条日记的位置
showJournalLocation: {
type: Boolean,
value: true
}
},
data: <JournalDetailPanelData>{
currentJournalIndex: 0,
},
observers: {
'journals, visible'(journals: JournalInfo[], visible: boolean) {
if (visible && journals && journals.length > 0) {
// 显示时重置索引和 margin
this.setData({
currentJournalIndex: 0,
});
}
}
},
methods: {
/** 关闭详情 */
closeDetail() {
this.triggerEvent('close');
},
/** swiper 切换事件 */
onSwiperChange(e: WechatMiniprogram.SwiperChange) {
this.setData({
currentJournalIndex: e.detail.current
});
},
openLocation(e: WechatMiniprogram.BaseEvent) {
const { journalIndex } = e.currentTarget.dataset;
const journals = this.properties.journals as JournalInfo[];
const journal = journals[journalIndex];
if (journal.lat && journal.lng) {
wx.openLocation({
latitude: journal.lat,
longitude: journal.lng,
});
}
},
/** 预览媒体 */
previewMedia(e: WechatMiniprogram.BaseEvent) {
const { mediaIndex } = e.currentTarget.dataset;
const journals = this.properties.journals as JournalInfo[];
if (!journals || journals.length === 0) return;
// 使用当前 swiper 的索引
const journal = journals[this.data.currentJournalIndex];
const sources = journal.items.map((item: any) => ({
url: item.sourceURL,
type: item.type === 0 ? "image" : "video"
}));
wx.previewMedia({
current: mediaIndex,
sources: sources as WechatMiniprogram.MediaSource[]
});
}
}
});

View File

@ -0,0 +1,62 @@
<!-- components/journal-detail-panel/index.wxml -->
<t-popup
class="popup"
visible="{{visible}}"
placement="bottom"
bind:visible-change="closeDetail"
>
<view class="detail-panel">
<view class="detail-content">
<view class="header">
<view class="info">
<view wx:if="{{title}}" class="title">
<t-icon wx:if="{{showLocationIcon}}" class="icon" name="location-filled" />
<text>{{title}}</text>
</view>
</view>
<view class="actions">
<view wx:if="{{journals.length > 1}}" class="indicator">
{{currentJournalIndex + 1}}/{{journals.length}}
</view>
<t-icon name="close" catchtap="closeDetail" size="48rpx" />
</view>
</view>
<swiper class="journals-swiper" current="{{currentJournalIndex}}" bindchange="onSwiperChange">
<block wx:for="{{journals}}" wx:key="id">
<swiper-item class="swiper-item-wrapper">
<view class="journal-item">
<view class="journal-header">
<view
wx:if="{{item.location && showJournalLocation}}"
class="location"
catchtap="openLocation"
data-journal-index="{{currentJournalIndex}}"
>
<t-icon class="icon" name="location-filled" />
<text class="text">{{item.location}}</text>
</view>
<view wx:if="{{showJournalDate}}" class="date">{{item.date}}</view>
</view>
<view wx:if="{{item.idea}}" class="idea">{{item.idea}}</view>
<scroll-view wx:if="{{item.items && item.items.length > 0}}" scroll-y class="items-scroll">
<view class="items">
<view class="wrapper">
<block wx:for="{{item.items}}" wx:key="mongoId" wx:for-item="media" wx:for-index="mediaIndex">
<image
class="item thumbnail {{media.type === 1 ? 'video' : 'image'}}"
src="{{media.thumbURL}}"
mode="widthFix"
catchtap="previewMedia"
data-media-index="{{mediaIndex}}"
/>
</block>
</view>
</view>
</scroll-view>
</view>
</swiper-item>
</block>
</swiper>
</view>
</view>
</t-popup>

View File

@ -8,5 +8,6 @@
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group",
"t-search": "tdesign-miniprogram/search/search",
"t-empty": "tdesign-miniprogram/empty/empty"
}
},
"styleIsolation": "shared"
}

View File

@ -17,27 +17,39 @@
height: 0;
padding: 0;
.t-cell {
padding: 16rpx 24rpx;
.t-cell__left {
display: flex;
align-items: center;
}
}
.item {
&.selected {
background: var(--td-bg-color-secondarycontainer);
}
.t-cell__left {
margin-right: 16rpx;
}
.thumb {
width: 96rpx;
height: 96rpx;
flex-shrink: 0;
object-fit: cover;
margin-right: 16rpx;
border-radius: 8rpx;
background: var(--td-bg-color-component);
flex-shrink: 0;
border-radius: 8rpx;
}
.date {
color: gray;
}
.location {
.description {
font-size: 24rpx;
}
}

View File

@ -1,6 +1,7 @@
// components/journal-list/index.ts
import config from "../../config/index";
import { JournalPage, JournalPageType } from "../../types/Journal";
import { OrderType } from "../../types/Model";
import Time from "../../utils/Time";
import Toolkit from "../../utils/Toolkit";
@ -58,7 +59,10 @@ Component<JournalListData, {}, {}, ComponentInstance>({
page: {
index: 0,
size: 16,
type: JournalPageType.PREVIEW
type: JournalPageType.PREVIEW,
orderMap: {
createdAt: OrderType.DESC
}
},
searchValue: ""
},
@ -94,6 +98,7 @@ Component<JournalListData, {}, {}, ComponentInstance>({
}
},
methods: {
/** 重置搜索页面 */
resetPage() {
const likeExample = this.data.searchValue ? {
idea: this.data.searchValue,
@ -110,12 +115,16 @@ Component<JournalListData, {}, {}, ComponentInstance>({
size: 16,
type: JournalPageType.PREVIEW,
equalsExample,
likeExample
likeExample,
orderMap: {
createdAt: OrderType.DESC
}
},
list: [],
isFinished: false
});
},
/** 获取数据 */
fetch() {
if (this.data.isFetching || this.data.isFinished) {
return;
@ -135,7 +144,6 @@ Component<JournalListData, {}, {}, ComponentInstance>({
return;
}
const result = list.map((journal: any) => {
// 获取第一张缩略图
const firstThumb = journal.items.find((item: any) => item.attachType === "THUMB");
return {
id: journal.id,
@ -148,7 +156,13 @@ Component<JournalListData, {}, {}, ComponentInstance>({
this.setData({
page: {
...this.data.page,
index: this.data.page.index + 1
index: this.data.page.index + 1,
type: JournalPageType.PREVIEW,
equalsExample: this.data.page.equalsExample,
likeExample: this.data.page.likeExample,
orderMap: {
createdAt: OrderType.DESC
}
},
list: this.data.list.concat(result),
isFinished: list.length < this.data.page.size
@ -159,19 +173,16 @@ Component<JournalListData, {}, {}, ComponentInstance>({
}
});
},
/** 输入搜索 */
onSearchChange(e: WechatMiniprogram.CustomEvent) {
const value = e.detail.value.trim();
this.setData({ searchValue: value });
// 如果是清空操作不使用防抖clear 事件会处理
if (value === "" && this.debouncedSearch) {
this.debouncedSearch.cancel();
return;
}
// 使用防抖自动搜索
// 使用防抖自动搜索(包括清空的情况
if (this.debouncedSearch) {
this.debouncedSearch(value);
}
},
/** 提交搜索 */
onSearchSubmit(e: WechatMiniprogram.CustomEvent) {
const value = e.detail.value.trim();
// 立即搜索,取消防抖
@ -180,6 +191,7 @@ Component<JournalListData, {}, {}, ComponentInstance>({
}
this.resetAndSearch(value);
},
/** 清空搜索 */
onSearchClear() {
// 取消防抖,立即搜索
if (this.debouncedSearch) {
@ -187,6 +199,11 @@ Component<JournalListData, {}, {}, ComponentInstance>({
}
this.resetAndSearch("");
},
/** 保留搜索关键字重新搜索 */
reSearch() {
this.resetAndSearch(this.data.searchValue);
},
/** 重置配置重新搜索 */
resetAndSearch(keyword: string) {
const likeExample = keyword ? {
idea: keyword,
@ -205,7 +222,10 @@ Component<JournalListData, {}, {}, ComponentInstance>({
size: 16,
type: JournalPageType.PREVIEW,
equalsExample,
likeExample
likeExample,
orderMap: {
createdAt: OrderType.DESC
}
},
isFetching: false,
isFinished: false

View File

@ -32,12 +32,14 @@
src="{{item.thumbUrl}}"
mode="aspectFill"
/>
<t-icon wx:else slot="left-icon" name="image" color="gray" size="96rpx" />
<view slot="title">
<text class="date">{{item.date}}</text>
<text wx:if="{{item.idea}}"> · {{item.idea}}</text>
<t-icon wx:else slot="left-icon" class="icon" name="image" color="gray" size="96rpx" />
<view wx:if="{{item.idea}}" slot="title">
<text>{{item.idea}}</text>
</view>
<view class="description" slot="description">
<text>{{item.date}}</text>
<text wx:if="{{item.location}}"> · {{item.location}}</text>
</view>
<text wx:if="{{item.location}}" class="location" slot="description">{{item.location}}</text>
<t-icon
wx:if="{{mode === 'select' && selectedId === item.id}}"
slot="right-icon"

View File

@ -1,4 +0,0 @@
{
"component": true,
"usingComponents": {}
}

View File

@ -1 +0,0 @@
/* components/search-list/index.wxss */

View File

@ -1,24 +0,0 @@
// components/search-list/index.ts
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
}
})

View File

@ -1,2 +0,0 @@
<!--components/search-list/index.wxml-->
<text>components/search-list/index.wxml</text>

View File

@ -1,6 +1,6 @@
const envArgs = {
develop: {
url: "https://api.imyeyu.com"
url: "http://192.168.3.137:8091"
},
trial: {
url: "https://api.imyeyu.com"

View File

@ -26,7 +26,7 @@
</view>
<view class="item">
<text class="label">版本:</text>
<text>1.4.0</text>
<text>1.5.1</text>
</view>
<view class="item copyright">
<text>{{copyright}}</text>

View File

@ -1,6 +1,7 @@
{
"component": true,
"usingComponents": {
"t-icon": "tdesign-miniprogram/icon/icon",
"t-button": "tdesign-miniprogram/button/button",
"t-navbar": "tdesign-miniprogram/navbar/navbar"
}

View File

@ -1,6 +1,5 @@
/* pages/main/journal-creater/index.wxss */
.container {
height: 100vh;
.content {
width: calc(100% - 64px);
@ -40,7 +39,6 @@
.gallery {
gap: 10rpx;
display: grid;
margin-top: 1rem;
grid-template-columns: repeat(3, 1fr);
.item {
@ -51,7 +49,15 @@
box-shadow: 1px 1px 6px var(--theme-shadow-light);
border-radius: 2rpx;
&.add {
color: var(--theme-wx);
margin: 0;
font-size: 80rpx;
background: transparent;
}
.thumbnail {
width: 200rpx;
height: 200rpx;
display: block;
}
@ -63,39 +69,59 @@
.play-icon {
top: 50%;
left: 50%;
width: 60rpx;
height: 60rpx;
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;
width: 40rpx;
height: 40rpx;
color: rgba(255, 255, 255, .6);
z-index: 3;
padding: 5rpx;
position: absolute;
background: rgba(0, 0, 0, 0.5);
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%;
}
}
}
}
}
}
.progress {
width: 100%;
margin-top: 1rem;
}
.ctrl {
width: 100%;
display: flex;
margin-top: 1rem;
align-items: center;
.clear {
width: 200rpx;
}
.submit {
width: 10rem;
margin-top: 1rem;
flex: 1;
margin-left: 12rpx;
}
}
}
}

View File

@ -36,23 +36,6 @@
<text wx:else bind:tap="chooseLocation">选择位置..</text>
</view>
<view class="section media">
<view class="ctrl">
<t-button
class="select"
theme="primary"
plain="true"
disabled="{{isSubmitting}}"
bind:tap="addMedia"
>选择照片/视频</t-button>
<t-button
class="clear"
theme="danger"
variant="outline"
disabled="{{isSubmitting}}"
bind:tap="clearMedia"
disabled="{{mediaList.length === 0}}"
>清空已选</t-button>
</view>
<view class="gallery">
<block wx:for="{{mediaList}}" wx:key="index">
<view class="item">
@ -74,17 +57,27 @@
bindtap="preview"
data-index="{{index}}"
></image>
<image class="play-icon" src="/assets/icon/play.png"></image>
<t-icon class="play-icon" name="play" />
</view>
<!-- 删除 -->
<image
src="/assets/icon/delete.png"
<t-icon
class="delete"
name="close"
bindtap="deleteMedia"
data-index="{{index}}"
></image>
data-new-media="{{true}}"
/>
</view>
</block>
<t-button
class="item add"
theme="primary"
plain="true"
disabled="{{isSubmitting}}"
bind:tap="addMedia"
>
<t-icon class="icon" name="add" />
</t-button>
</view>
</view>
<progress
@ -94,6 +87,15 @@
show-info
stroke-width="4"
/>
<view class="ctrl">
<t-button
class="clear"
theme="danger"
variant="outline"
disabled="{{isSubmitting}}"
bind:tap="clearMedia"
disabled="{{mediaList.length === 0}}"
>清空已选</t-button>
<t-button
class="submit"
theme="primary"
@ -101,4 +103,5 @@
disabled="{{(!idea && mediaList.length === 0) || isSubmitting}}"
>{{submitText}}</t-button>
</view>
</view>
</scroll-view>

View File

@ -0,0 +1,8 @@
{
"usingComponents": {
"t-navbar": "tdesign-miniprogram/navbar/navbar",
"calendar": "/components/calendar/index",
"journal-detail-panel": "/components/journal-detail-panel/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,193 @@
// pages/main/journal-date/index.ts
import config from "../../../config/index";
import Time from "../../../utils/Time";
import { Journal, JournalPageType } from "../../../types/Journal";
import { MediaAttachType } from "../../../types/Attachment";
interface JournalInfo {
id: number;
date: string;
time: string;
lat?: number;
lng?: number;
location?: string;
idea?: string;
items: Array<{
type: number;
thumbURL: string;
sourceURL: string;
mongoId: string;
}>;
}
interface SelectedDateInfo {
displayDate: string;
journals: JournalInfo[];
}
interface JournalDateData {
journalMap: Record<string, number[]>; // 存储每个日期的日记 id 列表
selectedDate: SelectedDateInfo | null;
isLoading: boolean;
popupVisible: boolean; // popup 显示状态
}
Page({
data: <JournalDateData>{
journalMap: {},
selectedDate: null,
isLoading: true,
popupVisible: false
},
async onLoad() {
await this.loadJournals();
},
/** 加载所有日记 */
async loadJournals() {
this.setData({ isLoading: true });
try {
const list: Journal[] = await new Promise((resolve, reject) => {
wx.request({
url: `${config.url}/journal/list`,
method: "POST",
header: {
Key: wx.getStorageSync("key")
},
data: {
page: 0,
size: 9007199254740992,
type: JournalPageType.PREVIEW
},
success: (resp: any) => {
if (resp.data.code === 20000) {
resolve(resp.data.data.list);
} else {
reject(new Error(resp.data.message || "加载失败"));
}
},
fail: reject
});
}) || [];
// 按日期分组,只存储 id
const journalMap: Record<string, number[]> = {};
list.forEach((journal: any) => {
const date = new Date(journal.createdAt);
const dateKey = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
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, year, month, day } = e.detail;
const journalIds = this.data.journalMap[date];
if (!journalIds || journalIds.length === 0) {
wx.showToast({
title: "该日期无日记",
icon: "none"
});
return;
}
// 调用接口获取详情
this.loadJournalsByIds(journalIds, `${year}${month}${day}`);
},
/** 根据 id 列表加载日记详情 */
async loadJournalsByIds(ids: number[], displayDate: string) {
wx.showLoading({ title: "加载中...", mask: true });
try {
const list: Journal[] = await new Promise((resolve, reject) => {
wx.request({
url: `${config.url}/journal/list/ids`,
method: "POST",
header: {
Key: wx.getStorageSync("key")
},
data: ids,
success: (resp: any) => {
if (resp.data.code === 20000) {
resolve(resp.data.data);
} else {
reject(new Error(resp.data.message || "加载失败"));
}
},
fail: reject
});
}) || [];
// 转换为 JournalInfo 格式
const journals: JournalInfo[] = list.sort((a, b) => a.createdAt! - b.createdAt!).map((journal: any) => {
const date = new Date(journal.createdAt);
return {
id: journal.id,
date: Time.toPassedDateTime(journal.createdAt),
time: `${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}`,
lat: journal.lat,
lng: journal.lng,
location: journal.location,
idea: journal.idea,
items: journal.items
.filter((item: any) => item.attachType === MediaAttachType.THUMB)
.map((item: any) => {
const ext = JSON.parse(item.ext);
return {
type: ext.isVideo ? 1 : 0,
thumbURL: `${config.url}/attachment/read/${item.mongoId}`,
sourceURL: `${config.url}/attachment/read/${ext.sourceMongoId}`,
mongoId: item.mongoId,
};
})
};
});
this.setData({
selectedDate: {
displayDate,
journals
},
popupVisible: true // 显示 popup
});
wx.hideLoading();
} catch (err: any) {
wx.hideLoading();
wx.showToast({
title: err.message || "加载失败",
icon: "error"
});
}
},
/** 关闭详情 */
closeDetail() {
this.setData({
popupVisible: false,
selectedDate: null
});
}
});

View File

@ -0,0 +1,19 @@
<!--pages/main/journal-date/index.wxml-->
<t-navbar title="日期查找" 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-panel
visible="{{popupVisible}}"
title="{{selectedDate.displayDate}}"
journals="{{selectedDate.journals}}"
show-journal-date="{{false}}"
show-journal-location="{{true}}"
bind:close="closeDetail"
/>

View File

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

View File

@ -0,0 +1,146 @@
/* 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;
&.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;
}
.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);
}
}
}
}
}
.progress {
width: 100%;
margin-top: 1rem;
}
.ctrl {
width: 100%;
display: flex;
margin-top: 1rem;
align-items: center;
.delete {
width: 200rpx;
}
.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,384 @@
// 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 { Journal } from "../../../types/Journal";
import { MediaAttachExt, MediaAttachType } from "../../../types/Attachment";
interface JournalEditorData {
id?: number;
idea: string;
date: string;
time: string;
mediaList: MediaItem[];
newMediaList: WechatMediaItem[];
location?: Location;
isAuthLocation: boolean;
isLoading: boolean;
saveText: string;
isSaving: boolean;
saveProgress: number;
mediaItemTypeEnum: any;
deleteDialogVisible: boolean;
deleteConfirmText: string;
}
Page({
data: <JournalEditorData>{
id: undefined,
idea: "",
date: "2025-06-28",
time: "16:00",
mediaList: [],
newMediaList: [],
location: undefined,
saveText: "保存",
isSaving: false,
saveProgress: 0,
isLoading: true,
mediaItemTypeEnum: {
...MediaItemType
},
isAuthLocation: false,
deleteDialogVisible: false,
deleteConfirmText: ""
},
async onLoad(options: any) {
// 授权定位
const setting = await wx.getSetting();
wx.setStorageSync("isAuthLocation", setting.authSetting["scope.userLocation"]);
let isAuthLocation = JSON.parse(wx.getStorageSync("isAuthLocation"));
this.setData({ isAuthLocation });
if (!isAuthLocation) {
wx.authorize({
scope: "scope.userLocation"
}).then(() => {
isAuthLocation = true;
this.setData({ isAuthLocation });
});
}
// 获取日记 ID
const id = options.id ? parseInt(options.id) : undefined;
if (!id) {
wx.showToast({
title: "缺少日志 ID",
icon: "error"
});
setTimeout(() => {
wx.navigateBack();
}, 1500);
return;
}
this.setData({ id });
await this.loadJournalDetail(id);
},
/** 加载日记详情 */
async loadJournalDetail(id: number) {
wx.showLoading({ title: "加载中...", mask: true });
try {
const journal: Journal = await new Promise((resolve, reject) => {
wx.request({
url: `${config.url}/journal/${id}`,
method: "POST",
header: {
Key: wx.getStorageSync("key")
},
success: (res: any) => {
if (res.data.code === 20000) {
resolve(res.data.data);
} else {
reject(new Error(res.data.message || "加载失败"));
}
},
fail: reject
});
});
const items = journal.items || [];
const thumbItems = items.filter((item) => item.attachType === MediaAttachType.THUMB);
const mediaList: MediaItem[] = thumbItems.map((thumbItem) => {
const ext = thumbItem.ext = JSON.parse(thumbItem.ext!.toString()) as MediaAttachExt;
const thumbURL = `${config.url}/attachment/read/${thumbItem.mongoId}`;
const sourceURL = `${config.url}/attachment/read/${ext.sourceMongoId}`;
return {
type: ext.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),
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);
}
},
/** 选择位置 */
async chooseLocation() {
const location = await wx.chooseLocation({});
this.setData({
location: {
lat: location.latitude,
lng: location.longitude,
text: location.name
}
});
},
/** 新增附件 */
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;
});
that.setData({
newMediaList: [...that.data.newMediaList, ...newMedia]
});
wx.hideLoading();
}
});
},
/** 预览附件 */
preview(e: WechatMiniprogram.BaseEvent) {
const isNewMedia = e.currentTarget.dataset.newMedia;
const index = e.currentTarget.dataset.index;
const sources = this.data.mediaList.map(item => ({
url: item.sourceURL,
type: MediaItemType[item.type].toLowerCase()
}));
const newSources = this.data.newMediaList.map(item => ({
url: item.path,
type: MediaItemType[item.type].toLowerCase()
}));
const allSources = [...sources, ...newSources];
const currentIndex = isNewMedia ? this.data.mediaList.length + index : index;
wx.previewMedia({
current: currentIndex,
sources: allSources as WechatMiniprogram.MediaSource[]
});
},
/** 删除附件 */
deleteMedia(e: WechatMiniprogram.BaseEvent) {
const isNewMedia = e.currentTarget.dataset.newMedia;
const index = e.currentTarget.dataset.index;
if (isNewMedia) {
const mediaList = [...this.data.mediaList];
mediaList.splice(index, 1);
this.setData({ mediaList });
} else {
const newMediaList = [...this.data.newMediaList];
newMediaList.splice(index, 1);
this.setData({ newMediaList });
}
},
/** 取消编辑 */
cancel() {
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();
},
/** 执行删除 */
executeDelete() {
wx.showLoading({ title: "删除中...", mask: true });
wx.request({
url: `${config.url}/journal/delete`,
method: "POST",
header: {
Key: wx.getStorageSync("key"),
"Content-Type": "application/json"
},
data: {
id: this.data.id
},
success: (res: any) => {
wx.hideLoading();
if (res.data.code === 20000 || res.statusCode === 200) {
Events.emit("JOURNAL_REFRESH");
Events.emit("JOURNAL_LIST_REFRESH");
wx.showToast({
title: "删除成功",
icon: "success"
});
setTimeout(() => {
wx.navigateBack();
}, 1000);
} else {
wx.showToast({
title: res.data.message || "删除失败",
icon: "error"
});
}
},
fail: () => {
wx.hideLoading();
wx.showToast({
title: "删除失败",
icon: "error"
});
}
});
},
/** 保存 */
save() {
const handleFail = () => {
wx.showToast({ title: "保存失败", icon: "error" });
this.setData({
saveText: "保存",
isSaving: false
});
};
this.setData({
saveText: "正在保存..",
isSaving: true
});
// 收集保留的附件 ID缩略图 ID
const attachmentIds = this.data.mediaList.map(item => item.attachmentId);
// 上传新媒体文件
const uploadFiles = new Promise<string[]>((resolve, reject) => {
const total = this.data.newMediaList.length;
let completed = 0;
if (total === 0) {
resolve([]);
return;
}
this.setData({
saveProgress: 0,
});
// 上传临时文件
const uploadPromises = this.data.newMediaList.map((item) => {
return new Promise<string>((uploadResolve, uploadReject) => {
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) {
completed++;
// 更新进度
this.setData({
saveProgress: (completed / total),
});
uploadResolve(result.data[0].id);
} else {
uploadReject(new Error(`文件上传失败: ${result?.message || '未知错误'}`));
}
},
fail: (err) => uploadReject(new Error(`文件上传失败: ${err.errMsg}`))
});
});
});
// 并行执行所有文件上传
Promise.all(uploadPromises).then((tempFileIds) => {
this.setData({
saveProgress: 1,
});
resolve(tempFileIds);
}).catch(reject);
});
// 提交保存
uploadFiles.then((tempFileIds) => {
wx.request({
url: `${config.url}/journal/update`,
method: "POST",
header: {
Key: wx.getStorageSync("key")
},
data: {
id: this.data.id,
idea: this.data.idea,
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(),
// 保留的现有附件 ID
attachmentIds,
// 新上传的临时文件 ID
tempFileIds
},
success: async (resp: any) => {
if (resp.data.code === 20000 || resp.statusCode === 200) {
Events.emit("JOURNAL_REFRESH");
Events.emit("JOURNAL_LIST_REFRESH");
wx.showToast({ title: "保存成功", icon: "success" });
this.setData({
saveText: "保存",
isSaving: false,
});
await Toolkit.sleep(1000);
wx.navigateBack();
} else {
handleFail();
}
},
fail: handleFail
});
}).catch(handleFail);
}
});

View File

@ -0,0 +1,166 @@
<!--pages/main/journal-editor/index.wxml-->
<t-navbar title="编辑记录">
<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 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">
<!-- 现有附件 -->
<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="{{true}}"
/>
</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>
<t-button
class="item add"
theme="primary"
plain="true"
disabled="{{isSaving}}"
bind:tap="addMedia"
>
<t-icon name="add" />
</t-button>
</view>
</view>
<progress
wx:if="{{isSaving}}"
class="progress"
percent="{{saveProgress.toFixed(2) * 100}}"
show-info
stroke-width="4"
/>
<view class="ctrl">
<t-button class="delete" theme="danger" bind:tap="deleteJournal" disabled="{{isSaving}}">删除记录</t-button>
<t-button
class="save"
theme="primary"
bind:tap="save"
disabled="{{(!idea && mediaList.length === 0 && newMediaList.length === 0) || isSaving}}"
>{{saveText}}</t-button>
</view>
</block>
</view>
</scroll-view>
<t-dialog
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
class="confirm-input"
model:value="{{deleteConfirmText}}"
placeholder="请输入:确认删除"
/>
</view>
</t-dialog>

View File

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

View File

@ -0,0 +1,101 @@
/* pages/main/journal-map/index.less */
.container {
width: 100%;
height: 100vh;
position: fixed;
overflow: hidden;
.map {
width: 100%;
height: 100%;
}
.custom-callout {
width: fit-content;
min-width: 350rpx;
max-width: 450rpx;
background: #fff;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, .15);
border-radius: 6rpx;
.callout-content {
display: flex;
padding: 8rpx 16rpx 8rpx 8rpx;
align-items: flex-start;
.thumb-container {
width: 72rpx;
height: 72rpx;
position: relative;
flex-shrink: 0;
margin-right: 12rpx;
overflow: hidden;
border-radius: 6rpx;
.thumb {
width: 100%;
height: 100%;
}
.count-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-container {
flex: 1;
display: flex;
overflow: hidden;
flex-direction: column;
.location {
color: #333;
overflow: hidden;
font-size: 30rpx;
white-space: nowrap;
text-overflow: ellipsis;
margin-bottom: 4rpx;
}
.date-count {
display: flex;
.date {
color: #999;
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,287 @@
// pages/main/journal-map/index.ts
import config from "../../../config/index";
import Time from "../../../utils/Time";
import { Journal, JournalPageType } from "../../../types/Journal";
import { MediaAttachExt, MediaAttachType } from "../../../types/Attachment";
import Toolkit from "../../../utils/Toolkit";
interface MapMarker {
id: number;
latitude: number;
longitude: number;
width: number;
height: number;
customCallout: {
anchorY: number;
anchorX: number;
display: string;
};
}
interface JournalInfo {
id: number;
date: string;
time: string;
location?: string;
idea?: string;
items: Array<{
type: number;
thumbURL: string;
sourceURL: string;
mongoId: string;
}>;
}
interface LocationMarker {
locationKey: string; // 位置键 "lat,lng"
lat: number;
lng: number;
location?: string;
journalIds: number[]; // 该位置的所有日记 ID
count: number; // 日记数量
date: string;
previewThumb?: string; // 预览缩略图
}
interface SelectedLocationInfo {
location?: string;
journals: JournalInfo[];
}
interface JournalMapData {
centerLat: number;
centerLng: number;
scale: number;
markers: MapMarker[];
locations: LocationMarker[]; // 位置标记列表
customCalloutMarkerIds: string[]; // 改为 string[] 以支持 locationKey
includePoints: Array<{ latitude: number; longitude: number }>; // 缩放视野以包含所有点
selectedLocation: SelectedLocationInfo | null; // 选中的位置信息
showDetail: boolean; // 是否显示详情(控制 DOM 存在)
detailVisible: boolean; // 详情是否可见(控制动画)
isLoading: boolean;
}
Page({
data: <JournalMapData>{
centerLat: 39.908823,
centerLng: 116.397470,
scale: 13,
markers: [],
locations: [],
customCalloutMarkerIds: [],
includePoints: [],
selectedLocation: null,
showDetail: false,
detailVisible: false,
isLoading: true,
},
async onLoad() {
await this.loadJournals();
},
/** 加载所有记录 */
async loadJournals() {
this.setData({ isLoading: true });
try {
const list: Journal[] = await new Promise((resolve, reject) => {
wx.request({
url: `${config.url}/journal/list`,
method: "POST",
header: {
Key: wx.getStorageSync("key")
},
data: {
page: 0,
size: 9007199254740992,
type: JournalPageType.PREVIEW
},
success: (resp: any) => {
if (resp.data.code === 20000) {
resolve(resp.data.data.list);
} else {
reject(new Error(resp.data.message || "加载失败"));
}
},
fail: reject
});
}) || [];
// 过滤有位置信息的记录,并按位置分组
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: 0,
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;
wx.showLoading({ title: "加载中...", mask: true });
try {
// 根据 journalIds 加载日记详情
const list: Journal[] = await new Promise((resolve, reject) => {
wx.request({
url: `${config.url}/journal/list/ids`,
method: "POST",
header: {
Key: wx.getStorageSync("key")
},
data: location.journalIds,
success: (resp: any) => {
if (resp.data.code === 20000) {
resolve(resp.data.data);
} else {
reject(new Error(resp.data.message || "加载失败"));
}
},
fail: reject
});
}) || [];
// 转换为 JournalInfo 格式
const journals: JournalInfo[] = list.map((journal: any) => {
const date = new Date(journal.createdAt);
return {
id: journal.id,
date: Time.toPassedDateTime(journal.createdAt),
time: `${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}`,
location: journal.location,
idea: journal.idea,
items: journal.items
.filter((item: any) => item.attachType === MediaAttachType.THUMB)
.map((item: any) => {
const ext = JSON.parse(item.ext);
return {
type: ext.isVideo ? 1 : 0,
thumbURL: `${config.url}/attachment/read/${item.mongoId}`,
sourceURL: `${config.url}/attachment/read/${ext.sourceMongoId}`,
mongoId: item.mongoId,
};
})
};
});
// 先显示元素,再触发动画
this.setData({
selectedLocation: {
location: location.location,
journals
},
showDetail: true
});
wx.nextTick(() => {
this.setData({ detailVisible: true });
});
wx.hideLoading();
} catch (err: any) {
wx.hideLoading();
wx.showToast({
title: err.message || "加载失败",
icon: "error"
});
}
},
/** 关闭详情 */
async closeDetail() {
this.setData({ detailVisible: false });
await Toolkit.sleep(350);
this.setData({
showDetail: false,
selectedLocation: null
});
},
});

View File

@ -0,0 +1,48 @@
<!--pages/main/journal-map/index.wxml-->
<t-navbar title="地图查找" left-arrow />
<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">
<block wx:for="{{locations}}" wx:key="locationKey" wx:for-index="markerIndex">
<cover-view class="custom-callout" marker-id="{{markerIndex}}">
<cover-view class="callout-content">
<cover-view wx:if="{{item.previewThumb}}" class="thumb-container">
<cover-image class="thumb" src="{{item.previewThumb}}" />
<cover-view wx:if="{{item.count > 1}}" class="count-badge">{{item.count}}</cover-view>
</cover-view>
<cover-view class="text-container">
<cover-view wx:if="{{item.location}}" class="location">{{item.location}}</cover-view>
<cover-view class="date-count">
<cover-view class="date">{{item.date}}</cover-view>
<cover-view wx:if="{{item.count > 1}}" class="count">{{item.count}} 条日记</cover-view>
</cover-view>
</cover-view>
</cover-view>
</cover-view>
</block>
</cover-view>
</map>
<view wx:if="{{isLoading}}" class="loading">
<view class="loading-text">加载中...</view>
</view>
</view>
<!-- 详情面板 -->
<journal-detail-panel
visible="{{showDetail && detailVisible}}"
title="{{selectedLocation.location}}"
journals="{{selectedLocation.journals}}"
show-location-icon="{{true}}"
show-journal-date="{{true}}"
show-journal-location="{{false}}"
bind:close="closeDetail"
/>

View File

@ -1,12 +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;
// TODO: 跳转到编辑页面或详情页
wx.showToast({
title: `编辑功能待开发 (ID: ${id})`,
icon: "none",
duration: 2000
wx.navigateTo({
url: `/pages/main/journal-editor/index?id=${id}`
});
}
});

View File

@ -1,12 +1,12 @@
<view class="custom-navbar">
<t-navbar title="列表查找" left-arrow />
<t-navbar title="列表查找" left-arrow />
</view>
<view class="content">
<journal-list
id="listRef"
searchable="{{true}}"
mode="navigate"
type="NORMAL"
bind:navigate="onNavigateItem"
/>
</view>

View File

@ -5,7 +5,6 @@
"t-icon": "tdesign-miniprogram/icon/icon",
"t-navbar": "tdesign-miniprogram/navbar/navbar",
"t-indexes": "tdesign-miniprogram/indexes/indexes",
"t-calendar": "tdesign-miniprogram/calendar/calendar",
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group",
"t-indexes-anchor": "tdesign-miniprogram/indexes-anchor/indexes-anchor"
},

View File

@ -19,18 +19,6 @@
}
}
.calendar {
// .t-calendar__dates-item {
// color: var(--td-text-color-disabled);
// &.t-calendar__dates-item--selected {
// color: var(--td-calendar-title-color);
// background: transparent;
// }
// }
}
.journal-list {
width: 100vw;
@ -46,7 +34,8 @@
font-size: 14px;
}
.text {
> .text {
color: var(--theme-text-primary);
width: calc(100% - 32px - 2rem);
padding: 8px 16px;
margin: .5rem 1rem 1rem 1rem;
@ -75,8 +64,18 @@
}
.location {
gap: 6rpx;
display: flex;
align-items: center;
justify-content: flex-end;
.icon {
color: var(--theme-wx);
}
.text {
color: var(--theme-text-secondary);
text-align: right;
}
}
}

View File

@ -4,6 +4,7 @@ import Time from "../../../utils/Time";
import config from "../../../config/index"
import Events from "../../../utils/Events";
import { JournalPage, JournalPageType } from "../../../types/Journal";
import { OrderType } from "../../../types/Model";
export type Journal = {
date: string;
@ -45,6 +46,9 @@ Page({
type: JournalPageType.NORMAL,
likeMap: {
type: "NORMAL"
},
orderMap: {
createdAt: OrderType.DESC
}
},
list: [],
@ -70,6 +74,9 @@ Page({
type: JournalPageType.NORMAL,
equalsExample: {
type: "NORMAL"
},
orderMap: {
createdAt: OrderType.DESC
}
},
list: [],
@ -82,20 +89,6 @@ Page({
list: []
})
this.fetch();
// 可选日期
wx.request({
url: `${config.url}/journal/list/date?key=${wx.getStorageSync("key")}`,
method: "GET",
success: async (resp: any) => {
const dates = resp.data.data.sort((a: number, b: number) => a - b);
this.setData({
// dateFilterMin: dates[0],
// dateFilterMax: dates[dates.length - 1],
dateFilterAllows: dates,
// dateFilterVisible: this.data.dateFilterVisible
});
}
});
},
onReady() {
this.getCustomNavbarHeight();
@ -121,17 +114,25 @@ Page({
isShowMoreMenu: !this.data.isShowMoreMenu
})
},
openDateFilter() {
this.setData({
dateFilterVisible: true
});
toCreater() {
wx.navigateTo({
"url": "/pages/main/journal-creater/index?from=journal"
})
},
tapCalendar(e: any) {
console.log(e);
toSearch() {
wx.navigateTo({
url: "/pages/main/journal-search/index"
})
},
toDateFilter(e: any) {
console.log(e);
// console.log(Toolkit.symmetricDiff(this.data.dateFilter.allows, e.detail.value));
toMap() {
wx.navigateTo({
url: "/pages/main/journal-map/index"
})
},
toDate() {
wx.navigateTo({
url: "/pages/main/journal-date/index"
})
},
fetch() {
if (this.data.isFetching || this.data.isFinished) {
@ -180,6 +181,9 @@ Page({
type: JournalPageType.NORMAL,
equalsExample: {
type: "NORMAL"
},
orderMap: {
createdAt: OrderType.DESC
}
},
list: this.data.list.concat(result),
@ -224,14 +228,4 @@ Page({
});
}
},
toCreater() {
wx.navigateTo({
"url": "/pages/main/journal-creater/index?from=journal"
})
},
toSearch() {
wx.navigateTo({
url: "/pages/main/journal-search/index"
})
}
});

View File

@ -6,24 +6,13 @@
<t-cell-group class="content" theme="card">
<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="openDateFilter" />
<t-cell title="按地图查找" leftIcon="location" />
<t-cell title="按日期查找" leftIcon="calendar-1" bind:tap="toDate" />
<t-cell title="按地图查找" leftIcon="location" bind:tap="toMap" />
</t-cell-group>
</view>
</view>
</t-navbar>
</view>
<t-calendar
class="calendar"
type="multiple"
min-date="{{dateFilterMin}}"
max-date="{{dateFilterMax}}"
value="{{dateFilterAllows}}"
visible="{{dateFilterVisible}}"
switch-mode="year-month"
confirm-btn="{{null}}"
bind:tap="tapCalendar"
/>
<t-indexes
class="journal-list"
bind:scroll="onScroll"
@ -38,7 +27,10 @@
class="location"
bind:tap="openLocation"
data-journal-index="{{journalIndex}}"
>📍 {{journal.location}}</view>
>
<t-icon class="icon" name="location-filled" />
<text class="text">{{journal.location}}</text>
</view>
</view>
<view wx:if="{{journal.items}}" class="items">
<block wx:for="{{journal.items}}" wx:for-item="item" wx:for-index="itemIndex" wx:key="date">

View File

@ -127,6 +127,7 @@
}
&.form {
padding-bottom: 32rpx;
.content {
padding: 16rpx 32rpx;

View File

@ -185,7 +185,6 @@
<journal-list
visible="{{archiveStep === 'select-journal'}}"
searchable="{{true}}"
type="{{type}}"
selectedId="{{selectedJournalId}}"
bind:select="onJournalListSelect"
/>

View File

@ -9,18 +9,18 @@ page {
--theme-wx: #07C160;
/* === 背景色 === */
--theme-bg-primary: #FFFFFF;
--theme-bg-primary: #FFF;
--theme-bg-secondary: #F5F5F5;
--theme-bg-card: #FFFFFF;
--theme-bg-journal: #FFF8E1;
--theme-bg-card: #FFF;
--theme-bg-journal: #fff2C8;
--theme-bg-overlay: rgba(0, 0, 0, .1);
--theme-bg-menu: rgba(255, 255, 255, .95);
/* === 文字颜色 === */
--theme-text-primary: #000000;
--theme-text-secondary: #777777;
--theme-text-tertiary: #999999;
--theme-text-disabled: #CCCCCC;
--theme-text-primary: #333;
--theme-text-secondary: #777;
--theme-text-tertiary: #999;
--theme-text-disabled: #CCC;
/* === 边框颜色 === */
--theme-border-light: rgba(0, 0, 0, .1);
@ -69,10 +69,10 @@ page[data-weui-theme="dark"] {
--theme-bg-menu: rgba(40, 40, 40, .95);
/* === 文字颜色 === */
--theme-text-primary: #FFFFFF;
--theme-text-secondary: #AAAAAA;
--theme-text-tertiary: #888888;
--theme-text-disabled: #666666;
--theme-text-primary: #FFF;
--theme-text-secondary: #AAA;
--theme-text-tertiary: #888;
--theme-text-disabled: #666;
/* === 边框颜色 === */
--theme-border-light: rgba(255, 255, 255, .1);

View File

@ -0,0 +1,55 @@
import { Model } from "./Model";
/** 附件 */
export type Attachment = {
/** 业务类型 */
bizType: string;
/** 业务 ID */
bizId: number;
/** 附件类型 */
attachType?: MediaAttachType;
/** 文件名 */
name: string;
/** 文件 MD5 */
md5: string;
/** 访问 mongoId */
mongoId: string;
/** 大小 */
size: number;
/** 扩展数据 */
ext?: string | MediaAttachExt;
} & Model;
/** 媒体附件类型 */
export enum MediaAttachType {
/** 原图 */
SOURCE = "SOURCE",
/** 缩略图 */
THUMB = "THUMB"
}
/** 媒体附件扩展数据 */
export type MediaAttachExt = {
/** 原文件附件 ID */
sourceId: number;
/** 原文件访问 mongoId */
sourceMongoId: string;
/** true 为图片 */
isImage: boolean;
/** true 为视频 */
isVideo: boolean;
}

View File

@ -1,11 +1,54 @@
import { QueryPage } from "./Model";
import { Attachment } from "./Attachment";
import { Model, QueryPage } from "./Model";
/** 日记 */
export type Journal = {
/** 类型 */
type: JournalType;
/** 想法、说明 */
idea?: string;
/** 维度 */
lat?: number;
/** 经度 */
lng?: number;
/** 位置 */
location?: string;
/** 天气 */
weatcher?: string;
/** 附件(照片、视频等) */
items?: Attachment[];
} & Model;
/** 日记类型 */
export enum JournalType {
/** 正常 */
NORMAL = "NORMAL",
/** 专业拍摄 */
PORTFOLIO = "PORTFOLIO"
}
/** 日记页面查询对象 */
export type JournalPage = {
/** 查询类型 */
type: JournalPageType;
} & QueryPage;
/** 日记页面查询类型 */
export enum JournalPageType {
/** 正常查询所有附件 */
NORMAL = "NORMAL",
/** 仅查询第一个附件用于预览 */
PREVIEW = "PREVIEW"
}

View File

@ -1,4 +1,4 @@
// 基本实体模型
/** 基本实体模型 */
export type Model = {
id?: number;
@ -7,37 +7,45 @@ export type Model = {
deletedAt?: number;
}
/** 基本返回对象 */
export type Response = {
code: number;
msg?: string;
data: object;
}
/** 基本页面查询对象 */
export type QueryPage = {
/** 页面下标,从 0 开始 */
index: number;
/** 单页数据量 */
size: number;
/** 排序 */
orderMap?: { [key: string]: OrderType };
/** 全等比较条件AND 连接) */
equalsExample?: { [key: string]: string | undefined | null };
/** 模糊查询条件OR 连接) */
likeExample?: { [key: string]: string | undefined | null };
}
/** 排序方式 */
export enum OrderType {
ASC = "ASC",
DESC = "DESC"
}
/** 页面查询返回 */
export type QueryPageResult<T> = {
total: number;
list: T[];
}
// 携带验证码的请求体
export type CaptchaData<T> = {
from: string;
captcha: string;
data: T;
}
/** 键值对对象 */
export type KeyValue<T> = {
key: string;
value: T;

64
miniprogram/types/UI.ts Normal file
View File

@ -0,0 +1,64 @@
/** 系统媒体项目 */
export type MediaItem = {
/** 类型 */
type: MediaItemType;
/** 缩略图访问 URL */
thumbURL: string;
/** 原图访问 URL */
sourceURL: string;
/** 文件大小 */
size: number;
/** 附件 ID */
attachmentId: number;
}
/** 微信媒体项目 */
export type WechatMediaItem = {
/** 类型 */
type: MediaItemType;
/** 本地路径 */
path: string;
/** 缩略图路径 */
thumbPath: string;
/** 文件大小 */
size: number;
/** 时长(视频) */
duration: number | undefined;
/** 微信原始媒体对象 */
raw?: any;
}
/** 媒体项目类型 */
export enum MediaItemType {
/** 图片 */
IMAGE,
/** 视频 */
VIDEO
}
/** 位置 */
export type Location = {
/** 维度 */
lat?: number;
/** 经度 */
lng?: number;
/** 描述 */
text?: string;
}