Compare commits
26 Commits
4786df0c36
...
980d0e1431
| Author | SHA1 | Date | |
|---|---|---|---|
| 980d0e1431 | |||
| 1905d1cd5a | |||
| 18c6a41549 | |||
| 920b3c87e8 | |||
| 1e54782600 | |||
| a5fb1d752b | |||
| 79bc51bc56 | |||
| b6be7c50e8 | |||
| fd533cb92d | |||
| 16335821e2 | |||
| d07fa0ef88 | |||
| 432cc85663 | |||
| 71cbf554d4 | |||
| 69bf186f0e | |||
| ad755c7d0e | |||
| 4f1942f3f0 | |||
| b4f25929df | |||
| 3305e4a508 | |||
| aa6b00a87d | |||
| ea0186447a | |||
| c3d1276a24 | |||
| 58c55f3672 | |||
| 630c7fefcb | |||
| a38ed44fd1 | |||
| 19b6206695 | |||
| 6dc4d71718 |
@ -4,6 +4,9 @@
|
|||||||
"pages/main/journal/index",
|
"pages/main/journal/index",
|
||||||
"pages/main/journal-creater/index",
|
"pages/main/journal-creater/index",
|
||||||
"pages/main/journal-search/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/portfolio/index",
|
||||||
"pages/main/travel/index",
|
"pages/main/travel/index",
|
||||||
"pages/main/about/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 |
6
miniprogram/components/calendar/index.json
Normal file
6
miniprogram/components/calendar/index.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"component": true,
|
||||||
|
"usingComponents": {
|
||||||
|
"t-icon": "tdesign-miniprogram/icon/icon"
|
||||||
|
}
|
||||||
|
}
|
||||||
114
miniprogram/components/calendar/index.less
Normal file
114
miniprogram/components/calendar/index.less
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
210
miniprogram/components/calendar/index.ts
Normal file
210
miniprogram/components/calendar/index.ts
Normal 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-DD,value 为日记 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
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
46
miniprogram/components/calendar/index.wxml
Normal file
46
miniprogram/components/calendar/index.wxml
Normal 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>
|
||||||
7
miniprogram/components/journal-detail-panel/index.json
Normal file
7
miniprogram/components/journal-detail-panel/index.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"component": true,
|
||||||
|
"usingComponents": {
|
||||||
|
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||||
|
"t-popup": "tdesign-miniprogram/popup/popup"
|
||||||
|
}
|
||||||
|
}
|
||||||
166
miniprogram/components/journal-detail-panel/index.less
Normal file
166
miniprogram/components/journal-detail-panel/index.less
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
116
miniprogram/components/journal-detail-panel/index.ts
Normal file
116
miniprogram/components/journal-detail-panel/index.ts
Normal 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[]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
62
miniprogram/components/journal-detail-panel/index.wxml
Normal file
62
miniprogram/components/journal-detail-panel/index.wxml
Normal 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>
|
||||||
@ -8,5 +8,6 @@
|
|||||||
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group",
|
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group",
|
||||||
"t-search": "tdesign-miniprogram/search/search",
|
"t-search": "tdesign-miniprogram/search/search",
|
||||||
"t-empty": "tdesign-miniprogram/empty/empty"
|
"t-empty": "tdesign-miniprogram/empty/empty"
|
||||||
}
|
},
|
||||||
|
"styleIsolation": "shared"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,27 +17,39 @@
|
|||||||
height: 0;
|
height: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|
||||||
|
.t-cell {
|
||||||
|
padding: 16rpx 24rpx;
|
||||||
|
|
||||||
|
.t-cell__left {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.item {
|
.item {
|
||||||
|
|
||||||
&.selected {
|
&.selected {
|
||||||
background: var(--td-bg-color-secondarycontainer);
|
background: var(--td-bg-color-secondarycontainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.t-cell__left {
|
||||||
|
margin-right: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.thumb {
|
.thumb {
|
||||||
width: 96rpx;
|
width: 96rpx;
|
||||||
height: 96rpx;
|
height: 96rpx;
|
||||||
flex-shrink: 0;
|
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
margin-right: 16rpx;
|
|
||||||
border-radius: 8rpx;
|
|
||||||
background: var(--td-bg-color-component);
|
background: var(--td-bg-color-component);
|
||||||
|
flex-shrink: 0;
|
||||||
|
border-radius: 8rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.date {
|
.date {
|
||||||
color: gray;
|
color: gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
.location {
|
.description {
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
// components/journal-list/index.ts
|
// components/journal-list/index.ts
|
||||||
import config from "../../config/index";
|
import config from "../../config/index";
|
||||||
import { JournalPage, JournalPageType } from "../../types/Journal";
|
import { JournalPage, JournalPageType } from "../../types/Journal";
|
||||||
|
import { OrderType } from "../../types/Model";
|
||||||
import Time from "../../utils/Time";
|
import Time from "../../utils/Time";
|
||||||
import Toolkit from "../../utils/Toolkit";
|
import Toolkit from "../../utils/Toolkit";
|
||||||
|
|
||||||
@ -58,7 +59,10 @@ Component<JournalListData, {}, {}, ComponentInstance>({
|
|||||||
page: {
|
page: {
|
||||||
index: 0,
|
index: 0,
|
||||||
size: 16,
|
size: 16,
|
||||||
type: JournalPageType.PREVIEW
|
type: JournalPageType.PREVIEW,
|
||||||
|
orderMap: {
|
||||||
|
createdAt: OrderType.DESC
|
||||||
|
}
|
||||||
},
|
},
|
||||||
searchValue: ""
|
searchValue: ""
|
||||||
},
|
},
|
||||||
@ -94,6 +98,7 @@ Component<JournalListData, {}, {}, ComponentInstance>({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
/** 重置搜索页面 */
|
||||||
resetPage() {
|
resetPage() {
|
||||||
const likeExample = this.data.searchValue ? {
|
const likeExample = this.data.searchValue ? {
|
||||||
idea: this.data.searchValue,
|
idea: this.data.searchValue,
|
||||||
@ -110,12 +115,16 @@ Component<JournalListData, {}, {}, ComponentInstance>({
|
|||||||
size: 16,
|
size: 16,
|
||||||
type: JournalPageType.PREVIEW,
|
type: JournalPageType.PREVIEW,
|
||||||
equalsExample,
|
equalsExample,
|
||||||
likeExample
|
likeExample,
|
||||||
|
orderMap: {
|
||||||
|
createdAt: OrderType.DESC
|
||||||
|
}
|
||||||
},
|
},
|
||||||
list: [],
|
list: [],
|
||||||
isFinished: false
|
isFinished: false
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
/** 获取数据 */
|
||||||
fetch() {
|
fetch() {
|
||||||
if (this.data.isFetching || this.data.isFinished) {
|
if (this.data.isFetching || this.data.isFinished) {
|
||||||
return;
|
return;
|
||||||
@ -135,7 +144,6 @@ Component<JournalListData, {}, {}, ComponentInstance>({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = list.map((journal: any) => {
|
const result = list.map((journal: any) => {
|
||||||
// 获取第一张缩略图
|
|
||||||
const firstThumb = journal.items.find((item: any) => item.attachType === "THUMB");
|
const firstThumb = journal.items.find((item: any) => item.attachType === "THUMB");
|
||||||
return {
|
return {
|
||||||
id: journal.id,
|
id: journal.id,
|
||||||
@ -148,7 +156,13 @@ Component<JournalListData, {}, {}, ComponentInstance>({
|
|||||||
this.setData({
|
this.setData({
|
||||||
page: {
|
page: {
|
||||||
...this.data.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),
|
list: this.data.list.concat(result),
|
||||||
isFinished: list.length < this.data.page.size
|
isFinished: list.length < this.data.page.size
|
||||||
@ -159,19 +173,16 @@ Component<JournalListData, {}, {}, ComponentInstance>({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
/** 输入搜索 */
|
||||||
onSearchChange(e: WechatMiniprogram.CustomEvent) {
|
onSearchChange(e: WechatMiniprogram.CustomEvent) {
|
||||||
const value = e.detail.value.trim();
|
const value = e.detail.value.trim();
|
||||||
this.setData({ searchValue: value });
|
this.setData({ searchValue: value });
|
||||||
// 如果是清空操作,不使用防抖(clear 事件会处理)
|
// 使用防抖自动搜索(包括清空的情况)
|
||||||
if (value === "" && this.debouncedSearch) {
|
|
||||||
this.debouncedSearch.cancel();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 使用防抖自动搜索
|
|
||||||
if (this.debouncedSearch) {
|
if (this.debouncedSearch) {
|
||||||
this.debouncedSearch(value);
|
this.debouncedSearch(value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
/** 提交搜索 */
|
||||||
onSearchSubmit(e: WechatMiniprogram.CustomEvent) {
|
onSearchSubmit(e: WechatMiniprogram.CustomEvent) {
|
||||||
const value = e.detail.value.trim();
|
const value = e.detail.value.trim();
|
||||||
// 立即搜索,取消防抖
|
// 立即搜索,取消防抖
|
||||||
@ -180,6 +191,7 @@ Component<JournalListData, {}, {}, ComponentInstance>({
|
|||||||
}
|
}
|
||||||
this.resetAndSearch(value);
|
this.resetAndSearch(value);
|
||||||
},
|
},
|
||||||
|
/** 清空搜索 */
|
||||||
onSearchClear() {
|
onSearchClear() {
|
||||||
// 取消防抖,立即搜索
|
// 取消防抖,立即搜索
|
||||||
if (this.debouncedSearch) {
|
if (this.debouncedSearch) {
|
||||||
@ -187,6 +199,11 @@ Component<JournalListData, {}, {}, ComponentInstance>({
|
|||||||
}
|
}
|
||||||
this.resetAndSearch("");
|
this.resetAndSearch("");
|
||||||
},
|
},
|
||||||
|
/** 保留搜索关键字重新搜索 */
|
||||||
|
reSearch() {
|
||||||
|
this.resetAndSearch(this.data.searchValue);
|
||||||
|
},
|
||||||
|
/** 重置配置重新搜索 */
|
||||||
resetAndSearch(keyword: string) {
|
resetAndSearch(keyword: string) {
|
||||||
const likeExample = keyword ? {
|
const likeExample = keyword ? {
|
||||||
idea: keyword,
|
idea: keyword,
|
||||||
@ -205,7 +222,10 @@ Component<JournalListData, {}, {}, ComponentInstance>({
|
|||||||
size: 16,
|
size: 16,
|
||||||
type: JournalPageType.PREVIEW,
|
type: JournalPageType.PREVIEW,
|
||||||
equalsExample,
|
equalsExample,
|
||||||
likeExample
|
likeExample,
|
||||||
|
orderMap: {
|
||||||
|
createdAt: OrderType.DESC
|
||||||
|
}
|
||||||
},
|
},
|
||||||
isFetching: false,
|
isFetching: false,
|
||||||
isFinished: false
|
isFinished: false
|
||||||
|
|||||||
@ -32,12 +32,14 @@
|
|||||||
src="{{item.thumbUrl}}"
|
src="{{item.thumbUrl}}"
|
||||||
mode="aspectFill"
|
mode="aspectFill"
|
||||||
/>
|
/>
|
||||||
<t-icon wx:else slot="left-icon" name="image" color="gray" size="96rpx" />
|
<t-icon wx:else slot="left-icon" class="icon" name="image" color="gray" size="96rpx" />
|
||||||
<view slot="title">
|
<view wx:if="{{item.idea}}" slot="title">
|
||||||
<text class="date">{{item.date}}</text>
|
<text>{{item.idea}}</text>
|
||||||
<text wx:if="{{item.idea}}"> · {{item.idea}}</text>
|
</view>
|
||||||
|
<view class="description" slot="description">
|
||||||
|
<text>{{item.date}}</text>
|
||||||
|
<text wx:if="{{item.location}}"> · {{item.location}}</text>
|
||||||
</view>
|
</view>
|
||||||
<text wx:if="{{item.location}}" class="location" slot="description">{{item.location}}</text>
|
|
||||||
<t-icon
|
<t-icon
|
||||||
wx:if="{{mode === 'select' && selectedId === item.id}}"
|
wx:if="{{mode === 'select' && selectedId === item.id}}"
|
||||||
slot="right-icon"
|
slot="right-icon"
|
||||||
|
|||||||
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"component": true,
|
|
||||||
"usingComponents": {}
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
/* components/search-list/index.wxss */
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
// components/search-list/index.ts
|
|
||||||
Component({
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 组件的属性列表
|
|
||||||
*/
|
|
||||||
properties: {
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 组件的初始数据
|
|
||||||
*/
|
|
||||||
data: {
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 组件的方法列表
|
|
||||||
*/
|
|
||||||
methods: {
|
|
||||||
|
|
||||||
}
|
|
||||||
})
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
<!--components/search-list/index.wxml-->
|
|
||||||
<text>components/search-list/index.wxml</text>
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
const envArgs = {
|
const envArgs = {
|
||||||
develop: {
|
develop: {
|
||||||
url: "https://api.imyeyu.com"
|
url: "http://192.168.3.137:8091"
|
||||||
},
|
},
|
||||||
trial: {
|
trial: {
|
||||||
url: "https://api.imyeyu.com"
|
url: "https://api.imyeyu.com"
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="item">
|
<view class="item">
|
||||||
<text class="label">版本:</text>
|
<text class="label">版本:</text>
|
||||||
<text>1.4.0</text>
|
<text>1.5.1</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="item copyright">
|
<view class="item copyright">
|
||||||
<text>{{copyright}}</text>
|
<text>{{copyright}}</text>
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"component": true,
|
"component": true,
|
||||||
"usingComponents": {
|
"usingComponents": {
|
||||||
|
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||||
"t-button": "tdesign-miniprogram/button/button",
|
"t-button": "tdesign-miniprogram/button/button",
|
||||||
"t-navbar": "tdesign-miniprogram/navbar/navbar"
|
"t-navbar": "tdesign-miniprogram/navbar/navbar"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
/* pages/main/journal-creater/index.wxss */
|
/* pages/main/journal-creater/index.wxss */
|
||||||
.container {
|
.container {
|
||||||
height: 100vh;
|
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
width: calc(100% - 64px);
|
width: calc(100% - 64px);
|
||||||
@ -40,7 +39,6 @@
|
|||||||
.gallery {
|
.gallery {
|
||||||
gap: 10rpx;
|
gap: 10rpx;
|
||||||
display: grid;
|
display: grid;
|
||||||
margin-top: 1rem;
|
|
||||||
grid-template-columns: repeat(3, 1fr);
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
|
||||||
.item {
|
.item {
|
||||||
@ -50,8 +48,16 @@
|
|||||||
background: var(--theme-bg-card);
|
background: var(--theme-bg-card);
|
||||||
box-shadow: 1px 1px 6px var(--theme-shadow-light);
|
box-shadow: 1px 1px 6px var(--theme-shadow-light);
|
||||||
border-radius: 2rpx;
|
border-radius: 2rpx;
|
||||||
|
|
||||||
|
&.add {
|
||||||
|
color: var(--theme-wx);
|
||||||
|
margin: 0;
|
||||||
|
font-size: 80rpx;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
.thumbnail {
|
.thumbnail {
|
||||||
|
width: 200rpx;
|
||||||
height: 200rpx;
|
height: 200rpx;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
@ -63,26 +69,34 @@
|
|||||||
.play-icon {
|
.play-icon {
|
||||||
top: 50%;
|
top: 50%;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
width: 60rpx;
|
color: rgba(255, 255, 255, .8);
|
||||||
height: 60rpx;
|
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
font-size: 128rpx;
|
||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
|
text-shadow: 4rpx 4rpx 0 rgba(0, 0, 0, .5);
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.delete {
|
.delete {
|
||||||
top: 10rpx;
|
top: 10rpx;
|
||||||
right: 10rpx;
|
right: 10rpx;
|
||||||
width: 40rpx;
|
color: rgba(255, 255, 255, .6);
|
||||||
height: 40rpx;
|
|
||||||
z-index: 3;
|
z-index: 3;
|
||||||
padding: 5rpx;
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background: rgba(0, 0, 0, 0.5);
|
font-size: 45rpx;
|
||||||
border-radius: 50%;
|
|
||||||
|
&::after {
|
||||||
|
content: "";
|
||||||
|
top: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
z-index: -1;
|
||||||
|
position: absolute;
|
||||||
|
background: rgba(0, 0, 0, .6);
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,11 +105,23 @@
|
|||||||
|
|
||||||
.progress {
|
.progress {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
margin-top: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.submit {
|
.ctrl {
|
||||||
width: 10rem;
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
margin-top: 1rem;
|
margin-top: 1rem;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.clear {
|
||||||
|
width: 200rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.submit {
|
||||||
|
flex: 1;
|
||||||
|
margin-left: 12rpx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -36,23 +36,6 @@
|
|||||||
<text wx:else bind:tap="chooseLocation">选择位置..</text>
|
<text wx:else bind:tap="chooseLocation">选择位置..</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="section media">
|
<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">
|
<view class="gallery">
|
||||||
<block wx:for="{{mediaList}}" wx:key="index">
|
<block wx:for="{{mediaList}}" wx:key="index">
|
||||||
<view class="item">
|
<view class="item">
|
||||||
@ -74,17 +57,27 @@
|
|||||||
bindtap="preview"
|
bindtap="preview"
|
||||||
data-index="{{index}}"
|
data-index="{{index}}"
|
||||||
></image>
|
></image>
|
||||||
<image class="play-icon" src="/assets/icon/play.png"></image>
|
<t-icon class="play-icon" name="play" />
|
||||||
</view>
|
</view>
|
||||||
<!-- 删除 -->
|
<!-- 删除 -->
|
||||||
<image
|
<t-icon
|
||||||
src="/assets/icon/delete.png"
|
|
||||||
class="delete"
|
class="delete"
|
||||||
|
name="close"
|
||||||
bindtap="deleteMedia"
|
bindtap="deleteMedia"
|
||||||
data-index="{{index}}"
|
data-index="{{index}}"
|
||||||
></image>
|
data-new-media="{{true}}"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</block>
|
</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>
|
||||||
</view>
|
</view>
|
||||||
<progress
|
<progress
|
||||||
@ -94,11 +87,21 @@
|
|||||||
show-info
|
show-info
|
||||||
stroke-width="4"
|
stroke-width="4"
|
||||||
/>
|
/>
|
||||||
<t-button
|
<view class="ctrl">
|
||||||
class="submit"
|
<t-button
|
||||||
theme="primary"
|
class="clear"
|
||||||
bind:tap="submit"
|
theme="danger"
|
||||||
disabled="{{(!idea && mediaList.length === 0) || isSubmitting}}"
|
variant="outline"
|
||||||
>{{submitText}}</t-button>
|
disabled="{{isSubmitting}}"
|
||||||
|
bind:tap="clearMedia"
|
||||||
|
disabled="{{mediaList.length === 0}}"
|
||||||
|
>清空已选</t-button>
|
||||||
|
<t-button
|
||||||
|
class="submit"
|
||||||
|
theme="primary"
|
||||||
|
bind:tap="submit"
|
||||||
|
disabled="{{(!idea && mediaList.length === 0) || isSubmitting}}"
|
||||||
|
>{{submitText}}</t-button>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
8
miniprogram/pages/main/journal-date/index.json
Normal file
8
miniprogram/pages/main/journal-date/index.json
Normal 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"
|
||||||
|
}
|
||||||
24
miniprogram/pages/main/journal-date/index.less
Normal file
24
miniprogram/pages/main/journal-date/index.less
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
193
miniprogram/pages/main/journal-date/index.ts
Normal file
193
miniprogram/pages/main/journal-date/index.ts
Normal 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
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
19
miniprogram/pages/main/journal-date/index.wxml
Normal file
19
miniprogram/pages/main/journal-date/index.wxml
Normal 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"
|
||||||
|
/>
|
||||||
10
miniprogram/pages/main/journal-editor/index.json
Normal file
10
miniprogram/pages/main/journal-editor/index.json
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
||||||
146
miniprogram/pages/main/journal-editor/index.less
Normal file
146
miniprogram/pages/main/journal-editor/index.less
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
384
miniprogram/pages/main/journal-editor/index.ts
Normal file
384
miniprogram/pages/main/journal-editor/index.ts
Normal 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);
|
||||||
|
}
|
||||||
|
});
|
||||||
166
miniprogram/pages/main/journal-editor/index.wxml
Normal file
166
miniprogram/pages/main/journal-editor/index.wxml
Normal 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>
|
||||||
7
miniprogram/pages/main/journal-map/index.json
Normal file
7
miniprogram/pages/main/journal-map/index.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {
|
||||||
|
"t-navbar": "tdesign-miniprogram/navbar/navbar",
|
||||||
|
"journal-detail-panel": "/components/journal-detail-panel/index"
|
||||||
|
},
|
||||||
|
"navigationStyle": "custom"
|
||||||
|
}
|
||||||
101
miniprogram/pages/main/journal-map/index.less
Normal file
101
miniprogram/pages/main/journal-map/index.less
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
287
miniprogram/pages/main/journal-map/index.ts
Normal file
287
miniprogram/pages/main/journal-map/index.ts
Normal 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
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
48
miniprogram/pages/main/journal-map/index.wxml
Normal file
48
miniprogram/pages/main/journal-map/index.wxml
Normal 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"
|
||||||
|
/>
|
||||||
@ -1,12 +1,19 @@
|
|||||||
// pages/main/journal-search/index.ts
|
// pages/main/journal-search/index.ts
|
||||||
|
import Events from "../../../utils/Events";
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
|
onLoad() {
|
||||||
|
Events.reset("JOURNAL_LIST_REFRESH", () => {
|
||||||
|
const listRef = this.selectComponent('#listRef');
|
||||||
|
if (listRef) {
|
||||||
|
listRef.reSearch();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
onNavigateItem(e: WechatMiniprogram.CustomEvent) {
|
onNavigateItem(e: WechatMiniprogram.CustomEvent) {
|
||||||
const { id } = e.detail;
|
const { id } = e.detail;
|
||||||
// TODO: 跳转到编辑页面或详情页
|
wx.navigateTo({
|
||||||
wx.showToast({
|
url: `/pages/main/journal-editor/index?id=${id}`
|
||||||
title: `编辑功能待开发 (ID: ${id})`,
|
|
||||||
icon: "none",
|
|
||||||
duration: 2000
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
<view class="custom-navbar">
|
<view class="custom-navbar">
|
||||||
<t-navbar title="按列表查找" left-arrow />
|
<t-navbar title="列表查找" left-arrow />
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="content">
|
<view class="content">
|
||||||
<journal-list
|
<journal-list
|
||||||
|
id="listRef"
|
||||||
searchable="{{true}}"
|
searchable="{{true}}"
|
||||||
mode="navigate"
|
mode="navigate"
|
||||||
type="NORMAL"
|
|
||||||
bind:navigate="onNavigateItem"
|
bind:navigate="onNavigateItem"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@ -5,7 +5,6 @@
|
|||||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||||
"t-navbar": "tdesign-miniprogram/navbar/navbar",
|
"t-navbar": "tdesign-miniprogram/navbar/navbar",
|
||||||
"t-indexes": "tdesign-miniprogram/indexes/indexes",
|
"t-indexes": "tdesign-miniprogram/indexes/indexes",
|
||||||
"t-calendar": "tdesign-miniprogram/calendar/calendar",
|
|
||||||
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group",
|
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group",
|
||||||
"t-indexes-anchor": "tdesign-miniprogram/indexes-anchor/indexes-anchor"
|
"t-indexes-anchor": "tdesign-miniprogram/indexes-anchor/indexes-anchor"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -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 {
|
.journal-list {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
|
|
||||||
@ -46,7 +34,8 @@
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text {
|
> .text {
|
||||||
|
color: var(--theme-text-primary);
|
||||||
width: calc(100% - 32px - 2rem);
|
width: calc(100% - 32px - 2rem);
|
||||||
padding: 8px 16px;
|
padding: 8px 16px;
|
||||||
margin: .5rem 1rem 1rem 1rem;
|
margin: .5rem 1rem 1rem 1rem;
|
||||||
@ -75,8 +64,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.location {
|
.location {
|
||||||
color: var(--theme-text-secondary);
|
gap: 6rpx;
|
||||||
text-align: right;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
color: var(--theme-wx);
|
||||||
|
}
|
||||||
|
|
||||||
|
.text {
|
||||||
|
color: var(--theme-text-secondary);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import Time from "../../../utils/Time";
|
|||||||
import config from "../../../config/index"
|
import config from "../../../config/index"
|
||||||
import Events from "../../../utils/Events";
|
import Events from "../../../utils/Events";
|
||||||
import { JournalPage, JournalPageType } from "../../../types/Journal";
|
import { JournalPage, JournalPageType } from "../../../types/Journal";
|
||||||
|
import { OrderType } from "../../../types/Model";
|
||||||
|
|
||||||
export type Journal = {
|
export type Journal = {
|
||||||
date: string;
|
date: string;
|
||||||
@ -45,6 +46,9 @@ Page({
|
|||||||
type: JournalPageType.NORMAL,
|
type: JournalPageType.NORMAL,
|
||||||
likeMap: {
|
likeMap: {
|
||||||
type: "NORMAL"
|
type: "NORMAL"
|
||||||
|
},
|
||||||
|
orderMap: {
|
||||||
|
createdAt: OrderType.DESC
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
list: [],
|
list: [],
|
||||||
@ -70,6 +74,9 @@ Page({
|
|||||||
type: JournalPageType.NORMAL,
|
type: JournalPageType.NORMAL,
|
||||||
equalsExample: {
|
equalsExample: {
|
||||||
type: "NORMAL"
|
type: "NORMAL"
|
||||||
|
},
|
||||||
|
orderMap: {
|
||||||
|
createdAt: OrderType.DESC
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
list: [],
|
list: [],
|
||||||
@ -82,20 +89,6 @@ Page({
|
|||||||
list: []
|
list: []
|
||||||
})
|
})
|
||||||
this.fetch();
|
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() {
|
onReady() {
|
||||||
this.getCustomNavbarHeight();
|
this.getCustomNavbarHeight();
|
||||||
@ -121,17 +114,25 @@ Page({
|
|||||||
isShowMoreMenu: !this.data.isShowMoreMenu
|
isShowMoreMenu: !this.data.isShowMoreMenu
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
openDateFilter() {
|
toCreater() {
|
||||||
this.setData({
|
wx.navigateTo({
|
||||||
dateFilterVisible: true
|
"url": "/pages/main/journal-creater/index?from=journal"
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
tapCalendar(e: any) {
|
toSearch() {
|
||||||
console.log(e);
|
wx.navigateTo({
|
||||||
|
url: "/pages/main/journal-search/index"
|
||||||
|
})
|
||||||
},
|
},
|
||||||
toDateFilter(e: any) {
|
toMap() {
|
||||||
console.log(e);
|
wx.navigateTo({
|
||||||
// console.log(Toolkit.symmetricDiff(this.data.dateFilter.allows, e.detail.value));
|
url: "/pages/main/journal-map/index"
|
||||||
|
})
|
||||||
|
},
|
||||||
|
toDate() {
|
||||||
|
wx.navigateTo({
|
||||||
|
url: "/pages/main/journal-date/index"
|
||||||
|
})
|
||||||
},
|
},
|
||||||
fetch() {
|
fetch() {
|
||||||
if (this.data.isFetching || this.data.isFinished) {
|
if (this.data.isFetching || this.data.isFinished) {
|
||||||
@ -180,6 +181,9 @@ Page({
|
|||||||
type: JournalPageType.NORMAL,
|
type: JournalPageType.NORMAL,
|
||||||
equalsExample: {
|
equalsExample: {
|
||||||
type: "NORMAL"
|
type: "NORMAL"
|
||||||
|
},
|
||||||
|
orderMap: {
|
||||||
|
createdAt: OrderType.DESC
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
list: this.data.list.concat(result),
|
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"
|
|
||||||
})
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -6,24 +6,13 @@
|
|||||||
<t-cell-group class="content" theme="card">
|
<t-cell-group class="content" theme="card">
|
||||||
<t-cell title="新纪录" leftIcon="add" bind:tap="toCreater" />
|
<t-cell title="新纪录" leftIcon="add" bind:tap="toCreater" />
|
||||||
<t-cell title="按列表查找" leftIcon="view-list" bind:tap="toSearch" />
|
<t-cell title="按列表查找" leftIcon="view-list" bind:tap="toSearch" />
|
||||||
<t-cell title="按日期查找" leftIcon="calendar-1" bind:tap="openDateFilter" />
|
<t-cell title="按日期查找" leftIcon="calendar-1" bind:tap="toDate" />
|
||||||
<t-cell title="按地图查找" leftIcon="location" />
|
<t-cell title="按地图查找" leftIcon="location" bind:tap="toMap" />
|
||||||
</t-cell-group>
|
</t-cell-group>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</t-navbar>
|
</t-navbar>
|
||||||
</view>
|
</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
|
<t-indexes
|
||||||
class="journal-list"
|
class="journal-list"
|
||||||
bind:scroll="onScroll"
|
bind:scroll="onScroll"
|
||||||
@ -38,7 +27,10 @@
|
|||||||
class="location"
|
class="location"
|
||||||
bind:tap="openLocation"
|
bind:tap="openLocation"
|
||||||
data-journal-index="{{journalIndex}}"
|
data-journal-index="{{journalIndex}}"
|
||||||
>📍 {{journal.location}}</view>
|
>
|
||||||
|
<t-icon class="icon" name="location-filled" />
|
||||||
|
<text class="text">{{journal.location}}</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view wx:if="{{journal.items}}" class="items">
|
<view wx:if="{{journal.items}}" class="items">
|
||||||
<block wx:for="{{journal.items}}" wx:for-item="item" wx:for-index="itemIndex" wx:key="date">
|
<block wx:for="{{journal.items}}" wx:for-item="item" wx:for-index="itemIndex" wx:key="date">
|
||||||
|
|||||||
@ -127,6 +127,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.form {
|
&.form {
|
||||||
|
padding-bottom: 32rpx;
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
padding: 16rpx 32rpx;
|
padding: 16rpx 32rpx;
|
||||||
|
|||||||
@ -185,7 +185,6 @@
|
|||||||
<journal-list
|
<journal-list
|
||||||
visible="{{archiveStep === 'select-journal'}}"
|
visible="{{archiveStep === 'select-journal'}}"
|
||||||
searchable="{{true}}"
|
searchable="{{true}}"
|
||||||
type="{{type}}"
|
|
||||||
selectedId="{{selectedJournalId}}"
|
selectedId="{{selectedJournalId}}"
|
||||||
bind:select="onJournalListSelect"
|
bind:select="onJournalListSelect"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -9,18 +9,18 @@ page {
|
|||||||
--theme-wx: #07C160;
|
--theme-wx: #07C160;
|
||||||
|
|
||||||
/* === 背景色 === */
|
/* === 背景色 === */
|
||||||
--theme-bg-primary: #FFFFFF;
|
--theme-bg-primary: #FFF;
|
||||||
--theme-bg-secondary: #F5F5F5;
|
--theme-bg-secondary: #F5F5F5;
|
||||||
--theme-bg-card: #FFFFFF;
|
--theme-bg-card: #FFF;
|
||||||
--theme-bg-journal: #FFF8E1;
|
--theme-bg-journal: #fff2C8;
|
||||||
--theme-bg-overlay: rgba(0, 0, 0, .1);
|
--theme-bg-overlay: rgba(0, 0, 0, .1);
|
||||||
--theme-bg-menu: rgba(255, 255, 255, .95);
|
--theme-bg-menu: rgba(255, 255, 255, .95);
|
||||||
|
|
||||||
/* === 文字颜色 === */
|
/* === 文字颜色 === */
|
||||||
--theme-text-primary: #000000;
|
--theme-text-primary: #333;
|
||||||
--theme-text-secondary: #777777;
|
--theme-text-secondary: #777;
|
||||||
--theme-text-tertiary: #999999;
|
--theme-text-tertiary: #999;
|
||||||
--theme-text-disabled: #CCCCCC;
|
--theme-text-disabled: #CCC;
|
||||||
|
|
||||||
/* === 边框颜色 === */
|
/* === 边框颜色 === */
|
||||||
--theme-border-light: rgba(0, 0, 0, .1);
|
--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-bg-menu: rgba(40, 40, 40, .95);
|
||||||
|
|
||||||
/* === 文字颜色 === */
|
/* === 文字颜色 === */
|
||||||
--theme-text-primary: #FFFFFF;
|
--theme-text-primary: #FFF;
|
||||||
--theme-text-secondary: #AAAAAA;
|
--theme-text-secondary: #AAA;
|
||||||
--theme-text-tertiary: #888888;
|
--theme-text-tertiary: #888;
|
||||||
--theme-text-disabled: #666666;
|
--theme-text-disabled: #666;
|
||||||
|
|
||||||
/* === 边框颜色 === */
|
/* === 边框颜色 === */
|
||||||
--theme-border-light: rgba(255, 255, 255, .1);
|
--theme-border-light: rgba(255, 255, 255, .1);
|
||||||
|
|||||||
55
miniprogram/types/Attachment.ts
Normal file
55
miniprogram/types/Attachment.ts
Normal 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;
|
||||||
|
}
|
||||||
@ -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 = {
|
export type JournalPage = {
|
||||||
|
|
||||||
|
/** 查询类型 */
|
||||||
type: JournalPageType;
|
type: JournalPageType;
|
||||||
} & QueryPage;
|
} & QueryPage;
|
||||||
|
|
||||||
|
/** 日记页面查询类型 */
|
||||||
export enum JournalPageType {
|
export enum JournalPageType {
|
||||||
|
|
||||||
|
/** 正常查询所有附件 */
|
||||||
NORMAL = "NORMAL",
|
NORMAL = "NORMAL",
|
||||||
|
|
||||||
|
/** 仅查询第一个附件用于预览 */
|
||||||
PREVIEW = "PREVIEW"
|
PREVIEW = "PREVIEW"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
// 基本实体模型
|
/** 基本实体模型 */
|
||||||
export type Model = {
|
export type Model = {
|
||||||
id?: number;
|
id?: number;
|
||||||
|
|
||||||
@ -7,37 +7,45 @@ export type Model = {
|
|||||||
deletedAt?: number;
|
deletedAt?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 基本返回对象 */
|
||||||
export type Response = {
|
export type Response = {
|
||||||
code: number;
|
code: number;
|
||||||
msg?: string;
|
msg?: string;
|
||||||
data: object;
|
data: object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 基本页面查询对象 */
|
||||||
export type QueryPage = {
|
export type QueryPage = {
|
||||||
|
|
||||||
|
/** 页面下标,从 0 开始 */
|
||||||
index: number;
|
index: number;
|
||||||
|
|
||||||
|
/** 单页数据量 */
|
||||||
size: number;
|
size: number;
|
||||||
|
|
||||||
|
/** 排序 */
|
||||||
orderMap?: { [key: string]: OrderType };
|
orderMap?: { [key: string]: OrderType };
|
||||||
|
|
||||||
|
/** 全等比较条件(AND 连接) */
|
||||||
equalsExample?: { [key: string]: string | undefined | null };
|
equalsExample?: { [key: string]: string | undefined | null };
|
||||||
|
|
||||||
|
/** 模糊查询条件(OR 连接) */
|
||||||
likeExample?: { [key: string]: string | undefined | null };
|
likeExample?: { [key: string]: string | undefined | null };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 排序方式 */
|
||||||
export enum OrderType {
|
export enum OrderType {
|
||||||
ASC = "ASC",
|
ASC = "ASC",
|
||||||
DESC = "DESC"
|
DESC = "DESC"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 页面查询返回 */
|
||||||
export type QueryPageResult<T> = {
|
export type QueryPageResult<T> = {
|
||||||
total: number;
|
total: number;
|
||||||
list: T[];
|
list: T[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 携带验证码的请求体
|
/** 键值对对象 */
|
||||||
export type CaptchaData<T> = {
|
|
||||||
from: string;
|
|
||||||
captcha: string;
|
|
||||||
data: T;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type KeyValue<T> = {
|
export type KeyValue<T> = {
|
||||||
key: string;
|
key: string;
|
||||||
value: T;
|
value: T;
|
||||||
|
|||||||
64
miniprogram/types/UI.ts
Normal file
64
miniprogram/types/UI.ts
Normal 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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user