Compare commits
24 Commits
69659a1746
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 8adc28ae9c | |||
| e31a3432a0 | |||
| 2c6478c729 | |||
| f4232e8752 | |||
| 41e2959a72 | |||
| bf5deff045 | |||
| f94cf05f62 | |||
| 9538a21e42 | |||
| 3b091c4f18 | |||
| b64e2767c2 | |||
| df7cfa95a0 | |||
| 84fc382c91 | |||
| 107177d095 | |||
| 2966289930 | |||
| 6f74559c01 | |||
| 186a74bc77 | |||
| 51e679dd83 | |||
| 1ad1da1c4e | |||
| 9f7df3cfed | |||
| 62186abdb8 | |||
| 369cfe2bf2 | |||
| 423775c255 | |||
| f0f2815971 | |||
| e650571563 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -62,4 +62,5 @@ ehthumbs.db
|
|||||||
|
|
||||||
.claude/
|
.claude/
|
||||||
CLAUDE.md
|
CLAUDE.md
|
||||||
|
AGENTS.md
|
||||||
/docs
|
/docs
|
||||||
|
|||||||
89
miniprogram/api/JournalApi.ts
Normal file
89
miniprogram/api/JournalApi.ts
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
import { Network } from "../utils/Network";
|
||||||
|
import { Journal, JournalPage } from "../types/Journal";
|
||||||
|
import { QueryPageResult } from "../types/Model";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Journal 日记 API
|
||||||
|
*
|
||||||
|
* 按业务模块封装网络请求,使代码更清晰、可维护
|
||||||
|
*/
|
||||||
|
export class JournalApi {
|
||||||
|
/**
|
||||||
|
* 获取日记详情
|
||||||
|
*
|
||||||
|
* @param id - 日记 ID
|
||||||
|
*/
|
||||||
|
static getDetail(id: number | string): Promise<Journal> {
|
||||||
|
return Network.post<Journal>(`/journal/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日记分页列表
|
||||||
|
*
|
||||||
|
* @param pageParams - 分页参数
|
||||||
|
*/
|
||||||
|
static getList(pageParams: JournalPage): Promise<QueryPageResult<Journal>> {
|
||||||
|
return Network.post<QueryPageResult<Journal>>("/journal/list", pageParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建日记
|
||||||
|
*
|
||||||
|
* @param data - 日记数据
|
||||||
|
*/
|
||||||
|
static create(data: Partial<Journal> & {
|
||||||
|
pusher?: string;
|
||||||
|
tempFileIds?: string[];
|
||||||
|
}): Promise<Journal> {
|
||||||
|
return Network.post<Journal>("/journal/create", data, {
|
||||||
|
showLoading: true,
|
||||||
|
loadingText: "正在保存.."
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新日记
|
||||||
|
*
|
||||||
|
* @param data - 日记数据(必须包含 id)
|
||||||
|
*/
|
||||||
|
static update(data: Partial<Journal> & {
|
||||||
|
id: number;
|
||||||
|
attachmentIds?: number[];
|
||||||
|
tempFileIds?: string[];
|
||||||
|
}): Promise<Journal> {
|
||||||
|
return Network.post<Journal>("/journal/update", data, {
|
||||||
|
showLoading: true,
|
||||||
|
loadingText: "正在保存.."
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除日记
|
||||||
|
*
|
||||||
|
* @param id - 日记 ID
|
||||||
|
*/
|
||||||
|
static delete(id: number): Promise<void> {
|
||||||
|
return Network.post<void>("/journal/delete", { id }, {
|
||||||
|
showLoading: true,
|
||||||
|
loadingText: "删除中..."
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 openId(用于推送)
|
||||||
|
*
|
||||||
|
* @param code - 微信登录 code
|
||||||
|
*/
|
||||||
|
static getOpenId(code: string): Promise<string> {
|
||||||
|
return Network.post<string>("/journal/openid", { code });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 ID 列表获取日记
|
||||||
|
*
|
||||||
|
* @param ids - 日记 ID 列表
|
||||||
|
*/
|
||||||
|
static getListByIds(ids: number[]): Promise<Journal[]> {
|
||||||
|
return Network.post<Journal[]>("/journal/list/ids", ids);
|
||||||
|
}
|
||||||
|
}
|
||||||
69
miniprogram/api/MomentApi.ts
Normal file
69
miniprogram/api/MomentApi.ts
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
import { Network } from "../utils/Network";
|
||||||
|
import { Attachment } from "../types/Attachment";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moment 瞬间 API
|
||||||
|
*
|
||||||
|
* 管理临时照片/视频上传、归档到日记等操作
|
||||||
|
*/
|
||||||
|
export class MomentApi {
|
||||||
|
/**
|
||||||
|
* 获取 moment 列表
|
||||||
|
*/
|
||||||
|
static getList(): Promise<Attachment[]> {
|
||||||
|
return Network.post<Attachment[]>("/journal/moment/list");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MD5 查重过滤
|
||||||
|
*
|
||||||
|
* @param md5s - MD5 值数组
|
||||||
|
* @returns 未重复的 MD5 数组
|
||||||
|
*/
|
||||||
|
static filterByMD5(md5s: string[]): Promise<string[]> {
|
||||||
|
return Network.post<string[]>("/journal/moment/filter", md5s);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建 moment 附件
|
||||||
|
*
|
||||||
|
* @param tempFileIds - 临时文件 ID 数组
|
||||||
|
* @returns 创建的附件列表
|
||||||
|
*/
|
||||||
|
static create(tempFileIds: string[]): Promise<Attachment[]> {
|
||||||
|
return Network.post<Attachment[]>("/journal/moment/create", tempFileIds, {
|
||||||
|
showLoading: true,
|
||||||
|
loadingText: "正在保存.."
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 归档 moments 到日记
|
||||||
|
*
|
||||||
|
* @param data - 归档数据
|
||||||
|
*/
|
||||||
|
static archive(data: {
|
||||||
|
id?: number;
|
||||||
|
type: string;
|
||||||
|
idea: string;
|
||||||
|
lat?: number;
|
||||||
|
lng?: number;
|
||||||
|
location?: string;
|
||||||
|
pusher: string;
|
||||||
|
thumbIds: number[];
|
||||||
|
}): Promise<void> {
|
||||||
|
return Network.post<void>("/journal/moment/archive", data, {
|
||||||
|
showLoading: true,
|
||||||
|
loadingText: "正在归档.."
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除 moments
|
||||||
|
*
|
||||||
|
* @param ids - 附件 ID 数组
|
||||||
|
*/
|
||||||
|
static delete(ids: number[]): Promise<void> {
|
||||||
|
return Network.post<void>("/journal/moment/delete", ids);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -3,22 +3,22 @@ import { Travel } from "../types/Travel";
|
|||||||
import { QueryPage, QueryPageResult } from "../types/Model";
|
import { QueryPage, QueryPageResult } from "../types/Model";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Travel 旅行计划 API
|
* Travel 出行计划 API
|
||||||
*
|
*
|
||||||
* 按业务模块封装网络请求,使代码更清晰、可维护
|
* 按业务模块封装网络请求,使代码更清晰、可维护
|
||||||
*/
|
*/
|
||||||
export class TravelApi {
|
export class TravelApi {
|
||||||
/**
|
/**
|
||||||
* 获取旅行详情
|
* 获取出行详情
|
||||||
*
|
*
|
||||||
* @param id - 旅行 ID
|
* @param id - 出行 ID
|
||||||
*/
|
*/
|
||||||
static getDetail(id: number | string): Promise<Travel> {
|
static getDetail(id: number | string): Promise<Travel> {
|
||||||
return Network.get<Travel>(`/journal/travel/${id}`);
|
return Network.get<Travel>(`/journal/travel/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 旅行分页列表
|
* 出行分页列表
|
||||||
*
|
*
|
||||||
* @param pageParams - 分页参数
|
* @param pageParams - 分页参数
|
||||||
*/
|
*/
|
||||||
@ -27,9 +27,9 @@ export class TravelApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建旅行
|
* 创建出行
|
||||||
*
|
*
|
||||||
* @param data - 旅行数据
|
* @param data - 出行数据
|
||||||
*/
|
*/
|
||||||
static create(data: Partial<Travel>): Promise<Travel> {
|
static create(data: Partial<Travel>): Promise<Travel> {
|
||||||
return Network.post<Travel>("/journal/travel/create", data, {
|
return Network.post<Travel>("/journal/travel/create", data, {
|
||||||
@ -39,9 +39,9 @@ export class TravelApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新旅行
|
* 更新出行
|
||||||
*
|
*
|
||||||
* @param data - 旅行数据(必须包含 id)
|
* @param data - 出行数据(必须包含 id)
|
||||||
*/
|
*/
|
||||||
static update(data: Partial<Travel> & { id: number }): Promise<Travel> {
|
static update(data: Partial<Travel> & { id: number }): Promise<Travel> {
|
||||||
return Network.post<Travel>("/journal/travel/update", data, {
|
return Network.post<Travel>("/journal/travel/update", data, {
|
||||||
@ -51,9 +51,9 @@ export class TravelApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除旅行
|
* 删除出行
|
||||||
*
|
*
|
||||||
* @param id - 旅行 ID
|
* @param id - 出行 ID
|
||||||
*/
|
*/
|
||||||
static delete(id: number): Promise<void> {
|
static delete(id: number): Promise<void> {
|
||||||
return Network.post<void>("/journal/travel/delete", { id });
|
return Network.post<void>("/journal/travel/delete", { id });
|
||||||
|
|||||||
@ -3,13 +3,13 @@ import { TravelLocation } from "../types/Travel";
|
|||||||
import { QueryPage, QueryPageResult } from "../types/Model";
|
import { QueryPage, QueryPageResult } from "../types/Model";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TravelLocation 旅行地点 API
|
* TravelLocation 出行地点 API
|
||||||
*
|
*
|
||||||
* 按业务模块封装网络请求,使代码更清晰、可维护
|
* 按业务模块封装网络请求,使代码更清晰、可维护
|
||||||
*/
|
*/
|
||||||
export class TravelLocationApi {
|
export class TravelLocationApi {
|
||||||
/**
|
/**
|
||||||
* 获取旅行地点详情
|
* 获取出行地点详情
|
||||||
*
|
*
|
||||||
* @param id - 地点 ID
|
* @param id - 地点 ID
|
||||||
*/
|
*/
|
||||||
@ -18,7 +18,7 @@ export class TravelLocationApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取旅行地点分页列表
|
* 获取出行地点分页列表
|
||||||
*
|
*
|
||||||
* @param pageParams - 分页参数(通常包含 travelId 筛选)
|
* @param pageParams - 分页参数(通常包含 travelId 筛选)
|
||||||
*/
|
*/
|
||||||
@ -27,7 +27,7 @@ export class TravelLocationApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建旅行地点
|
* 创建出行地点
|
||||||
*
|
*
|
||||||
* @param data - 地点数据
|
* @param data - 地点数据
|
||||||
*/
|
*/
|
||||||
@ -39,7 +39,7 @@ export class TravelLocationApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新旅行地点
|
* 更新出行地点
|
||||||
*
|
*
|
||||||
* @param data - 地点数据(必须包含 id)
|
* @param data - 地点数据(必须包含 id)
|
||||||
*/
|
*/
|
||||||
@ -51,7 +51,7 @@ export class TravelLocationApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除旅行地点
|
* 删除出行地点
|
||||||
*
|
*
|
||||||
* @param id - 地点 ID
|
* @param id - 地点 ID
|
||||||
*/
|
*/
|
||||||
@ -60,7 +60,7 @@ export class TravelLocationApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量获取旅行地点
|
* 批量获取出行地点
|
||||||
*
|
*
|
||||||
* @param ids - 地点 ID 数组
|
* @param ids - 地点 ID 数组
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -8,9 +8,10 @@
|
|||||||
"pages/main/journal-date/index",
|
"pages/main/journal-date/index",
|
||||||
"pages/main/portfolio/index",
|
"pages/main/portfolio/index",
|
||||||
"pages/main/travel/index",
|
"pages/main/travel/index",
|
||||||
"pages/main/travel-location-map/index",
|
|
||||||
"pages/main/travel-detail/index",
|
"pages/main/travel-detail/index",
|
||||||
"pages/main/travel-editor/index",
|
"pages/main/travel-editor/index",
|
||||||
|
"pages/main/travel-location-detail/index",
|
||||||
|
"pages/main/travel-location-map/index",
|
||||||
"pages/main/travel-location-editor/index",
|
"pages/main/travel-location-editor/index",
|
||||||
"pages/main/about/index",
|
"pages/main/about/index",
|
||||||
"pages/main/moment/index"
|
"pages/main/moment/index"
|
||||||
@ -19,8 +20,8 @@
|
|||||||
"themeLocation": "theme.json",
|
"themeLocation": "theme.json",
|
||||||
"window": {
|
"window": {
|
||||||
"navigationStyle": "custom",
|
"navigationStyle": "custom",
|
||||||
"navigationBarTextStyle": "black",
|
"navigationBarTextStyle": "@navigationBarTextStyle",
|
||||||
"navigationBarBackgroundColor": "#FFFFFF"
|
"navigationBarBackgroundColor": "@navigationBarBackgroundColor"
|
||||||
},
|
},
|
||||||
"lazyCodeLoading": "requiredComponents",
|
"lazyCodeLoading": "requiredComponents",
|
||||||
"tabBar": {
|
"tabBar": {
|
||||||
@ -48,7 +49,7 @@
|
|||||||
"selectedIconPath": "@tabBarIconMomentActive"
|
"selectedIconPath": "@tabBarIconMomentActive"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "旅行",
|
"text": "出行",
|
||||||
"pagePath": "pages/main/travel/index",
|
"pagePath": "pages/main/travel/index",
|
||||||
"iconPath": "@tabBarIconTravel",
|
"iconPath": "@tabBarIconTravel",
|
||||||
"selectedIconPath": "@tabBarIconTravelActive"
|
"selectedIconPath": "@tabBarIconTravelActive"
|
||||||
@ -70,4 +71,4 @@
|
|||||||
"getLocation",
|
"getLocation",
|
||||||
"chooseLocation"
|
"chooseLocation"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
17
miniprogram/app.less
Normal file
17
miniprogram/app.less
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/**app.wxss**/
|
||||||
|
@import "./timi-web.less";
|
||||||
|
@import "./tdesign.less";
|
||||||
|
@import "./theme.less";
|
||||||
|
|
||||||
|
.setting-bg {
|
||||||
|
background: var(--theme-bg-wx);
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: "";
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
z-index: -1;
|
||||||
|
position: fixed;
|
||||||
|
background: var(--theme-bg-wx);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,3 +0,0 @@
|
|||||||
/**app.wxss**/
|
|
||||||
@import "./tdesign.wxss";
|
|
||||||
@import "./theme.wxss";
|
|
||||||
@ -1,4 +1,6 @@
|
|||||||
{
|
{
|
||||||
"component": true,
|
"component": true,
|
||||||
"usingComponents": {}
|
"usingComponents": {
|
||||||
|
"t-icon": "tdesign-miniprogram/icon/icon"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -23,31 +23,9 @@ page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.snowflake {
|
.snowflake {
|
||||||
width: 10px;
|
color: var(--theme-brand-gao);
|
||||||
height: 10px;
|
|
||||||
display: block;
|
display: block;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
animation: snowflakeFall linear infinite;
|
animation: snowflakeFall linear infinite;
|
||||||
|
|
||||||
&::before,
|
|
||||||
&::after {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
background: var(--theme-brand-gao);
|
|
||||||
opacity: .8;
|
|
||||||
}
|
|
||||||
|
|
||||||
&::before {
|
|
||||||
top: 45%;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 10%;
|
|
||||||
}
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
left: 45%;
|
|
||||||
width: 10%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ Component({
|
|||||||
createSnowflake() {
|
createSnowflake() {
|
||||||
const snowflake = {
|
const snowflake = {
|
||||||
x: Toolkit.random(0, this.data.docWidth),
|
x: Toolkit.random(0, this.data.docWidth),
|
||||||
s: Toolkit.random(6, 20),
|
s: Toolkit.random(16, 64),
|
||||||
speed: Toolkit.random(14, 26)
|
speed: Toolkit.random(14, 26)
|
||||||
};
|
};
|
||||||
this.setData({
|
this.setData({
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
<!--components/background/snow/index.wxml-->
|
<!--components/background/snow/index.wxml-->
|
||||||
<view class="snowflakes" style="width: {{docWidth}}px; height: {{docHeight}}px;">
|
<view class="snowflakes" style="width: {{docWidth}}px; height: {{docHeight}}px;">
|
||||||
<view
|
<t-icon
|
||||||
class="snowflake"
|
class="snowflake"
|
||||||
wx:for="{{snowflakes}}"
|
wx:for="{{snowflakes}}"
|
||||||
wx:key="index"
|
wx:key="index"
|
||||||
style="left: {{item.x}}px; width: {{item.s}}px; height: {{item.s}}px; animation-duration: {{item.speed}}s;"
|
style="left: {{item.x}}px; font-size: {{item.s}}rpx; animation-duration: {{item.speed}}s;"
|
||||||
></view>
|
name="snowflake"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@ -57,7 +57,7 @@
|
|||||||
padding: 4rpx 12rpx;
|
padding: 4rpx 12rpx;
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
background: var(--theme-bg-journal);
|
background: var(--theme-bg-card);
|
||||||
border-radius: 12rpx;
|
border-radius: 12rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,9 +2,10 @@
|
|||||||
import { Journal } from "../../types/Journal";
|
import { Journal } from "../../types/Journal";
|
||||||
import config from "../../config/index";
|
import config from "../../config/index";
|
||||||
import Toolkit from "../../utils/Toolkit";
|
import Toolkit from "../../utils/Toolkit";
|
||||||
import { ImageMetadata, MediaAttachExt, MediaAttachType } from "../../types/Attachment";
|
import { MediaAttachType, PreviewImageMetadata } from "../../types/Attachment";
|
||||||
import { MediaItem, MediaItemType } from "../../types/UI";
|
import { MediaItem, MediaItemType } from "../../types/UI";
|
||||||
import Time from "../../utils/Time";
|
import Time from "../../utils/Time";
|
||||||
|
import { JournalApi } from "../../api/JournalApi";
|
||||||
|
|
||||||
interface JournalDetailPanelData {
|
interface JournalDetailPanelData {
|
||||||
journals: Journal[];
|
journals: Journal[];
|
||||||
@ -35,24 +36,7 @@ Component({
|
|||||||
if (visible && ids && 0 < ids.length) {
|
if (visible && ids && 0 < ids.length) {
|
||||||
wx.showLoading({ title: "加载中...", mask: true });
|
wx.showLoading({ title: "加载中...", mask: true });
|
||||||
try {
|
try {
|
||||||
const journals: Journal[] = await new Promise((resolve, reject) => {
|
const journals = await JournalApi.getListByIds(ids);
|
||||||
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
|
|
||||||
});
|
|
||||||
}) || [];
|
|
||||||
journals.forEach(journal => {
|
journals.forEach(journal => {
|
||||||
journal.date = Time.toPassedDate(journal.createdAt);
|
journal.date = Time.toPassedDate(journal.createdAt);
|
||||||
journal.time = Time.toTime(journal.createdAt);
|
journal.time = Time.toTime(journal.createdAt);
|
||||||
@ -63,12 +47,12 @@ Component({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const mediaItems: MediaItem[] = thumbItems.map((thumbItem, index) => {
|
const mediaItems: MediaItem[] = thumbItems.map((thumbItem, index) => {
|
||||||
const metadata = thumbItem.metadata as ImageMetadata;
|
const metadata = (typeof thumbItem.metadata === "string" ? JSON.parse(thumbItem.metadata) : thumbItem.metadata) as PreviewImageMetadata;
|
||||||
const ext = thumbItem.ext = JSON.parse(thumbItem.ext!.toString()) as MediaAttachExt;
|
|
||||||
const thumbURL = `${config.url}/attachment/read/${thumbItem.mongoId}`;
|
const thumbURL = `${config.url}/attachment/read/${thumbItem.mongoId}`;
|
||||||
const sourceURL = `${config.url}/attachment/read/${ext.sourceMongoId}`;
|
const sourceURL = `${config.url}/attachment/read/${metadata.sourceMongoId}`;
|
||||||
|
const isVideo = metadata.sourceMimeType?.startsWith("video/");
|
||||||
return {
|
return {
|
||||||
type: ext.isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
|
type: isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
|
||||||
thumbURL,
|
thumbURL,
|
||||||
sourceURL,
|
sourceURL,
|
||||||
size: thumbItem.size || 0,
|
size: thumbItem.size || 0,
|
||||||
|
|||||||
@ -57,7 +57,7 @@
|
|||||||
.loading,
|
.loading,
|
||||||
.finished {
|
.finished {
|
||||||
color: var(--td-text-color-placeholder);
|
color: var(--td-text-color-placeholder);
|
||||||
padding: 32rpx 0;
|
padding: 32rpx 0 64rpx 0;
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import { JournalPage, JournalPageType } from "../../types/Journal";
|
|||||||
import { OrderType } from "../../types/Model";
|
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";
|
||||||
|
import { JournalApi } from "../../api/JournalApi";
|
||||||
|
|
||||||
export type JournalListItem = {
|
export type JournalListItem = {
|
||||||
id: number;
|
id: number;
|
||||||
@ -19,14 +20,10 @@ interface JournalListData {
|
|||||||
isFinished: boolean;
|
isFinished: boolean;
|
||||||
page: JournalPage;
|
page: JournalPage;
|
||||||
searchValue: string;
|
searchValue: string;
|
||||||
|
debouncedSearch?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 组件实例类型扩展
|
Component({
|
||||||
interface ComponentInstance {
|
|
||||||
debouncedSearch?: ((keyword: string) => void) & { cancel(): void };
|
|
||||||
}
|
|
||||||
|
|
||||||
Component<JournalListData, {}, {}, ComponentInstance>({
|
|
||||||
options: {
|
options: {
|
||||||
styleIsolation: 'apply-shared'
|
styleIsolation: 'apply-shared'
|
||||||
},
|
},
|
||||||
@ -64,25 +61,28 @@ Component<JournalListData, {}, {}, ComponentInstance>({
|
|||||||
createdAt: OrderType.DESC
|
createdAt: OrderType.DESC
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
searchValue: ""
|
searchValue: "",
|
||||||
|
debouncedSearch: undefined
|
||||||
},
|
},
|
||||||
lifetimes: {
|
lifetimes: {
|
||||||
ready() {
|
ready() {
|
||||||
// 创建防抖搜索函数
|
// 创建防抖搜索函数
|
||||||
this.debouncedSearch = Toolkit.debounce(
|
this.setData({
|
||||||
(keyword: string) => {
|
debouncedSearch: Toolkit.debounce(
|
||||||
this.resetAndSearch(keyword);
|
(keyword: string) => {
|
||||||
},
|
this.resetAndSearch(keyword);
|
||||||
false, // 不立即执行,等待输入停止
|
},
|
||||||
400 // 400ms 延迟
|
false, // 不立即执行,等待输入停止
|
||||||
);
|
400 // 400ms 延迟
|
||||||
|
)
|
||||||
|
})
|
||||||
// 组件加载时就获取数据
|
// 组件加载时就获取数据
|
||||||
this.fetch();
|
this.fetch();
|
||||||
},
|
},
|
||||||
detached() {
|
detached() {
|
||||||
// 组件销毁时取消防抖
|
// 组件销毁时取消防抖
|
||||||
if (this.debouncedSearch) {
|
if (this.data.debouncedSearch) {
|
||||||
this.debouncedSearch.cancel();
|
this.data.debouncedSearch.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -125,77 +125,74 @@ Component<JournalListData, {}, {}, ComponentInstance>({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
/** 获取数据 */
|
/** 获取数据 */
|
||||||
fetch() {
|
async fetch() {
|
||||||
if (this.data.isFetching || this.data.isFinished) {
|
if (this.data.isFetching || this.data.isFinished) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.setData({ isFetching: true });
|
this.setData({ isFetching: true });
|
||||||
wx.request({
|
try {
|
||||||
url: `${config.url}/journal/list`,
|
const pageResult = await JournalApi.getList(this.data.page);
|
||||||
method: "POST",
|
const list = pageResult.list;
|
||||||
header: {
|
if (!list || list.length === 0) {
|
||||||
Key: wx.getStorageSync("key")
|
|
||||||
},
|
|
||||||
data: this.data.page,
|
|
||||||
success: (resp: any) => {
|
|
||||||
const list = resp.data.data.list;
|
|
||||||
if (!list || list.length === 0) {
|
|
||||||
this.setData({ isFinished: true });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const result = list.map((journal: any) => {
|
|
||||||
const firstThumb = journal.items.find((item: any) => item.attachType === "THUMB");
|
|
||||||
return {
|
|
||||||
id: journal.id,
|
|
||||||
date: Time.toPassedDate(journal.createdAt),
|
|
||||||
idea: journal.idea,
|
|
||||||
location: journal.location,
|
|
||||||
thumbUrl: firstThumb ? `${config.url}/attachment/read/${firstThumb.mongoId}` : undefined
|
|
||||||
} as JournalListItem;
|
|
||||||
});
|
|
||||||
this.setData({
|
this.setData({
|
||||||
page: {
|
isFinished: true,
|
||||||
...this.data.page,
|
isFetching: false
|
||||||
index: this.data.page.index + 1,
|
|
||||||
type: JournalPageType.PREVIEW,
|
|
||||||
equalsExample: this.data.page.equalsExample,
|
|
||||||
likeExample: this.data.page.likeExample,
|
|
||||||
orderMap: {
|
|
||||||
createdAt: OrderType.DESC
|
|
||||||
}
|
|
||||||
},
|
|
||||||
list: this.data.list.concat(result),
|
|
||||||
isFinished: list.length < this.data.page.size
|
|
||||||
});
|
});
|
||||||
},
|
return;
|
||||||
complete: () => {
|
|
||||||
this.setData({ isFetching: false });
|
|
||||||
}
|
}
|
||||||
});
|
const result = list.map((journal: any) => {
|
||||||
|
const firstThumb = journal.items.find((item: any) => item.attachType === "THUMB");
|
||||||
|
return {
|
||||||
|
id: journal.id,
|
||||||
|
date: Time.toPassedDate(journal.createdAt),
|
||||||
|
idea: journal.idea,
|
||||||
|
location: journal.location,
|
||||||
|
thumbUrl: firstThumb ? `${config.url}/attachment/read/${firstThumb.mongoId}` : undefined
|
||||||
|
} as JournalListItem;
|
||||||
|
});
|
||||||
|
this.setData({
|
||||||
|
page: {
|
||||||
|
...this.data.page,
|
||||||
|
index: this.data.page.index + 1,
|
||||||
|
type: JournalPageType.PREVIEW,
|
||||||
|
equalsExample: this.data.page.equalsExample,
|
||||||
|
likeExample: this.data.page.likeExample,
|
||||||
|
orderMap: {
|
||||||
|
createdAt: OrderType.DESC
|
||||||
|
}
|
||||||
|
},
|
||||||
|
list: this.data.list.concat(result),
|
||||||
|
isFinished: list.length < this.data.page.size,
|
||||||
|
isFetching: false
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("加载日记列表失败:", error);
|
||||||
|
this.setData({ isFetching: false });
|
||||||
|
}
|
||||||
},
|
},
|
||||||
/** 输入搜索 */
|
/** 输入搜索 */
|
||||||
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 });
|
||||||
// 使用防抖自动搜索(包括清空的情况)
|
// 使用防抖自动搜索(包括清空的情况)
|
||||||
if (this.debouncedSearch) {
|
if (this.data.debouncedSearch) {
|
||||||
this.debouncedSearch(value);
|
this.data.debouncedSearch(value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/** 提交搜索 */
|
/** 提交搜索 */
|
||||||
onSearchSubmit(e: WechatMiniprogram.CustomEvent) {
|
onSearchSubmit(e: WechatMiniprogram.CustomEvent) {
|
||||||
const value = e.detail.value.trim();
|
const value = e.detail.value.trim();
|
||||||
// 立即搜索,取消防抖
|
// 立即搜索,取消防抖
|
||||||
if (this.debouncedSearch) {
|
if (this.data.debouncedSearch) {
|
||||||
this.debouncedSearch.cancel();
|
this.data.debouncedSearch.cancel();
|
||||||
}
|
}
|
||||||
this.resetAndSearch(value);
|
this.resetAndSearch(value);
|
||||||
},
|
},
|
||||||
/** 清空搜索 */
|
/** 清空搜索 */
|
||||||
onSearchClear() {
|
onSearchClear() {
|
||||||
// 取消防抖,立即搜索
|
// 取消防抖,立即搜索
|
||||||
if (this.debouncedSearch) {
|
if (this.data.debouncedSearch) {
|
||||||
this.debouncedSearch.cancel();
|
this.data.debouncedSearch.cancel();
|
||||||
}
|
}
|
||||||
this.resetAndSearch("");
|
this.resetAndSearch("");
|
||||||
},
|
},
|
||||||
|
|||||||
@ -81,7 +81,7 @@
|
|||||||
padding: 4rpx 12rpx;
|
padding: 4rpx 12rpx;
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
background: var(--theme-bg-journal);
|
background: var(--theme-bg-card);
|
||||||
border-radius: 12rpx;
|
border-radius: 12rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
// components/travel-location-popup/index.ts
|
// components/travel-location-popup/index.ts
|
||||||
import { TravelLocation, TravelLocationTypeLabel, TravelLocationTypeIcon } from "../../types/Travel";
|
import { TravelLocation, TravelLocationTypeLabel, TravelLocationTypeIcon } from "../../types/Travel";
|
||||||
import { TravelLocationApi } from "../../api/TravelLocationApi";
|
import { TravelLocationApi } from "../../api/TravelLocationApi";
|
||||||
import { MediaAttachExt, MediaAttachType } from "../../types/Attachment";
|
import { MediaAttachType, PreviewImageMetadata } from "../../types/Attachment";
|
||||||
import { MediaItem, MediaItemType } from "../../types/UI";
|
import { MediaItem, MediaItemType } from "../../types/UI";
|
||||||
import config from "../../config/index";
|
import config from "../../config/index";
|
||||||
import Toolkit from "../../utils/Toolkit";
|
import Toolkit from "../../utils/Toolkit";
|
||||||
@ -39,16 +39,16 @@ Component({
|
|||||||
|
|
||||||
// 处理附件数据
|
// 处理附件数据
|
||||||
const attachments = location.items || [];
|
const attachments = location.items || [];
|
||||||
const thumbItems = attachments.filter((item: any) => item.attachType === MediaAttachType.THUMB);
|
const thumbItems = attachments.filter(item => item.attachType === MediaAttachType.THUMB);
|
||||||
|
|
||||||
if (0 < thumbItems.length) {
|
if (0 < thumbItems.length) {
|
||||||
const mediaItems: MediaItem[] = thumbItems.map((thumbItem: any, index: number) => {
|
const mediaItems: MediaItem[] = thumbItems.map((thumbItem, index) => {
|
||||||
const metadata = thumbItem.metadata;
|
const metadata = (typeof thumbItem.metadata === "string" ? JSON.parse(thumbItem.metadata) : thumbItem.metadata) as PreviewImageMetadata;
|
||||||
const ext = typeof thumbItem.ext === "string" ? JSON.parse(thumbItem.ext) : thumbItem.ext;
|
|
||||||
const thumbURL = `${config.url}/attachment/read/${thumbItem.mongoId}`;
|
const thumbURL = `${config.url}/attachment/read/${thumbItem.mongoId}`;
|
||||||
const sourceURL = `${config.url}/attachment/read/${ext.sourceMongoId}`;
|
const sourceURL = `${config.url}/attachment/read/${metadata.sourceMongoId}`;
|
||||||
|
const isVideo = metadata.sourceMimeType?.startsWith("video/");
|
||||||
return {
|
return {
|
||||||
type: ext.isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
|
type: isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
|
||||||
thumbURL,
|
thumbURL,
|
||||||
sourceURL,
|
sourceURL,
|
||||||
size: thumbItem.size || 0,
|
size: thumbItem.size || 0,
|
||||||
|
|||||||
@ -40,9 +40,15 @@
|
|||||||
<t-tag wx:if="{{item.score}}" theme="success" variant="outline">
|
<t-tag wx:if="{{item.score}}" theme="success" variant="outline">
|
||||||
评分 {{item.score}}
|
评分 {{item.score}}
|
||||||
</t-tag>
|
</t-tag>
|
||||||
|
<t-tag wx:if="{{item.importance}}" theme="success" variant="outline">
|
||||||
|
重要性 {{item.importance}}
|
||||||
|
</t-tag>
|
||||||
<t-tag wx:if="{{item.requireIdCard}}" theme="danger" variant="outline">
|
<t-tag wx:if="{{item.requireIdCard}}" theme="danger" variant="outline">
|
||||||
需要身份证
|
需要身份证
|
||||||
</t-tag>
|
</t-tag>
|
||||||
|
<t-tag wx:if="{{item.requireAppointment}}" theme="danger" variant="outline">
|
||||||
|
需要预约
|
||||||
|
</t-tag>
|
||||||
</view>
|
</view>
|
||||||
<view wx:if="{{item.description}}" class="description">{{item.description}}</view>
|
<view wx:if="{{item.description}}" class="description">{{item.description}}</view>
|
||||||
<view wx:if="{{item.columnedItems && item.columnedItems.length > 0}}" class="items">
|
<view wx:if="{{item.columnedItems && item.columnedItems.length > 0}}" class="items">
|
||||||
|
|||||||
@ -1,6 +1,12 @@
|
|||||||
const envArgs = {
|
const envArgs = {
|
||||||
develop: {
|
develop: {
|
||||||
url: "http://192.168.3.137:8091"
|
url: "http://localhost:8091"
|
||||||
|
// url: "https://api.imyeyu.dev"
|
||||||
|
// url: "https://api.imyeyu.com"
|
||||||
|
// url: "http://192.168.3.123:8091"
|
||||||
|
// url: "http://192.168.3.137:8091"
|
||||||
|
// url: "http://192.168.3.173:8091"
|
||||||
|
// url: "http://192.168.3.174:8091"
|
||||||
},
|
},
|
||||||
trial: {
|
trial: {
|
||||||
url: "https://api.imyeyu.com"
|
url: "https://api.imyeyu.com"
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
// index.ts
|
// index.ts
|
||||||
|
import { JournalPageType } from "../../types/Journal";
|
||||||
import config from "../../config/index"
|
import { JournalApi } from "../../api/JournalApi";
|
||||||
import { JournalPage, JournalPageType } from "../../types/Journal";
|
|
||||||
|
|
||||||
interface IndexData {
|
interface IndexData {
|
||||||
key: string;
|
key: string;
|
||||||
@ -19,32 +18,23 @@ Page({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
navigateToMain() {
|
async navigateToMain() {
|
||||||
wx.request({
|
try {
|
||||||
url: `${config.url}/journal/list`,
|
wx.setStorageSync("key", this.data.key);
|
||||||
method: "POST",
|
await JournalApi.getList({
|
||||||
header: {
|
|
||||||
Key: this.data.key
|
|
||||||
},
|
|
||||||
data: <JournalPage> {
|
|
||||||
index: 0,
|
index: 0,
|
||||||
size: 1,
|
size: 1,
|
||||||
type: JournalPageType.PREVIEW
|
type: JournalPageType.PREVIEW
|
||||||
},
|
});
|
||||||
success: (resp) => {
|
wx.switchTab({
|
||||||
const data = resp.data as any;
|
url: "/pages/main/journal/index",
|
||||||
if (data.code === 20000) {
|
})
|
||||||
wx.setStorageSync("key", this.data.key);
|
} catch (error: any) {
|
||||||
wx.switchTab({
|
if (error?.code === 40100) {
|
||||||
url: "/pages/main/journal/index",
|
wx.showToast({ title: "密码错误", icon: "error" });
|
||||||
})
|
} else {
|
||||||
} else if (data.code === 40100) {
|
wx.showToast({ title: "验证失败", icon: "error" });
|
||||||
wx.showToast({ title: "密码错误", icon: "error" });
|
}
|
||||||
} else {
|
}
|
||||||
wx.showToast({ title: "服务异常", icon: "error" });
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: () => wx.showToast({ title: "验证失败", icon: "error" })
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
/* pages/info/info.less */
|
/* pages/info/info.less */
|
||||||
page {
|
page {
|
||||||
height: 100vh;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="item">
|
<view class="item">
|
||||||
<text class="label">版本:</text>
|
<text class="label">版本:</text>
|
||||||
<text>1.5.4</text>
|
<text>1.6.6</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="item copyright">
|
<view class="item copyright">
|
||||||
<text>{{copyright}}</text>
|
<text>{{copyright}}</text>
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
// pages/main/journal-date/index.ts
|
// pages/main/journal-date/index.ts
|
||||||
import config from "../../../config/index";
|
|
||||||
import { Journal, JournalPageType } from "../../../types/Journal";
|
import { Journal, JournalPageType } from "../../../types/Journal";
|
||||||
import Time from "../../../utils/Time";
|
import Time from "../../../utils/Time";
|
||||||
|
import { JournalApi } from "../../../api/JournalApi";
|
||||||
|
|
||||||
interface JournalDateData {
|
interface JournalDateData {
|
||||||
// 存储每个日期的日记 id 列表
|
// 存储每个日期的日记 id 列表
|
||||||
@ -27,28 +27,12 @@ Page({
|
|||||||
async loadJournals() {
|
async loadJournals() {
|
||||||
this.setData({ isLoading: true });
|
this.setData({ isLoading: true });
|
||||||
try {
|
try {
|
||||||
const list: Journal[] = await new Promise((resolve, reject) => {
|
const pageResult = await JournalApi.getList({
|
||||||
wx.request({
|
index: 0,
|
||||||
url: `${config.url}/journal/list`,
|
size: 9007199254740992,
|
||||||
method: "POST",
|
type: JournalPageType.PREVIEW
|
||||||
header: {
|
});
|
||||||
Key: wx.getStorageSync("key")
|
const list: Journal[] = pageResult.list || [];
|
||||||
},
|
|
||||||
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
|
// 按日期分组,只存储 id
|
||||||
const journalMap: Record<string, number[]> = {};
|
const journalMap: Record<string, number[]> = {};
|
||||||
list.forEach((journal: any) => {
|
list.forEach((journal: any) => {
|
||||||
|
|||||||
@ -26,6 +26,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
.radio {
|
.radio {
|
||||||
|
background: transparent;
|
||||||
margin-right: 1em;
|
margin-right: 1em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -59,6 +60,10 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 80rpx;
|
font-size: 80rpx;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.thumbnail {
|
.thumbnail {
|
||||||
|
|||||||
@ -4,9 +4,10 @@ import Time from "../../../utils/Time";
|
|||||||
import Toolkit from "../../../utils/Toolkit";
|
import Toolkit from "../../../utils/Toolkit";
|
||||||
import config from "../../../config/index";
|
import config from "../../../config/index";
|
||||||
import { Location, MediaItem, MediaItemType, WechatMediaItem } from "../../../types/UI";
|
import { Location, MediaItem, MediaItemType, WechatMediaItem } from "../../../types/UI";
|
||||||
import { Journal, JournalType } from "../../../types/Journal";
|
import { JournalType } from "../../../types/Journal";
|
||||||
import { MediaAttachExt, MediaAttachType } from "../../../types/Attachment";
|
import { MediaAttachType, PreviewImageMetadata } from "../../../types/Attachment";
|
||||||
import IOSize, { Unit } from "../../../utils/IOSize";
|
import IOSize, { Unit } from "../../../utils/IOSize";
|
||||||
|
import { JournalApi } from "../../../api/JournalApi";
|
||||||
|
|
||||||
interface JournalEditorData {
|
interface JournalEditorData {
|
||||||
/** 模式:create 或 edit */
|
/** 模式:create 或 edit */
|
||||||
@ -77,7 +78,7 @@ Page({
|
|||||||
async onLoad(options: any) {
|
async onLoad(options: any) {
|
||||||
// 授权定位
|
// 授权定位
|
||||||
const setting = await wx.getSetting();
|
const setting = await wx.getSetting();
|
||||||
wx.setStorageSync("isAuthLocation", setting.authSetting["scope.userLocation"]);
|
wx.setStorageSync("isAuthLocation", setting.authSetting["scope.userLocation"] || false);
|
||||||
let isAuthLocation = JSON.parse(wx.getStorageSync("isAuthLocation"));
|
let isAuthLocation = JSON.parse(wx.getStorageSync("isAuthLocation"));
|
||||||
this.setData({ isAuthLocation });
|
this.setData({ isAuthLocation });
|
||||||
if (!isAuthLocation) {
|
if (!isAuthLocation) {
|
||||||
@ -148,35 +149,19 @@ Page({
|
|||||||
},
|
},
|
||||||
/** 加载日记详情(编辑模式) */
|
/** 加载日记详情(编辑模式) */
|
||||||
async loadJournalDetail(id: number) {
|
async loadJournalDetail(id: number) {
|
||||||
wx.showLoading({ title: "加载中...", mask: true });
|
|
||||||
try {
|
try {
|
||||||
const journal: Journal = await new Promise((resolve, reject) => {
|
const journal = await JournalApi.getDetail(id);
|
||||||
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 items = journal.items || [];
|
||||||
const thumbItems = items.filter((item) => item.attachType === MediaAttachType.THUMB);
|
const thumbItems = items.filter((item) => item.attachType === MediaAttachType.THUMB);
|
||||||
|
|
||||||
const mediaList: MediaItem[] = thumbItems.map((thumbItem) => {
|
const mediaList: MediaItem[] = thumbItems.map((thumbItem) => {
|
||||||
const ext = thumbItem.ext = JSON.parse(thumbItem.ext!.toString()) as MediaAttachExt;
|
const metadata = (typeof thumbItem.metadata === "string" ? JSON.parse(thumbItem.metadata) : thumbItem.metadata) as PreviewImageMetadata;
|
||||||
const thumbURL = `${config.url}/attachment/read/${thumbItem.mongoId}`;
|
const thumbURL = `${config.url}/attachment/read/${thumbItem.mongoId}`;
|
||||||
const sourceURL = `${config.url}/attachment/read/${ext.sourceMongoId}`;
|
const sourceURL = `${config.url}/attachment/read/${metadata.sourceMongoId}`;
|
||||||
|
const isVideo = metadata.sourceMimeType?.startsWith("video/");
|
||||||
return {
|
return {
|
||||||
type: ext.isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
|
type: isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
|
||||||
thumbURL,
|
thumbURL,
|
||||||
sourceURL,
|
sourceURL,
|
||||||
size: thumbItem.size || 0,
|
size: thumbItem.size || 0,
|
||||||
@ -293,7 +278,7 @@ Page({
|
|||||||
// 创建模式:只有 mediaList
|
// 创建模式:只有 mediaList
|
||||||
const sources = (this.data.mediaList as WechatMediaItem[]).map(item => ({
|
const sources = (this.data.mediaList as WechatMediaItem[]).map(item => ({
|
||||||
url: item.path,
|
url: item.path,
|
||||||
type: MediaItemType[item.type].toLowerCase()
|
type: item.type.toLowerCase()
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const total = sources.length;
|
const total = sources.length;
|
||||||
@ -309,11 +294,11 @@ Page({
|
|||||||
// 编辑模式:mediaList + newMediaList
|
// 编辑模式:mediaList + newMediaList
|
||||||
const sources = (this.data.mediaList as MediaItem[]).map(item => ({
|
const sources = (this.data.mediaList as MediaItem[]).map(item => ({
|
||||||
url: item.sourceURL,
|
url: item.sourceURL,
|
||||||
type: MediaItemType[item.type].toLowerCase()
|
type: item.type
|
||||||
}));
|
}));
|
||||||
const newSources = this.data.newMediaList.map(item => ({
|
const newSources = this.data.newMediaList.map(item => ({
|
||||||
url: item.path,
|
url: item.path,
|
||||||
type: MediaItemType[item.type].toLowerCase()
|
type: item.type
|
||||||
}));
|
}));
|
||||||
const allSources = [...sources, ...newSources];
|
const allSources = [...sources, ...newSources];
|
||||||
const itemIndex = isNewMedia ? this.data.mediaList.length + index : index;
|
const itemIndex = isNewMedia ? this.data.mediaList.length + index : index;
|
||||||
@ -392,45 +377,21 @@ Page({
|
|||||||
this.executeDelete();
|
this.executeDelete();
|
||||||
},
|
},
|
||||||
/** 执行删除 */
|
/** 执行删除 */
|
||||||
executeDelete() {
|
async executeDelete() {
|
||||||
wx.showLoading({ title: "删除中...", mask: true });
|
try {
|
||||||
wx.request({
|
await JournalApi.delete(this.data.id!);
|
||||||
url: `${config.url}/journal/delete`,
|
Events.emit("JOURNAL_REFRESH");
|
||||||
method: "POST",
|
Events.emit("JOURNAL_LIST_REFRESH");
|
||||||
header: {
|
wx.showToast({
|
||||||
Key: wx.getStorageSync("key"),
|
title: "删除成功",
|
||||||
"Content-Type": "application/json"
|
icon: "success"
|
||||||
},
|
});
|
||||||
data: {
|
setTimeout(() => {
|
||||||
id: this.data.id
|
wx.navigateBack();
|
||||||
},
|
}, 1000);
|
||||||
success: (res: any) => {
|
} catch (error) {
|
||||||
wx.hideLoading();
|
console.error("删除日记失败:", error);
|
||||||
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"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
/** 提交/保存 */
|
/** 提交/保存 */
|
||||||
submit() {
|
submit() {
|
||||||
@ -441,10 +402,9 @@ Page({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
/** 创建日记 */
|
/** 创建日记 */
|
||||||
createJournal() {
|
async createJournal() {
|
||||||
const handleFail = () => {
|
const handleFail = () => {
|
||||||
wx.showToast({ title: "上传失败", icon: "error" });
|
wx.showToast({ title: "上传失败", icon: "error" });
|
||||||
wx.hideLoading();
|
|
||||||
this.setData({
|
this.setData({
|
||||||
isSaving: false
|
isSaving: false
|
||||||
});
|
});
|
||||||
@ -452,83 +412,64 @@ Page({
|
|||||||
this.setData({
|
this.setData({
|
||||||
isSaving: true
|
isSaving: true
|
||||||
});
|
});
|
||||||
// 获取 openId
|
try {
|
||||||
const getOpenId = new Promise<string>((resolve, reject) => {
|
// 获取 openId
|
||||||
wx.login({
|
const getOpenId = new Promise<string>((resolve, reject) => {
|
||||||
success: (res) => {
|
wx.login({
|
||||||
if (res.code) {
|
success: async (res) => {
|
||||||
wx.request({
|
if (res.code) {
|
||||||
url: `${config.url}/journal/openid`,
|
try {
|
||||||
method: "POST",
|
const openId = await JournalApi.getOpenId(res.code);
|
||||||
header: {
|
resolve(openId);
|
||||||
Key: wx.getStorageSync("key")
|
} catch (error) {
|
||||||
},
|
reject(new Error("获取 openId 失败"));
|
||||||
data: {
|
}
|
||||||
code: res.code
|
} else {
|
||||||
},
|
reject(new Error("获取登录凭证失败"));
|
||||||
success: (resp) => {
|
}
|
||||||
const data = resp.data as any;
|
},
|
||||||
if (data.code === 20000) {
|
fail: () => reject(new Error("登录失败"))
|
||||||
resolve(data.data);
|
});
|
||||||
} else {
|
|
||||||
reject(new Error("获取 openId 失败"));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: () => reject(new Error("获取 openId 请求失败"))
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
reject(new Error("获取登录凭证失败"));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: () => reject(new Error("登录失败"))
|
|
||||||
});
|
});
|
||||||
});
|
// 文件上传
|
||||||
// 文件上传
|
const uploadFiles = this.uploadMediaFiles(this.data.mediaList as WechatMediaItem[]);
|
||||||
const uploadFiles = this.uploadMediaFiles(this.data.mediaList as WechatMediaItem[]);
|
// 并行执行获取 openId 和文件上传
|
||||||
// 并行执行获取 openId 和文件上传
|
const [openId, tempFileIds] = await Promise.all([getOpenId, uploadFiles]);
|
||||||
Promise.all([getOpenId, uploadFiles]).then(([openId, tempFileIds]) => {
|
|
||||||
wx.showLoading({ title: "正在保存..", mask: true });
|
await JournalApi.create({
|
||||||
wx.request({
|
idea: this.data.idea,
|
||||||
url: `${config.url}/journal/create`,
|
type: this.data.type,
|
||||||
method: "POST",
|
lat: this.data.location?.lat,
|
||||||
header: {
|
lng: this.data.location?.lng,
|
||||||
Key: wx.getStorageSync("key")
|
location: this.data.location?.text,
|
||||||
},
|
pusher: openId,
|
||||||
data: {
|
createdAt: Date.parse(`${this.data.date} ${this.data.time}`),
|
||||||
idea: this.data.idea,
|
tempFileIds
|
||||||
type: this.data.type,
|
|
||||||
lat: this.data.location?.lat,
|
|
||||||
lng: this.data.location?.lng,
|
|
||||||
location: this.data.location?.text,
|
|
||||||
pusher: openId,
|
|
||||||
createdAt: Date.parse(`${this.data.date} ${this.data.time}`),
|
|
||||||
tempFileIds
|
|
||||||
},
|
|
||||||
success: async () => {
|
|
||||||
Events.emit("JOURNAL_REFRESH");
|
|
||||||
wx.showToast({ title: "提交成功", icon: "success" });
|
|
||||||
this.setData({
|
|
||||||
idea: "",
|
|
||||||
mediaList: [],
|
|
||||||
isSaving: false,
|
|
||||||
uploaded: "0",
|
|
||||||
uploadTotal: "0 MB",
|
|
||||||
uploadProgress: 0
|
|
||||||
});
|
|
||||||
await Toolkit.sleep(1000);
|
|
||||||
wx.switchTab({
|
|
||||||
url: "/pages/main/journal/index"
|
|
||||||
});
|
|
||||||
},
|
|
||||||
fail: handleFail
|
|
||||||
});
|
});
|
||||||
}).catch(handleFail);
|
|
||||||
|
Events.emit("JOURNAL_REFRESH");
|
||||||
|
wx.showToast({ title: "提交成功", icon: "success" });
|
||||||
|
this.setData({
|
||||||
|
idea: "",
|
||||||
|
mediaList: [],
|
||||||
|
isSaving: false,
|
||||||
|
uploaded: "0",
|
||||||
|
uploadTotal: "0 MB",
|
||||||
|
uploadProgress: 0
|
||||||
|
});
|
||||||
|
await Toolkit.sleep(1000);
|
||||||
|
wx.switchTab({
|
||||||
|
url: "/pages/main/journal/index"
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("创建日记失败:", error);
|
||||||
|
handleFail();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
/** 更新日记 */
|
/** 更新日记 */
|
||||||
updateJournal() {
|
async updateJournal() {
|
||||||
const handleFail = () => {
|
const handleFail = () => {
|
||||||
wx.showToast({ title: "保存失败", icon: "error" });
|
wx.showToast({ title: "保存失败", icon: "error" });
|
||||||
wx.hideLoading();
|
|
||||||
this.setData({
|
this.setData({
|
||||||
isSaving: false
|
isSaving: false
|
||||||
});
|
});
|
||||||
@ -536,53 +477,39 @@ Page({
|
|||||||
this.setData({
|
this.setData({
|
||||||
isSaving: true
|
isSaving: true
|
||||||
});
|
});
|
||||||
// 收集保留的附件 ID(缩略图 ID)
|
try {
|
||||||
const attachmentIds = (this.data.mediaList as MediaItem[]).map(item => item.attachmentId);
|
// 收集保留的附件 ID(缩略图 ID)
|
||||||
// 上传新媒体文件
|
const attachmentIds = (this.data.mediaList as MediaItem[]).map(item => item.attachmentId);
|
||||||
const uploadFiles = this.uploadMediaFiles(this.data.newMediaList);
|
// 上传新媒体文件
|
||||||
|
const tempFileIds = await this.uploadMediaFiles(this.data.newMediaList);
|
||||||
|
|
||||||
// 提交保存
|
await JournalApi.update({
|
||||||
uploadFiles.then((tempFileIds) => {
|
id: this.data.id!,
|
||||||
wx.showLoading({ title: "正在保存..", mask: true });
|
idea: this.data.idea,
|
||||||
wx.request({
|
type: this.data.type,
|
||||||
url: `${config.url}/journal/update`,
|
lat: this.data.location?.lat,
|
||||||
method: "POST",
|
lng: this.data.location?.lng,
|
||||||
header: {
|
location: this.data.location?.text,
|
||||||
Key: wx.getStorageSync("key")
|
createdAt: new Date(`${this.data.date}T${this.data.time}:00`).getTime(),
|
||||||
},
|
attachmentIds,
|
||||||
data: {
|
tempFileIds
|
||||||
id: this.data.id,
|
|
||||||
idea: this.data.idea,
|
|
||||||
type: this.data.type,
|
|
||||||
lat: this.data.location?.lat,
|
|
||||||
lng: this.data.location?.lng,
|
|
||||||
location: this.data.location?.text,
|
|
||||||
createdAt: new Date(`${this.data.date}T${this.data.time}:00`).getTime(),
|
|
||||||
// 保留的现有附件 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({
|
|
||||||
isSaving: false,
|
|
||||||
uploaded: "0",
|
|
||||||
uploadTotal: "0 MB",
|
|
||||||
uploadProgress: 0
|
|
||||||
});
|
|
||||||
await Toolkit.sleep(1000);
|
|
||||||
wx.navigateBack();
|
|
||||||
} else {
|
|
||||||
handleFail();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: handleFail
|
|
||||||
});
|
});
|
||||||
}).catch(handleFail);
|
|
||||||
|
Events.emit("JOURNAL_REFRESH");
|
||||||
|
Events.emit("JOURNAL_LIST_REFRESH");
|
||||||
|
wx.showToast({ title: "保存成功", icon: "success" });
|
||||||
|
this.setData({
|
||||||
|
isSaving: false,
|
||||||
|
uploaded: "0",
|
||||||
|
uploadTotal: "0 MB",
|
||||||
|
uploadProgress: 0
|
||||||
|
});
|
||||||
|
await Toolkit.sleep(1000);
|
||||||
|
wx.navigateBack();
|
||||||
|
} catch (error) {
|
||||||
|
console.error("更新日记失败:", error);
|
||||||
|
handleFail();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
/** 上传媒体文件 */
|
/** 上传媒体文件 */
|
||||||
uploadMediaFiles(mediaList: WechatMediaItem[]): Promise<string[]> {
|
uploadMediaFiles(mediaList: WechatMediaItem[]): Promise<string[]> {
|
||||||
|
|||||||
@ -238,10 +238,6 @@
|
|||||||
<text style="color: var(--theme-error)">确认删除</text>
|
<text style="color: var(--theme-error)">确认删除</text>
|
||||||
<text>" 以继续</text>
|
<text>" 以继续</text>
|
||||||
</view>
|
</view>
|
||||||
<t-input
|
<t-input model:value="{{deleteConfirmText}}" placeholder="请输入:确认删除" />
|
||||||
class="confirm-input"
|
|
||||||
model:value="{{deleteConfirmText}}"
|
|
||||||
placeholder="请输入:确认删除"
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
</t-dialog>
|
</t-dialog>
|
||||||
|
|||||||
@ -8,75 +8,74 @@
|
|||||||
.map {
|
.map {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
|
||||||
|
|
||||||
.custom-callout {
|
.location {
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
min-width: 350rpx;
|
background: var(--theme-bg-card);
|
||||||
max-width: 450rpx;
|
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, .15);
|
||||||
background: #fff;
|
border-radius: 6rpx;
|
||||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, .15);
|
|
||||||
border-radius: 6rpx;
|
.content {
|
||||||
|
|
||||||
.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;
|
display: flex;
|
||||||
overflow: hidden;
|
padding: 8rpx 16rpx 8rpx 8rpx;
|
||||||
flex-direction: column;
|
align-items: flex-start;
|
||||||
|
|
||||||
.location {
|
.thumb {
|
||||||
color: #333;
|
width: 72rpx;
|
||||||
|
height: 72rpx;
|
||||||
|
position: relative;
|
||||||
|
flex-shrink: 0;
|
||||||
|
margin-right: 12rpx;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
font-size: 30rpx;
|
border-radius: 6rpx;
|
||||||
white-space: nowrap;
|
|
||||||
text-overflow: ellipsis;
|
.img {
|
||||||
margin-bottom: 4rpx;
|
width: 100%;
|
||||||
}
|
height: 100%;
|
||||||
|
|
||||||
.date-count {
|
|
||||||
display: flex;
|
|
||||||
|
|
||||||
.date {
|
|
||||||
color: #999;
|
|
||||||
font-size: 24rpx;
|
|
||||||
margin-right: 16rpx;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.count {
|
.badge {
|
||||||
color: var(--theme-wx);
|
top: 4rpx;
|
||||||
font-size: 24rpx;
|
right: 4rpx;
|
||||||
font-weight: 600;
|
color: #fff;
|
||||||
|
padding: 2rpx 6rpx;
|
||||||
|
position: absolute;
|
||||||
|
font-size: 20rpx;
|
||||||
|
background: rgba(0, 0, 0, .7);
|
||||||
|
border-radius: 8rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.text {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
overflow: hidden;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
.value {
|
||||||
|
color: var(--theme-text-primary);
|
||||||
|
width: calc(var(--title-length) * 30rpx);
|
||||||
|
overflow: hidden;
|
||||||
|
font-size: 30rpx;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
margin-bottom: 4rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-count {
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
.date {
|
||||||
|
color: var(--theme-text-secondary);
|
||||||
|
font-size: 24rpx;
|
||||||
|
margin-right: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.count {
|
||||||
|
color: var(--theme-wx);
|
||||||
|
font-size: 24rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,21 +1,10 @@
|
|||||||
// pages/main/journal-map/index.ts
|
// pages/main/journal-map/index.ts
|
||||||
import config from "../../../config/index";
|
import config from "../../../config/index";
|
||||||
import Time from "../../../utils/Time";
|
import Time from "../../../utils/Time";
|
||||||
import { Journal, JournalPageType } from "../../../types/Journal";
|
import { JournalPageType } from "../../../types/Journal";
|
||||||
import Toolkit from "../../../utils/Toolkit";
|
import Toolkit from "../../../utils/Toolkit";
|
||||||
|
import { MapMarker } from "../../../types/UI";
|
||||||
interface MapMarker {
|
import { JournalApi } from "../../../api/JournalApi";
|
||||||
id: number;
|
|
||||||
latitude: number;
|
|
||||||
longitude: number;
|
|
||||||
width: number;
|
|
||||||
height: number;
|
|
||||||
customCallout: {
|
|
||||||
anchorY: number;
|
|
||||||
anchorX: number;
|
|
||||||
display: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
interface LocationMarker {
|
interface LocationMarker {
|
||||||
locationKey: string; // 位置键 "lat,lng"
|
locationKey: string; // 位置键 "lat,lng"
|
||||||
@ -62,28 +51,12 @@ Page({
|
|||||||
async loadJournals() {
|
async loadJournals() {
|
||||||
this.setData({ isLoading: true });
|
this.setData({ isLoading: true });
|
||||||
try {
|
try {
|
||||||
const list: Journal[] = await new Promise((resolve, reject) => {
|
const result = await JournalApi.getList({
|
||||||
wx.request({
|
index: 0,
|
||||||
url: `${config.url}/journal/list`,
|
size: 9007199254740992,
|
||||||
method: "POST",
|
type: JournalPageType.PREVIEW
|
||||||
header: {
|
});
|
||||||
Key: wx.getStorageSync("key")
|
const list = result.list || [];
|
||||||
},
|
|
||||||
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>();
|
const locationMap = new Map<string, LocationMarker>();
|
||||||
list.filter((journal: any) => journal.lat && journal.lng).forEach((journal: any) => {
|
list.filter((journal: any) => journal.lat && journal.lng).forEach((journal: any) => {
|
||||||
|
|||||||
@ -13,23 +13,28 @@
|
|||||||
bindcallouttap="onCalloutTap"
|
bindcallouttap="onCalloutTap"
|
||||||
>
|
>
|
||||||
<cover-view slot="callout">
|
<cover-view slot="callout">
|
||||||
<block wx:for="{{locations}}" wx:key="locationKey" wx:for-index="markerIndex">
|
<cover-view
|
||||||
<cover-view class="custom-callout" marker-id="{{markerIndex}}">
|
class="location"
|
||||||
<cover-view class="callout-content">
|
wx:for="{{locations}}"
|
||||||
<cover-view wx:if="{{item.previewThumb}}" class="thumb-container">
|
wx:key="locationKey"
|
||||||
<cover-image class="thumb" src="{{item.previewThumb}}" />
|
wx:for-index="locationIndex"
|
||||||
<cover-view wx:if="{{item.count > 1}}" class="count-badge">{{item.count}}</cover-view>
|
marker-id="{{locationIndex}}"
|
||||||
</cover-view>
|
style="{{'--title-length: ' + item.location.length}}"
|
||||||
<cover-view class="text-container">
|
>
|
||||||
<cover-view wx:if="{{item.location}}" class="location">{{item.location}}</cover-view>
|
<cover-view class="content">
|
||||||
<cover-view class="date-count">
|
<cover-view wx:if="{{item.previewThumb}}" class="thumb">
|
||||||
<cover-view class="date">{{item.date}}</cover-view>
|
<cover-image class="img" src="{{item.previewThumb}}" />
|
||||||
<cover-view wx:if="{{item.count > 1}}" class="count">{{item.count}} 条日记</cover-view>
|
<cover-view wx:if="{{1 < item.count}}" class="badge">{{item.count}}</cover-view>
|
||||||
</cover-view>
|
</cover-view>
|
||||||
|
<cover-view class="text">
|
||||||
|
<cover-view wx:if="{{item.location}}" class="value">{{item.location}}</cover-view>
|
||||||
|
<cover-view class="date-count">
|
||||||
|
<cover-view class="date">{{item.date}}</cover-view>
|
||||||
|
<cover-view wx:if="{{1 < item.count}}" class="count">{{item.count}} 条日记</cover-view>
|
||||||
</cover-view>
|
</cover-view>
|
||||||
</cover-view>
|
</cover-view>
|
||||||
</cover-view>
|
</cover-view>
|
||||||
</block>
|
</cover-view>
|
||||||
</cover-view>
|
</cover-view>
|
||||||
</map>
|
</map>
|
||||||
<view wx:if="{{isLoading}}" class="loading">
|
<view wx:if="{{isLoading}}" class="loading">
|
||||||
|
|||||||
@ -1,8 +1,21 @@
|
|||||||
page {
|
page {
|
||||||
|
height: 100vh;
|
||||||
background: var(--td-bg-color-page);
|
background: var(--td-bg-color-page);
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.page-container {
|
||||||
width: 100vw;
|
width: 100%;
|
||||||
height: calc(100vh - var(--navbar-height, 88rpx));
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
overflow: hidden;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
.navbar {
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
flex: 1;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
<view class="custom-navbar">
|
<view class="page-container">
|
||||||
<t-navbar title="列表查找" left-arrow />
|
<view class="navbar">
|
||||||
</view>
|
<t-navbar title="列表查找" left-arrow />
|
||||||
|
</view>
|
||||||
<view class="content">
|
<view class="content">
|
||||||
<journal-list
|
<journal-list
|
||||||
id="listRef"
|
id="listRef"
|
||||||
searchable="{{true}}"
|
searchable="{{true}}"
|
||||||
mode="navigate"
|
mode="navigate"
|
||||||
bind:navigate="onNavigateItem"
|
bind:navigate="onNavigateItem"
|
||||||
/>
|
/>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@ -5,9 +5,10 @@ import config from "../../../config/index"
|
|||||||
import Events from "../../../utils/Events";
|
import Events from "../../../utils/Events";
|
||||||
import Toolkit from "../../../utils/Toolkit";
|
import Toolkit from "../../../utils/Toolkit";
|
||||||
import { Journal, JournalPage, JournalPageType } from "../../../types/Journal";
|
import { Journal, JournalPage, JournalPageType } from "../../../types/Journal";
|
||||||
import { OrderType, QueryPageResult } from "../../../types/Model";
|
import { OrderType } from "../../../types/Model";
|
||||||
import { ImageMetadata, MediaAttachExt } from "../../../types/Attachment";
|
import { PreviewImageMetadata } from "../../../types/Attachment";
|
||||||
import { MediaItem, MediaItemType } from "../../../types/UI";
|
import { MediaItem, MediaItemType } from "../../../types/UI";
|
||||||
|
import { JournalApi } from "../../../api/JournalApi";
|
||||||
|
|
||||||
interface JournalData {
|
interface JournalData {
|
||||||
page: JournalPage;
|
page: JournalPage;
|
||||||
@ -143,79 +144,71 @@ Page({
|
|||||||
url: "/pages/main/journal-date/index"
|
url: "/pages/main/journal-date/index"
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
fetch() {
|
async fetch() {
|
||||||
if (this.data.isFetching || this.data.isFinished) {
|
if (this.data.isFetching || this.data.isFinished) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.setData({
|
this.setData({
|
||||||
isFetching: true
|
isFetching: true
|
||||||
});
|
});
|
||||||
wx.request({
|
try {
|
||||||
url: `${config.url}/journal/list`,
|
const pageResult = await JournalApi.getList(this.data.page);
|
||||||
method: "POST",
|
const list = pageResult.list;
|
||||||
header: {
|
if (!list || list.length === 0) {
|
||||||
Key: wx.getStorageSync("key")
|
|
||||||
},
|
|
||||||
data: this.data.page,
|
|
||||||
success: async (resp: any) => {
|
|
||||||
const pageResult = resp.data.data as QueryPageResult<Journal>;
|
|
||||||
const list = pageResult.list;
|
|
||||||
if (!list || list.length === 0) {
|
|
||||||
this.setData({
|
|
||||||
isFinished: true
|
|
||||||
})
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
list.forEach(journal => {
|
|
||||||
const mediaItems = journal.items!.filter((item) => item.attachType === "THUMB").map((thumbItem, index) => {
|
|
||||||
const metadata = thumbItem.metadata as ImageMetadata;
|
|
||||||
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,
|
|
||||||
width: metadata.width,
|
|
||||||
height: metadata.height,
|
|
||||||
originalIndex: index
|
|
||||||
} as MediaItem;
|
|
||||||
});
|
|
||||||
journal.date = Time.toDate(journal.createdAt);
|
|
||||||
journal.time = Time.toTime(journal.createdAt);
|
|
||||||
journal.datetime = Time.toPassedDateTime(journal.createdAt);
|
|
||||||
journal.mediaItems = mediaItems;
|
|
||||||
journal.columnedItems = Toolkit.splitItemsIntoColumns(mediaItems, 3, (item) => {
|
|
||||||
if (item.width && item.height && 0 < item.width) {
|
|
||||||
return item.height / item.width;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
})
|
|
||||||
this.setData({
|
|
||||||
page: {
|
|
||||||
index: this.data.page.index + 1,
|
|
||||||
size: 8,
|
|
||||||
type: JournalPageType.NORMAL,
|
|
||||||
equalsExample: {
|
|
||||||
type: "NORMAL"
|
|
||||||
},
|
|
||||||
orderMap: {
|
|
||||||
createdAt: OrderType.DESC
|
|
||||||
}
|
|
||||||
},
|
|
||||||
list: this.data.list.concat(list),
|
|
||||||
isFinished: list.length < this.data.page.size
|
|
||||||
});
|
|
||||||
},
|
|
||||||
complete: () => {
|
|
||||||
this.setData({
|
this.setData({
|
||||||
|
isFinished: true,
|
||||||
isFetching: false
|
isFetching: false
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
});
|
list.forEach(journal => {
|
||||||
|
const mediaItems = journal.items!.filter((item) => item.attachType === "THUMB").map((thumbItem, index) => {
|
||||||
|
const metadata = (typeof thumbItem.metadata === "string" ? JSON.parse(thumbItem.metadata) : thumbItem.metadata) as PreviewImageMetadata;
|
||||||
|
const thumbURL = `${config.url}/attachment/read/${thumbItem.mongoId}`;
|
||||||
|
const sourceURL = `${config.url}/attachment/read/${metadata.sourceMongoId}`;
|
||||||
|
const isVideo = metadata.sourceMimeType?.startsWith("video/");
|
||||||
|
return {
|
||||||
|
type: isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
|
||||||
|
thumbURL,
|
||||||
|
sourceURL,
|
||||||
|
size: thumbItem.size || 0,
|
||||||
|
attachmentId: thumbItem.id,
|
||||||
|
width: metadata.width,
|
||||||
|
height: metadata.height,
|
||||||
|
originalIndex: index
|
||||||
|
} as MediaItem;
|
||||||
|
});
|
||||||
|
journal.date = Time.toDate(journal.createdAt);
|
||||||
|
journal.time = Time.toTime(journal.createdAt);
|
||||||
|
journal.datetime = Time.toPassedDateTime(journal.createdAt);
|
||||||
|
journal.mediaItems = mediaItems;
|
||||||
|
journal.columnedItems = Toolkit.splitItemsIntoColumns(mediaItems, 3, (item) => {
|
||||||
|
if (item.width && item.height && 0 < item.width) {
|
||||||
|
return item.height / item.width;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
});
|
||||||
|
this.setData({
|
||||||
|
page: {
|
||||||
|
index: this.data.page.index + 1,
|
||||||
|
size: 8,
|
||||||
|
type: JournalPageType.NORMAL,
|
||||||
|
equalsExample: {
|
||||||
|
type: "NORMAL"
|
||||||
|
},
|
||||||
|
orderMap: {
|
||||||
|
createdAt: OrderType.DESC
|
||||||
|
}
|
||||||
|
},
|
||||||
|
list: this.data.list.concat(list),
|
||||||
|
isFinished: list.length < this.data.page.size,
|
||||||
|
isFetching: false
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("加载日记失败:", error);
|
||||||
|
this.setData({ isFetching: false });
|
||||||
|
}
|
||||||
},
|
},
|
||||||
preview(e: WechatMiniprogram.BaseEvent) {
|
preview(e: WechatMiniprogram.BaseEvent) {
|
||||||
const { journalIndex, itemIndex } = e.currentTarget.dataset;
|
const { journalIndex, itemIndex } = e.currentTarget.dataset;
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
sticky-offset="{{stickyOffset}}"
|
sticky-offset="{{stickyOffset}}"
|
||||||
>
|
>
|
||||||
<view class="content" wx:for="{{list}}" wx:for-item="journal" wx:for-index="journalIndex" wx:key="index">
|
<view class="content" wx:for="{{list}}" wx:for-item="journal" wx:for-index="journalIndex" wx:key="index">
|
||||||
<t-indexes-anchor class="date" index="{{journal.date}}" />
|
<t-indexes-anchor class="date" index="{{journal.datetime}}" />
|
||||||
<view wx:if="{{journal.idea || journal.location}}" class="text">
|
<view wx:if="{{journal.idea || journal.location}}" class="text">
|
||||||
<text class="idea">{{journal.idea}}</text>
|
<text class="idea">{{journal.idea}}</text>
|
||||||
<view
|
<view
|
||||||
@ -41,7 +41,7 @@
|
|||||||
<view wx:for="{{journal.columnedItems}}" wx:for-item="column" wx:for-index="columnIndex" wx:key="columnIndex" class="column">
|
<view wx:for="{{journal.columnedItems}}" wx:for-item="column" wx:for-index="columnIndex" wx:key="columnIndex" class="column">
|
||||||
<block wx:for="{{column}}" wx:for-item="item" wx:for-index="itemIndex" wx:key="attachmentId">
|
<block wx:for="{{column}}" wx:for-item="item" wx:for-index="itemIndex" wx:key="attachmentId">
|
||||||
<image
|
<image
|
||||||
class="item thumbnail {{item.type === 0 ? 'image' : 'video'}}"
|
class="item thumbnail {{item.type}}"
|
||||||
src="{{item.thumbURL}}"
|
src="{{item.thumbURL}}"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
bindtap="preview"
|
bindtap="preview"
|
||||||
|
|||||||
@ -4,22 +4,20 @@ import Events from "../../../utils/Events";
|
|||||||
import IOSize, { Unit } from "../../../utils/IOSize";
|
import IOSize, { Unit } from "../../../utils/IOSize";
|
||||||
import Time from "../../../utils/Time";
|
import Time from "../../../utils/Time";
|
||||||
import Toolkit from "../../../utils/Toolkit";
|
import Toolkit from "../../../utils/Toolkit";
|
||||||
import type { Location } from "../../../types/UI";
|
import { Location, MediaItemType } from "../../../types/UI";
|
||||||
|
import { PreviewImageMetadata } from "../../../types/Attachment";
|
||||||
|
import { MomentApi } from "../../../api/MomentApi";
|
||||||
|
import { JournalApi } from "../../../api/JournalApi";
|
||||||
|
import { Network } from "../../../utils/Network";
|
||||||
|
|
||||||
type Item = {
|
type Item = {
|
||||||
id: number;
|
id: number;
|
||||||
type: ItemType;
|
type: MediaItemType;
|
||||||
mongoId: string;
|
thumbURL: string;
|
||||||
thumbUrl: string;
|
sourceURL: string;
|
||||||
sourceMongoId: string;
|
|
||||||
checked: boolean;
|
checked: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ItemType {
|
|
||||||
IMAGE,
|
|
||||||
VIDEO
|
|
||||||
}
|
|
||||||
|
|
||||||
type MD5Result = {
|
type MD5Result = {
|
||||||
path: string;
|
path: string;
|
||||||
md5: string;
|
md5: string;
|
||||||
@ -73,7 +71,7 @@ Page({
|
|||||||
|
|
||||||
// 授权定位
|
// 授权定位
|
||||||
const setting = await wx.getSetting();
|
const setting = await wx.getSetting();
|
||||||
wx.setStorageSync("isAuthLocation", setting.authSetting["scope.userLocation"]);
|
wx.setStorageSync("isAuthLocation", setting.authSetting["scope.userLocation"] || false);
|
||||||
let isAuthLocation = JSON.parse(wx.getStorageSync("isAuthLocation"));
|
let isAuthLocation = JSON.parse(wx.getStorageSync("isAuthLocation"));
|
||||||
this.setData({ isAuthLocation });
|
this.setData({ isAuthLocation });
|
||||||
if (!isAuthLocation) {
|
if (!isAuthLocation) {
|
||||||
@ -128,33 +126,30 @@ Page({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
fetch() {
|
async fetch() {
|
||||||
wx.request({
|
try {
|
||||||
url: `${config.url}/journal/moment/list`,
|
const list = await MomentApi.getList();
|
||||||
method: "POST",
|
if (!list || list.length === 0) {
|
||||||
header: {
|
return;
|
||||||
Key: wx.getStorageSync("key")
|
|
||||||
},
|
|
||||||
success: async (resp: any) => {
|
|
||||||
const list = resp.data.data;
|
|
||||||
if (!list || list.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.setData({
|
|
||||||
list: list.map((item: any) => {
|
|
||||||
const extData = JSON.parse(item.ext);
|
|
||||||
return {
|
|
||||||
id: item.id,
|
|
||||||
type: extData.isImage ? ItemType.IMAGE : ItemType.VIDEO,
|
|
||||||
mongoId: item.mongoId,
|
|
||||||
thumbUrl: `${config.url}/attachment/read/${item.mongoId}`,
|
|
||||||
sourceMongoId: extData.sourceMongoId,
|
|
||||||
checked: false
|
|
||||||
} as Item;
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
this.setData({
|
||||||
|
list: list.map((item: any) => {
|
||||||
|
const metadata = (typeof item.metadata === "string" ? JSON.parse(item.metadata) : item.metadata) as PreviewImageMetadata;
|
||||||
|
const thumbURL = `${config.url}/attachment/read/${item.mongoId}`;
|
||||||
|
const sourceURL = `${config.url}/attachment/read/${metadata.sourceMongoId}`;
|
||||||
|
const isImage = metadata.sourceMimeType?.startsWith("image/");
|
||||||
|
return {
|
||||||
|
id: item.id,
|
||||||
|
type: isImage ? MediaItemType.IMAGE : MediaItemType.VIDEO,
|
||||||
|
thumbURL,
|
||||||
|
sourceURL,
|
||||||
|
checked: false
|
||||||
|
} as Item;
|
||||||
|
})
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("加载 moment 列表失败:", error);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
updateHasChecked() {
|
updateHasChecked() {
|
||||||
this.setData({ hasChecked: this.data.list.some(item => item.checked) });
|
this.setData({ hasChecked: this.data.list.some(item => item.checked) });
|
||||||
@ -176,8 +171,8 @@ Page({
|
|||||||
|
|
||||||
const sources = this.data.list.slice(startIndex, endIndex).map((item: Item) => {
|
const sources = this.data.list.slice(startIndex, endIndex).map((item: Item) => {
|
||||||
return {
|
return {
|
||||||
url: `${config.url}/attachment/read/${item.sourceMongoId}`,
|
url: item.sourceURL,
|
||||||
type: item.type === 0 ? "image" : "video"
|
type: item.type.toLowerCase()
|
||||||
}
|
}
|
||||||
}) as any;
|
}) as any;
|
||||||
wx.previewMedia({
|
wx.previewMedia({
|
||||||
@ -230,154 +225,66 @@ Page({
|
|||||||
} as MD5Result);
|
} as MD5Result);
|
||||||
}));
|
}));
|
||||||
// 查重
|
// 查重
|
||||||
const filterMD5Result: string[] = await new Promise((resolve, reject) => {
|
const filterMD5Result: string[] = await MomentApi.filterByMD5(
|
||||||
wx.request({
|
md5Results.map(item => item.md5)
|
||||||
url: `${config.url}/journal/moment/filter`,
|
);
|
||||||
method: "POST",
|
|
||||||
header: {
|
|
||||||
Key: wx.getStorageSync("key")
|
|
||||||
},
|
|
||||||
data: md5Results.map(item => item.md5),
|
|
||||||
success: async (resp: any) => {
|
|
||||||
resolve(resp.data.data);
|
|
||||||
},
|
|
||||||
fail: reject
|
|
||||||
});
|
|
||||||
});
|
|
||||||
// 过滤文件
|
// 过滤文件
|
||||||
const filterPath = md5Results.filter(item => filterMD5Result.indexOf(item.md5) !== -1)
|
const filterPath = md5Results.filter(item => filterMD5Result.indexOf(item.md5) !== -1)
|
||||||
.map(item => item.path);
|
.map(item => item.path);
|
||||||
files = files.filter(file => filterPath.indexOf(file.tempFilePath) !== -1);
|
files = files.filter(file => filterPath.indexOf(file.tempFilePath) !== -1);
|
||||||
if (files.length === 0) {
|
if (files.length === 0) {
|
||||||
wx.hideLoading();
|
wx.hideLoading();
|
||||||
|
that.setData({ isUploading: false });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wx.showLoading({
|
|
||||||
title: "正在上传..",
|
|
||||||
mask: true
|
|
||||||
})
|
|
||||||
// 计算上传大小
|
|
||||||
const sizePromises = files.map(file => {
|
|
||||||
return new Promise<number>((sizeResolve, sizeReject) => {
|
|
||||||
wx.getFileSystemManager().getFileInfo({
|
|
||||||
filePath: file.tempFilePath,
|
|
||||||
success: (res) => sizeResolve(res.size),
|
|
||||||
fail: (err) => sizeReject(err)
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
Promise.all(sizePromises).then(fileSizes => {
|
|
||||||
const totalSize = fileSizes.reduce((acc, size) => acc + size, 0);
|
|
||||||
const uploadTasks: WechatMiniprogram.UploadTask[] = [];
|
|
||||||
let uploadedSize = 0;
|
|
||||||
let lastUploadedSize = 0;
|
|
||||||
|
|
||||||
|
// 使用 Network.uploadFiles 上传文件
|
||||||
|
try {
|
||||||
|
const tempFileIds = await Network.uploadFiles({
|
||||||
|
mediaList: files.map(file => ({
|
||||||
|
path: file.tempFilePath,
|
||||||
|
size: file.size
|
||||||
|
})),
|
||||||
|
onProgress: (progress) => {
|
||||||
|
that.setData({
|
||||||
|
uploaded: IOSize.formatWithoutUnit(progress.uploaded, 2, Unit.MB),
|
||||||
|
uploadTotal: IOSize.format(progress.total, 2, Unit.MB),
|
||||||
|
uploadSpeed: `${IOSize.format(progress.speed)} / s`,
|
||||||
|
uploadProgress: progress.percent
|
||||||
|
});
|
||||||
|
},
|
||||||
|
showLoading: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// 上传完成转附件
|
||||||
|
const list = await MomentApi.create(tempFileIds);
|
||||||
|
wx.showToast({ title: "上传成功", icon: "success" });
|
||||||
|
const added = list.map((item: any) => {
|
||||||
|
const metadata = (typeof item.metadata === "string" ? JSON.parse(item.metadata) : item.metadata) as PreviewImageMetadata;
|
||||||
|
const thumbURL = `${config.url}/attachment/read/${item.mongoId}`;
|
||||||
|
const sourceURL = `${config.url}/attachment/read/${metadata.sourceMongoId}`;
|
||||||
|
const isImage = item.mimeType?.startsWith("image/");
|
||||||
|
return {
|
||||||
|
id: item.id,
|
||||||
|
type: isImage ? MediaItemType.IMAGE : MediaItemType.VIDEO,
|
||||||
|
thumbURL,
|
||||||
|
sourceURL,
|
||||||
|
checked: false
|
||||||
|
} as Item;
|
||||||
|
});
|
||||||
|
// 前插列表
|
||||||
|
that.data.list.unshift(...added);
|
||||||
that.setData({
|
that.setData({
|
||||||
uploadTotal: IOSize.format(totalSize, 2, Unit.MB)
|
list: that.data.list,
|
||||||
|
isUploading: false,
|
||||||
|
uploaded: "0",
|
||||||
|
uploadTotal: "0 MB",
|
||||||
|
uploadProgress: 0
|
||||||
});
|
});
|
||||||
|
that.updateHasChecked();
|
||||||
// 计算上传速度
|
} catch (error) {
|
||||||
const speedUpdateInterval = setInterval(() => {
|
handleFail(error);
|
||||||
const chunkSize = uploadedSize - lastUploadedSize;
|
}
|
||||||
that.setData({
|
|
||||||
uploadSpeed: `${IOSize.format(chunkSize)} / s`
|
|
||||||
});
|
|
||||||
lastUploadedSize = uploadedSize;
|
|
||||||
}, 1000);
|
|
||||||
// 上传文件
|
|
||||||
const uploadPromises = files.map(file => {
|
|
||||||
return new Promise<string>((uploadResolve, uploadReject) => {
|
|
||||||
const task = wx.uploadFile({
|
|
||||||
url: `${config.url}/temp/file/upload`,
|
|
||||||
filePath: file.tempFilePath,
|
|
||||||
name: "file",
|
|
||||||
success: (resp) => {
|
|
||||||
const result = JSON.parse(resp.data);
|
|
||||||
if (result && result.code === 20000) {
|
|
||||||
// 更新进度
|
|
||||||
const progress = totalSize > 0 ? uploadedSize / totalSize : 1;
|
|
||||||
that.setData({
|
|
||||||
uploadProgress: Math.round(progress * 10000) / 100
|
|
||||||
});
|
|
||||||
uploadResolve(result.data[0].id);
|
|
||||||
} else {
|
|
||||||
uploadReject(new Error(`文件上传失败: ${result?.message || "未知错误"}`));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: (err) => uploadReject(new Error(`文件上传失败: ${err.errMsg}`))
|
|
||||||
});
|
|
||||||
// 监听上传进度事件
|
|
||||||
let prevProgress = 0;
|
|
||||||
task.onProgressUpdate((res) => {
|
|
||||||
const fileUploaded = (res.totalBytesExpectedToSend * res.progress) / 100;
|
|
||||||
const delta = fileUploaded - prevProgress;
|
|
||||||
uploadedSize += delta;
|
|
||||||
// 保存当前进度
|
|
||||||
prevProgress = fileUploaded;
|
|
||||||
// 更新进度条
|
|
||||||
that.setData({
|
|
||||||
uploaded: IOSize.formatWithoutUnit(uploadedSize, 2, Unit.MB),
|
|
||||||
uploadProgress: Math.round((uploadedSize / totalSize) * 10000) / 100
|
|
||||||
});
|
|
||||||
});
|
|
||||||
uploadTasks.push(task);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
Promise.all(uploadPromises).then((tempFileIds) => {
|
|
||||||
wx.showLoading({
|
|
||||||
title: "正在保存..",
|
|
||||||
mask: true
|
|
||||||
})
|
|
||||||
// 清除定时器
|
|
||||||
clearInterval(speedUpdateInterval);
|
|
||||||
uploadTasks.forEach(task => task.offProgressUpdate());
|
|
||||||
that.setData({
|
|
||||||
uploadProgress: 100,
|
|
||||||
uploadSpeed: "0 MB / s"
|
|
||||||
});
|
|
||||||
// 上传完成转附件
|
|
||||||
wx.request({
|
|
||||||
url: `${config.url}/journal/moment/create`,
|
|
||||||
method: "POST",
|
|
||||||
header: {
|
|
||||||
Key: wx.getStorageSync("key")
|
|
||||||
},
|
|
||||||
data: tempFileIds,
|
|
||||||
success: async (resp: any) => {
|
|
||||||
wx.showToast({ title: "上传成功", icon: "success" });
|
|
||||||
const list = resp.data.data;
|
|
||||||
const added = list.map((item: any) => {
|
|
||||||
const extData = JSON.parse(item.ext);
|
|
||||||
return {
|
|
||||||
id: item.id,
|
|
||||||
type: extData.isImage ? ItemType.IMAGE : ItemType.VIDEO,
|
|
||||||
mongoId: item.mongoId,
|
|
||||||
thumbUrl: `${config.url}/attachment/read/${item.mongoId}`,
|
|
||||||
sourceMongoId: extData.sourceMongoId,
|
|
||||||
checked: false
|
|
||||||
} as Item;
|
|
||||||
});
|
|
||||||
// 前插列表
|
|
||||||
that.data.list.unshift(...added);
|
|
||||||
that.setData({
|
|
||||||
list: that.data.list,
|
|
||||||
isUploading: false,
|
|
||||||
uploaded: "0",
|
|
||||||
uploadTotal: "0 MB",
|
|
||||||
uploadProgress: 0
|
|
||||||
});
|
|
||||||
that.updateHasChecked();
|
|
||||||
wx.hideLoading();
|
|
||||||
},
|
|
||||||
fail: handleFail
|
|
||||||
});
|
|
||||||
}).catch((e: Error) => {
|
|
||||||
// 取消所有上传任务
|
|
||||||
uploadTasks.forEach(task => task.abort());
|
|
||||||
that.updateHasChecked();
|
|
||||||
handleFail(e);
|
|
||||||
});
|
|
||||||
}).catch(handleFail);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -453,27 +360,14 @@ Page({
|
|||||||
})
|
})
|
||||||
const openId = await new Promise<string>((resolve, reject) => {
|
const openId = await new Promise<string>((resolve, reject) => {
|
||||||
wx.login({
|
wx.login({
|
||||||
success: (res) => {
|
success: async (res) => {
|
||||||
if (res.code) {
|
if (res.code) {
|
||||||
wx.request({
|
try {
|
||||||
url: `${config.url}/journal/openid`,
|
const openId = await JournalApi.getOpenId(res.code);
|
||||||
method: "POST",
|
resolve(openId);
|
||||||
header: {
|
} catch (error) {
|
||||||
Key: wx.getStorageSync("key")
|
reject(new Error("获取 openId 失败"));
|
||||||
},
|
}
|
||||||
data: {
|
|
||||||
code: res.code
|
|
||||||
},
|
|
||||||
success: (resp) => {
|
|
||||||
const data = resp.data as any;
|
|
||||||
if (data.code === 20000) {
|
|
||||||
resolve(data.data);
|
|
||||||
} else {
|
|
||||||
reject(new Error("获取 openId 失败"));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: () => reject(new Error("获取 openId 请求失败"))
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
reject(new Error("获取登录凭证失败"));
|
reject(new Error("获取登录凭证失败"));
|
||||||
}
|
}
|
||||||
@ -494,36 +388,23 @@ Page({
|
|||||||
if (this.data.selectedJournalId) {
|
if (this.data.selectedJournalId) {
|
||||||
archiveData.id = this.data.selectedJournalId;
|
archiveData.id = this.data.selectedJournalId;
|
||||||
}
|
}
|
||||||
wx.request({
|
try {
|
||||||
url: `${config.url}/journal/moment/archive`,
|
await MomentApi.archive(archiveData);
|
||||||
method: "POST",
|
Events.emit("JOURNAL_REFRESH");
|
||||||
header: {
|
wx.showToast({ title: "归档成功", icon: "success" });
|
||||||
Key: wx.getStorageSync("key")
|
this.setData({
|
||||||
},
|
idea: "",
|
||||||
data: archiveData,
|
list: [],
|
||||||
success: async (resp: any) => {
|
hasChecked: false,
|
||||||
if (resp.data && resp.data.code === 20000) {
|
isArchiving: false,
|
||||||
Events.emit("JOURNAL_REFRESH");
|
selectedJournalId: undefined,
|
||||||
wx.showToast({ title: "归档成功", icon: "success" });
|
isVisibleArchivePopup: false
|
||||||
this.setData({
|
});
|
||||||
idea: "",
|
await Toolkit.sleep(1000);
|
||||||
list: [],
|
this.fetch();
|
||||||
hasChecked: false,
|
} catch (error) {
|
||||||
isArchiving: false,
|
handleFail();
|
||||||
selectedJournalId: undefined,
|
}
|
||||||
isVisibleArchivePopup: false
|
|
||||||
});
|
|
||||||
await Toolkit.sleep(1000);
|
|
||||||
this.fetch();
|
|
||||||
} else {
|
|
||||||
wx.showToast({ title: "归档失败", icon: "error" });
|
|
||||||
this.setData({
|
|
||||||
isArchiving: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: handleFail
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
allChecked() {
|
allChecked() {
|
||||||
this.data.list.forEach(item => item.checked = true);
|
this.data.list.forEach(item => item.checked = true);
|
||||||
@ -559,27 +440,21 @@ Page({
|
|||||||
confirmText: "删除已选",
|
confirmText: "删除已选",
|
||||||
confirmColor: "#E64340",
|
confirmColor: "#E64340",
|
||||||
cancelText: "取消",
|
cancelText: "取消",
|
||||||
success: res => {
|
success: async (res) => {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
const selected = this.data.list.filter(item => item.checked);
|
const selected = this.data.list.filter(item => item.checked);
|
||||||
wx.request({
|
try {
|
||||||
url: `${config.url}/journal/moment/delete`,
|
await MomentApi.delete(selected.map(item => item.id));
|
||||||
method: "POST",
|
wx.showToast({ title: "删除成功", icon: "success" });
|
||||||
header: {
|
const list = this.data.list.filter(item => !item.checked);
|
||||||
Key: wx.getStorageSync("key")
|
this.setData({
|
||||||
},
|
list
|
||||||
data: selected.map(item => item.id),
|
});
|
||||||
success: async (resp: any) => {
|
this.updateHasChecked();
|
||||||
if (resp.data && resp.data.code === 20000) {
|
} catch (error) {
|
||||||
wx.showToast({ title: "删除成功", icon: "success" });
|
console.error("删除 moment 失败:", error);
|
||||||
const list = this.data.list.filter(item => !item.checked);
|
wx.showToast({ title: "删除失败", icon: "error" });
|
||||||
this.setData({
|
}
|
||||||
list
|
|
||||||
});
|
|
||||||
this.updateHasChecked();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -63,8 +63,8 @@
|
|||||||
<view class="items">
|
<view class="items">
|
||||||
<view class="item" wx:for="{{list}}" wx:key="mongoId">
|
<view class="item" wx:for="{{list}}" wx:key="mongoId">
|
||||||
<image
|
<image
|
||||||
class="thumbnail {{item.type === 0 ? 'image' : 'video'}}"
|
class="thumbnail {{item.type}}"
|
||||||
src="{{item.thumbUrl}}"
|
src="{{item.thumbURL}}"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
bind:tap="preview"
|
bind:tap="preview"
|
||||||
data-index="{{index}}"
|
data-index="{{index}}"
|
||||||
|
|||||||
@ -5,9 +5,10 @@ import config from "../../../config/index"
|
|||||||
import Events from "../../../utils/Events";
|
import Events from "../../../utils/Events";
|
||||||
import Toolkit from "../../../utils/Toolkit";
|
import Toolkit from "../../../utils/Toolkit";
|
||||||
import { Journal, JournalPage, JournalPageType } from "../../../types/Journal";
|
import { Journal, JournalPage, JournalPageType } from "../../../types/Journal";
|
||||||
import { OrderType, QueryPageResult } from "../../../types/Model";
|
import { OrderType, } from "../../../types/Model";
|
||||||
import { ImageMetadata, MediaAttachExt } from "../../../types/Attachment";
|
import { PreviewImageMetadata } from "../../../types/Attachment";
|
||||||
import { MediaItem, MediaItemType } from "../../../types/UI";
|
import { MediaItem, MediaItemType } from "../../../types/UI";
|
||||||
|
import { JournalApi } from "../../../api/JournalApi";
|
||||||
|
|
||||||
interface IPortfolioData {
|
interface IPortfolioData {
|
||||||
page: JournalPage;
|
page: JournalPage;
|
||||||
@ -72,79 +73,71 @@ Page({
|
|||||||
this.setData({ stickyOffset: height });
|
this.setData({ stickyOffset: height });
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
fetch() {
|
async fetch() {
|
||||||
if (this.data.isFetching || this.data.isFinished) {
|
if (this.data.isFetching || this.data.isFinished) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.setData({
|
this.setData({
|
||||||
isFetching: true
|
isFetching: true
|
||||||
});
|
});
|
||||||
wx.request({
|
try {
|
||||||
url: `${config.url}/journal/list`,
|
const pageResult = await JournalApi.getList(this.data.page);
|
||||||
method: "POST",
|
const list = pageResult.list;
|
||||||
header: {
|
if (!list || list.length === 0) {
|
||||||
Key: wx.getStorageSync("key")
|
|
||||||
},
|
|
||||||
data: this.data.page,
|
|
||||||
success: async (resp: any) => {
|
|
||||||
const pageResult = resp.data.data as QueryPageResult<Journal>;
|
|
||||||
const list = pageResult.list;
|
|
||||||
if (!list || list.length === 0) {
|
|
||||||
this.setData({
|
|
||||||
isFinished: true
|
|
||||||
})
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
list.forEach(journal => {
|
|
||||||
const mediaItems = journal.items!.filter((item) => item.attachType === "THUMB").map((thumbItem, index) => {
|
|
||||||
const metadata = thumbItem.metadata as ImageMetadata;
|
|
||||||
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,
|
|
||||||
width: metadata.width,
|
|
||||||
height: metadata.height,
|
|
||||||
originalIndex: index
|
|
||||||
} as MediaItem;
|
|
||||||
});
|
|
||||||
journal.date = Time.toDate(journal.createdAt);
|
|
||||||
journal.time = Time.toTime(journal.createdAt);
|
|
||||||
journal.datetime = Time.toPassedDateTime(journal.createdAt);
|
|
||||||
journal.mediaItems = mediaItems;
|
|
||||||
journal.columnedItems = Toolkit.splitItemsIntoColumns(mediaItems, 3, (item) => {
|
|
||||||
if (item.width && item.height && 0 < item.width) {
|
|
||||||
return item.height / item.width;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
})
|
|
||||||
this.setData({
|
|
||||||
page: {
|
|
||||||
index: this.data.page.index + 1,
|
|
||||||
size: 8,
|
|
||||||
type: JournalPageType.NORMAL,
|
|
||||||
equalsExample: {
|
|
||||||
type: "PORTFOLIO"
|
|
||||||
},
|
|
||||||
orderMap: {
|
|
||||||
createdAt: OrderType.DESC
|
|
||||||
}
|
|
||||||
},
|
|
||||||
list: this.data.list.concat(list),
|
|
||||||
isFinished: list.length < this.data.page.size
|
|
||||||
});
|
|
||||||
},
|
|
||||||
complete: () => {
|
|
||||||
this.setData({
|
this.setData({
|
||||||
|
isFinished: true,
|
||||||
isFetching: false
|
isFetching: false
|
||||||
});
|
})
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
});
|
list.forEach(journal => {
|
||||||
|
const mediaItems = journal.items!.filter((item) => item.attachType === "THUMB").map((thumbItem, index) => {
|
||||||
|
const metadata = (typeof thumbItem.metadata === "string" ? JSON.parse(thumbItem.metadata) : thumbItem.metadata) as PreviewImageMetadata;
|
||||||
|
const thumbURL = `${config.url}/attachment/read/${thumbItem.mongoId}`;
|
||||||
|
const sourceURL = `${config.url}/attachment/read/${metadata.sourceMongoId}`;
|
||||||
|
const isVideo = metadata.sourceMimeType?.startsWith("video/");
|
||||||
|
return {
|
||||||
|
type: isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
|
||||||
|
thumbURL,
|
||||||
|
sourceURL,
|
||||||
|
size: thumbItem.size || 0,
|
||||||
|
attachmentId: thumbItem.id,
|
||||||
|
width: metadata.width,
|
||||||
|
height: metadata.height,
|
||||||
|
originalIndex: index
|
||||||
|
} as MediaItem;
|
||||||
|
});
|
||||||
|
journal.date = Time.toDate(journal.createdAt);
|
||||||
|
journal.time = Time.toTime(journal.createdAt);
|
||||||
|
journal.datetime = Time.toPassedDateTime(journal.createdAt);
|
||||||
|
journal.mediaItems = mediaItems;
|
||||||
|
journal.columnedItems = Toolkit.splitItemsIntoColumns(mediaItems, 3, (item) => {
|
||||||
|
if (item.width && item.height && 0 < item.width) {
|
||||||
|
return item.height / item.width;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
})
|
||||||
|
this.setData({
|
||||||
|
page: {
|
||||||
|
index: this.data.page.index + 1,
|
||||||
|
size: 8,
|
||||||
|
type: JournalPageType.NORMAL,
|
||||||
|
equalsExample: {
|
||||||
|
type: "PORTFOLIO"
|
||||||
|
},
|
||||||
|
orderMap: {
|
||||||
|
createdAt: OrderType.DESC
|
||||||
|
}
|
||||||
|
},
|
||||||
|
list: this.data.list.concat(list),
|
||||||
|
isFinished: list.length < this.data.page.size,
|
||||||
|
isFetching: false
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("加载 portfolio 列表失败:", error);
|
||||||
|
this.setData({ isFetching: false });
|
||||||
|
}
|
||||||
},
|
},
|
||||||
preview(e: WechatMiniprogram.BaseEvent) {
|
preview(e: WechatMiniprogram.BaseEvent) {
|
||||||
const { journalIndex, itemIndex } = e.currentTarget.dataset;
|
const { journalIndex, itemIndex } = e.currentTarget.dataset;
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
<view wx:for="{{journal.columnedItems}}" wx:for-item="column" wx:for-index="columnIndex" wx:key="columnIndex" class="column">
|
<view wx:for="{{journal.columnedItems}}" wx:for-item="column" wx:for-index="columnIndex" wx:key="columnIndex" class="column">
|
||||||
<block wx:for="{{column}}" wx:for-item="item" wx:for-index="itemIndex" wx:key="attachmentId">
|
<block wx:for="{{column}}" wx:for-item="item" wx:for-index="itemIndex" wx:key="attachmentId">
|
||||||
<image
|
<image
|
||||||
class="item thumbnail {{item.type === 0 ? 'image' : 'video'}}"
|
class="item thumbnail {{item.type.toLowerCase()}}"
|
||||||
src="{{item.thumbURL}}"
|
src="{{item.thumbURL}}"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
bindtap="preview"
|
bindtap="preview"
|
||||||
|
|||||||
@ -2,12 +2,14 @@
|
|||||||
"component": true,
|
"component": true,
|
||||||
"usingComponents": {
|
"usingComponents": {
|
||||||
"t-tag": "tdesign-miniprogram/tag/tag",
|
"t-tag": "tdesign-miniprogram/tag/tag",
|
||||||
|
"t-cell": "tdesign-miniprogram/cell/cell",
|
||||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||||
"t-input": "tdesign-miniprogram/input/input",
|
"t-input": "tdesign-miniprogram/input/input",
|
||||||
"t-button": "tdesign-miniprogram/button/button",
|
"t-button": "tdesign-miniprogram/button/button",
|
||||||
"t-dialog": "tdesign-miniprogram/dialog/dialog",
|
"t-dialog": "tdesign-miniprogram/dialog/dialog",
|
||||||
"t-navbar": "tdesign-miniprogram/navbar/navbar",
|
"t-navbar": "tdesign-miniprogram/navbar/navbar",
|
||||||
"t-loading": "tdesign-miniprogram/loading/loading"
|
"t-loading": "tdesign-miniprogram/loading/loading",
|
||||||
|
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group"
|
||||||
},
|
},
|
||||||
"styleIsolation": "shared"
|
"styleIsolation": "shared"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,308 +1,149 @@
|
|||||||
// pages/main/travel-detail/index.less
|
// pages/main/travel-detail/index.less
|
||||||
|
|
||||||
.detail-container {
|
.travel-detail {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
min-height: 100vh;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
background: var(--theme-bg-page);
|
background: var(--theme-bg-page);
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
gap: 24rpx;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
padding-top: 48rpx;
|
padding-top: 48rpx;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
.status-section {
|
.section {
|
||||||
display: flex;
|
margin-top: 32rpx;
|
||||||
padding: 16rpx 0;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.title-section {
|
> .title {
|
||||||
padding: 24rpx;
|
color: var(--theme-text-secondary);
|
||||||
text-align: center;
|
padding: 0 32rpx;
|
||||||
background: var(--theme-bg-card);
|
font-size: 28rpx;
|
||||||
box-shadow: 0 2px 12px var(--theme-shadow-light);
|
line-height: 64rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.title {
|
&.status {
|
||||||
|
display: flex;
|
||||||
|
margin-top: 24rpx;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.title {
|
||||||
color: var(--theme-text-primary);
|
color: var(--theme-text-primary);
|
||||||
|
padding: 24rpx;
|
||||||
font-size: 40rpx;
|
font-size: 40rpx;
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 24rpx;
|
||||||
|
background: var(--theme-bg-card);
|
||||||
|
box-shadow: 0 2px 12px var(--theme-shadow-light);
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.info-card,
|
&.locations {
|
||||||
.content-card,
|
|
||||||
.locations-card {
|
|
||||||
overflow: hidden;
|
|
||||||
background: var(--theme-bg-card);
|
|
||||||
box-shadow: 0 2px 12px var(--theme-shadow-light);
|
|
||||||
|
|
||||||
.card-title {
|
.header {
|
||||||
display: flex;
|
padding: 16rpx 32rpx;
|
||||||
padding: 24rpx;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
border-bottom: 1px solid var(--theme-border-light);
|
|
||||||
|
|
||||||
.title-left {
|
.left-actions {
|
||||||
gap: 12rpx;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
.icon {
|
|
||||||
color: var(--theme-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.text {
|
|
||||||
color: var(--theme-text-primary);
|
|
||||||
font-size: 32rpx;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.title-right {
|
|
||||||
gap: 16rpx;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
.icon-btn {
|
|
||||||
display: flex;
|
|
||||||
padding: 8rpx;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
transition: all .2s;
|
|
||||||
|
|
||||||
&:active {
|
|
||||||
transform: scale(1.1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.info-list {
|
|
||||||
padding: 24rpx;
|
|
||||||
|
|
||||||
.info-item {
|
|
||||||
display: flex;
|
|
||||||
padding: 20rpx 0;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
border-bottom: 1px solid var(--theme-border-light);
|
|
||||||
|
|
||||||
&:last-child {
|
|
||||||
border-bottom: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.label {
|
|
||||||
gap: 12rpx;
|
|
||||||
flex: 1;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
.icon {
|
|
||||||
color: var(--theme-text-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.text {
|
|
||||||
color: var(--theme-text-secondary);
|
|
||||||
font-size: 28rpx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.value {
|
|
||||||
color: var(--theme-text-primary);
|
|
||||||
font-size: 28rpx;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.content-text {
|
|
||||||
color: var(--theme-text-primary);
|
|
||||||
padding: 24rpx;
|
|
||||||
font-size: 28rpx;
|
|
||||||
line-height: 1.8;
|
|
||||||
white-space: pre-wrap;
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
|
||||||
|
|
||||||
.loading-container {
|
|
||||||
display: flex;
|
|
||||||
padding: 48rpx;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.locations-list {
|
|
||||||
padding: 24rpx;
|
|
||||||
|
|
||||||
.location-item {
|
|
||||||
gap: 24rpx;
|
|
||||||
display: flex;
|
|
||||||
padding: 24rpx;
|
|
||||||
margin-bottom: 20rpx;
|
|
||||||
border-radius: 12rpx;
|
|
||||||
background: var(--theme-bg-page);
|
|
||||||
border: 1px solid var(--theme-border-light);
|
|
||||||
transition: all .3s;
|
|
||||||
|
|
||||||
&:last-child {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:active {
|
|
||||||
transform: scale(.98);
|
|
||||||
background: var(--theme-bg-card);
|
|
||||||
}
|
|
||||||
|
|
||||||
.location-icon {
|
|
||||||
display: flex;
|
|
||||||
flex-shrink: 0;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.location-content {
|
|
||||||
gap: 16rpx;
|
gap: 16rpx;
|
||||||
flex: 1;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
overflow: hidden;
|
align-items: center;
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
.location-header {
|
.type-picker {
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
|
|
||||||
.location-title {
|
.picker-button {
|
||||||
flex: 1;
|
gap: 8rpx;
|
||||||
color: var(--theme-text-primary);
|
color: var(--theme-wx);
|
||||||
overflow: hidden;
|
border: 1px solid var(--theme-wx);
|
||||||
font-size: 30rpx;
|
display: flex;
|
||||||
font-weight: bold;
|
padding: 14rpx 24rpx 14rpx 32rpx;
|
||||||
text-overflow: ellipsis;
|
font-size: 26rpx;
|
||||||
white-space: nowrap;
|
background: var(--theme-bg-card);
|
||||||
|
align-items: center;
|
||||||
|
border-radius: 16rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.location-description {
|
.location {
|
||||||
color: var(--theme-text-secondary);
|
.thumb {
|
||||||
font-size: 26rpx;
|
width: 96rpx;
|
||||||
line-height: 1.6;
|
height: 96rpx;
|
||||||
word-break: break-all;
|
border: 1px solid var(--theme-border-light);
|
||||||
}
|
overflow: hidden;
|
||||||
|
background: var(--theme-bg-page);
|
||||||
|
flex-shrink: 0;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.location-info {
|
.thumb-img {
|
||||||
gap: 24rpx;
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.thumb-placeholder {
|
||||||
|
color: var(--theme-text-secondary);
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
font-size: 24rpx;
|
||||||
|
background: var(--theme-bg-page);
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.note {
|
||||||
|
width: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.description {
|
||||||
|
column-gap: 24rpx;
|
||||||
|
color: var(--theme-text-secondary);
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
font-size: 26rpx;
|
||||||
|
|
||||||
|
.item {
|
||||||
|
gap: 12rpx;
|
||||||
|
width: fit-content;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
padding: 2rpx 4rpx;
|
||||||
|
align-items: center;
|
||||||
|
background: var(--theme-bg-page);
|
||||||
|
|
||||||
.info-item {
|
.stars {
|
||||||
gap: 8rpx;
|
gap: 8rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
|
||||||
color: var(--theme-text-secondary);
|
|
||||||
font-size: 24rpx;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.location-arrow {
|
|
||||||
display: flex;
|
|
||||||
flex-shrink: 0;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-state {
|
&.action {
|
||||||
gap: 16rpx;
|
gap: 24rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 64rpx 24rpx;
|
padding: 24rpx 16rpx 128rpx 16rpx;
|
||||||
align-items: center;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
|
|
||||||
.empty-text {
|
.edit {
|
||||||
color: var(--theme-text-secondary);
|
flex: 2;
|
||||||
font-size: 26rpx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.time-card {
|
|
||||||
gap: 16rpx;
|
|
||||||
display: flex;
|
|
||||||
padding: 24rpx;
|
|
||||||
flex-direction: column;
|
|
||||||
background: var(--theme-bg-card);
|
|
||||||
box-shadow: 0 2px 12px var(--theme-shadow-light);
|
|
||||||
|
|
||||||
.time-item {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
|
|
||||||
.label {
|
|
||||||
color: var(--theme-text-secondary);
|
|
||||||
font-size: 24rpx;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.value {
|
.delete {
|
||||||
color: var(--theme-text-secondary);
|
flex: 1;
|
||||||
font-size: 24rpx;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-section {
|
|
||||||
gap: 24rpx;
|
|
||||||
display: flex;
|
|
||||||
padding: 24rpx 16rpx 48rpx 16rpx;
|
|
||||||
|
|
||||||
.edit-btn {
|
|
||||||
flex: 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.delete-btn {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.delete-dialog-content {
|
.delete-dialog {
|
||||||
gap: 32rpx;
|
padding: 16rpx 0;
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
.delete-warning {
|
.tips {
|
||||||
gap: 16rpx;
|
color: var(--theme-text-secondary);
|
||||||
display: flex;
|
font-size: 28rpx;
|
||||||
padding: 24rpx;
|
line-height: 1.5;
|
||||||
align-items: center;
|
margin-bottom: 24rpx;
|
||||||
border-radius: 12rpx;
|
|
||||||
flex-direction: column;
|
|
||||||
background: #FFF4F4;
|
|
||||||
|
|
||||||
.warning-text {
|
|
||||||
color: #E34D59;
|
|
||||||
font-size: 28rpx;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.delete-confirm {
|
|
||||||
gap: 16rpx;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
.confirm-label {
|
|
||||||
color: var(--theme-text-primary);
|
|
||||||
font-size: 28rpx;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,17 +3,23 @@
|
|||||||
import Time from "../../../utils/Time";
|
import Time from "../../../utils/Time";
|
||||||
import { TravelApi } from "../../../api/TravelApi";
|
import { TravelApi } from "../../../api/TravelApi";
|
||||||
import { TravelLocationApi } from "../../../api/TravelLocationApi";
|
import { TravelLocationApi } from "../../../api/TravelLocationApi";
|
||||||
import { Travel, TravelStatusLabel, TravelStatusIcon, TransportationTypeLabel, TravelLocation, TravelLocationTypeLabel, TravelLocationTypeIcon } from "../../../types/Travel";
|
import config from "../../../config/index";
|
||||||
|
import { Travel, TravelStatusLabel, TravelStatusIcon, TransportationTypeLabel, TravelLocation, TravelLocationTypeLabel, TravelLocationTypeIcon, TransportationTypeIcon, TravelLocationType } from "../../../types/Travel";
|
||||||
|
|
||||||
|
interface TravelLocationView extends TravelLocation {
|
||||||
|
/** 预览图 */
|
||||||
|
previewThumb?: string;
|
||||||
|
}
|
||||||
|
|
||||||
interface TravelDetailData {
|
interface TravelDetailData {
|
||||||
/** 旅行详情 */
|
/** 出行详情 */
|
||||||
travel: Travel | null;
|
travel: Travel | null;
|
||||||
/** 旅行 ID */
|
/** 出行 ID */
|
||||||
travelId: string;
|
travelId: string;
|
||||||
/** 是否正在加载 */
|
/** 是否正在加载 */
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
/** 地点列表 */
|
/** 地点列表 */
|
||||||
locations: TravelLocation[];
|
locations: TravelLocationView[];
|
||||||
/** 是否正在加载地点 */
|
/** 是否正在加载地点 */
|
||||||
isLoadingLocations: boolean;
|
isLoadingLocations: boolean;
|
||||||
/** 状态标签映射 */
|
/** 状态标签映射 */
|
||||||
@ -22,10 +28,16 @@ interface TravelDetailData {
|
|||||||
statusIcons: typeof TravelStatusIcon;
|
statusIcons: typeof TravelStatusIcon;
|
||||||
/** 交通类型标签映射 */
|
/** 交通类型标签映射 */
|
||||||
transportLabels: typeof TransportationTypeLabel;
|
transportLabels: typeof TransportationTypeLabel;
|
||||||
|
/** 交通类型图标映射 */
|
||||||
|
transportIcons: typeof TransportationTypeIcon;
|
||||||
/** 地点类型标签映射 */
|
/** 地点类型标签映射 */
|
||||||
locationTypeLabels: typeof TravelLocationTypeLabel;
|
locationTypeLabels: typeof TravelLocationTypeLabel;
|
||||||
/** 地点类型图标映射 */
|
/** 地点类型图标映射 */
|
||||||
locationTypeIcons: typeof TravelLocationTypeIcon;
|
locationTypeIcons: typeof TravelLocationTypeIcon;
|
||||||
|
/** 地点类型选项 */
|
||||||
|
locationTypes: string[];
|
||||||
|
/** 选中的地点类型索引 */
|
||||||
|
selectedLocationTypeIndex: number;
|
||||||
/** 删除对话框可见性 */
|
/** 删除对话框可见性 */
|
||||||
deleteDialogVisible: boolean;
|
deleteDialogVisible: boolean;
|
||||||
/** 删除确认文本 */
|
/** 删除确认文本 */
|
||||||
@ -42,8 +54,11 @@ Page({
|
|||||||
statusLabels: TravelStatusLabel,
|
statusLabels: TravelStatusLabel,
|
||||||
statusIcons: TravelStatusIcon,
|
statusIcons: TravelStatusIcon,
|
||||||
transportLabels: TransportationTypeLabel,
|
transportLabels: TransportationTypeLabel,
|
||||||
|
transportIcons: TransportationTypeIcon,
|
||||||
locationTypeLabels: TravelLocationTypeLabel,
|
locationTypeLabels: TravelLocationTypeLabel,
|
||||||
locationTypeIcons: TravelLocationTypeIcon,
|
locationTypeIcons: TravelLocationTypeIcon,
|
||||||
|
locationTypes: ["全部", ...Object.values(TravelLocationTypeLabel)],
|
||||||
|
selectedLocationTypeIndex: 0,
|
||||||
deleteDialogVisible: false,
|
deleteDialogVisible: false,
|
||||||
deleteConfirmText: ""
|
deleteConfirmText: ""
|
||||||
},
|
},
|
||||||
@ -71,7 +86,7 @@ Page({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/** 获取旅行详情 */
|
/** 获取出行详情 */
|
||||||
async fetchDetail(id: string) {
|
async fetchDetail(id: string) {
|
||||||
this.setData({ isLoading: true });
|
this.setData({ isLoading: true });
|
||||||
|
|
||||||
@ -83,21 +98,12 @@ Page({
|
|||||||
travel.travelDate = Time.toDate(travel.travelAt);
|
travel.travelDate = Time.toDate(travel.travelAt);
|
||||||
travel.travelTime = Time.toTime(travel.travelAt);
|
travel.travelTime = Time.toTime(travel.travelAt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 格式化创建和更新时间
|
|
||||||
if (travel.createdAt) {
|
|
||||||
(travel as any).createdAtFormatted = Time.toDateTime(travel.createdAt);
|
|
||||||
}
|
|
||||||
if (travel.updatedAt) {
|
|
||||||
(travel as any).updatedAtFormatted = Time.toDateTime(travel.updatedAt);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setData({ travel });
|
this.setData({ travel });
|
||||||
|
|
||||||
// 获取地点列表
|
// 获取地点列表
|
||||||
this.fetchLocations(id);
|
this.fetchLocations(id);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取旅行详情失败:", error);
|
console.error("获取出行详情失败:", error);
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
title: "加载失败",
|
title: "加载失败",
|
||||||
icon: "error"
|
icon: "error"
|
||||||
@ -115,15 +121,39 @@ Page({
|
|||||||
this.setData({ isLoadingLocations: true });
|
this.setData({ isLoadingLocations: true });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const { selectedLocationTypeIndex, locationTypes } = this.data;
|
||||||
|
|
||||||
|
// 构建查询条件
|
||||||
|
const equalsExample: { [key: string]: number | string } = {
|
||||||
|
travelId: Number(travelId)
|
||||||
|
};
|
||||||
|
|
||||||
|
// 添加类型过滤(索引 0 表示"全部")
|
||||||
|
if (0 < selectedLocationTypeIndex) {
|
||||||
|
const selectedTypeLabel = locationTypes[selectedLocationTypeIndex];
|
||||||
|
const selectedType = Object.keys(TravelLocationTypeLabel).find(
|
||||||
|
key => TravelLocationTypeLabel[key as TravelLocationType] === selectedTypeLabel
|
||||||
|
) as TravelLocationType | undefined;
|
||||||
|
|
||||||
|
if (selectedType) {
|
||||||
|
equalsExample.type = selectedType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const result = await TravelLocationApi.getList({
|
const result = await TravelLocationApi.getList({
|
||||||
index: 0,
|
index: 0,
|
||||||
size: 100,
|
size: 999,
|
||||||
equalsExample: {
|
equalsExample
|
||||||
travelId: Number(travelId)
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.setData({ locations: result.list });
|
const locations = result.list.map((location) => {
|
||||||
|
const previewItem = location.items && 0 < location.items.length ? location.items[0] : undefined;
|
||||||
|
return {
|
||||||
|
...location,
|
||||||
|
previewThumb: previewItem ? `${config.url}/attachment/read/${previewItem.mongoId}` : undefined
|
||||||
|
};
|
||||||
|
});
|
||||||
|
this.setData({ locations });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取地点列表失败:", error);
|
console.error("获取地点列表失败:", error);
|
||||||
} finally {
|
} finally {
|
||||||
@ -131,7 +161,15 @@ Page({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/** 编辑旅行 */
|
/** 地点类型改变 */
|
||||||
|
onLocationTypeChange(e: WechatMiniprogram.PickerChange) {
|
||||||
|
const index = Number(e.detail.value);
|
||||||
|
this.setData({ selectedLocationTypeIndex: index });
|
||||||
|
// 重新从接口获取过滤后的数据
|
||||||
|
this.fetchLocations(this.data.travelId);
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 编辑出行 */
|
||||||
toEdit() {
|
toEdit() {
|
||||||
const { travel } = this.data;
|
const { travel } = this.data;
|
||||||
if (travel && travel.id) {
|
if (travel && travel.id) {
|
||||||
@ -151,13 +189,13 @@ Page({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/** 编辑地点 */
|
/** 查看地点详情 */
|
||||||
toEditLocation(e: WechatMiniprogram.BaseEvent) {
|
toLocationDetail(e: WechatMiniprogram.BaseEvent) {
|
||||||
const { id } = e.currentTarget.dataset;
|
const { id } = e.currentTarget.dataset;
|
||||||
const { travel } = this.data;
|
const { travel } = this.data;
|
||||||
if (id && travel && travel.id) {
|
if (id && travel && travel.id) {
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: `/pages/main/travel-location-editor/index?id=${id}&travelId=${travel.id}`
|
url: `/pages/main/travel-location-detail/index?id=${id}&travelId=${travel.id}`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -172,7 +210,7 @@ Page({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/** 删除旅行 */
|
/** 删除出行 */
|
||||||
deleteTravel() {
|
deleteTravel() {
|
||||||
this.setData({
|
this.setData({
|
||||||
deleteDialogVisible: true,
|
deleteDialogVisible: true,
|
||||||
|
|||||||
@ -1,170 +1,127 @@
|
|||||||
<!--pages/main/travel-detail/index.wxml-->
|
<!--pages/main/travel-detail/index.wxml-->
|
||||||
<view class="custom-navbar">
|
<view class="custom-navbar">
|
||||||
<t-navbar title="旅行详情" leftArrow bind:go-back="goBack">
|
<t-navbar title="出行详情" leftArrow bind:go-back="goBack">
|
||||||
<view slot="right" class="edit-btn" bind:tap="toEdit">
|
<view slot="right" class="edit-btn" bind:tap="toEdit">
|
||||||
<t-icon name="edit" size="24px" />
|
<t-icon name="edit" size="24px" />
|
||||||
</view>
|
</view>
|
||||||
</t-navbar>
|
</t-navbar>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="detail-container">
|
<view class="travel-detail setting-bg">
|
||||||
<!-- 加载状态 -->
|
<!-- 加载状态 -->
|
||||||
<t-loading wx:if="{{isLoading}}" theme="dots" size="40rpx" />
|
<t-loading wx:if="{{isLoading}}" theme="dots" size="40rpx" />
|
||||||
|
|
||||||
<!-- 详情内容 -->
|
<!-- 详情内容 -->
|
||||||
<view wx:if="{{!isLoading && travel}}" class="content">
|
<view wx:if="{{!isLoading && travel}}" class="content">
|
||||||
<!-- 状态标签 -->
|
<!-- 状态标签 -->
|
||||||
<view class="status-section">
|
<view class="section status">
|
||||||
<t-tag
|
<t-tag
|
||||||
size="large"
|
size="large"
|
||||||
theme="{{travel.status === 'PLANNING' ? 'default' : travel.status === 'ONGOING' ? 'warning' : 'success'}}"
|
theme="{{travel.status === 'PLANNING' ? 'default' : travel.status === 'ONGOING' ? 'warning' : 'success'}}"
|
||||||
variant="light"
|
variant="outline"
|
||||||
icon="{{statusIcons[travel.status]}}"
|
icon="{{statusIcons[travel.status]}}"
|
||||||
>
|
>
|
||||||
{{statusLabels[travel.status]}}
|
{{statusLabels[travel.status]}}
|
||||||
</t-tag>
|
</t-tag>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 标题 -->
|
<!-- 标题 -->
|
||||||
<view class="title-section">
|
<view class="section title">{{travel.title || '未命名出行'}}</view>
|
||||||
<text class="title">{{travel.title || '未命名旅行'}}</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 基本信息 -->
|
<!-- 基本信息 -->
|
||||||
<view class="info-card">
|
<t-cell-group class="section info">
|
||||||
<view class="card-title">
|
<view slot="title" class="title">基本信息</view>
|
||||||
<t-icon name="info-circle" size="20px" class="icon" />
|
<t-cell left-icon="time" title="出行时间">
|
||||||
<text class="text">基本信息</text>
|
<view slot="note">
|
||||||
</view>
|
<text wx:if="{{travel.travelDate}}">{{travel.travelDate}} {{travel.travelTime}}</text>
|
||||||
|
<text wx:else class="undecided-value">未定</text>
|
||||||
<view class="info-list">
|
|
||||||
<view class="info-item">
|
|
||||||
<view class="label">
|
|
||||||
<t-icon name="time" size="18px" class="icon" />
|
|
||||||
<text class="text">出行时间</text>
|
|
||||||
</view>
|
|
||||||
<view class="value">{{travel.travelDate}} {{travel.travelTime}}</view>
|
|
||||||
</view>
|
</view>
|
||||||
|
</t-cell>
|
||||||
<view wx:if="{{travel.days}}" class="info-item">
|
<t-cell left-icon="calendar" title="出行天数">
|
||||||
<view class="label">
|
<view slot="note">
|
||||||
<t-icon name="calendar" size="18px" class="icon" />
|
<text wx:if="{{travel.days}}">{{travel.days}} 天</text>
|
||||||
<text class="text">旅行天数</text>
|
<text wx:else class="undecided-value">未定</text>
|
||||||
</view>
|
|
||||||
<view class="value">{{travel.days}} 天</view>
|
|
||||||
</view>
|
</view>
|
||||||
|
</t-cell>
|
||||||
<view wx:if="{{travel.transportationType}}" class="info-item">
|
<t-cell left-icon="{{transportIcons[travel.transportationType]}}" title="交通方式">
|
||||||
<view class="label">
|
<view slot="note">{{transportLabels[travel.transportationType]}}</view>
|
||||||
<t-icon name="{{travel.transportationType === 'PLANE' ? 'flight-takeoff' : travel.transportationType === 'TRAIN' ? 'map-route' : travel.transportationType === 'SELF_DRIVING' ? 'control-platform' : 'location'}}" size="18px" class="icon" />
|
</t-cell>
|
||||||
<text class="text">交通方式</text>
|
</t-cell-group>
|
||||||
</view>
|
<!-- 出行内容 -->
|
||||||
<view class="value">{{transportLabels[travel.transportationType]}}</view>
|
<t-cell-group wx:if="{{travel.content}}" class="section">
|
||||||
|
<view slot="title" class="title">详细说明</view>
|
||||||
|
<t-cell title="{{travel.content}}" />
|
||||||
|
</t-cell-group>
|
||||||
|
<t-cell-group class="section locations">
|
||||||
|
<view slot="title" class="title">地点列表</view>
|
||||||
|
<t-cell class="header">
|
||||||
|
<view slot="left-icon" class="left-actions">
|
||||||
|
<t-button theme="primary" icon="map" size="small" bind:tap="toMap">地图浏览</t-button>
|
||||||
|
<picker class="type-picker" mode="selector" range="{{locationTypes}}" value="{{selectedLocationTypeIndex}}" bind:change="onLocationTypeChange">
|
||||||
|
<view class="picker-button">
|
||||||
|
<text>{{locationTypes[selectedLocationTypeIndex]}}</text>
|
||||||
|
<t-icon class="icon" name="chevron-down" size="16px" />
|
||||||
|
</view>
|
||||||
|
</picker>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
<t-icon slot="right-icon" name="add" size="20px" color="var(--theme-wx)" bind:tap="toAddLocation" />
|
||||||
</view>
|
</t-cell>
|
||||||
|
<t-cell wx:if="{{isLoadingLocations}}" class="loading">
|
||||||
<!-- 旅行内容 -->
|
<t-loading slot="title" theme="dots" size="40rpx" />
|
||||||
<view wx:if="{{travel.content}}" class="content-card">
|
</t-cell>
|
||||||
<view class="card-title">
|
<block wx:elif="{{0 < locations.length}}">
|
||||||
<t-icon name="edit" size="20px" class="icon" />
|
<t-cell
|
||||||
<text class="text">详细说明</text>
|
class="location"
|
||||||
</view>
|
|
||||||
<view class="content-text">{{travel.content}}</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 地点列表 -->
|
|
||||||
<view class="locations-card">
|
|
||||||
<view class="card-title">
|
|
||||||
<view class="title-left">
|
|
||||||
<t-icon name="location" size="20px" class="icon" />
|
|
||||||
<text class="text">地点列表</text>
|
|
||||||
</view>
|
|
||||||
<view class="title-right">
|
|
||||||
<view class="icon-btn" catch:tap="toMap">
|
|
||||||
<t-icon name="map" size="20px" color="#5E7CE0" />
|
|
||||||
</view>
|
|
||||||
<view class="icon-btn" catch:tap="toAddLocation">
|
|
||||||
<t-icon name="add" size="20px" color="#5E7CE0" />
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 加载中 -->
|
|
||||||
<view wx:if="{{isLoadingLocations}}" class="loading-container">
|
|
||||||
<t-loading theme="dots" size="40rpx" />
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 地点列表 -->
|
|
||||||
<view wx:elif="{{locations.length > 0}}" class="locations-list">
|
|
||||||
<view
|
|
||||||
wx:for="{{locations}}"
|
wx:for="{{locations}}"
|
||||||
wx:key="id"
|
wx:key="id"
|
||||||
class="location-item"
|
title="{{item.title || '未命名地点'}}"
|
||||||
bind:tap="toEditLocation"
|
bind:tap="toLocationDetail"
|
||||||
data-id="{{item.id}}"
|
data-id="{{item.id}}"
|
||||||
|
arrow
|
||||||
>
|
>
|
||||||
<view class="location-icon">
|
<view slot="left-icon" class="thumb">
|
||||||
<t-icon name="{{locationTypeIcons[item.type]}}" size="24px" color="#5E7CE0" />
|
<image wx:if="{{item.previewThumb}}" class="thumb-img" src="{{item.previewThumb}}" mode="aspectFill" />
|
||||||
</view>
|
<view wx:else class="thumb-placeholder">
|
||||||
<view class="location-content">
|
<t-icon name="{{locationTypeIcons[item.type]}}" size="28px" color="var(--theme-wx)" />
|
||||||
<view class="location-header">
|
|
||||||
<text class="location-title">{{item.title || '未命名地点'}}</text>
|
|
||||||
<t-tag size="small" variant="light">{{locationTypeLabels[item.type]}}</t-tag>
|
|
||||||
</view>
|
</view>
|
||||||
<view wx:if="{{item.description}}" class="location-description">{{item.description}}</view>
|
</view>
|
||||||
<view class="location-info">
|
<view slot="note" class="note">{{locationTypeLabels[item.type]}}</view>
|
||||||
<view wx:if="{{item.location}}" class="info-item">
|
<view slot="description" class="description">
|
||||||
<t-icon name="location" size="14px" />
|
<view wx:if="{{item.requireIdCard}}" class="item">
|
||||||
<text>{{item.location}}</text>
|
<t-icon name="user" size="14px" />
|
||||||
</view>
|
<text>需要身份证</text>
|
||||||
<view wx:if="{{item.amount}}" class="info-item">
|
</view>
|
||||||
<t-icon name="money-circle" size="14px" />
|
<view wx:if="{{item.requireAppointment}}" class="item">
|
||||||
<text>¥{{item.amount}}</text>
|
<t-icon name="user" size="14px" />
|
||||||
</view>
|
<text>需要预约</text>
|
||||||
<view wx:if="{{item.requireIdCard}}" class="info-item">
|
</view>
|
||||||
<t-icon name="user" size="14px" />
|
<view wx:if="{{item.amount}}" class="item">
|
||||||
<text>需要身份证</text>
|
<t-icon name="money" size="14px" />
|
||||||
</view>
|
<text>¥{{item.amount}}</text>
|
||||||
<view wx:if="{{item.score}}" class="info-item">
|
</view>
|
||||||
<t-icon name="star" size="14px" />
|
<view wx:if="{{item.importance}}" class="item">
|
||||||
<text>必要度 {{item.score}}</text>
|
<t-icon name="chart-bubble" size="14px" />
|
||||||
|
<text>重要程度</text>
|
||||||
|
<view class="stars orange">
|
||||||
|
<t-icon
|
||||||
|
wx:for="{{item.importance}}"
|
||||||
|
wx:for-index="index"
|
||||||
|
wx:key="index"
|
||||||
|
name="star-filled"
|
||||||
|
size="14px"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="location-arrow">
|
</t-cell>
|
||||||
<t-icon name="chevron-right" size="20px" color="#DCDCDC" />
|
</block>
|
||||||
</view>
|
<t-cell wx:else class="empty-state" description="暂无地点信息" />
|
||||||
</view>
|
</t-cell-group>
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 空状态 -->
|
|
||||||
<view wx:else class="empty-state">
|
|
||||||
<t-icon name="location" size="48px" color="#DCDCDC" />
|
|
||||||
<text class="empty-text">暂无地点信息</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 时间信息 -->
|
|
||||||
<view class="time-card">
|
|
||||||
<view class="time-item">
|
|
||||||
<text class="label">创建时间</text>
|
|
||||||
<text class="value">{{travel.createdAtFormatted || ''}}</text>
|
|
||||||
</view>
|
|
||||||
<view wx:if="{{travel.updatedAt && travel.updatedAt !== travel.createdAt}}" class="time-item">
|
|
||||||
<text class="label">更新时间</text>
|
|
||||||
<text class="value">{{travel.updatedAtFormatted || ''}}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 操作按钮 -->
|
<!-- 操作按钮 -->
|
||||||
<view class="action-section">
|
<view class="section action">
|
||||||
<t-button
|
<t-button
|
||||||
theme="danger"
|
theme="danger"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
size="large"
|
size="large"
|
||||||
icon="delete"
|
icon="delete"
|
||||||
t-class="delete-btn"
|
t-class="delete"
|
||||||
bind:tap="deleteTravel"
|
bind:tap="deleteTravel"
|
||||||
>
|
>
|
||||||
删除
|
删除
|
||||||
@ -173,10 +130,10 @@
|
|||||||
theme="primary"
|
theme="primary"
|
||||||
size="large"
|
size="large"
|
||||||
icon="edit"
|
icon="edit"
|
||||||
t-class="edit-btn"
|
t-class="edit"
|
||||||
bind:tap="toEdit"
|
bind:tap="toEdit"
|
||||||
>
|
>
|
||||||
编辑旅行计划
|
编辑出行计划
|
||||||
</t-button>
|
</t-button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -185,24 +142,18 @@
|
|||||||
<!-- 删除确认对话框 -->
|
<!-- 删除确认对话框 -->
|
||||||
<t-dialog
|
<t-dialog
|
||||||
visible="{{deleteDialogVisible}}"
|
visible="{{deleteDialogVisible}}"
|
||||||
title="删除旅行计划"
|
title="删除出行计划"
|
||||||
confirm-btn="删除"
|
confirm-btn="{{ {content: '删除', variant: 'text', theme: 'danger'} }}"
|
||||||
cancel-btn="取消"
|
cancel-btn="取消"
|
||||||
bind:confirm="confirmDelete"
|
bind:confirm="confirmDelete"
|
||||||
bind:cancel="cancelDelete"
|
bind:cancel="cancelDelete"
|
||||||
>
|
>
|
||||||
<view class="delete-dialog-content">
|
<view slot="content" class="delete-dialog">
|
||||||
<view class="delete-warning">
|
<view class="tips">
|
||||||
<t-icon name="error-circle" size="48rpx" color="#E34D59" />
|
<text>此计划的地点、图片和视频也会同步删除,删除后无法恢复,请输入 "</text>
|
||||||
<text class="warning-text">删除后无法恢复,请谨慎操作!</text>
|
<text style="color: var(--theme-error)">确认删除</text>
|
||||||
</view>
|
<text>" 以继续</text>
|
||||||
<view class="delete-confirm">
|
|
||||||
<text class="confirm-label">请输入"确认删除"以继续:</text>
|
|
||||||
<t-input
|
|
||||||
placeholder="请输入确认删除"
|
|
||||||
model:value="{{deleteConfirmText}}"
|
|
||||||
borderless="{{false}}"
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
|
<t-input placeholder="请输入:确认删除" model:value="{{deleteConfirmText}}" />
|
||||||
</view>
|
</view>
|
||||||
</t-dialog>
|
</t-dialog>
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
// pages/main/travel-editor/index.less
|
// pages/main/travel-editor/index.less
|
||||||
|
|
||||||
.container {
|
.travel-editor {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
background: var(--theme-bg-secondary);
|
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
padding-bottom: 64rpx;
|
padding-bottom: 64rpx;
|
||||||
@ -24,15 +23,58 @@
|
|||||||
.section {
|
.section {
|
||||||
margin-top: 48rpx;
|
margin-top: 48rpx;
|
||||||
|
|
||||||
|
> .title {
|
||||||
|
color: var(--theme-text-secondary);
|
||||||
|
padding: 0 32rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
line-height: 64rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.picker .slot {
|
.picker .slot {
|
||||||
gap: 16rpx;
|
gap: 16rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.days-stepper {
|
.note {
|
||||||
|
color: var(--theme-text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.travel-at-content,
|
||||||
|
.days-content {
|
||||||
|
gap: 16rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
|
.clear-icon {
|
||||||
|
color: var(--theme-text-tertiary);
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
opacity: .6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.undecided-text {
|
||||||
|
color: var(--theme-text-tertiary);
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
opacity: .6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.days {
|
||||||
|
|
||||||
|
&.decided {
|
||||||
|
--td-cell-vertical-padding: 24rpx;
|
||||||
|
|
||||||
|
.t-cell__title {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,35 +100,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.delete-dialog-content {
|
.delete-dialog {
|
||||||
gap: 32rpx;
|
padding: 16rpx 0;
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
.delete-warning {
|
.tips {
|
||||||
gap: 16rpx;
|
color: var(--theme-text-secondary);
|
||||||
display: flex;
|
font-size: 28rpx;
|
||||||
padding: 24rpx;
|
line-height: 1.5;
|
||||||
align-items: center;
|
margin-bottom: 24rpx;
|
||||||
border-radius: 12rpx;
|
|
||||||
flex-direction: column;
|
|
||||||
background: #FFF4F4;
|
|
||||||
|
|
||||||
.warning-text {
|
|
||||||
color: #E34D59;
|
|
||||||
font-size: 28rpx;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.delete-confirm {
|
|
||||||
gap: 16rpx;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
.confirm-label {
|
|
||||||
color: var(--theme-text-primary);
|
|
||||||
font-size: 28rpx;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import { TravelStatus, TransportationType } from "../../../types/Travel";
|
|||||||
interface TravelEditorData {
|
interface TravelEditorData {
|
||||||
/** 模式:create 或 edit */
|
/** 模式:create 或 edit */
|
||||||
mode: "create" | "edit";
|
mode: "create" | "edit";
|
||||||
/** 旅行 ID(编辑模式) */
|
/** 出行 ID(编辑模式) */
|
||||||
id?: number;
|
id?: number;
|
||||||
/** 标题 */
|
/** 标题 */
|
||||||
title: string;
|
title: string;
|
||||||
@ -17,8 +17,12 @@ interface TravelEditorData {
|
|||||||
date: string;
|
date: string;
|
||||||
/** 出行时间 */
|
/** 出行时间 */
|
||||||
time: string;
|
time: string;
|
||||||
|
/** 出行时间是否未定 */
|
||||||
|
travelAtUndecided: boolean;
|
||||||
/** 天数 */
|
/** 天数 */
|
||||||
days: number;
|
days: number;
|
||||||
|
/** 天数是否未定 */
|
||||||
|
daysUndecided: boolean;
|
||||||
/** 交通类型 */
|
/** 交通类型 */
|
||||||
transportationType: TransportationType;
|
transportationType: TransportationType;
|
||||||
/** 状态 */
|
/** 状态 */
|
||||||
@ -49,9 +53,11 @@ Page({
|
|||||||
content: "",
|
content: "",
|
||||||
date: "2025-06-28",
|
date: "2025-06-28",
|
||||||
time: "16:00",
|
time: "16:00",
|
||||||
|
travelAtUndecided: true,
|
||||||
days: 1,
|
days: 1,
|
||||||
transportationType: TransportationType.PLANE,
|
daysUndecided: true,
|
||||||
transportationTypeIndex: 0,
|
transportationType: TransportationType.SELF_DRIVING,
|
||||||
|
transportationTypeIndex: 4,
|
||||||
status: TravelStatus.PLANNING,
|
status: TravelStatus.PLANNING,
|
||||||
statusIndex: 0,
|
statusIndex: 0,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
@ -99,7 +105,7 @@ Page({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/** 加载旅行详情(编辑模式) */
|
/** 加载出行详情(编辑模式) */
|
||||||
async loadTravelDetail(id: number) {
|
async loadTravelDetail(id: number) {
|
||||||
wx.showLoading({ title: "加载中...", mask: true });
|
wx.showLoading({ title: "加载中...", mask: true });
|
||||||
try {
|
try {
|
||||||
@ -108,13 +114,19 @@ Page({
|
|||||||
// 格式化数据
|
// 格式化数据
|
||||||
let date = "";
|
let date = "";
|
||||||
let time = "";
|
let time = "";
|
||||||
|
let travelAtUndecided = true;
|
||||||
if (travel.travelAt) {
|
if (travel.travelAt) {
|
||||||
date = Time.toDate(travel.travelAt);
|
date = Time.toDate(travel.travelAt);
|
||||||
time = Time.toTime(travel.travelAt);
|
time = Time.toTime(travel.travelAt);
|
||||||
|
travelAtUndecided = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 判断天数是否未定
|
||||||
|
const daysUndecided = !travel.days;
|
||||||
|
const days = travel.days || 1;
|
||||||
|
|
||||||
// 计算交通类型索引
|
// 计算交通类型索引
|
||||||
const transportationType = travel.transportationType || TransportationType.PLANE;
|
const transportationType = travel.transportationType || TransportationType.SELF_DRIVING;
|
||||||
const transportationTypeIndex = this.data.transportationTypes.findIndex(
|
const transportationTypeIndex = this.data.transportationTypes.findIndex(
|
||||||
item => item.value === transportationType
|
item => item.value === transportationType
|
||||||
);
|
);
|
||||||
@ -128,9 +140,11 @@ Page({
|
|||||||
content: travel.content || "",
|
content: travel.content || "",
|
||||||
date,
|
date,
|
||||||
time,
|
time,
|
||||||
days: travel.days || 1,
|
travelAtUndecided,
|
||||||
|
days,
|
||||||
|
daysUndecided,
|
||||||
transportationType,
|
transportationType,
|
||||||
transportationTypeIndex: transportationTypeIndex >= 0 ? transportationTypeIndex : 0,
|
transportationTypeIndex: transportationTypeIndex >= 0 ? transportationTypeIndex : 4,
|
||||||
status,
|
status,
|
||||||
statusIndex: statusIndex >= 0 ? statusIndex : 0,
|
statusIndex: statusIndex >= 0 ? statusIndex : 0,
|
||||||
isLoading: false
|
isLoading: false
|
||||||
@ -163,13 +177,42 @@ Page({
|
|||||||
status: this.data.statuses[index].value
|
status: this.data.statuses[index].value
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
/** 切换出行时间未定状态 */
|
||||||
|
toggleTravelAtUndecided(e: any) {
|
||||||
|
this.setData({ travelAtUndecided: e.detail.value });
|
||||||
|
},
|
||||||
|
/** 切换天数未定状态 */
|
||||||
|
toggleDaysUndecided(e: any) {
|
||||||
|
this.setData({ daysUndecided: e.detail.value });
|
||||||
|
},
|
||||||
|
/** 清除出行时间 */
|
||||||
|
clearTravelAt() {
|
||||||
|
this.setData({ travelAtUndecided: true });
|
||||||
|
},
|
||||||
|
/** 清除天数 */
|
||||||
|
clearDays() {
|
||||||
|
this.setData({ daysUndecided: true });
|
||||||
|
},
|
||||||
|
/** 点击未定文字选择时间 */
|
||||||
|
selectTravelAt() {
|
||||||
|
// 设置为已定状态,会自动显示选择器
|
||||||
|
const unixTime = new Date().getTime();
|
||||||
|
this.setData({
|
||||||
|
travelAtUndecided: false,
|
||||||
|
date: Time.toDate(unixTime),
|
||||||
|
time: Time.toTime(unixTime)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 点击未定文字选择天数 */
|
||||||
|
selectDays() {
|
||||||
|
this.setData({
|
||||||
|
daysUndecided: false,
|
||||||
|
days: 1
|
||||||
|
});
|
||||||
|
},
|
||||||
/** 取消 */
|
/** 取消 */
|
||||||
cancel() {
|
cancel() {
|
||||||
if (this.data.mode === "create") {
|
wx.navigateBack();
|
||||||
wx.navigateBack();
|
|
||||||
} else {
|
|
||||||
wx.navigateBack();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
/** 提交/保存 */
|
/** 提交/保存 */
|
||||||
submit() {
|
submit() {
|
||||||
@ -187,7 +230,7 @@ Page({
|
|||||||
this.updateTravel();
|
this.updateTravel();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/** 创建旅行 */
|
/** 创建出行 */
|
||||||
async createTravel() {
|
async createTravel() {
|
||||||
this.setData({ isSaving: true });
|
this.setData({ isSaving: true });
|
||||||
|
|
||||||
@ -195,8 +238,8 @@ Page({
|
|||||||
await TravelApi.create({
|
await TravelApi.create({
|
||||||
title: this.data.title.trim(),
|
title: this.data.title.trim(),
|
||||||
content: this.data.content.trim(),
|
content: this.data.content.trim(),
|
||||||
travelAt: new Date(`${this.data.date}T${this.data.time}:00`).getTime(),
|
travelAt: this.data.travelAtUndecided ? null : Time.now(),
|
||||||
days: this.data.days,
|
days: this.data.daysUndecided ? null : this.data.days,
|
||||||
transportationType: this.data.transportationType,
|
transportationType: this.data.transportationType,
|
||||||
status: this.data.status
|
status: this.data.status
|
||||||
});
|
});
|
||||||
@ -211,7 +254,7 @@ Page({
|
|||||||
this.setData({ isSaving: false });
|
this.setData({ isSaving: false });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/** 更新旅行 */
|
/** 更新出行 */
|
||||||
async updateTravel() {
|
async updateTravel() {
|
||||||
this.setData({ isSaving: true });
|
this.setData({ isSaving: true });
|
||||||
try {
|
try {
|
||||||
@ -219,8 +262,10 @@ Page({
|
|||||||
id: this.data.id!,
|
id: this.data.id!,
|
||||||
title: this.data.title.trim(),
|
title: this.data.title.trim(),
|
||||||
content: this.data.content.trim(),
|
content: this.data.content.trim(),
|
||||||
travelAt: new Date(`${this.data.date}T${this.data.time}:00`).getTime(),
|
travelAt: this.data.travelAtUndecided
|
||||||
days: this.data.days,
|
? null
|
||||||
|
: new Date(`${this.data.date}T${this.data.time}:00`).getTime(),
|
||||||
|
days: this.data.daysUndecided ? null : this.data.days,
|
||||||
transportationType: this.data.transportationType,
|
transportationType: this.data.transportationType,
|
||||||
status: this.data.status
|
status: this.data.status
|
||||||
});
|
});
|
||||||
@ -236,7 +281,7 @@ Page({
|
|||||||
this.setData({ isSaving: false });
|
this.setData({ isSaving: false });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/** 删除旅行 */
|
/** 删除出行 */
|
||||||
deleteTravel() {
|
deleteTravel() {
|
||||||
this.setData({
|
this.setData({
|
||||||
deleteDialogVisible: true,
|
deleteDialogVisible: true,
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
<!--pages/main/travel-editor/index.wxml-->
|
<!--pages/main/travel-editor/index.wxml-->
|
||||||
<t-navbar title="{{mode === 'create' ? '新建旅行' : '编辑旅行'}}">
|
<t-navbar title="{{mode === 'create' ? '新建出行' : '编辑出行'}}">
|
||||||
<text slot="left" bindtap="cancel">取消</text>
|
<text slot="left" bindtap="cancel">取消</text>
|
||||||
</t-navbar>
|
</t-navbar>
|
||||||
|
|
||||||
<scroll-view class="container" type="custom" scroll-y show-scrollbar="{{false}}">
|
<scroll-view class="travel-editor setting-bg" type="custom" scroll-y show-scrollbar="{{false}}">
|
||||||
<view class="content">
|
<view class="content">
|
||||||
<view wx:if="{{isLoading}}" class="loading">
|
<view wx:if="{{isLoading}}" class="loading">
|
||||||
<t-loading theme="dots" size="40rpx" />
|
<t-loading theme="dots" size="40rpx" />
|
||||||
@ -11,12 +11,12 @@
|
|||||||
</view>
|
</view>
|
||||||
<block wx:else>
|
<block wx:else>
|
||||||
<t-cell-group class="section">
|
<t-cell-group class="section">
|
||||||
|
<view slot="title" class="title">基本信息</view>
|
||||||
<t-input
|
<t-input
|
||||||
class="input"
|
class="input"
|
||||||
placeholder="请输入旅行标题"
|
placeholder="请输入出行标题"
|
||||||
model:value="{{title}}"
|
model:value="{{title}}"
|
||||||
maxlength="50"
|
maxlength="50"
|
||||||
borderless
|
|
||||||
>
|
>
|
||||||
<text slot="label">标题</text>
|
<text slot="label">标题</text>
|
||||||
</t-input>
|
</t-input>
|
||||||
@ -31,62 +31,72 @@
|
|||||||
</t-textarea>
|
</t-textarea>
|
||||||
</t-cell-group>
|
</t-cell-group>
|
||||||
<t-cell-group class="section">
|
<t-cell-group class="section">
|
||||||
|
<view slot="title" class="title">详细信息</view>
|
||||||
<t-cell class="travel-at" title="出行时间">
|
<t-cell class="travel-at" title="出行时间">
|
||||||
<view slot="right-icon">
|
<view slot="right-icon" class="travel-at-content">
|
||||||
<picker class="picker" mode="date" model:value="{{date}}">
|
<picker wx:if="{{!travelAtUndecided}}" class="picker" mode="date" model:value="{{date}}">
|
||||||
<view slot="content" class="slot">
|
<view slot="content" class="slot">
|
||||||
<t-icon name="calendar" size="20px" class="icon" />
|
<t-icon name="calendar" size="20px" class="icon" />
|
||||||
<text>{{date}}</text>
|
<text>{{date}}</text>
|
||||||
</view>
|
</view>
|
||||||
</picker>
|
</picker>
|
||||||
|
<view wx:else class="slot" bindtap="selectTravelAt">
|
||||||
|
<text class="undecided-text">未定</text>
|
||||||
|
</view>
|
||||||
|
<t-icon
|
||||||
|
wx:if="{{!travelAtUndecided}}"
|
||||||
|
name="close-circle-filled"
|
||||||
|
size="20px"
|
||||||
|
class="clear-icon"
|
||||||
|
bindtap="clearTravelAt"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</t-cell>
|
</t-cell>
|
||||||
<t-cell title="旅行天数" t-class="days-cell">
|
<t-cell title="出行天数" class="days {{daysUndecided ? 'undecided' : 'decided'}}">
|
||||||
<view slot="right-icon" class="days-stepper">
|
<view slot="right-icon" class="days-content">
|
||||||
<t-stepper
|
<t-stepper
|
||||||
|
wx:if="{{!daysUndecided}}"
|
||||||
theme="filled"
|
theme="filled"
|
||||||
model:value="{{days}}"
|
model:value="{{days}}"
|
||||||
size="medium"
|
size="large"
|
||||||
min="{{1}}"
|
min="{{1}}"
|
||||||
max="{{999}}"
|
max="{{999}}"
|
||||||
t-class="stepper"
|
t-class="stepper"
|
||||||
/>
|
/>
|
||||||
|
<view wx:else class="slot" bindtap="selectDays">
|
||||||
|
<text class="undecided-text">未定</text>
|
||||||
|
</view>
|
||||||
|
<t-icon
|
||||||
|
wx:if="{{!daysUndecided}}"
|
||||||
|
name="close-circle-filled"
|
||||||
|
size="20px"
|
||||||
|
class="clear-icon"
|
||||||
|
bindtap="clearDays"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</t-cell>
|
</t-cell>
|
||||||
<t-cell title="交通方式">
|
<picker
|
||||||
<view slot="right-icon">
|
mode="selector"
|
||||||
<picker
|
range="{{transportationTypes}}"
|
||||||
class="picker"
|
range-key="label"
|
||||||
mode="selector"
|
value="{{transportationTypeIndex}}"
|
||||||
range="{{transportationTypes}}"
|
bindchange="onChangeTransportationType"
|
||||||
range-key="label"
|
>
|
||||||
value="{{transportationTypeIndex}}"
|
<t-cell title="交通方式" arrow>
|
||||||
bindchange="onChangeTransportationType"
|
<view slot="note" class="note">{{transportationTypes[transportationTypeIndex].label}}</view>
|
||||||
>
|
</t-cell>
|
||||||
<view class="slot">
|
</picker>
|
||||||
<text>{{transportationTypes[transportationTypeIndex].label}}</text>
|
<picker
|
||||||
<t-icon name="chevron-right" size="20px" class="icon" />
|
mode="selector"
|
||||||
</view>
|
range="{{statuses}}"
|
||||||
</picker>
|
range-key="label"
|
||||||
</view>
|
value="{{statusIndex}}"
|
||||||
</t-cell>
|
bindchange="onChangeStatus"
|
||||||
<t-cell title="状态">
|
>
|
||||||
<view slot="right-icon">
|
<t-cell title="状态" arrow>
|
||||||
<picker
|
<view slot="note" class="note">{{statuses[statusIndex].label}}</view>
|
||||||
class="picker"
|
</t-cell>
|
||||||
mode="selector"
|
</picker>
|
||||||
range="{{statuses}}"
|
|
||||||
range-key="label"
|
|
||||||
value="{{statusIndex}}"
|
|
||||||
bindchange="onChangeStatus"
|
|
||||||
>
|
|
||||||
<view class="slot">
|
|
||||||
<text>{{statuses[statusIndex].label}}</text>
|
|
||||||
<t-icon name="chevron-right" size="20px" class="icon" />
|
|
||||||
</view>
|
|
||||||
</picker>
|
|
||||||
</view>
|
|
||||||
</t-cell>
|
|
||||||
</t-cell-group>
|
</t-cell-group>
|
||||||
<view wx:if="{{mode === 'create'}}" class="submit-section">
|
<view wx:if="{{mode === 'create'}}" class="submit-section">
|
||||||
<t-button
|
<t-button
|
||||||
@ -96,7 +106,7 @@
|
|||||||
bind:tap="submit"
|
bind:tap="submit"
|
||||||
disabled="{{isSaving}}"
|
disabled="{{isSaving}}"
|
||||||
>
|
>
|
||||||
创建旅行
|
创建出行
|
||||||
</t-button>
|
</t-button>
|
||||||
</view>
|
</view>
|
||||||
<view wx:else class="submit-section horizontal">
|
<view wx:else class="submit-section horizontal">
|
||||||
@ -127,24 +137,18 @@
|
|||||||
<!-- 删除确认对话框 -->
|
<!-- 删除确认对话框 -->
|
||||||
<t-dialog
|
<t-dialog
|
||||||
visible="{{deleteDialogVisible}}"
|
visible="{{deleteDialogVisible}}"
|
||||||
title="删除旅行计划"
|
title="删除出行计划"
|
||||||
confirm-btn="删除"
|
confirm-btn="{{ {content: '删除', variant: 'text', theme: 'danger'} }}"
|
||||||
cancel-btn="取消"
|
cancel-btn="取消"
|
||||||
bind:confirm="confirmDelete"
|
bind:confirm="confirmDelete"
|
||||||
bind:cancel="cancelDelete"
|
bind:cancel="cancelDelete"
|
||||||
>
|
>
|
||||||
<view class="delete-dialog-content">
|
<view slot="content" class="delete-dialog">
|
||||||
<view class="delete-warning">
|
<view class="tips">
|
||||||
<t-icon name="error-circle" size="48rpx" color="#E34D59" />
|
<text>此计划的地点、图片和视频也会同步删除,删除后无法恢复,请输入 "</text>
|
||||||
<text class="warning-text">删除后无法恢复,请谨慎操作!</text>
|
<text style="color: var(--theme-error)">确认删除</text>
|
||||||
</view>
|
<text>" 以继续</text>
|
||||||
<view class="delete-confirm">
|
|
||||||
<text class="confirm-label">请输入"确认删除"以继续:</text>
|
|
||||||
<t-input
|
|
||||||
placeholder="请输入确认删除"
|
|
||||||
model:value="{{deleteConfirmText}}"
|
|
||||||
borderless="{{false}}"
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
|
<t-input placeholder="请输入:确认删除" model:value="{{deleteConfirmText}}" />
|
||||||
</view>
|
</view>
|
||||||
</t-dialog>
|
</t-dialog>
|
||||||
|
|||||||
16
miniprogram/pages/main/travel-location-detail/index.json
Normal file
16
miniprogram/pages/main/travel-location-detail/index.json
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"component": true,
|
||||||
|
"usingComponents": {
|
||||||
|
"t-cell": "tdesign-miniprogram/cell/cell",
|
||||||
|
"t-rate": "tdesign-miniprogram/rate/rate",
|
||||||
|
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||||
|
"t-input": "tdesign-miniprogram/input/input",
|
||||||
|
"t-button": "tdesign-miniprogram/button/button",
|
||||||
|
"t-empty": "tdesign-miniprogram/empty/empty",
|
||||||
|
"t-dialog": "tdesign-miniprogram/dialog/dialog",
|
||||||
|
"t-navbar": "tdesign-miniprogram/navbar/navbar",
|
||||||
|
"t-loading": "tdesign-miniprogram/loading/loading",
|
||||||
|
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group"
|
||||||
|
},
|
||||||
|
"styleIsolation": "shared"
|
||||||
|
}
|
||||||
150
miniprogram/pages/main/travel-location-detail/index.less
Normal file
150
miniprogram/pages/main/travel-location-detail/index.less
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
// pages/main/travel-location-detail/index.less
|
||||||
|
.travel-location-detail {
|
||||||
|
width: 100vw;
|
||||||
|
min-height: 100vh;
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
|
.status-card {
|
||||||
|
padding: 64rpx 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
display: flex;
|
||||||
|
padding-top: 48rpx;
|
||||||
|
flex-direction: column;
|
||||||
|
padding-bottom: 128rpx;
|
||||||
|
|
||||||
|
.section {
|
||||||
|
margin-top: 32rpx;
|
||||||
|
|
||||||
|
> .title {
|
||||||
|
color: var(--theme-text-secondary);
|
||||||
|
padding: 0 32rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
line-height: 64rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.title {
|
||||||
|
color: var(--theme-text-primary);
|
||||||
|
padding: 24rpx;
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 24rpx;
|
||||||
|
background: var(--theme-bg-card);
|
||||||
|
box-shadow: 0 2px 12px var(--theme-shadow-light);
|
||||||
|
|
||||||
|
.title-text {
|
||||||
|
color: var(--theme-text-primary);
|
||||||
|
font-size: 40rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtitle {
|
||||||
|
color: var(--theme-text-secondary);
|
||||||
|
display: block;
|
||||||
|
font-size: 28rpx;
|
||||||
|
margin-top: 12rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.location {
|
||||||
|
|
||||||
|
.t-cell__title {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map {
|
||||||
|
padding: 0;
|
||||||
|
|
||||||
|
.instance {
|
||||||
|
width: 100%;
|
||||||
|
height: 520rpx;
|
||||||
|
|
||||||
|
.marker {
|
||||||
|
width: calc(var(--title-length) * 28rpx);
|
||||||
|
color: var(--theme-text-primary);
|
||||||
|
padding: 8rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
font-size: 28rpx;
|
||||||
|
background: var(--theme-bg-card);
|
||||||
|
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, .15);
|
||||||
|
white-space: nowrap;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.media {
|
||||||
|
|
||||||
|
.media-grid {
|
||||||
|
gap: 16rpx;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
|
||||||
|
.media-item {
|
||||||
|
width: 220rpx;
|
||||||
|
height: 220rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.thumbnail {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.video-container {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.thumbnail {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.play-icon {
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
color: rgba(255, 255, 255, .9);
|
||||||
|
position: absolute;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.navigate {
|
||||||
|
padding: 0 16rpx;
|
||||||
|
margin-top: 90rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.action {
|
||||||
|
gap: 24rpx;
|
||||||
|
display: flex;
|
||||||
|
padding: 0 16rpx;
|
||||||
|
|
||||||
|
.edit {
|
||||||
|
flex: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.delete {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.delete-dialog {
|
||||||
|
padding: 16rpx 0;
|
||||||
|
|
||||||
|
.tips {
|
||||||
|
color: var(--theme-text-secondary);
|
||||||
|
font-size: 28rpx;
|
||||||
|
line-height: 1.5;
|
||||||
|
margin-bottom: 24rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
273
miniprogram/pages/main/travel-location-detail/index.ts
Normal file
273
miniprogram/pages/main/travel-location-detail/index.ts
Normal file
@ -0,0 +1,273 @@
|
|||||||
|
// pages/main/travel-location-detail/index.ts
|
||||||
|
|
||||||
|
import config from "../../../config/index";
|
||||||
|
import { TravelLocationApi } from "../../../api/TravelLocationApi";
|
||||||
|
import { TravelLocation, TravelLocationTypeIcon, TravelLocationTypeLabel } from "../../../types/Travel";
|
||||||
|
import { MediaAttachType, PreviewImageMetadata } from "../../../types/Attachment";
|
||||||
|
import { MapMarker, MediaItem, MediaItemType } from "../../../types/UI";
|
||||||
|
import Toolkit from "../../../utils/Toolkit";
|
||||||
|
|
||||||
|
interface TravelLocationView extends TravelLocation {
|
||||||
|
/** 媒体列表 */
|
||||||
|
mediaItems?: MediaItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TravelLocationDetailData {
|
||||||
|
/** 地点详情 */
|
||||||
|
location: TravelLocationView | null;
|
||||||
|
/** 地点 ID */
|
||||||
|
locationId: string;
|
||||||
|
/** 出行 ID */
|
||||||
|
travelId: string;
|
||||||
|
/** 是否正在加载 */
|
||||||
|
isLoading: boolean;
|
||||||
|
/** 错误信息 */
|
||||||
|
errorMessage: string;
|
||||||
|
/** 地点类型标签映射 */
|
||||||
|
locationTypeLabels: typeof TravelLocationTypeLabel;
|
||||||
|
/** 地点类型图标映射 */
|
||||||
|
locationTypeIcons: typeof TravelLocationTypeIcon;
|
||||||
|
/** 媒体类型枚举 */
|
||||||
|
mediaItemTypeEnum: typeof MediaItemType;
|
||||||
|
/** 地图标记 */
|
||||||
|
mapMarkers: MapMarker[];
|
||||||
|
/** 删除对话框可见性 */
|
||||||
|
deleteDialogVisible: boolean;
|
||||||
|
/** 删除确认文本 */
|
||||||
|
deleteConfirmText: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
Page({
|
||||||
|
data: <TravelLocationDetailData>{
|
||||||
|
location: null,
|
||||||
|
locationId: "",
|
||||||
|
travelId: "",
|
||||||
|
isLoading: true,
|
||||||
|
errorMessage: "",
|
||||||
|
locationTypeLabels: TravelLocationTypeLabel,
|
||||||
|
locationTypeIcons: TravelLocationTypeIcon,
|
||||||
|
mediaItemTypeEnum: {
|
||||||
|
...MediaItemType
|
||||||
|
},
|
||||||
|
mapMarkers: [],
|
||||||
|
deleteDialogVisible: false,
|
||||||
|
deleteConfirmText: ""
|
||||||
|
},
|
||||||
|
|
||||||
|
onLoad(options: any) {
|
||||||
|
const { id, travelId } = options;
|
||||||
|
if (id) {
|
||||||
|
this.setData({
|
||||||
|
locationId: id,
|
||||||
|
travelId: travelId || ""
|
||||||
|
});
|
||||||
|
this.fetchDetail(id);
|
||||||
|
} else {
|
||||||
|
wx.showToast({
|
||||||
|
title: "参数错误",
|
||||||
|
icon: "error"
|
||||||
|
});
|
||||||
|
setTimeout(() => {
|
||||||
|
wx.navigateBack();
|
||||||
|
}, 1500);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onShow() {
|
||||||
|
// 页面显示时刷新数据(从编辑页返回时)
|
||||||
|
if (this.data.locationId && !this.data.isLoading && this.data.location) {
|
||||||
|
this.fetchDetail(this.data.locationId);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 获取地点详情 */
|
||||||
|
async fetchDetail(id: string) {
|
||||||
|
this.setData({
|
||||||
|
isLoading: true,
|
||||||
|
errorMessage: ""
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const location = await TravelLocationApi.getDetail(id);
|
||||||
|
|
||||||
|
const thumbItems = (location.items || []).filter((item) => item.attachType === MediaAttachType.THUMB);
|
||||||
|
const mediaItems: MediaItem[] = [];
|
||||||
|
|
||||||
|
thumbItems.forEach((thumbItem) => {
|
||||||
|
try {
|
||||||
|
const metadata = (typeof thumbItem.metadata === "string" ? JSON.parse(thumbItem.metadata) : thumbItem.metadata) as PreviewImageMetadata;
|
||||||
|
const thumbURL = `${config.url}/attachment/read/${thumbItem.mongoId}`;
|
||||||
|
const sourceURL = `${config.url}/attachment/read/${metadata.sourceMongoId}`;
|
||||||
|
const isVideo = metadata.sourceMimeType?.startsWith("video/");
|
||||||
|
mediaItems.push({
|
||||||
|
type: isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
|
||||||
|
thumbURL,
|
||||||
|
sourceURL,
|
||||||
|
size: thumbItem.size || 0,
|
||||||
|
attachmentId: thumbItem.id!
|
||||||
|
});
|
||||||
|
} catch (parseError) {
|
||||||
|
console.warn("解析附件元数据失败", parseError);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 构建地图标记
|
||||||
|
const mapMarkers: MapMarker[] = [];
|
||||||
|
if (location.lat !== undefined && location.lng !== undefined) {
|
||||||
|
mapMarkers.push({
|
||||||
|
id: 0,
|
||||||
|
latitude: location.lat,
|
||||||
|
longitude: location.lng,
|
||||||
|
width: 24,
|
||||||
|
height: 30,
|
||||||
|
customCallout: {
|
||||||
|
anchorY: -2,
|
||||||
|
anchorX: 0,
|
||||||
|
display: "ALWAYS"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.setData({
|
||||||
|
location: {
|
||||||
|
...location,
|
||||||
|
mediaItems
|
||||||
|
},
|
||||||
|
travelId: location.travelId ? String(location.travelId) : this.data.travelId,
|
||||||
|
mapMarkers
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("获取地点详情失败:", error);
|
||||||
|
this.setData({
|
||||||
|
errorMessage: "加载失败,请稍后重试"
|
||||||
|
});
|
||||||
|
wx.showToast({
|
||||||
|
title: "加载失败",
|
||||||
|
icon: "error"
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
this.setData({ isLoading: false });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 重新加载 */
|
||||||
|
retryFetch() {
|
||||||
|
if (this.data.locationId) {
|
||||||
|
this.fetchDetail(this.data.locationId);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 编辑地点 */
|
||||||
|
toEdit() {
|
||||||
|
const { location, travelId } = this.data;
|
||||||
|
if (location && location.id) {
|
||||||
|
wx.navigateTo({
|
||||||
|
url: `/pages/main/travel-location-editor/index?id=${location.id}&travelId=${travelId || location.travelId || ""}`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 出发(打开地图导航) */
|
||||||
|
navigate() {
|
||||||
|
const { location } = this.data;
|
||||||
|
if (location && location.lat !== undefined && location.lng !== undefined) {
|
||||||
|
wx.openLocation({
|
||||||
|
latitude: location.lat,
|
||||||
|
longitude: location.lng,
|
||||||
|
name: location.title || "目的地",
|
||||||
|
address: location.location || "",
|
||||||
|
scale: 15
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
wx.showToast({
|
||||||
|
title: "位置信息不完整",
|
||||||
|
icon: "error"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 预览媒体 */
|
||||||
|
preview(e: WechatMiniprogram.BaseEvent) {
|
||||||
|
const index = e.currentTarget.dataset.index;
|
||||||
|
const { location } = this.data;
|
||||||
|
|
||||||
|
if (!location || !location.mediaItems) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const sources = location.mediaItems.map(item => ({
|
||||||
|
url: item.sourceURL,
|
||||||
|
type: item.type
|
||||||
|
}));
|
||||||
|
|
||||||
|
const total = sources.length;
|
||||||
|
const startIndex = Math.max(0, index - 25);
|
||||||
|
const endIndex = Math.min(total, startIndex + 50);
|
||||||
|
const newCurrentIndex = index - startIndex;
|
||||||
|
|
||||||
|
wx.previewMedia({
|
||||||
|
current: newCurrentIndex,
|
||||||
|
sources: sources.slice(startIndex, endIndex) as WechatMiniprogram.MediaSource[]
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 删除地点 */
|
||||||
|
deleteLocation() {
|
||||||
|
this.setData({
|
||||||
|
deleteDialogVisible: true,
|
||||||
|
deleteConfirmText: ""
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 取消删除 */
|
||||||
|
cancelDelete() {
|
||||||
|
this.setData({
|
||||||
|
deleteDialogVisible: false,
|
||||||
|
deleteConfirmText: ""
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 确认删除 */
|
||||||
|
confirmDelete() {
|
||||||
|
const inputText = this.data.deleteConfirmText.trim();
|
||||||
|
if (inputText !== "确认删除") {
|
||||||
|
wx.showToast({
|
||||||
|
title: "输入不匹配",
|
||||||
|
icon: "error"
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.setData({
|
||||||
|
deleteDialogVisible: false
|
||||||
|
});
|
||||||
|
this.executeDelete();
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 执行删除 */
|
||||||
|
async executeDelete() {
|
||||||
|
if (!this.data.location || !this.data.location.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wx.showLoading({ title: "删除中...", mask: true });
|
||||||
|
|
||||||
|
try {
|
||||||
|
await TravelLocationApi.delete(this.data.location.id);
|
||||||
|
wx.showToast({
|
||||||
|
title: "删除成功",
|
||||||
|
icon: "success"
|
||||||
|
});
|
||||||
|
setTimeout(() => {
|
||||||
|
wx.navigateBack();
|
||||||
|
}, 1500);
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已由 Network 类处理
|
||||||
|
} finally {
|
||||||
|
wx.hideLoading();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 返回 */
|
||||||
|
async goBack() {
|
||||||
|
Toolkit.async(() => wx.navigateBack()); // 微信 BUG,需要延时
|
||||||
|
}
|
||||||
|
});
|
||||||
157
miniprogram/pages/main/travel-location-detail/index.wxml
Normal file
157
miniprogram/pages/main/travel-location-detail/index.wxml
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
<!--pages/main/travel-location-detail/index.wxml-->
|
||||||
|
<view class="custom-navbar">
|
||||||
|
<t-navbar title="地点详情" leftArrow bind:go-back="goBack">
|
||||||
|
<view slot="right" class="edit-btn" bind:tap="toEdit">
|
||||||
|
<t-icon name="edit" size="24px" />
|
||||||
|
</view>
|
||||||
|
</t-navbar>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="travel-location-detail setting-bg">
|
||||||
|
<t-loading wx:if="{{isLoading}}" theme="dots" size="40rpx" />
|
||||||
|
<view wx:elif="{{errorMessage}}" class="status-card">
|
||||||
|
<t-empty icon="error-circle" description="{{errorMessage}}">
|
||||||
|
<t-button size="small" theme="primary" variant="outline" bind:tap="retryFetch">
|
||||||
|
重新加载
|
||||||
|
</t-button>
|
||||||
|
</t-empty>
|
||||||
|
</view>
|
||||||
|
<view wx:elif="{{!location}}" class="status-card">
|
||||||
|
<t-empty icon="location" description="暂无地点信息" />
|
||||||
|
</view>
|
||||||
|
<view wx:else class="content">
|
||||||
|
<!-- 标题 -->
|
||||||
|
<view class="section title">
|
||||||
|
<text class="title-text">{{location.title || '未命名地点'}}</text>
|
||||||
|
</view>
|
||||||
|
<!-- 位置信息 -->
|
||||||
|
<t-cell-group wx:if="{{location.lat !== undefined && location.lng !== undefined}}" class="section location">
|
||||||
|
<view slot="title" class="title">位置信息</view>
|
||||||
|
<t-cell
|
||||||
|
left-icon="{{locationTypeIcons[location.type]}}"
|
||||||
|
title="类型"
|
||||||
|
note="{{locationTypeLabels[location.type]}}"
|
||||||
|
/>
|
||||||
|
<t-cell class="map">
|
||||||
|
<map
|
||||||
|
slot="description"
|
||||||
|
class="instance"
|
||||||
|
latitude="{{location.lat}}"
|
||||||
|
longitude="{{location.lng}}"
|
||||||
|
markers="{{mapMarkers}}"
|
||||||
|
scale="15"
|
||||||
|
show-location
|
||||||
|
>
|
||||||
|
<cover-view slot="callout">
|
||||||
|
<cover-view class="marker" marker-id="0" style="--title-length: {{location.title.length}}">
|
||||||
|
{{location.title || '地点'}}
|
||||||
|
</cover-view>
|
||||||
|
</cover-view>
|
||||||
|
</map>
|
||||||
|
</t-cell>
|
||||||
|
<t-cell
|
||||||
|
left-icon="location"
|
||||||
|
title="{{location.location || '位置信息'}}"
|
||||||
|
arrow
|
||||||
|
bind:tap="navigate"
|
||||||
|
/>
|
||||||
|
</t-cell-group>
|
||||||
|
<!-- 基础信息 -->
|
||||||
|
<t-cell-group class="section info">
|
||||||
|
<view slot="title" class="title">基础信息</view>
|
||||||
|
<t-cell wx:if="{{location.amount !== undefined && location.amount !== null}}" left-icon="money" title="费用">
|
||||||
|
<view slot="note">¥{{location.amount}}</view>
|
||||||
|
</t-cell>
|
||||||
|
<t-cell left-icon="verify" title="身份证">
|
||||||
|
<view slot="note" class="{{location.requireIdCard ? 'red' : ''}}">
|
||||||
|
{{location.requireIdCard ? '需要' : '无需'}}
|
||||||
|
</view>
|
||||||
|
</t-cell>
|
||||||
|
<t-cell left-icon="calendar" title="预约">
|
||||||
|
<view slot="note" class="{{location.requireAppointment ? 'red' : ''}}">
|
||||||
|
{{location.requireAppointment ? '需要' : '无需'}}
|
||||||
|
</view>
|
||||||
|
</t-cell>
|
||||||
|
<t-cell wx:if="{{location.score !== undefined && location.score !== null}}" left-icon="star" title="评分">
|
||||||
|
<view slot="note">
|
||||||
|
<t-rate value="{{location.score}}" count="{{5}}" size="20px" readonly />
|
||||||
|
</view>
|
||||||
|
</t-cell>
|
||||||
|
<t-cell wx:if="{{location.importance !== undefined && location.importance !== null}}" left-icon="chart-bubble" title="重要程度">
|
||||||
|
<view slot="note">
|
||||||
|
<t-rate value="{{location.importance}}" count="{{5}}" size="20px" readonly />
|
||||||
|
</view>
|
||||||
|
</t-cell>
|
||||||
|
</t-cell-group>
|
||||||
|
<!-- 详细说明 -->
|
||||||
|
<t-cell-group wx:if="{{location.description}}" class="section">
|
||||||
|
<view slot="title" class="title">详细说明</view>
|
||||||
|
<t-cell title="{{location.description}}" />
|
||||||
|
</t-cell-group>
|
||||||
|
<!-- 照片/视频 -->
|
||||||
|
<t-cell-group wx:if="{{location.mediaItems && 0 < location.mediaItems.length}}" class="section media">
|
||||||
|
<view slot="title" class="title">照片视频</view>
|
||||||
|
<t-cell>
|
||||||
|
<view slot="title" class="media-grid">
|
||||||
|
<view
|
||||||
|
wx:for="{{location.mediaItems}}"
|
||||||
|
wx:key="attachmentId"
|
||||||
|
class="media-item"
|
||||||
|
bind:tap="preview"
|
||||||
|
data-index="{{index}}"
|
||||||
|
>
|
||||||
|
<image
|
||||||
|
wx:if="{{item.type === mediaItemTypeEnum.IMAGE}}"
|
||||||
|
src="{{item.thumbURL}}"
|
||||||
|
class="thumbnail"
|
||||||
|
mode="aspectFill"
|
||||||
|
></image>
|
||||||
|
<view wx:if="{{item.type === mediaItemTypeEnum.VIDEO}}" class="video-container">
|
||||||
|
<image src="{{item.thumbURL}}" class="thumbnail" mode="aspectFill"></image>
|
||||||
|
<t-icon class="play-icon" name="play-circle-filled" size="48px" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</t-cell>
|
||||||
|
</t-cell-group>
|
||||||
|
<view class="section navigate">
|
||||||
|
<t-button theme="primary" size="large" icon="rocket" block bind:tap="navigate">
|
||||||
|
出发导航
|
||||||
|
</t-button>
|
||||||
|
</view>
|
||||||
|
<!-- 操作按钮 -->
|
||||||
|
<view class="section action">
|
||||||
|
<t-button
|
||||||
|
theme="danger"
|
||||||
|
variant="outline"
|
||||||
|
size="large"
|
||||||
|
icon="delete"
|
||||||
|
t-class="delete"
|
||||||
|
bind:tap="deleteLocation"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</t-button>
|
||||||
|
<t-button theme="primary" size="large" icon="edit" t-class="edit" bind:tap="toEdit">
|
||||||
|
编辑地点
|
||||||
|
</t-button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</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 placeholder="请输入:确认删除" model:value="{{deleteConfirmText}}" />
|
||||||
|
</view>
|
||||||
|
</t-dialog>
|
||||||
@ -6,6 +6,7 @@
|
|||||||
"t-rate": "tdesign-miniprogram/rate/rate",
|
"t-rate": "tdesign-miniprogram/rate/rate",
|
||||||
"t-input": "tdesign-miniprogram/input/input",
|
"t-input": "tdesign-miniprogram/input/input",
|
||||||
"t-button": "tdesign-miniprogram/button/button",
|
"t-button": "tdesign-miniprogram/button/button",
|
||||||
|
"t-dialog": "tdesign-miniprogram/dialog/dialog",
|
||||||
"t-navbar": "tdesign-miniprogram/navbar/navbar",
|
"t-navbar": "tdesign-miniprogram/navbar/navbar",
|
||||||
"t-loading": "tdesign-miniprogram/loading/loading",
|
"t-loading": "tdesign-miniprogram/loading/loading",
|
||||||
"t-stepper": "tdesign-miniprogram/stepper/stepper",
|
"t-stepper": "tdesign-miniprogram/stepper/stepper",
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
// pages/main/travel-location-editor/index.less
|
// pages/main/travel-location-editor/index.less
|
||||||
|
|
||||||
.container {
|
.travel-location-editor {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
background: var(--theme-bg-secondary);
|
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
padding-bottom: 64rpx;
|
padding-bottom: 64rpx;
|
||||||
@ -14,7 +13,7 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
.loading-text {
|
.text {
|
||||||
color: var(--theme-text-secondary);
|
color: var(--theme-text-secondary);
|
||||||
margin-top: 24rpx;
|
margin-top: 24rpx;
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
@ -24,25 +23,52 @@
|
|||||||
.section {
|
.section {
|
||||||
margin-top: 48rpx;
|
margin-top: 48rpx;
|
||||||
|
|
||||||
.picker .slot {
|
.rate-cell {
|
||||||
gap: 16rpx;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.location-slot {
|
&.decided {
|
||||||
gap: 16rpx;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
.location-text {
|
.rate {
|
||||||
color: var(--theme-text-primary);
|
display: block;
|
||||||
font-size: 28rpx;
|
gap: 16rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.location-placeholder {
|
&.undecided {
|
||||||
color: var(--theme-text-placeholder);
|
|
||||||
font-size: 28rpx;
|
.rate {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
> .title {
|
||||||
|
color: var(--theme-text-secondary);
|
||||||
|
padding: 0 32rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
line-height: 64rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.location {
|
||||||
|
|
||||||
|
.note {
|
||||||
|
color: var(--theme-text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.value {
|
||||||
|
|
||||||
|
.title {
|
||||||
|
width: 2em;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,12 +76,13 @@
|
|||||||
|
|
||||||
.gallery {
|
.gallery {
|
||||||
gap: 10rpx;
|
gap: 10rpx;
|
||||||
|
padding: 0 6rpx;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(3, 1fr);
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
|
||||||
.item {
|
.item {
|
||||||
width: 240rpx;
|
width: 220rpx;
|
||||||
height: 240rpx;
|
height: 220rpx;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: var(--theme-bg-card);
|
background: var(--theme-bg-card);
|
||||||
@ -67,6 +94,10 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 80rpx;
|
font-size: 80rpx;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.thumbnail {
|
.thumbnail {
|
||||||
@ -125,102 +156,46 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.media-section {
|
&.upload {
|
||||||
margin-top: 48rpx;
|
gap: 16rpx;
|
||||||
padding: 32rpx;
|
display: flex;
|
||||||
background: var(--theme-bg-card);
|
padding: 24rpx 32rpx;
|
||||||
|
margin-top: 24rpx;
|
||||||
|
align-items: center;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
background: var(--theme-bg-card);
|
||||||
|
|
||||||
.section-title {
|
.text {
|
||||||
color: var(--theme-text-primary);
|
color: var(--theme-text-secondary);
|
||||||
margin-bottom: 24rpx;
|
font-size: 28rpx;
|
||||||
font-size: 32rpx;
|
}
|
||||||
font-weight: bold;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.media-grid {
|
&.action {
|
||||||
gap: 24rpx;
|
gap: 24rpx;
|
||||||
display: grid;
|
display: flex;
|
||||||
grid-template-columns: repeat(3, 1fr);
|
padding: 24rpx 16rpx 48rpx 16rpx;
|
||||||
|
|
||||||
.media-item {
|
.delete {
|
||||||
width: 100%;
|
flex: .6;
|
||||||
height: 200rpx;
|
|
||||||
overflow: hidden;
|
|
||||||
position: relative;
|
|
||||||
border-radius: 12rpx;
|
|
||||||
|
|
||||||
.media-img {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.video-badge {
|
|
||||||
top: 50%;
|
|
||||||
left: 50%;
|
|
||||||
display: flex;
|
|
||||||
position: absolute;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.media-delete {
|
|
||||||
top: 8rpx;
|
|
||||||
right: 8rpx;
|
|
||||||
width: 48rpx;
|
|
||||||
height: 48rpx;
|
|
||||||
display: flex;
|
|
||||||
position: absolute;
|
|
||||||
background: rgba(0, 0, 0, .5);
|
|
||||||
align-items: center;
|
|
||||||
border-radius: 50%;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.media-add {
|
.submit {
|
||||||
width: 100%;
|
flex: 1;
|
||||||
height: 200rpx;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
border-radius: 12rpx;
|
|
||||||
justify-content: center;
|
|
||||||
background: var(--theme-bg-page);
|
|
||||||
border: 2rpx dashed var(--theme-border);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
.upload-info {
|
}
|
||||||
gap: 16rpx;
|
|
||||||
display: flex;
|
.delete-dialog {
|
||||||
padding: 24rpx 32rpx;
|
padding: 16rpx 0;
|
||||||
margin-top: 24rpx;
|
|
||||||
align-items: center;
|
.tips {
|
||||||
border-radius: 12rpx;
|
color: var(--theme-text-secondary);
|
||||||
background: var(--theme-bg-card);
|
font-size: 28rpx;
|
||||||
|
line-height: 1.5;
|
||||||
.upload-text {
|
margin-bottom: 24rpx;
|
||||||
color: var(--theme-text-secondary);
|
|
||||||
font-size: 28rpx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.submit-section {
|
|
||||||
gap: 24rpx;
|
|
||||||
display: flex;
|
|
||||||
padding: 24rpx 16rpx 48rpx 16rpx;
|
|
||||||
margin-top: 64rpx;
|
|
||||||
|
|
||||||
.delete-btn {
|
|
||||||
flex: .6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.submit-btn {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,17 +2,17 @@
|
|||||||
|
|
||||||
import { Network, WechatMediaItem } from "../../../utils/Network";
|
import { Network, WechatMediaItem } from "../../../utils/Network";
|
||||||
import { TravelLocationApi } from "../../../api/TravelLocationApi";
|
import { TravelLocationApi } from "../../../api/TravelLocationApi";
|
||||||
import { TravelLocationType } from "../../../types/Travel";
|
import { TravelLocationType, TravelLocationTypeLabel } from "../../../types/Travel";
|
||||||
import { MediaAttachExt, MediaAttachType } from "../../../types/Attachment";
|
import { MediaAttachType, PreviewImageMetadata } from "../../../types/Attachment";
|
||||||
import config from "../../../config/index";
|
import config from "../../../config/index";
|
||||||
import { MediaItem, MediaItemType } from "../../../types/UI";
|
import { MediaItem, MediaItemType } from "../../../types/UI";
|
||||||
|
|
||||||
interface TravelLocationEditorData {
|
interface TravelLocationEditorData {
|
||||||
/** 模式:create 或 edit */
|
/** 模式:create 或 edit */
|
||||||
mode: "create" | "edit";
|
mode: "create" | "edit";
|
||||||
/** 旅行地点 ID(编辑模式) */
|
/** 出行地点 ID(编辑模式) */
|
||||||
id?: number;
|
id?: number;
|
||||||
/** 关联的旅行计划 ID */
|
/** 关联的出行计划 ID */
|
||||||
travelId: number;
|
travelId: number;
|
||||||
/** 地点类型 */
|
/** 地点类型 */
|
||||||
type: TravelLocationType;
|
type: TravelLocationType;
|
||||||
@ -30,8 +30,16 @@ interface TravelLocationEditorData {
|
|||||||
amount: number;
|
amount: number;
|
||||||
/** 是否需要身份证 */
|
/** 是否需要身份证 */
|
||||||
requireIdCard: boolean;
|
requireIdCard: boolean;
|
||||||
/** 必要评分 */
|
/** 是否需要预约 */
|
||||||
|
requireAppointment: boolean;
|
||||||
|
/** 评分 */
|
||||||
score: number;
|
score: number;
|
||||||
|
/** 评分是否未定 */
|
||||||
|
scoreUndecided: boolean;
|
||||||
|
/** 重要程度 */
|
||||||
|
importance: number;
|
||||||
|
/** 重要程度是否未定 */
|
||||||
|
importanceUndecided: boolean;
|
||||||
/** 媒体列表(创建和编辑模式使用) */
|
/** 媒体列表(创建和编辑模式使用) */
|
||||||
mediaList: (MediaItem | WechatMediaItem)[];
|
mediaList: (MediaItem | WechatMediaItem)[];
|
||||||
/** 新媒体列表(编辑模式使用) */
|
/** 新媒体列表(编辑模式使用) */
|
||||||
@ -45,9 +53,15 @@ interface TravelLocationEditorData {
|
|||||||
/** 上传进度信息 */
|
/** 上传进度信息 */
|
||||||
uploadInfo: string;
|
uploadInfo: string;
|
||||||
/** 地点类型选项 */
|
/** 地点类型选项 */
|
||||||
locationTypes: { label: string; value: TravelLocationType }[];
|
locationTypes: string[];
|
||||||
|
/** 地点类型值数组 */
|
||||||
|
locationTypeValues: TravelLocationType[];
|
||||||
/** 地点类型选中索引 */
|
/** 地点类型选中索引 */
|
||||||
locationTypeIndex: number;
|
locationTypeIndex: number;
|
||||||
|
/** 删除对话框可见性 */
|
||||||
|
deleteDialogVisible: boolean;
|
||||||
|
/** 删除确认文本 */
|
||||||
|
deleteConfirmText: string;
|
||||||
/** 媒体类型枚举 */
|
/** 媒体类型枚举 */
|
||||||
mediaItemTypeEnum: any;
|
mediaItemTypeEnum: any;
|
||||||
}
|
}
|
||||||
@ -57,7 +71,7 @@ Page({
|
|||||||
mode: "create",
|
mode: "create",
|
||||||
id: undefined,
|
id: undefined,
|
||||||
travelId: 0,
|
travelId: 0,
|
||||||
type: TravelLocationType.ATTRACTION,
|
type: TravelLocationType.FOOD,
|
||||||
title: "",
|
title: "",
|
||||||
description: "",
|
description: "",
|
||||||
location: "",
|
location: "",
|
||||||
@ -65,7 +79,11 @@ Page({
|
|||||||
lng: 0,
|
lng: 0,
|
||||||
amount: 0,
|
amount: 0,
|
||||||
requireIdCard: false,
|
requireIdCard: false,
|
||||||
|
requireAppointment: false,
|
||||||
score: 3,
|
score: 3,
|
||||||
|
scoreUndecided: true,
|
||||||
|
importance: 1,
|
||||||
|
importanceUndecided: true,
|
||||||
mediaList: [],
|
mediaList: [],
|
||||||
newMediaList: [],
|
newMediaList: [],
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
@ -75,15 +93,19 @@ Page({
|
|||||||
mediaItemTypeEnum: {
|
mediaItemTypeEnum: {
|
||||||
...MediaItemType
|
...MediaItemType
|
||||||
},
|
},
|
||||||
locationTypes: [
|
locationTypes: Object.values(TravelLocationTypeLabel),
|
||||||
{ label: "景点", value: TravelLocationType.ATTRACTION },
|
locationTypeValues: [
|
||||||
{ label: "酒店", value: TravelLocationType.HOTEL },
|
TravelLocationType.FOOD,
|
||||||
{ label: "餐厅", value: TravelLocationType.RESTAURANT },
|
TravelLocationType.HOTEL,
|
||||||
{ label: "交通站点", value: TravelLocationType.TRANSPORT },
|
TravelLocationType.TRANSPORT,
|
||||||
{ label: "购物", value: TravelLocationType.SHOPPING },
|
TravelLocationType.ATTRACTION,
|
||||||
{ label: "其他", value: TravelLocationType.OTHER }
|
TravelLocationType.SHOPPING,
|
||||||
|
TravelLocationType.PLAY,
|
||||||
|
TravelLocationType.LIFE
|
||||||
],
|
],
|
||||||
locationTypeIndex: 0
|
locationTypeIndex: 0,
|
||||||
|
deleteDialogVisible: false,
|
||||||
|
deleteConfirmText: ""
|
||||||
},
|
},
|
||||||
|
|
||||||
onLoad(options: any) {
|
onLoad(options: any) {
|
||||||
@ -91,7 +113,7 @@ Page({
|
|||||||
const travelId = options.travelId ? parseInt(options.travelId) : 0;
|
const travelId = options.travelId ? parseInt(options.travelId) : 0;
|
||||||
if (!travelId) {
|
if (!travelId) {
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
title: "缺少旅行计划 ID",
|
title: "缺少出行计划 ID",
|
||||||
icon: "error"
|
icon: "error"
|
||||||
});
|
});
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -131,19 +153,20 @@ Page({
|
|||||||
|
|
||||||
// 计算地点类型索引
|
// 计算地点类型索引
|
||||||
const type = location.type || TravelLocationType.ATTRACTION;
|
const type = location.type || TravelLocationType.ATTRACTION;
|
||||||
const locationTypeIndex = this.data.locationTypes.findIndex(
|
const locationTypeIndex = this.data.locationTypeValues.findIndex(
|
||||||
item => item.value === type
|
item => item === type
|
||||||
);
|
);
|
||||||
|
|
||||||
const items = location.items || [];
|
const items = location.items || [];
|
||||||
const thumbItems = items.filter((item) => item.attachType === MediaAttachType.THUMB);
|
const thumbItems = items.filter((item) => item.attachType === MediaAttachType.THUMB);
|
||||||
|
|
||||||
const mediaList: MediaItem[] = thumbItems.map((thumbItem) => {
|
const mediaList: MediaItem[] = thumbItems.map((thumbItem) => {
|
||||||
const ext = thumbItem.ext = JSON.parse(thumbItem.ext!.toString()) as MediaAttachExt;
|
const metadata = (typeof thumbItem.metadata === "string" ? JSON.parse(thumbItem.metadata) : thumbItem.metadata) as PreviewImageMetadata;
|
||||||
const thumbURL = `${config.url}/attachment/read/${thumbItem.mongoId}`;
|
const thumbURL = `${config.url}/attachment/read/${thumbItem.mongoId}`;
|
||||||
const sourceURL = `${config.url}/attachment/read/${ext.sourceMongoId}`;
|
const sourceURL = `${config.url}/attachment/read/${metadata.sourceMongoId}`;
|
||||||
|
const isVideo = metadata.sourceMimeType?.startsWith("video/");
|
||||||
return {
|
return {
|
||||||
type: ext.isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
|
type: isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
|
||||||
thumbURL,
|
thumbURL,
|
||||||
sourceURL,
|
sourceURL,
|
||||||
size: thumbItem.size || 0,
|
size: thumbItem.size || 0,
|
||||||
@ -151,6 +174,14 @@ Page({
|
|||||||
} as MediaItem;
|
} as MediaItem;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 判断评分是否未定
|
||||||
|
const scoreUndecided = location.score === null || location.score === undefined;
|
||||||
|
const score = location.score !== null && location.score !== undefined ? location.score : 3;
|
||||||
|
|
||||||
|
// 判断重要程度是否未定
|
||||||
|
const importanceUndecided = location.importance === null || location.importance === undefined;
|
||||||
|
const importance = location.importance !== null && location.importance !== undefined ? location.importance : 1;
|
||||||
|
|
||||||
this.setData({
|
this.setData({
|
||||||
type,
|
type,
|
||||||
locationTypeIndex: locationTypeIndex >= 0 ? locationTypeIndex : 0,
|
locationTypeIndex: locationTypeIndex >= 0 ? locationTypeIndex : 0,
|
||||||
@ -161,7 +192,11 @@ Page({
|
|||||||
lng: location.lng || 0,
|
lng: location.lng || 0,
|
||||||
amount: location.amount || 0,
|
amount: location.amount || 0,
|
||||||
requireIdCard: location.requireIdCard || false,
|
requireIdCard: location.requireIdCard || false,
|
||||||
score: location.score !== undefined ? location.score : 3,
|
requireAppointment: location.requireAppointment || false,
|
||||||
|
score,
|
||||||
|
scoreUndecided,
|
||||||
|
importance,
|
||||||
|
importanceUndecided,
|
||||||
mediaList,
|
mediaList,
|
||||||
isLoading: false
|
isLoading: false
|
||||||
});
|
});
|
||||||
@ -183,7 +218,7 @@ Page({
|
|||||||
const index = e.detail.value;
|
const index = e.detail.value;
|
||||||
this.setData({
|
this.setData({
|
||||||
locationTypeIndex: index,
|
locationTypeIndex: index,
|
||||||
type: this.data.locationTypes[index].value
|
type: this.data.locationTypeValues[index]
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -192,16 +227,52 @@ Page({
|
|||||||
this.setData({ requireIdCard: e.detail.value });
|
this.setData({ requireIdCard: e.detail.value });
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** 改变是否需要预约 */
|
||||||
|
onChangeRequireAppointment(e: any) {
|
||||||
|
this.setData({ requireAppointment: e.detail.value });
|
||||||
|
},
|
||||||
|
|
||||||
/** 改变评分 */
|
/** 改变评分 */
|
||||||
onChangeScore(e: any) {
|
onChangeScore(e: any) {
|
||||||
this.setData({ score: e.detail.value });
|
this.setData({ score: e.detail.value });
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** 改变重要程度 */
|
||||||
|
onChangeImportance(e: any) {
|
||||||
|
this.setData({ importance: e.detail.value });
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 清除评分 */
|
||||||
|
clearScore() {
|
||||||
|
this.setData({ scoreUndecided: true });
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 清除重要程度 */
|
||||||
|
clearImportance() {
|
||||||
|
this.setData({ importanceUndecided: true });
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 点击未定文字选择评分 */
|
||||||
|
selectScore() {
|
||||||
|
this.setData({
|
||||||
|
scoreUndecided: false,
|
||||||
|
score: 3
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 点击未定文字选择重要程度 */
|
||||||
|
selectImportance() {
|
||||||
|
this.setData({
|
||||||
|
importanceUndecided: false,
|
||||||
|
importance: 1
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
/** 选择位置 */
|
/** 选择位置 */
|
||||||
chooseLocation() {
|
chooseLocation() {
|
||||||
wx.chooseLocation({
|
wx.chooseLocation({
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
const locationName = res.address || res.name;
|
const locationName = res.name || res.address;
|
||||||
const updateData: any = {
|
const updateData: any = {
|
||||||
location: locationName,
|
location: locationName,
|
||||||
lat: res.latitude,
|
lat: res.latitude,
|
||||||
@ -296,7 +367,7 @@ Page({
|
|||||||
// 创建模式:只有 mediaList
|
// 创建模式:只有 mediaList
|
||||||
const sources = (this.data.mediaList as WechatMediaItem[]).map(item => ({
|
const sources = (this.data.mediaList as WechatMediaItem[]).map(item => ({
|
||||||
url: item.path,
|
url: item.path,
|
||||||
type: MediaItemType[item.type].toLowerCase()
|
type: item.type!.toLowerCase()
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const total = sources.length;
|
const total = sources.length;
|
||||||
@ -312,11 +383,11 @@ Page({
|
|||||||
// 编辑模式:mediaList + newMediaList
|
// 编辑模式:mediaList + newMediaList
|
||||||
const sources = (this.data.mediaList as MediaItem[]).map(item => ({
|
const sources = (this.data.mediaList as MediaItem[]).map(item => ({
|
||||||
url: item.sourceURL,
|
url: item.sourceURL,
|
||||||
type: MediaItemType[item.type].toLowerCase()
|
type: item.type.toLowerCase()
|
||||||
}));
|
}));
|
||||||
const newSources = this.data.newMediaList.map(item => ({
|
const newSources = this.data.newMediaList.map(item => ({
|
||||||
url: item.path,
|
url: item.path,
|
||||||
type: MediaItemType[item.type].toLowerCase()
|
type: item.type!.toLowerCase()
|
||||||
}));
|
}));
|
||||||
const allSources = [...sources, ...newSources];
|
const allSources = [...sources, ...newSources];
|
||||||
const itemIndex = isNewMedia ? this.data.mediaList.length + index : index;
|
const itemIndex = isNewMedia ? this.data.mediaList.length + index : index;
|
||||||
@ -340,31 +411,60 @@ Page({
|
|||||||
|
|
||||||
/** 删除地点 */
|
/** 删除地点 */
|
||||||
deleteLocation() {
|
deleteLocation() {
|
||||||
wx.showModal({
|
this.setData({
|
||||||
title: "确认删除",
|
deleteDialogVisible: true,
|
||||||
content: "确定要删除这个地点吗?删除后无法恢复。",
|
deleteConfirmText: ""
|
||||||
success: async (res) => {
|
|
||||||
if (res.confirm && this.data.id) {
|
|
||||||
try {
|
|
||||||
await TravelLocationApi.delete(this.data.id);
|
|
||||||
wx.showToast({
|
|
||||||
title: "删除成功",
|
|
||||||
icon: "success"
|
|
||||||
});
|
|
||||||
setTimeout(() => {
|
|
||||||
wx.navigateBack();
|
|
||||||
}, 1000);
|
|
||||||
} catch (error) {
|
|
||||||
wx.showToast({
|
|
||||||
title: "删除失败",
|
|
||||||
icon: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** 取消删除 */
|
||||||
|
cancelDelete() {
|
||||||
|
this.setData({
|
||||||
|
deleteDialogVisible: false,
|
||||||
|
deleteConfirmText: ""
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 确认删除 */
|
||||||
|
confirmDelete() {
|
||||||
|
const inputText = this.data.deleteConfirmText.trim();
|
||||||
|
if (inputText !== "确认删除") {
|
||||||
|
wx.showToast({
|
||||||
|
title: "输入不匹配",
|
||||||
|
icon: "error"
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.setData({
|
||||||
|
deleteDialogVisible: false
|
||||||
|
});
|
||||||
|
this.executeDelete();
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 执行删除 */
|
||||||
|
async executeDelete() {
|
||||||
|
if (!this.data.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wx.showLoading({ title: "删除中...", mask: true });
|
||||||
|
|
||||||
|
try {
|
||||||
|
await TravelLocationApi.delete(this.data.id);
|
||||||
|
wx.showToast({
|
||||||
|
title: "删除成功",
|
||||||
|
icon: "success"
|
||||||
|
});
|
||||||
|
setTimeout(() => {
|
||||||
|
wx.navigateBack();
|
||||||
|
}, 1500);
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已由 Network 类处理
|
||||||
|
} finally {
|
||||||
|
wx.hideLoading();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/** 提交/保存 */
|
/** 提交/保存 */
|
||||||
submit() {
|
submit() {
|
||||||
// 验证必填字段
|
// 验证必填字段
|
||||||
@ -425,7 +525,9 @@ Page({
|
|||||||
lng: this.data.lng,
|
lng: this.data.lng,
|
||||||
amount: this.data.amount,
|
amount: this.data.amount,
|
||||||
requireIdCard: this.data.requireIdCard,
|
requireIdCard: this.data.requireIdCard,
|
||||||
score: this.data.score,
|
requireAppointment: this.data.requireAppointment,
|
||||||
|
score: this.data.scoreUndecided ? null : this.data.score,
|
||||||
|
importance: this.data.importanceUndecided ? null : this.data.importance,
|
||||||
tempFileIds
|
tempFileIds
|
||||||
});
|
});
|
||||||
wx.showToast({
|
wx.showToast({
|
||||||
@ -479,7 +581,9 @@ Page({
|
|||||||
lng: this.data.lng,
|
lng: this.data.lng,
|
||||||
amount: this.data.amount,
|
amount: this.data.amount,
|
||||||
requireIdCard: this.data.requireIdCard,
|
requireIdCard: this.data.requireIdCard,
|
||||||
score: this.data.score,
|
requireAppointment: this.data.requireAppointment,
|
||||||
|
score: this.data.scoreUndecided ? null : this.data.score,
|
||||||
|
importance: this.data.importanceUndecided ? null : this.data.importance,
|
||||||
attachmentIds,
|
attachmentIds,
|
||||||
tempFileIds
|
tempFileIds
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,42 +3,27 @@
|
|||||||
<text slot="left" bindtap="cancel">取消</text>
|
<text slot="left" bindtap="cancel">取消</text>
|
||||||
</t-navbar>
|
</t-navbar>
|
||||||
|
|
||||||
<scroll-view class="container" type="custom" scroll-y show-scrollbar="{{false}}">
|
<scroll-view class="travel-location-editor setting-bg" type="custom" scroll-y show-scrollbar="{{false}}">
|
||||||
<view class="content">
|
<view class="content">
|
||||||
<view wx:if="{{isLoading}}" class="loading">
|
<view wx:if="{{isLoading}}" class="loading">
|
||||||
<t-loading theme="dots" size="40rpx" />
|
<t-loading theme="dots" size="40rpx" />
|
||||||
<text class="loading-text">加载中...</text>
|
<text class="text">加载中...</text>
|
||||||
</view>
|
</view>
|
||||||
<block wx:else>
|
<block wx:else>
|
||||||
<t-cell-group class="section">
|
<t-cell-group class="section location">
|
||||||
<t-cell title="地点类型">
|
<view slot="title" class="title">位置信息</view>
|
||||||
<view slot="right-icon">
|
<picker mode="selector" range="{{locationTypes}}" value="{{locationTypeIndex}}" bindchange="onChangeLocationType">
|
||||||
<picker
|
<t-cell title="地点类型" arrow>
|
||||||
class="picker"
|
<view slot="note" class="note">{{locationTypes[locationTypeIndex]}}</view>
|
||||||
mode="selector"
|
</t-cell>
|
||||||
range="{{locationTypes}}"
|
</picker>
|
||||||
range-key="label"
|
<t-cell class="value" required arrow bind:click="chooseLocation">
|
||||||
value="{{locationTypeIndex}}"
|
<view slot="title" class="title">位置</view>
|
||||||
bindchange="onChangeLocationType"
|
<view slot="note" class="note">{{location}}</view>
|
||||||
>
|
|
||||||
<view class="slot">
|
|
||||||
<text>{{locationTypes[locationTypeIndex].label}}</text>
|
|
||||||
<t-icon name="chevron-right" size="20px" class="icon" />
|
|
||||||
</view>
|
|
||||||
</picker>
|
|
||||||
</view>
|
|
||||||
</t-cell>
|
|
||||||
<t-cell title="位置" required bind:click="chooseLocation">
|
|
||||||
<view slot="right-icon">
|
|
||||||
<view class="location-slot">
|
|
||||||
<text wx:if="{{location}}" class="location-text">{{location}}</text>
|
|
||||||
<text wx:else class="location-placeholder">点击选择位置</text>
|
|
||||||
<t-icon name="chevron-right" size="20px" class="icon" />
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</t-cell>
|
</t-cell>
|
||||||
</t-cell-group>
|
</t-cell-group>
|
||||||
<t-cell-group class="section">
|
<t-cell-group class="section">
|
||||||
|
<view slot="title" class="title">基本信息</view>
|
||||||
<t-input
|
<t-input
|
||||||
class="input"
|
class="input"
|
||||||
placeholder="请输入地点名称"
|
placeholder="请输入地点名称"
|
||||||
@ -57,86 +42,117 @@
|
|||||||
</t-textarea>
|
</t-textarea>
|
||||||
</t-cell-group>
|
</t-cell-group>
|
||||||
<t-cell-group class="section">
|
<t-cell-group class="section">
|
||||||
|
<view slot="title" class="title">详细信息</view>
|
||||||
<t-input
|
<t-input
|
||||||
model:value="{{amount}}"
|
model:value="{{amount}}"
|
||||||
placeholder="0"
|
placeholder="0"
|
||||||
label="费用"
|
label="费用"
|
||||||
suffix="元"
|
suffix="元"
|
||||||
|
type="digit"
|
||||||
align="right"
|
align="right"
|
||||||
/>
|
/>
|
||||||
<t-cell title="必要评分">
|
|
||||||
<view slot="right-icon">
|
|
||||||
<t-rate
|
|
||||||
value="{{score}}"
|
|
||||||
count="{{5}}"
|
|
||||||
size="24px"
|
|
||||||
bind:change="onChangeScore"
|
|
||||||
/>
|
|
||||||
</view>
|
|
||||||
</t-cell>
|
|
||||||
<t-cell title="需要身份证">
|
<t-cell title="需要身份证">
|
||||||
<view slot="right-icon">
|
<view slot="right-icon">
|
||||||
<switch checked="{{requireIdCard}}" bindchange="onChangeRequireIdCard" />
|
<switch checked="{{requireIdCard}}" bindchange="onChangeRequireIdCard" />
|
||||||
</view>
|
</view>
|
||||||
</t-cell>
|
</t-cell>
|
||||||
|
<t-cell title="需要预约">
|
||||||
|
<view slot="right-icon">
|
||||||
|
<switch checked="{{requireAppointment}}" bindchange="onChangeRequireAppointment" />
|
||||||
|
</view>
|
||||||
|
</t-cell>
|
||||||
|
<t-cell title="重要程度" class="rate-cell importance {{importanceUndecided ? 'undecided' : 'decided'}}">
|
||||||
|
<view slot="note">
|
||||||
|
<view class="rate">
|
||||||
|
<t-rate
|
||||||
|
value="{{importance}}"
|
||||||
|
count="{{5}}"
|
||||||
|
size="20px"
|
||||||
|
bind:change="onChangeImportance"
|
||||||
|
/>
|
||||||
|
<t-icon
|
||||||
|
name="close-circle-filled"
|
||||||
|
size="20px"
|
||||||
|
class="clear-icon"
|
||||||
|
bindtap="clearImportance"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<view class="text" bindtap="selectImportance">
|
||||||
|
未定
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</t-cell>
|
||||||
|
<t-cell title="评分" class="rate-cell score {{scoreUndecided ? 'undecided' : 'decided'}}">
|
||||||
|
<view slot="note">
|
||||||
|
<view class="rate">
|
||||||
|
<t-rate
|
||||||
|
value="{{score}}"
|
||||||
|
count="{{5}}"
|
||||||
|
size="20px"
|
||||||
|
bind:change="onChangeScore"
|
||||||
|
/>
|
||||||
|
<t-icon
|
||||||
|
name="close-circle-filled"
|
||||||
|
size="20px"
|
||||||
|
class="clear-icon"
|
||||||
|
bindtap="clearScore"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<view class="text" bindtap="selectScore">
|
||||||
|
未定
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</t-cell>
|
||||||
</t-cell-group>
|
</t-cell-group>
|
||||||
<view class="section media">
|
<t-cell-group class="section media">
|
||||||
<view class="gallery">
|
<view slot="title" class="title">图片视频</view>
|
||||||
<!-- 创建模式:mediaList 显示新选择的媒体 -->
|
<t-cell>
|
||||||
<block wx:if="{{mode === 'create'}}">
|
<view slot="title" class="gallery">
|
||||||
<block wx:for="{{mediaList}}" wx:key="index">
|
<!-- 创建模式:mediaList 显示新选择的媒体 -->
|
||||||
<view class="item">
|
<block wx:if="{{mode === 'create'}}">
|
||||||
<!-- 图片 -->
|
<block wx:for="{{mediaList}}" wx:key="index">
|
||||||
<image
|
<view class="item">
|
||||||
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
|
<image
|
||||||
src="{{item.thumbPath}}"
|
wx:if="{{item.type === mediaItemTypeEnum.IMAGE}}"
|
||||||
|
src="{{item.path}}"
|
||||||
class="thumbnail"
|
class="thumbnail"
|
||||||
mode="aspectFill"
|
mode="aspectFill"
|
||||||
bindtap="preview"
|
bindtap="preview"
|
||||||
data-index="{{index}}"
|
data-index="{{index}}"
|
||||||
data-new-media="{{true}}"
|
data-new-media="{{true}}"
|
||||||
></image>
|
></image>
|
||||||
<t-icon class="play-icon" name="play" />
|
<!-- 视频 -->
|
||||||
|
<view wx:if="{{item.type === mediaItemTypeEnum.VIDEO}}" class="video-container">
|
||||||
|
<image
|
||||||
|
src="{{item.thumbPath}}"
|
||||||
|
class="thumbnail"
|
||||||
|
mode="aspectFill"
|
||||||
|
bindtap="preview"
|
||||||
|
data-index="{{index}}"
|
||||||
|
data-new-media="{{true}}"
|
||||||
|
></image>
|
||||||
|
<t-icon class="play-icon" name="play" />
|
||||||
|
</view>
|
||||||
|
<!-- 删除 -->
|
||||||
|
<t-icon
|
||||||
|
class="delete"
|
||||||
|
name="close"
|
||||||
|
bindtap="deleteMedia"
|
||||||
|
data-index="{{index}}"
|
||||||
|
data-new-media="{{true}}"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
<!-- 删除 -->
|
</block>
|
||||||
<t-icon
|
|
||||||
class="delete"
|
|
||||||
name="close"
|
|
||||||
bindtap="deleteMedia"
|
|
||||||
data-index="{{index}}"
|
|
||||||
data-new-media="{{true}}"
|
|
||||||
/>
|
|
||||||
</view>
|
|
||||||
</block>
|
</block>
|
||||||
</block>
|
<!-- 编辑模式:mediaList 显示现有附件,newMediaList 显示新添加的附件 -->
|
||||||
<!-- 编辑模式:mediaList 显示现有附件,newMediaList 显示新添加的附件 -->
|
<block wx:else>
|
||||||
<block wx:else>
|
<!-- 现有附件 -->
|
||||||
<!-- 现有附件 -->
|
<block wx:for="{{mediaList}}" wx:key="attachmentId">
|
||||||
<block wx:for="{{mediaList}}" wx:key="attachmentId">
|
<view class="item">
|
||||||
<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
|
<image
|
||||||
|
wx:if="{{item.type === mediaItemTypeEnum.IMAGE}}"
|
||||||
src="{{item.thumbURL}}"
|
src="{{item.thumbURL}}"
|
||||||
class="thumbnail"
|
class="thumbnail"
|
||||||
mode="aspectFill"
|
mode="aspectFill"
|
||||||
@ -144,80 +160,91 @@
|
|||||||
data-index="{{index}}"
|
data-index="{{index}}"
|
||||||
data-new-media="{{false}}"
|
data-new-media="{{false}}"
|
||||||
></image>
|
></image>
|
||||||
<t-icon class="play-icon" name="play" />
|
<!-- 视频 -->
|
||||||
|
<view wx:if="{{item.type === mediaItemTypeEnum.VIDEO}}" class="video-container">
|
||||||
|
<image
|
||||||
|
src="{{item.thumbURL}}"
|
||||||
|
class="thumbnail"
|
||||||
|
mode="aspectFill"
|
||||||
|
bindtap="preview"
|
||||||
|
data-index="{{index}}"
|
||||||
|
data-new-media="{{false}}"
|
||||||
|
></image>
|
||||||
|
<t-icon class="play-icon" name="play" />
|
||||||
|
</view>
|
||||||
|
<!-- 删除 -->
|
||||||
|
<t-icon
|
||||||
|
class="delete"
|
||||||
|
name="close"
|
||||||
|
bindtap="deleteMedia"
|
||||||
|
data-index="{{index}}"
|
||||||
|
data-new-media="{{false}}"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
<!-- 删除 -->
|
</block>
|
||||||
<t-icon
|
<!-- 新选择附件 -->
|
||||||
class="delete"
|
<block wx:for="{{newMediaList}}" wx:key="index">
|
||||||
name="close"
|
<view class="item new-item">
|
||||||
bindtap="deleteMedia"
|
<!-- 图片 -->
|
||||||
data-index="{{index}}"
|
|
||||||
data-new-media="{{false}}"
|
|
||||||
/>
|
|
||||||
</view>
|
|
||||||
</block>
|
|
||||||
<!-- 新选择附件 -->
|
|
||||||
<block wx:for="{{newMediaList}}" wx:key="index">
|
|
||||||
<view class="item new-item">
|
|
||||||
<!-- 图片 -->
|
|
||||||
<image
|
|
||||||
wx:if="{{item.type === mediaItemTypeEnum.IMAGE}}"
|
|
||||||
src="{{item.path}}"
|
|
||||||
class="thumbnail"
|
|
||||||
mode="aspectFill"
|
|
||||||
bindtap="preview"
|
|
||||||
data-index="{{index}}"
|
|
||||||
data-new-media="{{true}}"
|
|
||||||
></image>
|
|
||||||
<!-- 视频 -->
|
|
||||||
<view wx:if="{{item.type === mediaItemTypeEnum.VIDEO}}" class="video-container">
|
|
||||||
<image
|
<image
|
||||||
src="{{item.thumbPath}}"
|
wx:if="{{item.type === mediaItemTypeEnum.IMAGE}}"
|
||||||
|
src="{{item.path}}"
|
||||||
class="thumbnail"
|
class="thumbnail"
|
||||||
mode="aspectFill"
|
mode="aspectFill"
|
||||||
bindtap="preview"
|
bindtap="preview"
|
||||||
data-index="{{index}}"
|
data-index="{{index}}"
|
||||||
data-new-media="{{true}}"
|
data-new-media="{{true}}"
|
||||||
></image>
|
></image>
|
||||||
<t-icon class="play-icon" name="play" />
|
<!-- 视频 -->
|
||||||
|
<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="deleteNewMedia"
|
||||||
|
data-index="{{index}}"
|
||||||
|
data-new-media="{{true}}"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
<!-- 新增标识 -->
|
</block>
|
||||||
<t-icon class="new-badge" name="add" />
|
|
||||||
<!-- 删除 -->
|
|
||||||
<t-icon
|
|
||||||
class="delete"
|
|
||||||
name="close"
|
|
||||||
bindtap="deleteMedia"
|
|
||||||
data-index="{{index}}"
|
|
||||||
data-new-media="{{true}}"
|
|
||||||
/>
|
|
||||||
</view>
|
|
||||||
</block>
|
</block>
|
||||||
</block>
|
<!-- 添加按钮 -->
|
||||||
<!-- 添加按钮 -->
|
<t-button
|
||||||
<t-button
|
class="item add"
|
||||||
class="item add"
|
theme="primary"
|
||||||
theme="primary"
|
plain="true"
|
||||||
plain="true"
|
disabled="{{isSaving}}"
|
||||||
disabled="{{isSaving}}"
|
bind:tap="addMedia"
|
||||||
bind:tap="addMedia"
|
>
|
||||||
>
|
<t-icon name="add" />
|
||||||
<t-icon name="add" />
|
</t-button>
|
||||||
</t-button>
|
</view>
|
||||||
</view>
|
</t-cell>
|
||||||
</view>
|
</t-cell-group>
|
||||||
|
|
||||||
<!-- 上传进度提示 -->
|
<!-- 上传进度提示 -->
|
||||||
<view wx:if="{{isUploading}}" class="upload-info">
|
<view wx:if="{{isUploading}}" class="section upload">
|
||||||
<t-loading theme="circular" size="32rpx" />
|
<t-loading theme="circular" size="32rpx" />
|
||||||
<text class="upload-text">{{uploadInfo}}</text>
|
<text class="text">{{uploadInfo}}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 按钮 -->
|
<!-- 按钮 -->
|
||||||
<view class="submit-section">
|
<view class="section action">
|
||||||
<t-button
|
<t-button
|
||||||
wx:if="{{mode === 'edit'}}"
|
wx:if="{{mode === 'edit'}}"
|
||||||
class="delete-btn"
|
class="delete"
|
||||||
theme="danger"
|
theme="danger"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
size="large"
|
size="large"
|
||||||
@ -227,7 +254,7 @@
|
|||||||
删除
|
删除
|
||||||
</t-button>
|
</t-button>
|
||||||
<t-button
|
<t-button
|
||||||
class="submit-btn"
|
class="submit"
|
||||||
theme="primary"
|
theme="primary"
|
||||||
size="large"
|
size="large"
|
||||||
bind:tap="submit"
|
bind:tap="submit"
|
||||||
@ -240,3 +267,22 @@
|
|||||||
</block>
|
</block>
|
||||||
</view>
|
</view>
|
||||||
</scroll-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 placeholder="请输入:确认删除" model:value="{{deleteConfirmText}}" />
|
||||||
|
</view>
|
||||||
|
</t-dialog>
|
||||||
|
|||||||
@ -8,46 +8,40 @@
|
|||||||
.map {
|
.map {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
|
||||||
|
|
||||||
.custom-callout {
|
.marker {
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
padding: 12rpx 16rpx;
|
|
||||||
display: flex;
|
|
||||||
min-width: 300rpx;
|
|
||||||
max-width: 400rpx;
|
|
||||||
background: #fff;
|
|
||||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, .15);
|
|
||||||
border-radius: 6rpx;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
.location-item {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 6rpx 0;
|
background: var(--theme-bg-card);
|
||||||
align-items: center;
|
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, .15);
|
||||||
|
border-radius: 6rpx;
|
||||||
&:not(:last-child) {
|
flex-direction: column;
|
||||||
border-bottom: 1px solid #eee;
|
|
||||||
}
|
.location {
|
||||||
|
display: flex;
|
||||||
.type {
|
padding: 8rpx 16rpx 8rpx 8rpx;
|
||||||
color: #fff;
|
align-items: center;
|
||||||
padding: 2rpx 8rpx;
|
|
||||||
font-size: 24rpx;
|
.type {
|
||||||
flex-shrink: 0;
|
color: #fff;
|
||||||
background: var(--theme-wx, #07c160);
|
padding: 4rpx 12rpx 6rpx 12rpx;
|
||||||
margin-right: 12rpx;
|
font-size: 28rpx;
|
||||||
border-radius: 4rpx;
|
flex-shrink: 0;
|
||||||
}
|
background: var(--theme-wx, #07c160);
|
||||||
|
margin-right: 12rpx;
|
||||||
.title {
|
border-radius: 4rpx;
|
||||||
flex: 1;
|
}
|
||||||
color: #333;
|
|
||||||
overflow: hidden;
|
.title {
|
||||||
font-size: 28rpx;
|
flex: 1;
|
||||||
font-weight: bold;
|
width: calc(var(--title-length) * 28rpx);
|
||||||
white-space: nowrap;
|
color: var(--theme-text-primary, #333);
|
||||||
text-overflow: ellipsis;
|
overflow: hidden;
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,9 +54,9 @@
|
|||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
|
|
||||||
.loading-text {
|
.loading-text {
|
||||||
color: #666;
|
color: var(--theme-text-secondary, #666);
|
||||||
padding: 24rpx 48rpx;
|
padding: 24rpx 48rpx;
|
||||||
background: #FFF;
|
background: var(--theme-bg-card, #fff);
|
||||||
border-radius: 8rpx;
|
border-radius: 8rpx;
|
||||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, .15);
|
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, .15);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { TravelLocationApi } from "../../../api/TravelLocationApi";
|
import { TravelLocationApi } from "../../../api/TravelLocationApi";
|
||||||
import { TravelLocation, TravelLocationTypeLabel } from "../../../types/Travel";
|
import { TravelLocation, TravelLocationTypeLabel } from "../../../types/Travel";
|
||||||
|
import Toolkit from "../../../utils/Toolkit";
|
||||||
|
|
||||||
interface MapMarker {
|
interface MapMarker {
|
||||||
id: number;
|
id: number;
|
||||||
@ -110,7 +111,8 @@ Page({
|
|||||||
height: 30,
|
height: 30,
|
||||||
customCallout: {
|
customCallout: {
|
||||||
anchorY: -2,
|
anchorY: -2,
|
||||||
anchorX: 0,
|
// 随机错位避免近距离重叠
|
||||||
|
anchorX: Toolkit.random(-10, 10),
|
||||||
display: "ALWAYS"
|
display: "ALWAYS"
|
||||||
},
|
},
|
||||||
locations: locs
|
locations: locs
|
||||||
|
|||||||
@ -13,16 +13,25 @@
|
|||||||
bindcallouttap="onCalloutTap"
|
bindcallouttap="onCalloutTap"
|
||||||
>
|
>
|
||||||
<cover-view slot="callout">
|
<cover-view slot="callout">
|
||||||
<block wx:for="{{markers}}" wx:key="id" wx:for-index="markerIndex">
|
<cover-view
|
||||||
<cover-view class="custom-callout" marker-id="{{markerIndex}}">
|
class="marker"
|
||||||
<block wx:for="{{item.locations}}" wx:key="id" wx:for-item="location">
|
wx:for="{{markers}}"
|
||||||
<cover-view class="location-item">
|
wx:key="id"
|
||||||
<cover-view wx:if="{{location.typeLabel}}" class="type">{{location.typeLabel}}</cover-view>
|
wx:for-item="marker"
|
||||||
<cover-view class="title">{{location.title || '未命名地点'}}</cover-view>
|
wx:for-index="markerIndex"
|
||||||
</cover-view>
|
marker-id="{{markerIndex}}"
|
||||||
</block>
|
>
|
||||||
|
<cover-view
|
||||||
|
class="location"
|
||||||
|
wx:for="{{marker.locations}}"
|
||||||
|
wx:key="id"
|
||||||
|
wx:for-item="location"
|
||||||
|
style="{{'--title-length: ' + location.title.length}}"
|
||||||
|
>
|
||||||
|
<cover-view wx:if="{{location.typeLabel}}" class="type">{{location.typeLabel}}</cover-view>
|
||||||
|
<cover-view class="title">{{location.title || '未命名地点'}}</cover-view>
|
||||||
</cover-view>
|
</cover-view>
|
||||||
</block>
|
</cover-view>
|
||||||
</cover-view>
|
</cover-view>
|
||||||
</map>
|
</map>
|
||||||
<view wx:if="{{isLoading}}" class="loading">
|
<view wx:if="{{isLoading}}" class="loading">
|
||||||
|
|||||||
@ -18,32 +18,31 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.travel-list {
|
.travels {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
padding: 16rpx;
|
padding: 16rpx;
|
||||||
min-height: 100vh;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding-bottom: 120rpx;
|
padding-bottom: 120rpx;
|
||||||
|
|
||||||
.travel-card {
|
.travel {
|
||||||
background: var(--theme-bg-card);
|
|
||||||
margin-bottom: 24rpx;
|
|
||||||
border-radius: 16rpx;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
box-shadow: 0 2px 12px var(--theme-shadow-light);
|
box-shadow: 0 2px 12px var(--theme-shadow-light);
|
||||||
transition: all .3s;
|
transition: all .3s;
|
||||||
|
background: var(--theme-bg-card);
|
||||||
|
margin-bottom: 24rpx;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
|
||||||
&:active {
|
&:active {
|
||||||
transform: scale(.98);
|
transform: scale(.98);
|
||||||
box-shadow: 0 2px 8px var(--theme-shadow-light);
|
box-shadow: 0 2px 8px var(--theme-shadow-light);
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-header {
|
.header {
|
||||||
padding: 24rpx;
|
padding: 24rpx;
|
||||||
border-bottom: 1px solid var(--theme-border-light);
|
border-bottom: 1px solid var(--theme-border-light);
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-body {
|
.body {
|
||||||
padding: 24rpx;
|
padding: 24rpx;
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
@ -67,11 +66,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.meta {
|
.meta {
|
||||||
gap: 16rpx;
|
gap: 32rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|
||||||
.meta-item {
|
.item {
|
||||||
gap: 8rpx;
|
gap: 8rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@ -2,13 +2,12 @@
|
|||||||
|
|
||||||
import Time from "../../../utils/Time";
|
import Time from "../../../utils/Time";
|
||||||
import { TravelApi } from "../../../api/TravelApi";
|
import { TravelApi } from "../../../api/TravelApi";
|
||||||
import { Travel, TravelPage, TravelStatus, TravelStatusLabel, TravelStatusIcon, TransportationTypeLabel } from "../../../types/Travel";
|
import { Travel, TravelPage, TravelStatus, TravelStatusLabel, TravelStatusIcon, TransportationTypeLabel, TransportationTypeIcon } from "../../../types/Travel";
|
||||||
import { OrderType } from "../../../types/Model";
|
|
||||||
|
|
||||||
interface TravelData {
|
interface TravelData {
|
||||||
/** 分页参数 */
|
/** 分页参数 */
|
||||||
page: TravelPage;
|
page: TravelPage;
|
||||||
/** 旅行列表 */
|
/** 出行列表 */
|
||||||
list: Travel[];
|
list: Travel[];
|
||||||
/** 当前筛选状态 */
|
/** 当前筛选状态 */
|
||||||
currentStatus: TravelStatus | "ALL";
|
currentStatus: TravelStatus | "ALL";
|
||||||
@ -27,16 +26,15 @@ interface TravelData {
|
|||||||
statusIcons: typeof TravelStatusIcon;
|
statusIcons: typeof TravelStatusIcon;
|
||||||
/** 交通类型标签映射 */
|
/** 交通类型标签映射 */
|
||||||
transportLabels: typeof TransportationTypeLabel;
|
transportLabels: typeof TransportationTypeLabel;
|
||||||
|
/** 交通类型图标映射 */
|
||||||
|
transportIcons: typeof TransportationTypeIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
data: <TravelData>{
|
data: <TravelData>{
|
||||||
page: {
|
page: {
|
||||||
index: 0,
|
index: 0,
|
||||||
size: 10,
|
size: 10
|
||||||
orderMap: {
|
|
||||||
travelAt: OrderType.DESC
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
list: [],
|
list: [],
|
||||||
currentStatus: "ALL",
|
currentStatus: "ALL",
|
||||||
@ -47,11 +45,18 @@ Page({
|
|||||||
menuLeft: 0,
|
menuLeft: 0,
|
||||||
statusLabels: TravelStatusLabel,
|
statusLabels: TravelStatusLabel,
|
||||||
statusIcons: TravelStatusIcon,
|
statusIcons: TravelStatusIcon,
|
||||||
transportLabels: TransportationTypeLabel
|
transportLabels: TransportationTypeLabel,
|
||||||
|
transportIcons: TransportationTypeIcon
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
this.resetAndFetch();
|
this.resetAndFetch();
|
||||||
},
|
},
|
||||||
|
onShow() {
|
||||||
|
// 页面显示时刷新数据(从编辑页返回时)
|
||||||
|
if (0 < this.data.list.length) {
|
||||||
|
this.resetAndFetch();
|
||||||
|
}
|
||||||
|
},
|
||||||
onHide() {
|
onHide() {
|
||||||
this.setData({
|
this.setData({
|
||||||
isShowFilterMenu: false
|
isShowFilterMenu: false
|
||||||
@ -70,9 +75,6 @@ Page({
|
|||||||
page: {
|
page: {
|
||||||
index: 0,
|
index: 0,
|
||||||
size: 10,
|
size: 10,
|
||||||
orderMap: {
|
|
||||||
travelAt: OrderType.DESC
|
|
||||||
},
|
|
||||||
equalsExample: this.data.currentStatus === "ALL" ? undefined : {
|
equalsExample: this.data.currentStatus === "ALL" ? undefined : {
|
||||||
status: this.data.currentStatus as TravelStatus
|
status: this.data.currentStatus as TravelStatus
|
||||||
}
|
}
|
||||||
@ -83,7 +85,7 @@ Page({
|
|||||||
});
|
});
|
||||||
this.fetch();
|
this.fetch();
|
||||||
},
|
},
|
||||||
/** 获取旅行列表 */
|
/** 获取出行列表 */
|
||||||
async fetch() {
|
async fetch() {
|
||||||
if (this.data.isFetching || this.data.isFinished) {
|
if (this.data.isFetching || this.data.isFinished) {
|
||||||
return;
|
return;
|
||||||
@ -117,7 +119,7 @@ Page({
|
|||||||
isFinished: list.length < this.data.page.size
|
isFinished: list.length < this.data.page.size
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取旅行列表失败:", error);
|
console.error("获取出行列表失败:", error);
|
||||||
} finally {
|
} finally {
|
||||||
this.setData({ isFetching: false });
|
this.setData({ isFetching: false });
|
||||||
}
|
}
|
||||||
@ -158,7 +160,7 @@ Page({
|
|||||||
});
|
});
|
||||||
this.resetAndFetch();
|
this.resetAndFetch();
|
||||||
},
|
},
|
||||||
/** 新建旅行 */
|
/** 新建出行 */
|
||||||
toCreate() {
|
toCreate() {
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: "/pages/main/travel-editor/index"
|
url: "/pages/main/travel-editor/index"
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<!--pages/main/travel/index.wxml-->
|
<!--pages/main/travel/index.wxml-->
|
||||||
<view class="custom-navbar">
|
<view class="custom-navbar">
|
||||||
<t-navbar title="旅行计划">
|
<t-navbar title="出行计划">
|
||||||
<view slot="left" class="filter-btn" bind:tap="toggleFilterMenu">
|
<view slot="left" class="filter-btn" bind:tap="toggleFilterMenu">
|
||||||
<t-icon name="filter" size="24px" />
|
<t-icon name="filter" size="24px" />
|
||||||
</view>
|
</view>
|
||||||
@ -46,26 +46,25 @@
|
|||||||
</t-cell-group>
|
</t-cell-group>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 旅行列表 -->
|
<!-- 出行列表 -->
|
||||||
<view class="travel-list">
|
<view class="travels">
|
||||||
<!-- 空状态 -->
|
<!-- 空状态 -->
|
||||||
<t-empty
|
<t-empty
|
||||||
wx:if="{{!isFetching && list.length === 0}}"
|
wx:if="{{!isFetching && list.length === 0}}"
|
||||||
icon="travel"
|
icon="travel"
|
||||||
description="暂无旅行计划"
|
description="暂无出行计划"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 列表内容 -->
|
<!-- 列表内容 -->
|
||||||
<view
|
<view
|
||||||
wx:for="{{list}}"
|
wx:for="{{list}}"
|
||||||
wx:for-item="travel"
|
wx:for-item="travel"
|
||||||
wx:for-index="travelIndex"
|
wx:for-index="travelIndex"
|
||||||
wx:key="id"
|
wx:key="id"
|
||||||
class="travel-card"
|
class="travel"
|
||||||
bind:tap="toDetail"
|
bind:tap="toDetail"
|
||||||
data-id="{{travel.id}}"
|
data-id="{{travel.id}}"
|
||||||
>
|
>
|
||||||
<view class="card-header">
|
<view class="header">
|
||||||
<t-tag
|
<t-tag
|
||||||
theme="{{travel.status === 'PLANNING' ? 'default' : travel.status === 'ONGOING' ? 'warning' : 'success'}}"
|
theme="{{travel.status === 'PLANNING' ? 'default' : travel.status === 'ONGOING' ? 'warning' : 'success'}}"
|
||||||
variant="light"
|
variant="light"
|
||||||
@ -74,31 +73,25 @@
|
|||||||
{{statusLabels[travel.status]}}
|
{{statusLabels[travel.status]}}
|
||||||
</t-tag>
|
</t-tag>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="body">
|
||||||
<view class="card-body">
|
<view class="title">{{travel.title || '未命名出行'}}</view>
|
||||||
<view class="title">{{travel.title || '未命名旅行'}}</view>
|
|
||||||
|
|
||||||
<view wx:if="{{travel.content}}" class="content">{{travel.content}}</view>
|
<view wx:if="{{travel.content}}" class="content">{{travel.content}}</view>
|
||||||
|
|
||||||
<view class="meta">
|
<view class="meta">
|
||||||
<view class="meta-item">
|
<view wx:if="{{travel.travelDate}}" class="item">
|
||||||
<t-icon name="time" size="16px" class="icon" />
|
<t-icon name="time" size="16px" class="icon" />
|
||||||
<text class="text">{{travel.travelDate}} {{travel.travelTime}}</text>
|
<text class="text">{{travel.travelDate}}</text>
|
||||||
</view>
|
</view>
|
||||||
|
<view wx:if="{{travel.days}}" class="item">
|
||||||
<view wx:if="{{travel.days}}" class="meta-item">
|
|
||||||
<t-icon name="calendar" size="16px" class="icon" />
|
<t-icon name="calendar" size="16px" class="icon" />
|
||||||
<text class="text">{{travel.days}} 天</text>
|
<text class="text">{{travel.days}} 天</text>
|
||||||
</view>
|
</view>
|
||||||
|
<view wx:if="{{travel.transportationType}}" class="item">
|
||||||
<view wx:if="{{travel.transportationType}}" class="meta-item">
|
<t-icon name="{{transportIcons[travel.transportationType]}}" size="16px" class="icon" />
|
||||||
<t-icon name="{{travel.transportationType === 'PLANE' ? 'flight-takeoff' : travel.transportationType === 'TRAIN' ? 'map-route' : travel.transportationType === 'SELF_DRIVING' ? 'control-platform' : 'location'}}" size="16px" class="icon" />
|
|
||||||
<text class="text">{{transportLabels[travel.transportationType]}}</text>
|
<text class="text">{{transportLabels[travel.transportationType]}}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 加载完成提示 -->
|
<!-- 加载完成提示 -->
|
||||||
<view wx:if="{{isFinished && 0 < list.length}}" class="finished">没有更多了</view>
|
<view wx:if="{{isFinished && 0 < list.length}}" class="finished">没有更多了</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@ -256,10 +256,10 @@ page {
|
|||||||
--td-font-size-l: var(--td-font-size-title-large);
|
--td-font-size-l: var(--td-font-size-title-large);
|
||||||
--td-font-size-xl: var(--td-font-size-title-extra-large);
|
--td-font-size-xl: var(--td-font-size-title-extra-large);
|
||||||
--td-font-size-xxl: var(--td-font-size-headline-large);
|
--td-font-size-xxl: var(--td-font-size-headline-large);
|
||||||
--td-radius-small: 2px;
|
--td-radius-small: 8rpx;
|
||||||
--td-radius-default: 4px;
|
--td-radius-default: 16rpx;
|
||||||
--td-radius-large: 6px;
|
--td-radius-large: 24px;
|
||||||
--td-radius-extraLarge: 7px;
|
--td-radius-extraLarge: 32rpx;
|
||||||
--td-radius-round: 999px;
|
--td-radius-round: 9999rpx;
|
||||||
--td-radius-circle: 50%;
|
--td-radius-circle: 50%;
|
||||||
}
|
}
|
||||||
@ -1,14 +1,14 @@
|
|||||||
{
|
{
|
||||||
"light": {
|
"light": {
|
||||||
"navigationBarBackgroundColor": "#FFFFFF",
|
"navigationBarBackgroundColor": "#FFF",
|
||||||
"navigationBarTextStyle": "black",
|
"navigationBarTextStyle": "black",
|
||||||
"backgroundColor": "#FFFFFF",
|
"backgroundColor": "#EDEDED",
|
||||||
"backgroundTextStyle": "dark",
|
"backgroundTextStyle": "#111",
|
||||||
"backgroundColorTop": "#FFFFFF",
|
"backgroundColorTop": "#F00",
|
||||||
"backgroundColorBottom": "#FFFFFF",
|
"backgroundColorBottom": "#EDEDED",
|
||||||
"tabBarColor": "#8a8a8a",
|
"tabBarColor": "#8A8A8A",
|
||||||
"tabBarSelectedColor": "#07C160",
|
"tabBarSelectedColor": "#07C160",
|
||||||
"tabBarBackgroundColor": "#ffffff",
|
"tabBarBackgroundColor": "#FFF",
|
||||||
"tabBarBorderStyle": "white",
|
"tabBarBorderStyle": "white",
|
||||||
"tabBarIconJournal": "assets/icon/light/journal.png",
|
"tabBarIconJournal": "assets/icon/light/journal.png",
|
||||||
"tabBarIconJournalActive": "assets/icon/light/journal_active.png",
|
"tabBarIconJournalActive": "assets/icon/light/journal_active.png",
|
||||||
@ -24,11 +24,11 @@
|
|||||||
"dark": {
|
"dark": {
|
||||||
"navigationBarBackgroundColor": "#1A1A1A",
|
"navigationBarBackgroundColor": "#1A1A1A",
|
||||||
"navigationBarTextStyle": "white",
|
"navigationBarTextStyle": "white",
|
||||||
"backgroundColor": "#1A1A1A",
|
"backgroundColor": "#111",
|
||||||
"backgroundTextStyle": "light",
|
"backgroundTextStyle": "light",
|
||||||
"backgroundColorTop": "#1A1A1A",
|
"backgroundColorTop": "#1A1A1A",
|
||||||
"backgroundColorBottom": "#1A1A1A",
|
"backgroundColorBottom": "#1A1A1A",
|
||||||
"tabBarColor": "#aaaaaa",
|
"tabBarColor": "#AAA",
|
||||||
"tabBarSelectedColor": "#07C160",
|
"tabBarSelectedColor": "#07C160",
|
||||||
"tabBarBackgroundColor": "#1A1A1A",
|
"tabBarBackgroundColor": "#1A1A1A",
|
||||||
"tabBarBorderStyle": "black",
|
"tabBarBorderStyle": "black",
|
||||||
|
|||||||
@ -9,9 +9,11 @@ page {
|
|||||||
--theme-wx: #07C160;
|
--theme-wx: #07C160;
|
||||||
|
|
||||||
/* === 背景色 === */
|
/* === 背景色 === */
|
||||||
|
--theme-bg-wx: #EDEDED;
|
||||||
--theme-bg-primary: #FFF;
|
--theme-bg-primary: #FFF;
|
||||||
--theme-bg-secondary: #F5F5F5;
|
--theme-bg-secondary: #F5F5F5;
|
||||||
--theme-bg-card: #FFF;
|
--theme-bg-card: #FFF;
|
||||||
|
--theme-bg-card-secondary: #F4F4F4;
|
||||||
--theme-bg-journal: #FFF2C8;
|
--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);
|
||||||
@ -63,10 +65,12 @@ page {
|
|||||||
--theme-wx: #07C160;
|
--theme-wx: #07C160;
|
||||||
|
|
||||||
/* === 背景色 === */
|
/* === 背景色 === */
|
||||||
|
--theme-bg-wx: #111;
|
||||||
--theme-bg-primary: #1A1A1A;
|
--theme-bg-primary: #1A1A1A;
|
||||||
--theme-bg-secondary: #2A2A2A;
|
--theme-bg-secondary: #2A2A2A;
|
||||||
--theme-bg-card: #2C2C2C;
|
--theme-bg-card: #3D3D3D;
|
||||||
--theme-bg-journal: #3A3A2E;
|
--theme-bg-card-secondary: #525252;
|
||||||
|
--theme-bg-journal: #4B4B4B;
|
||||||
--theme-bg-overlay: rgba(0, 0, 0, .3);
|
--theme-bg-overlay: rgba(0, 0, 0, .3);
|
||||||
--theme-bg-menu: rgba(40, 40, 40, .95);
|
--theme-bg-menu: rgba(40, 40, 40, .95);
|
||||||
|
|
||||||
59
miniprogram/timi-web.less
Normal file
59
miniprogram/timi-web.less
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
@tuiColors: {
|
||||||
|
red: #F33;
|
||||||
|
pink: #FF7A9B;
|
||||||
|
black: #111;
|
||||||
|
blue: #006EFF;
|
||||||
|
light-blue: #00A6FF;
|
||||||
|
green: GREEN;
|
||||||
|
orange: #E7913B;
|
||||||
|
gray: #666;
|
||||||
|
light-gray: #AAA;
|
||||||
|
white: #FFF;
|
||||||
|
dark-white: #E7EAEF;
|
||||||
|
yellow: #FF0;
|
||||||
|
purple: PURPLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--tui-font: SimSun, PingFang SC, Microsoft YaHei, Arial Regular;
|
||||||
|
--tui-cur-default: url("../img/default.png"), default;
|
||||||
|
--tui-cur-pointer: url("../img/link.png"), pointer;
|
||||||
|
--tui-cur-text: url("../img/input.png"), text;
|
||||||
|
|
||||||
|
--tui-shadow: 3px 3px 0 var(--tui-shadow-color);
|
||||||
|
--tui-bezier: cubic-bezier(.19, .1, .22, 1);
|
||||||
|
--tui-shadow-color: rgba(0, 0, 0, .2);
|
||||||
|
|
||||||
|
each(@tuiColors, {
|
||||||
|
--tui-@{key}: @value;
|
||||||
|
});
|
||||||
|
--tui-border: 1px solid var(--tui-light-gray);
|
||||||
|
|
||||||
|
/* 等级对应颜色 */
|
||||||
|
--tui-level-0: #BFBFBF;
|
||||||
|
--tui-level-1: #BFBFBF;
|
||||||
|
--tui-level-2: #95DDB2;
|
||||||
|
--tui-level-3: #92D1E5;
|
||||||
|
--tui-level-4: #FFB37C;
|
||||||
|
--tui-level-5: #FF6C00;
|
||||||
|
--tui-level-6: #F00;
|
||||||
|
--tui-level-7: #E52FEC;
|
||||||
|
--tui-level-8: #841CF9;
|
||||||
|
--tui-level-9: #151515;
|
||||||
|
|
||||||
|
--tui-page-padding: .5rem 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 字体颜色
|
||||||
|
each(@tuiColors, {
|
||||||
|
.@{key} {
|
||||||
|
color: @value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 背景颜色
|
||||||
|
each(@tuiColors, {
|
||||||
|
.bg-@{key} {
|
||||||
|
background: @value;
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -17,7 +17,7 @@ export type Attachment = {
|
|||||||
|
|
||||||
mimeType?: string;
|
mimeType?: string;
|
||||||
|
|
||||||
metadata?: string | ImageMetadata;
|
metadata?: string | ImageMetadata | PreviewImageMetadata;
|
||||||
|
|
||||||
/** 文件 MD5 */
|
/** 文件 MD5 */
|
||||||
md5: string;
|
md5: string;
|
||||||
@ -27,9 +27,6 @@ export type Attachment = {
|
|||||||
|
|
||||||
/** 大小 */
|
/** 大小 */
|
||||||
size: number;
|
size: number;
|
||||||
|
|
||||||
/** 扩展数据 */
|
|
||||||
ext?: string | MediaAttachExt;
|
|
||||||
} & Model;
|
} & Model;
|
||||||
|
|
||||||
/** 媒体附件类型 */
|
/** 媒体附件类型 */
|
||||||
@ -52,8 +49,7 @@ export type ImageMetadata = {
|
|||||||
height: number;
|
height: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 媒体附件扩展数据 */
|
export type PreviewImageMetadata = {
|
||||||
export type MediaAttachExt = {
|
|
||||||
|
|
||||||
/** 原文件附件 ID */
|
/** 原文件附件 ID */
|
||||||
sourceId: number;
|
sourceId: number;
|
||||||
@ -61,15 +57,6 @@ export type MediaAttachExt = {
|
|||||||
/** 原文件访问 mongoId */
|
/** 原文件访问 mongoId */
|
||||||
sourceMongoId: string;
|
sourceMongoId: string;
|
||||||
|
|
||||||
/** true 为图片 */
|
/** 原文件 MimeType */
|
||||||
isImage: boolean;
|
sourceMimeType: string;
|
||||||
|
} & ImageMetadata;
|
||||||
/** true 为视频 */
|
|
||||||
isVideo: boolean;
|
|
||||||
|
|
||||||
/** 原图宽度(像素) */
|
|
||||||
width?: number;
|
|
||||||
|
|
||||||
/** 原图高度(像素) */
|
|
||||||
height?: number;
|
|
||||||
}
|
|
||||||
|
|||||||
@ -22,28 +22,38 @@ export const TransportationTypeLabel: Record<TransportationType, string> = {
|
|||||||
[TransportationType.OTHER]: "其他"
|
[TransportationType.OTHER]: "其他"
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 旅行状态 */
|
/** 交通类型图标映射 */
|
||||||
|
export const TransportationTypeIcon: Record<TransportationType, string> = {
|
||||||
|
[TransportationType.PLANE]: "flight-takeoff",
|
||||||
|
[TransportationType.TRAIN]: "map-route",
|
||||||
|
[TransportationType.CAR]: "vehicle",
|
||||||
|
[TransportationType.SHIP]: "anchor",
|
||||||
|
[TransportationType.SELF_DRIVING]: "vehicle",
|
||||||
|
[TransportationType.OTHER]: "compass"
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 出行状态 */
|
||||||
export enum TravelStatus {
|
export enum TravelStatus {
|
||||||
PLANNING = "PLANNING",
|
PLANNING = "PLANNING",
|
||||||
ONGOING = "ONGOING",
|
ONGOING = "ONGOING",
|
||||||
COMPLETED = "COMPLETED"
|
COMPLETED = "COMPLETED"
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 旅行状态中文映射 */
|
/** 出行状态中文映射 */
|
||||||
export const TravelStatusLabel: Record<TravelStatus, string> = {
|
export const TravelStatusLabel: Record<TravelStatus, string> = {
|
||||||
[TravelStatus.PLANNING]: "计划中",
|
[TravelStatus.PLANNING]: "计划中",
|
||||||
[TravelStatus.ONGOING]: "进行中",
|
[TravelStatus.ONGOING]: "进行中",
|
||||||
[TravelStatus.COMPLETED]: "已完成"
|
[TravelStatus.COMPLETED]: "已完成"
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 旅行状态图标映射 */
|
/** 出行状态图标映射 */
|
||||||
export const TravelStatusIcon: Record<TravelStatus, string> = {
|
export const TravelStatusIcon: Record<TravelStatus, string> = {
|
||||||
[TravelStatus.PLANNING]: "calendar",
|
[TravelStatus.PLANNING]: "calendar",
|
||||||
[TravelStatus.ONGOING]: "play-circle",
|
[TravelStatus.ONGOING]: "play-circle",
|
||||||
[TravelStatus.COMPLETED]: "check-circle"
|
[TravelStatus.COMPLETED]: "check-circle"
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 旅行计划实体 */
|
/** 出行计划实体 */
|
||||||
export interface Travel extends Model {
|
export interface Travel extends Model {
|
||||||
/** 交通类型 */
|
/** 交通类型 */
|
||||||
transportationType?: TransportationType;
|
transportationType?: TransportationType;
|
||||||
@ -55,10 +65,10 @@ export interface Travel extends Model {
|
|||||||
content?: string;
|
content?: string;
|
||||||
|
|
||||||
/** 出行时间戳 */
|
/** 出行时间戳 */
|
||||||
travelAt?: number;
|
travelAt?: number | null;
|
||||||
|
|
||||||
/** 天数 */
|
/** 天数 */
|
||||||
days?: number;
|
days?: number | null;
|
||||||
|
|
||||||
/** 状态 */
|
/** 状态 */
|
||||||
status?: TravelStatus;
|
status?: TravelStatus;
|
||||||
@ -70,7 +80,7 @@ export interface Travel extends Model {
|
|||||||
travelTime?: string;
|
travelTime?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 旅行分页查询 */
|
/** 出行分页查询 */
|
||||||
export interface TravelPage extends QueryPage {
|
export interface TravelPage extends QueryPage {
|
||||||
/** 条件过滤 */
|
/** 条件过滤 */
|
||||||
equalsExample?: {
|
equalsExample?: {
|
||||||
@ -80,37 +90,43 @@ export interface TravelPage extends QueryPage {
|
|||||||
|
|
||||||
/** 地点类型 */
|
/** 地点类型 */
|
||||||
export enum TravelLocationType {
|
export enum TravelLocationType {
|
||||||
ATTRACTION = "ATTRACTION",
|
FOOD = "FOOD",
|
||||||
HOTEL = "HOTEL",
|
HOTEL = "HOTEL",
|
||||||
RESTAURANT = "RESTAURANT",
|
|
||||||
TRANSPORT = "TRANSPORT",
|
TRANSPORT = "TRANSPORT",
|
||||||
|
ATTRACTION = "ATTRACTION",
|
||||||
|
MALL = "MALL",
|
||||||
SHOPPING = "SHOPPING",
|
SHOPPING = "SHOPPING",
|
||||||
OTHER = "OTHER"
|
PLAY = "PLAY",
|
||||||
|
LIFE = "LIFE"
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 地点类型中文映射 */
|
/** 地点类型中文映射 */
|
||||||
export const TravelLocationTypeLabel: Record<TravelLocationType, string> = {
|
export const TravelLocationTypeLabel: Record<TravelLocationType, string> = {
|
||||||
[TravelLocationType.ATTRACTION]: "景点",
|
[TravelLocationType.FOOD]: "美食",
|
||||||
[TravelLocationType.HOTEL]: "酒店",
|
[TravelLocationType.HOTEL]: "酒店",
|
||||||
[TravelLocationType.RESTAURANT]: "餐厅",
|
[TravelLocationType.TRANSPORT]: "交通",
|
||||||
[TravelLocationType.TRANSPORT]: "交通站点",
|
[TravelLocationType.ATTRACTION]: "景点",
|
||||||
|
[TravelLocationType.MALL]: "商场",
|
||||||
[TravelLocationType.SHOPPING]: "购物",
|
[TravelLocationType.SHOPPING]: "购物",
|
||||||
[TravelLocationType.OTHER]: "其他"
|
[TravelLocationType.PLAY]: "玩乐",
|
||||||
|
[TravelLocationType.LIFE]: "生活"
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 地点类型图标映射 */
|
/** 地点类型图标映射 */
|
||||||
export const TravelLocationTypeIcon: Record<TravelLocationType, string> = {
|
export const TravelLocationTypeIcon: Record<TravelLocationType, string> = {
|
||||||
[TravelLocationType.ATTRACTION]: "location",
|
[TravelLocationType.FOOD]: "chicken",
|
||||||
[TravelLocationType.HOTEL]: "home",
|
[TravelLocationType.HOTEL]: "city-8",
|
||||||
[TravelLocationType.RESTAURANT]: "shop",
|
[TravelLocationType.TRANSPORT]: "map-route-planning",
|
||||||
[TravelLocationType.TRANSPORT]: "map-route",
|
[TravelLocationType.ATTRACTION]: "image-1",
|
||||||
[TravelLocationType.SHOPPING]: "cart",
|
[TravelLocationType.MALL]: "chart-3d",
|
||||||
[TravelLocationType.OTHER]: "ellipsis"
|
[TravelLocationType.SHOPPING]: "shop",
|
||||||
|
[TravelLocationType.PLAY]: "ferris-wheel",
|
||||||
|
[TravelLocationType.LIFE]: "location"
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 旅行地点实体 */
|
/** 出行地点实体 */
|
||||||
export interface TravelLocation extends Model {
|
export interface TravelLocation extends Model {
|
||||||
/** 关联的旅行计划 ID */
|
/** 关联的出行计划 ID */
|
||||||
travelId?: number;
|
travelId?: number;
|
||||||
|
|
||||||
/** 地点类型 */
|
/** 地点类型 */
|
||||||
@ -137,8 +153,14 @@ export interface TravelLocation extends Model {
|
|||||||
/** 是否需要身份证 */
|
/** 是否需要身份证 */
|
||||||
requireIdCard?: boolean;
|
requireIdCard?: boolean;
|
||||||
|
|
||||||
/** 必要评分 */
|
/** 是否需要预约 */
|
||||||
score?: number;
|
requireAppointment?: boolean;
|
||||||
|
|
||||||
|
/** 评分 */
|
||||||
|
score?: number | null;
|
||||||
|
|
||||||
|
/** 重要程度 */
|
||||||
|
importance?: number | null;
|
||||||
|
|
||||||
/** 附件 */
|
/** 附件 */
|
||||||
items?: Attachment[];
|
items?: Attachment[];
|
||||||
|
|||||||
@ -55,10 +55,10 @@ export type WechatMediaItem = {
|
|||||||
export enum MediaItemType {
|
export enum MediaItemType {
|
||||||
|
|
||||||
/** 图片 */
|
/** 图片 */
|
||||||
IMAGE,
|
IMAGE = "image",
|
||||||
|
|
||||||
/** 视频 */
|
/** 视频 */
|
||||||
VIDEO
|
VIDEO = "video"
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 位置 */
|
/** 位置 */
|
||||||
@ -79,4 +79,17 @@ export enum JournalDetailType {
|
|||||||
DATE = "DATE",
|
DATE = "DATE",
|
||||||
|
|
||||||
LOCATION = "LOCATION"
|
LOCATION = "LOCATION"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MapMarker {
|
||||||
|
id: number;
|
||||||
|
latitude: number;
|
||||||
|
longitude: number;
|
||||||
|
width: number;
|
||||||
|
height: number;
|
||||||
|
customCallout: {
|
||||||
|
anchorY: number;
|
||||||
|
anchorX: number;
|
||||||
|
display: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import config from "../config/index";
|
import config from "../config/index";
|
||||||
import { Response, QueryPage, QueryPageResult, TempFileResponse } from "../types/Model";
|
import { Response, QueryPage, QueryPageResult, TempFileResponse } from "../types/Model";
|
||||||
|
import { MediaItemType } from "../types/UI";
|
||||||
|
|
||||||
/** 微信媒体项(用于上传) */
|
/** 微信媒体项(用于上传) */
|
||||||
export interface WechatMediaItem {
|
export interface WechatMediaItem {
|
||||||
@ -13,7 +14,7 @@ export interface WechatMediaItem {
|
|||||||
size?: number;
|
size?: number;
|
||||||
|
|
||||||
/** 媒体类型 */
|
/** 媒体类型 */
|
||||||
type?: string;
|
type?: MediaItemType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 请求选项 */
|
/** 请求选项 */
|
||||||
|
|||||||
Reference in New Issue
Block a user