Compare commits

...

4 Commits

Author SHA1 Message Date
9f7df3cfed update 1.6.2 2025-12-17 16:56:45 +08:00
62186abdb8 apply Network.ts 2025-12-17 16:56:33 +08:00
369cfe2bf2 update style 2025-12-17 16:16:10 +08:00
423775c255 fix travel style 2025-12-17 10:18:10 +08:00
52 changed files with 962 additions and 1197 deletions

View 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);
}
}

View 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);
}
}

View File

@ -3,22 +3,22 @@ import { Travel } from "../types/Travel";
import { QueryPage, QueryPageResult } from "../types/Model";
/**
* Travel 行计划 API
* Travel 行计划 API
*
* 按业务模块封装网络请求,使代码更清晰、可维护
*/
export class TravelApi {
/**
* 获取行详情
* 获取行详情
*
* @param id - 行 ID
* @param id - 行 ID
*/
static getDetail(id: number | string): Promise<Travel> {
return Network.get<Travel>(`/journal/travel/${id}`);
}
/**
* 行分页列表
* 行分页列表
*
* @param pageParams - 分页参数
*/
@ -27,9 +27,9 @@ export class TravelApi {
}
/**
* 创建
* 创建
*
* @param data - 行数据
* @param data - 行数据
*/
static create(data: Partial<Travel>): Promise<Travel> {
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> {
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> {
return Network.post<void>("/journal/travel/delete", { id });

View File

@ -3,13 +3,13 @@ import { TravelLocation } from "../types/Travel";
import { QueryPage, QueryPageResult } from "../types/Model";
/**
* TravelLocation 行地点 API
* TravelLocation 行地点 API
*
* 按业务模块封装网络请求,使代码更清晰、可维护
*/
export class TravelLocationApi {
/**
* 获取行地点详情
* 获取行地点详情
*
* @param id - 地点 ID
*/
@ -18,7 +18,7 @@ export class TravelLocationApi {
}
/**
* 获取行地点分页列表
* 获取行地点分页列表
*
* @param pageParams - 分页参数(通常包含 travelId 筛选)
*/
@ -27,7 +27,7 @@ export class TravelLocationApi {
}
/**
* 创建行地点
* 创建行地点
*
* @param data - 地点数据
*/
@ -39,7 +39,7 @@ export class TravelLocationApi {
}
/**
* 更新行地点
* 更新行地点
*
* @param data - 地点数据(必须包含 id
*/
@ -51,7 +51,7 @@ export class TravelLocationApi {
}
/**
* 删除行地点
* 删除行地点
*
* @param id - 地点 ID
*/
@ -60,7 +60,7 @@ export class TravelLocationApi {
}
/**
* 批量获取行地点
* 批量获取行地点
*
* @param ids - 地点 ID 数组
*/

View File

@ -49,7 +49,7 @@
"selectedIconPath": "@tabBarIconMomentActive"
},
{
"text": "行",
"text": "行",
"pagePath": "pages/main/travel/index",
"iconPath": "@tabBarIconTravel",
"selectedIconPath": "@tabBarIconTravelActive"

View File

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

View File

@ -23,31 +23,9 @@ page {
}
.snowflake {
width: 10px;
height: 10px;
color: var(--theme-brand-gao);
display: block;
position: absolute;
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%;
}
}
}

View File

@ -20,7 +20,7 @@ Component({
createSnowflake() {
const snowflake = {
x: Toolkit.random(0, this.data.docWidth),
s: Toolkit.random(6, 20),
s: Toolkit.random(16, 64),
speed: Toolkit.random(14, 26)
};
this.setData({

View File

@ -1,9 +1,10 @@
<!--components/background/snow/index.wxml-->
<view class="snowflakes" style="width: {{docWidth}}px; height: {{docHeight}}px;">
<view
<t-icon
class="snowflake"
wx:for="{{snowflakes}}"
wx:key="index"
style="left: {{item.x}}px; width: {{item.s}}px; height: {{item.s}}px; animation-duration: {{item.speed}}s;"
></view>
style="left: {{item.x}}px; font-size: {{item.s}}rpx; animation-duration: {{item.speed}}s;"
name="snowflake"
/>
</view>

View File

@ -57,7 +57,7 @@
padding: 4rpx 12rpx;
font-size: 24rpx;
font-weight: bold;
background: var(--theme-bg-journal);
background: var(--theme-bg-card);
border-radius: 12rpx;
}
}

View File

@ -5,6 +5,7 @@ import Toolkit from "../../utils/Toolkit";
import { ImageMetadata, MediaAttachExt, MediaAttachType } from "../../types/Attachment";
import { MediaItem, MediaItemType } from "../../types/UI";
import Time from "../../utils/Time";
import { JournalApi } from "../../api/JournalApi";
interface JournalDetailPanelData {
journals: Journal[];
@ -35,24 +36,7 @@ Component({
if (visible && ids && 0 < ids.length) {
wx.showLoading({ title: "加载中...", mask: true });
try {
const journals: Journal[] = await new Promise((resolve, reject) => {
wx.request({
url: `${config.url}/journal/list/ids`,
method: "POST",
header: {
Key: wx.getStorageSync("key")
},
data: ids,
success: (resp: any) => {
if (resp.data.code === 20000) {
resolve(resp.data.data);
} else {
reject(new Error(resp.data.message || "加载失败"));
}
},
fail: reject
});
}) || [];
const journals = await JournalApi.getListByIds(ids);
journals.forEach(journal => {
journal.date = Time.toPassedDate(journal.createdAt);
journal.time = Time.toTime(journal.createdAt);

View File

@ -4,6 +4,7 @@ import { JournalPage, JournalPageType } from "../../types/Journal";
import { OrderType } from "../../types/Model";
import Time from "../../utils/Time";
import Toolkit from "../../utils/Toolkit";
import { JournalApi } from "../../api/JournalApi";
export type JournalListItem = {
id: number;
@ -19,14 +20,10 @@ interface JournalListData {
isFinished: boolean;
page: JournalPage;
searchValue: string;
debouncedSearch?: any;
}
// 组件实例类型扩展
interface ComponentInstance {
debouncedSearch?: ((keyword: string) => void) & { cancel(): void };
}
Component<JournalListData, {}, {}, ComponentInstance>({
Component({
options: {
styleIsolation: 'apply-shared'
},
@ -64,25 +61,28 @@ Component<JournalListData, {}, {}, ComponentInstance>({
createdAt: OrderType.DESC
}
},
searchValue: ""
searchValue: "",
debouncedSearch: undefined
},
lifetimes: {
ready() {
// 创建防抖搜索函数
this.debouncedSearch = Toolkit.debounce(
this.setData({
debouncedSearch: Toolkit.debounce(
(keyword: string) => {
this.resetAndSearch(keyword);
},
false, // 不立即执行,等待输入停止
400 // 400ms 延迟
);
)
})
// 组件加载时就获取数据
this.fetch();
},
detached() {
// 组件销毁时取消防抖
if (this.debouncedSearch) {
this.debouncedSearch.cancel();
if (this.data.debouncedSearch) {
this.data.debouncedSearch.cancel();
}
}
},
@ -125,22 +125,19 @@ Component<JournalListData, {}, {}, ComponentInstance>({
});
},
/** 获取数据 */
fetch() {
async fetch() {
if (this.data.isFetching || this.data.isFinished) {
return;
}
this.setData({ isFetching: true });
wx.request({
url: `${config.url}/journal/list`,
method: "POST",
header: {
Key: wx.getStorageSync("key")
},
data: this.data.page,
success: (resp: any) => {
const list = resp.data.data.list;
try {
const pageResult = await JournalApi.getList(this.data.page);
const list = pageResult.list;
if (!list || list.length === 0) {
this.setData({ isFinished: true });
this.setData({
isFinished: true,
isFetching: false
});
return;
}
const result = list.map((journal: any) => {
@ -165,37 +162,37 @@ Component<JournalListData, {}, {}, ComponentInstance>({
}
},
list: this.data.list.concat(result),
isFinished: list.length < this.data.page.size
isFinished: list.length < this.data.page.size,
isFetching: false
});
},
complete: () => {
} catch (error) {
console.error("加载日记列表失败:", error);
this.setData({ isFetching: false });
}
});
},
/** 输入搜索 */
onSearchChange(e: WechatMiniprogram.CustomEvent) {
const value = e.detail.value.trim();
this.setData({ searchValue: value });
// 使用防抖自动搜索(包括清空的情况)
if (this.debouncedSearch) {
this.debouncedSearch(value);
if (this.data.debouncedSearch) {
this.data.debouncedSearch(value);
}
},
/** 提交搜索 */
onSearchSubmit(e: WechatMiniprogram.CustomEvent) {
const value = e.detail.value.trim();
// 立即搜索,取消防抖
if (this.debouncedSearch) {
this.debouncedSearch.cancel();
if (this.data.debouncedSearch) {
this.data.debouncedSearch.cancel();
}
this.resetAndSearch(value);
},
/** 清空搜索 */
onSearchClear() {
// 取消防抖,立即搜索
if (this.debouncedSearch) {
this.debouncedSearch.cancel();
if (this.data.debouncedSearch) {
this.data.debouncedSearch.cancel();
}
this.resetAndSearch("");
},

View File

@ -81,7 +81,7 @@
padding: 4rpx 12rpx;
font-size: 24rpx;
font-weight: bold;
background: var(--theme-bg-journal);
background: var(--theme-bg-card);
border-radius: 12rpx;
}
}

View File

@ -1,7 +1,7 @@
// components/travel-location-popup/index.ts
import { TravelLocation, TravelLocationTypeLabel, TravelLocationTypeIcon } from "../../types/Travel";
import { TravelLocationApi } from "../../api/TravelLocationApi";
import { MediaAttachExt, MediaAttachType } from "../../types/Attachment";
import { ImageMetadata, MediaAttachType } from "../../types/Attachment";
import { MediaItem, MediaItemType } from "../../types/UI";
import config from "../../config/index";
import Toolkit from "../../utils/Toolkit";
@ -39,11 +39,11 @@ Component({
// 处理附件数据
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) {
const mediaItems: MediaItem[] = thumbItems.map((thumbItem: any, index: number) => {
const metadata = thumbItem.metadata;
const mediaItems: MediaItem[] = thumbItems.map((thumbItem, index) => {
const metadata = thumbItem.metadata as ImageMetadata;
const ext = typeof thumbItem.ext === "string" ? JSON.parse(thumbItem.ext) : thumbItem.ext;
const thumbURL = `${config.url}/attachment/read/${thumbItem.mongoId}`;
const sourceURL = `${config.url}/attachment/read/${ext.sourceMongoId}`;

View File

@ -43,9 +43,6 @@
<t-tag wx:if="{{item.importance}}" theme="success" variant="outline">
重要性 {{item.importance}}
</t-tag>
<t-tag wx:if="{{item.travelCount > 0}}" theme="default" variant="outline">
已出行 {{item.travelCount}} 次
</t-tag>
<t-tag wx:if="{{item.requireIdCard}}" theme="danger" variant="outline">
需要身份证
</t-tag>

View File

@ -1,6 +1,11 @@
const envArgs = {
develop: {
url: "http://192.168.3.137: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: {
url: "https://api.imyeyu.com"

View File

@ -2,6 +2,7 @@
import config from "../../config/index"
import { JournalPage, JournalPageType } from "../../types/Journal";
import { JournalApi } from "../../api/JournalApi";
interface IndexData {
key: string;
@ -19,32 +20,23 @@ Page({
});
}
},
navigateToMain() {
wx.request({
url: `${config.url}/journal/list`,
method: "POST",
header: {
Key: this.data.key
},
data: <JournalPage> {
async navigateToMain() {
try {
await JournalApi.getList({
index: 0,
size: 1,
type: JournalPageType.PREVIEW
},
success: (resp) => {
const data = resp.data as any;
if (data.code === 20000) {
});
wx.setStorageSync("key", this.data.key);
wx.switchTab({
url: "/pages/main/journal/index",
})
} else if (data.code === 40100) {
} catch (error: any) {
if (error?.code === 40100) {
wx.showToast({ title: "密码错误", icon: "error" });
} else {
wx.showToast({ title: "服务异常", icon: "error" });
wx.showToast({ title: "验证失败", icon: "error" });
}
}
},
fail: () => wx.showToast({ title: "验证失败", icon: "error" })
});
}
})

View File

@ -1,7 +1,6 @@
/* pages/info/info.less */
page {
display: flex;
background: var(--theme-bg-wx);
flex-direction: column;
}

View File

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

View File

@ -1,7 +1,7 @@
// pages/main/journal-date/index.ts
import config from "../../../config/index";
import { Journal, JournalPageType } from "../../../types/Journal";
import Time from "../../../utils/Time";
import { JournalApi } from "../../../api/JournalApi";
interface JournalDateData {
// 存储每个日期的日记 id 列表
@ -27,28 +27,12 @@ Page({
async loadJournals() {
this.setData({ isLoading: true });
try {
const list: Journal[] = await new Promise((resolve, reject) => {
wx.request({
url: `${config.url}/journal/list`,
method: "POST",
header: {
Key: wx.getStorageSync("key")
},
data: {
page: 0,
const pageResult = await JournalApi.getList({
index: 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 list: Journal[] = pageResult.list || [];
// 按日期分组,只存储 id
const journalMap: Record<string, number[]> = {};
list.forEach((journal: any) => {

View File

@ -26,6 +26,7 @@
display: flex;
.radio {
background: transparent;
margin-right: 1em;
}
}

View File

@ -4,9 +4,10 @@ import Time from "../../../utils/Time";
import Toolkit from "../../../utils/Toolkit";
import config from "../../../config/index";
import { Location, MediaItem, MediaItemType, WechatMediaItem } from "../../../types/UI";
import { Journal, JournalType } from "../../../types/Journal";
import { JournalType } from "../../../types/Journal";
import { MediaAttachExt, MediaAttachType } from "../../../types/Attachment";
import IOSize, { Unit } from "../../../utils/IOSize";
import { JournalApi } from "../../../api/JournalApi";
interface JournalEditorData {
/** 模式create 或 edit */
@ -77,7 +78,7 @@ Page({
async onLoad(options: any) {
// 授权定位
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"));
this.setData({ isAuthLocation });
if (!isAuthLocation) {
@ -148,25 +149,8 @@ Page({
},
/** 加载日记详情(编辑模式) */
async loadJournalDetail(id: number) {
wx.showLoading({ title: "加载中...", mask: true });
try {
const journal: Journal = await new Promise((resolve, reject) => {
wx.request({
url: `${config.url}/journal/${id}`,
method: "POST",
header: {
Key: wx.getStorageSync("key")
},
success: (res: any) => {
if (res.data.code === 20000) {
resolve(res.data.data);
} else {
reject(new Error(res.data.message || "加载失败"));
}
},
fail: reject
});
});
const journal = await JournalApi.getDetail(id);
const items = journal.items || [];
const thumbItems = items.filter((item) => item.attachType === MediaAttachType.THUMB);
@ -293,7 +277,7 @@ Page({
// 创建模式:只有 mediaList
const sources = (this.data.mediaList as WechatMediaItem[]).map(item => ({
url: item.path,
type: MediaItemType[item.type].toLowerCase()
type: item.type.toLowerCase()
}));
const total = sources.length;
@ -309,11 +293,11 @@ Page({
// 编辑模式mediaList + newMediaList
const sources = (this.data.mediaList as MediaItem[]).map(item => ({
url: item.sourceURL,
type: MediaItemType[item.type].toLowerCase()
type: item.type
}));
const newSources = this.data.newMediaList.map(item => ({
url: item.path,
type: MediaItemType[item.type].toLowerCase()
type: item.type
}));
const allSources = [...sources, ...newSources];
const itemIndex = isNewMedia ? this.data.mediaList.length + index : index;
@ -392,21 +376,9 @@ Page({
this.executeDelete();
},
/** 执行删除 */
executeDelete() {
wx.showLoading({ title: "删除中...", mask: true });
wx.request({
url: `${config.url}/journal/delete`,
method: "POST",
header: {
Key: wx.getStorageSync("key"),
"Content-Type": "application/json"
},
data: {
id: this.data.id
},
success: (res: any) => {
wx.hideLoading();
if (res.data.code === 20000 || res.statusCode === 200) {
async executeDelete() {
try {
await JournalApi.delete(this.data.id!);
Events.emit("JOURNAL_REFRESH");
Events.emit("JOURNAL_LIST_REFRESH");
wx.showToast({
@ -416,22 +388,10 @@ Page({
setTimeout(() => {
wx.navigateBack();
}, 1000);
} else {
wx.showToast({
title: res.data.message || "删除失败",
icon: "error"
});
} catch (error) {
console.error("删除日记失败:", error);
}
},
fail: () => {
wx.hideLoading();
wx.showToast({
title: "删除失败",
icon: "error"
});
}
});
},
/** 提交/保存 */
submit() {
if (this.data.mode === "create") {
@ -441,10 +401,9 @@ Page({
}
},
/** 创建日记 */
createJournal() {
async createJournal() {
const handleFail = () => {
wx.showToast({ title: "上传失败", icon: "error" });
wx.hideLoading();
this.setData({
isSaving: false
});
@ -452,30 +411,18 @@ Page({
this.setData({
isSaving: true
});
try {
// 获取 openId
const getOpenId = new Promise<string>((resolve, reject) => {
wx.login({
success: (res) => {
success: async (res) => {
if (res.code) {
wx.request({
url: `${config.url}/journal/openid`,
method: "POST",
header: {
Key: wx.getStorageSync("key")
},
data: {
code: res.code
},
success: (resp) => {
const data = resp.data as any;
if (data.code === 20000) {
resolve(data.data);
} else {
try {
const openId = await JournalApi.getOpenId(res.code);
resolve(openId);
} catch (error) {
reject(new Error("获取 openId 失败"));
}
},
fail: () => reject(new Error("获取 openId 请求失败"))
});
} else {
reject(new Error("获取登录凭证失败"));
}
@ -486,15 +433,9 @@ Page({
// 文件上传
const uploadFiles = this.uploadMediaFiles(this.data.mediaList as WechatMediaItem[]);
// 并行执行获取 openId 和文件上传
Promise.all([getOpenId, uploadFiles]).then(([openId, tempFileIds]) => {
wx.showLoading({ title: "正在保存..", mask: true });
wx.request({
url: `${config.url}/journal/create`,
method: "POST",
header: {
Key: wx.getStorageSync("key")
},
data: {
const [openId, tempFileIds] = await Promise.all([getOpenId, uploadFiles]);
await JournalApi.create({
idea: this.data.idea,
type: this.data.type,
lat: this.data.location?.lat,
@ -503,8 +444,8 @@ Page({
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({
@ -519,16 +460,15 @@ Page({
wx.switchTab({
url: "/pages/main/journal/index"
});
},
fail: handleFail
});
}).catch(handleFail);
} catch (error) {
console.error("创建日记失败:", error);
handleFail();
}
},
/** 更新日记 */
updateJournal() {
async updateJournal() {
const handleFail = () => {
wx.showToast({ title: "保存失败", icon: "error" });
wx.hideLoading();
this.setData({
isSaving: false
});
@ -536,35 +476,24 @@ Page({
this.setData({
isSaving: true
});
try {
// 收集保留的附件 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);
// 提交保存
uploadFiles.then((tempFileIds) => {
wx.showLoading({ title: "正在保存..", mask: true });
wx.request({
url: `${config.url}/journal/update`,
method: "POST",
header: {
Key: wx.getStorageSync("key")
},
data: {
id: this.data.id,
await JournalApi.update({
id: this.data.id!,
idea: this.data.idea,
type: this.data.type,
lat: this.data.location?.lat,
lng: this.data.location?.lng,
location: this.data.location?.text,
createdAt: new Date(`${this.data.date}T${this.data.time}:00`).getTime(),
// 保留的现有附件 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" });
@ -576,14 +505,11 @@ Page({
});
await Toolkit.sleep(1000);
wx.navigateBack();
} else {
} catch (error) {
console.error("更新日记失败:", error);
handleFail();
}
},
fail: handleFail
});
}).catch(handleFail);
},
/** 上传媒体文件 */
uploadMediaFiles(mediaList: WechatMediaItem[]): Promise<string[]> {
return new Promise<string[]>((resolve, reject) => {

View File

@ -14,7 +14,7 @@
width: fit-content;
min-width: 350rpx;
max-width: 450rpx;
background: #fff;
background: var(--theme-bg-card-secondary);
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, .15);
border-radius: 6rpx;
@ -56,7 +56,7 @@
flex-direction: column;
.location {
color: #333;
color: var(--theme-text-primary);
overflow: hidden;
font-size: 30rpx;
white-space: nowrap;
@ -68,7 +68,7 @@
display: flex;
.date {
color: #999;
color: var(--theme-text-secondary);
font-size: 24rpx;
margin-right: 16rpx;
}

View File

@ -1,21 +1,10 @@
// pages/main/journal-map/index.ts
import config from "../../../config/index";
import Time from "../../../utils/Time";
import { Journal, JournalPageType } from "../../../types/Journal";
import { JournalPageType } from "../../../types/Journal";
import Toolkit from "../../../utils/Toolkit";
interface MapMarker {
id: number;
latitude: number;
longitude: number;
width: number;
height: number;
customCallout: {
anchorY: number;
anchorX: number;
display: string;
};
}
import { MapMarker } from "../../../types/UI";
import { JournalApi } from "../../../api/JournalApi";
interface LocationMarker {
locationKey: string; // 位置键 "lat,lng"
@ -62,28 +51,12 @@ Page({
async loadJournals() {
this.setData({ isLoading: true });
try {
const list: Journal[] = await new Promise((resolve, reject) => {
wx.request({
url: `${config.url}/journal/list`,
method: "POST",
header: {
Key: wx.getStorageSync("key")
},
data: {
page: 0,
const result = await JournalApi.getList({
index: 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 list = result.list || [];
// 过滤有位置信息的记录,并按位置分组
const locationMap = new Map<string, LocationMarker>();
list.filter((journal: any) => journal.lat && journal.lng).forEach((journal: any) => {

View File

@ -5,9 +5,10 @@ import config from "../../../config/index"
import Events from "../../../utils/Events";
import Toolkit from "../../../utils/Toolkit";
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 { MediaItem, MediaItemType } from "../../../types/UI";
import { JournalApi } from "../../../api/JournalApi";
interface JournalData {
page: JournalPage;
@ -143,27 +144,21 @@ Page({
url: "/pages/main/journal-date/index"
})
},
fetch() {
async fetch() {
if (this.data.isFetching || this.data.isFinished) {
return;
}
this.setData({
isFetching: true
});
wx.request({
url: `${config.url}/journal/list`,
method: "POST",
header: {
Key: wx.getStorageSync("key")
},
data: this.data.page,
success: async (resp: any) => {
const pageResult = resp.data.data as QueryPageResult<Journal>;
try {
const pageResult = await JournalApi.getList(this.data.page);
const list = pageResult.list;
if (!list || list.length === 0) {
this.setData({
isFinished: true
})
isFinished: true,
isFetching: false
});
return;
}
list.forEach(journal => {
@ -193,7 +188,7 @@ Page({
}
return 1;
})
})
});
this.setData({
page: {
index: this.data.page.index + 1,
@ -207,15 +202,13 @@ Page({
}
},
list: this.data.list.concat(list),
isFinished: list.length < this.data.page.size
});
},
complete: () => {
this.setData({
isFinished: list.length < this.data.page.size,
isFetching: false
});
} catch (error) {
console.error("加载日记失败:", error);
this.setData({ isFetching: false });
}
});
},
preview(e: WechatMiniprogram.BaseEvent) {
const { journalIndex, itemIndex } = e.currentTarget.dataset;

View File

@ -41,7 +41,7 @@
<view wx:for="{{journal.columnedItems}}" wx:for-item="column" wx:for-index="columnIndex" wx:key="columnIndex" class="column">
<block wx:for="{{column}}" wx:for-item="item" wx:for-index="itemIndex" wx:key="attachmentId">
<image
class="item thumbnail {{item.type === 0 ? 'image' : 'video'}}"
class="item thumbnail {{item.type}}"
src="{{item.thumbURL}}"
mode="widthFix"
bindtap="preview"

View File

@ -4,22 +4,20 @@ import Events from "../../../utils/Events";
import IOSize, { Unit } from "../../../utils/IOSize";
import Time from "../../../utils/Time";
import Toolkit from "../../../utils/Toolkit";
import type { Location } from "../../../types/UI";
import { Location, MediaItemType } from "../../../types/UI";
import { MediaAttachExt } from "../../../types/Attachment";
import { MomentApi } from "../../../api/MomentApi";
import { JournalApi } from "../../../api/JournalApi";
import { Network } from "../../../utils/Network";
type Item = {
id: number;
type: ItemType;
mongoId: string;
thumbUrl: string;
sourceMongoId: string;
type: MediaItemType;
thumbURL: string;
sourceURL: string;
checked: boolean;
}
enum ItemType {
IMAGE,
VIDEO
}
type MD5Result = {
path: string;
md5: string;
@ -73,7 +71,7 @@ Page({
// 授权定位
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"));
this.setData({ isAuthLocation });
if (!isAuthLocation) {
@ -128,33 +126,29 @@ Page({
}
});
},
fetch() {
wx.request({
url: `${config.url}/journal/moment/list`,
method: "POST",
header: {
Key: wx.getStorageSync("key")
},
success: async (resp: any) => {
const list = resp.data.data;
async fetch() {
try {
const list = await MomentApi.getList();
if (!list || list.length === 0) {
return;
}
this.setData({
list: list.map((item: any) => {
const extData = JSON.parse(item.ext);
const ext = JSON.parse(item.ext) as MediaAttachExt;
const thumbURL = `${config.url}/attachment/read/${item.mongoId}`;
const sourceURL = `${config.url}/attachment/read/${ext.sourceMongoId}`;
return {
id: item.id,
type: extData.isImage ? ItemType.IMAGE : ItemType.VIDEO,
mongoId: item.mongoId,
thumbUrl: `${config.url}/attachment/read/${item.mongoId}`,
sourceMongoId: extData.sourceMongoId,
type: ext.isImage ? MediaItemType.IMAGE : MediaItemType.VIDEO,
thumbURL,
sourceURL,
checked: false
} as Item;
})
});
} catch (error) {
console.error("加载 moment 列表失败:", error);
}
});
},
updateHasChecked() {
this.setData({ hasChecked: this.data.list.some(item => item.checked) });
@ -176,8 +170,8 @@ Page({
const sources = this.data.list.slice(startIndex, endIndex).map((item: Item) => {
return {
url: `${config.url}/attachment/read/${item.sourceMongoId}`,
type: item.type === 0 ? "image" : "video"
url: item.sourceURL,
type: item.type.toLowerCase()
}
}) as any;
wx.previewMedia({
@ -230,130 +224,49 @@ Page({
} as MD5Result);
}));
// 查重
const filterMD5Result: string[] = await new Promise((resolve, reject) => {
wx.request({
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 filterMD5Result: string[] = await MomentApi.filterByMD5(
md5Results.map(item => item.md5)
);
// 过滤文件
const filterPath = md5Results.filter(item => filterMD5Result.indexOf(item.md5) !== -1)
.map(item => item.path);
files = files.filter(file => filterPath.indexOf(file.tempFilePath) !== -1);
if (files.length === 0) {
wx.hideLoading();
that.setData({ isUploading: false });
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({
uploadTotal: IOSize.format(totalSize, 2, Unit.MB)
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
});
// 计算上传速度
const speedUpdateInterval = setInterval(() => {
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"
showLoading: true
});
// 上传完成转附件
wx.request({
url: `${config.url}/journal/moment/create`,
method: "POST",
header: {
Key: wx.getStorageSync("key")
},
data: tempFileIds,
success: async (resp: any) => {
const list = await MomentApi.create(tempFileIds);
wx.showToast({ title: "上传成功", icon: "success" });
const list = resp.data.data;
const added = list.map((item: any) => {
const extData = JSON.parse(item.ext);
const ext = JSON.parse(item.ext) as MediaAttachExt;
const thumbURL = `${config.url}/attachment/read/${item.mongoId}`;
const sourceURL = `${config.url}/attachment/read/${ext.sourceMongoId}`;
return {
id: item.id,
type: extData.isImage ? ItemType.IMAGE : ItemType.VIDEO,
mongoId: item.mongoId,
thumbUrl: `${config.url}/attachment/read/${item.mongoId}`,
sourceMongoId: extData.sourceMongoId,
type: ext.isImage ? MediaItemType.IMAGE : MediaItemType.VIDEO,
thumbURL,
sourceURL,
checked: false
} as Item;
});
@ -367,17 +280,9 @@ Page({
uploadProgress: 0
});
that.updateHasChecked();
wx.hideLoading();
},
fail: handleFail
});
}).catch((e: Error) => {
// 取消所有上传任务
uploadTasks.forEach(task => task.abort());
that.updateHasChecked();
handleFail(e);
});
}).catch(handleFail);
} catch (error) {
handleFail(error);
}
}
})
},
@ -453,27 +358,14 @@ Page({
})
const openId = await new Promise<string>((resolve, reject) => {
wx.login({
success: (res) => {
success: async (res) => {
if (res.code) {
wx.request({
url: `${config.url}/journal/openid`,
method: "POST",
header: {
Key: wx.getStorageSync("key")
},
data: {
code: res.code
},
success: (resp) => {
const data = resp.data as any;
if (data.code === 20000) {
resolve(data.data);
} else {
try {
const openId = await JournalApi.getOpenId(res.code);
resolve(openId);
} catch (error) {
reject(new Error("获取 openId 失败"));
}
},
fail: () => reject(new Error("获取 openId 请求失败"))
});
} else {
reject(new Error("获取登录凭证失败"));
}
@ -494,15 +386,8 @@ Page({
if (this.data.selectedJournalId) {
archiveData.id = this.data.selectedJournalId;
}
wx.request({
url: `${config.url}/journal/moment/archive`,
method: "POST",
header: {
Key: wx.getStorageSync("key")
},
data: archiveData,
success: async (resp: any) => {
if (resp.data && resp.data.code === 20000) {
try {
await MomentApi.archive(archiveData);
Events.emit("JOURNAL_REFRESH");
wx.showToast({ title: "归档成功", icon: "success" });
this.setData({
@ -515,16 +400,10 @@ Page({
});
await Toolkit.sleep(1000);
this.fetch();
} else {
wx.showToast({ title: "归档失败", icon: "error" });
this.setData({
isArchiving: false
});
} catch (error) {
handleFail();
}
},
fail: handleFail
});
},
allChecked() {
this.data.list.forEach(item => item.checked = true);
this.setData({
@ -559,27 +438,21 @@ Page({
confirmText: "删除已选",
confirmColor: "#E64340",
cancelText: "取消",
success: res => {
success: async (res) => {
if (res.confirm) {
const selected = this.data.list.filter(item => item.checked);
wx.request({
url: `${config.url}/journal/moment/delete`,
method: "POST",
header: {
Key: wx.getStorageSync("key")
},
data: selected.map(item => item.id),
success: async (resp: any) => {
if (resp.data && resp.data.code === 20000) {
try {
await MomentApi.delete(selected.map(item => item.id));
wx.showToast({ title: "删除成功", icon: "success" });
const list = this.data.list.filter(item => !item.checked);
this.setData({
list
});
this.updateHasChecked();
} catch (error) {
console.error("删除 moment 失败:", error);
wx.showToast({ title: "删除失败", icon: "error" });
}
},
});
}
}
})

View File

@ -63,8 +63,8 @@
<view class="items">
<view class="item" wx:for="{{list}}" wx:key="mongoId">
<image
class="thumbnail {{item.type === 0 ? 'image' : 'video'}}"
src="{{item.thumbUrl}}"
class="thumbnail {{item.type}}"
src="{{item.thumbURL}}"
mode="widthFix"
bind:tap="preview"
data-index="{{index}}"

View File

@ -5,9 +5,10 @@ import config from "../../../config/index"
import Events from "../../../utils/Events";
import Toolkit from "../../../utils/Toolkit";
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 { MediaItem, MediaItemType } from "../../../types/UI";
import { JournalApi } from "../../../api/JournalApi";
interface IPortfolioData {
page: JournalPage;
@ -72,26 +73,20 @@ Page({
this.setData({ stickyOffset: height });
});
},
fetch() {
async fetch() {
if (this.data.isFetching || this.data.isFinished) {
return;
}
this.setData({
isFetching: true
});
wx.request({
url: `${config.url}/journal/list`,
method: "POST",
header: {
Key: wx.getStorageSync("key")
},
data: this.data.page,
success: async (resp: any) => {
const pageResult = resp.data.data as QueryPageResult<Journal>;
try {
const pageResult = await JournalApi.getList(this.data.page);
const list = pageResult.list;
if (!list || list.length === 0) {
this.setData({
isFinished: true
isFinished: true,
isFetching: false
})
return;
}
@ -136,15 +131,13 @@ Page({
}
},
list: this.data.list.concat(list),
isFinished: list.length < this.data.page.size
});
},
complete: () => {
this.setData({
isFinished: list.length < this.data.page.size,
isFetching: false
});
} catch (error) {
console.error("加载 portfolio 列表失败:", error);
this.setData({ isFetching: false });
}
});
},
preview(e: WechatMiniprogram.BaseEvent) {
const { journalIndex, itemIndex } = e.currentTarget.dataset;

View File

@ -18,7 +18,7 @@
<view wx:for="{{journal.columnedItems}}" wx:for-item="column" wx:for-index="columnIndex" wx:key="columnIndex" class="column">
<block wx:for="{{column}}" wx:for-item="item" wx:for-index="itemIndex" wx:key="attachmentId">
<image
class="item thumbnail {{item.type === 0 ? 'image' : 'video'}}"
class="item thumbnail {{item.type.toLowerCase()}}"
src="{{item.thumbURL}}"
mode="widthFix"
bindtap="preview"

View File

@ -40,9 +40,8 @@
&.locations {
.action {
gap: 32rpx;
display: flex;
.header {
padding: 16rpx 32rpx;
}
.location {

View File

@ -6,9 +6,9 @@ import { TravelLocationApi } from "../../../api/TravelLocationApi";
import { Travel, TravelStatusLabel, TravelStatusIcon, TransportationTypeLabel, TravelLocation, TravelLocationTypeLabel, TravelLocationTypeIcon } from "../../../types/Travel";
interface TravelDetailData {
/** 行详情 */
/** 行详情 */
travel: Travel | null;
/** 行 ID */
/** 行 ID */
travelId: string;
/** 是否正在加载 */
isLoading: boolean;
@ -71,7 +71,7 @@ Page({
}
},
/** 获取行详情 */
/** 获取行详情 */
async fetchDetail(id: string) {
this.setData({ isLoading: true });
@ -88,7 +88,7 @@ Page({
// 获取地点列表
this.fetchLocations(id);
} catch (error) {
console.error("获取行详情失败:", error);
console.error("获取行详情失败:", error);
wx.showToast({
title: "加载失败",
icon: "error"
@ -122,7 +122,7 @@ Page({
}
},
/** 编辑行 */
/** 编辑行 */
toEdit() {
const { travel } = this.data;
if (travel && travel.id) {
@ -163,7 +163,7 @@ Page({
}
},
/** 删除行 */
/** 删除行 */
deleteTravel() {
this.setData({
deleteDialogVisible: true,

View File

@ -1,6 +1,6 @@
<!--pages/main/travel-detail/index.wxml-->
<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">
<t-icon name="edit" size="24px" />
</view>
@ -24,7 +24,7 @@
</t-tag>
</view>
<!-- 标题 -->
<view class="section title">{{travel.title || '未命名行'}}</view>
<view class="section title">{{travel.title || '未命名行'}}</view>
<!-- 基本信息 -->
<t-cell-group class="section info">
<view slot="title" class="title">基本信息</view>
@ -34,7 +34,7 @@
<text wx:else class="undecided-value">未定</text>
</view>
</t-cell>
<t-cell left-icon="calendar" title="行天数">
<t-cell left-icon="calendar" title="行天数">
<view slot="note">
<text wx:if="{{travel.days}}">{{travel.days}} 天</text>
<text wx:else class="undecided-value">未定</text>
@ -44,18 +44,16 @@
<view slot="note">{{transportLabels[travel.transportationType]}}</view>
</t-cell>
</t-cell-group>
<!-- 行内容 -->
<t-cell-group class="section">
<!-- 行内容 -->
<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>
<view slot="right-icon" class="action">
<t-icon name="map" size="20px" color="var(--theme-wx)" bind:tap="toMap" />
<t-icon name="add" size="20px" color="var(--theme-wx)" bind:tap="toAddLocation" />
</view>
<t-cell class="header">
<t-button slot="left-icon" theme="primary" icon="map" size="small" bind:tap="toMap">地图浏览</t-button>
<t-icon slot="right-icon" name="add" size="20px" color="var(--theme-wx)" bind:tap="toAddLocation" />
</t-cell>
<t-cell wx:if="{{isLoadingLocations}}" class="loading">
<t-loading slot="title" theme="dots" size="40rpx" />
@ -73,14 +71,18 @@
>
<view slot="note" class="note">{{locationTypeLabels[item.type]}}</view>
<view slot="description" class="description">
<view wx:if="{{item.amount}}" class="item">
<t-icon name="money" size="14px" />
<text>¥{{item.amount}}</text>
</view>
<view wx:if="{{item.requireIdCard}}" class="item">
<t-icon name="user" size="14px" />
<text>需要身份证</text>
</view>
<view wx:if="{{item.requireAppointment}}" class="item">
<t-icon name="user" size="14px" />
<text>需要预约</text>
</view>
<view wx:if="{{item.amount}}" class="item">
<t-icon name="money" size="14px" />
<text>¥{{item.amount}}</text>
</view>
<view wx:if="{{item.importance}}" class="item">
<t-icon name="chart-bubble" size="14px" />
<text>重要程度</text>
@ -97,6 +99,7 @@
</view>
</t-cell>
</block>
<t-cell wx:else class="empty-state" description="暂无地点信息" />
</t-cell-group>
<!-- 操作按钮 -->
<view class="section action">
@ -117,7 +120,7 @@
t-class="edit"
bind:tap="toEdit"
>
编辑行计划
编辑行计划
</t-button>
</view>
</view>
@ -126,7 +129,7 @@
<!-- 删除确认对话框 -->
<t-dialog
visible="{{deleteDialogVisible}}"
title="删除行计划"
title="删除行计划"
confirm-btn="{{ {content: '删除', variant: 'text', theme: 'danger'} }}"
cancel-btn="取消"
bind:confirm="confirmDelete"

View File

@ -1,9 +1,8 @@
// pages/main/travel-editor/index.less
.container {
.travel-editor {
width: 100vw;
min-height: 100vh;
background: var(--theme-bg-secondary);
.content {
padding-bottom: 64rpx;
@ -24,12 +23,23 @@
.section {
margin-top: 48rpx;
> .title {
color: var(--theme-text-secondary);
padding: 0 32rpx;
font-size: 28rpx;
line-height: 64rpx;
}
.picker .slot {
gap: 16rpx;
display: flex;
align-items: center;
}
.note {
color: var(--theme-text-primary);
}
.travel-at-content,
.days-content {
gap: 16rpx;
@ -55,11 +65,18 @@
}
}
.days-stepper {
.days {
&.decided {
--td-cell-vertical-padding: 24rpx;
.t-cell__title {
display: flex;
align-items: center;
}
}
}
}
.submit-section {
gap: 24rpx;

View File

@ -7,7 +7,7 @@ import { TravelStatus, TransportationType } from "../../../types/Travel";
interface TravelEditorData {
/** 模式create 或 edit */
mode: "create" | "edit";
/** 行 ID编辑模式 */
/** 行 ID编辑模式 */
id?: number;
/** 标题 */
title: string;
@ -105,7 +105,7 @@ Page({
});
}
},
/** 加载行详情(编辑模式) */
/** 加载行详情(编辑模式) */
async loadTravelDetail(id: number) {
wx.showLoading({ title: "加载中...", mask: true });
try {
@ -230,7 +230,7 @@ Page({
this.updateTravel();
}
},
/** 创建行 */
/** 创建行 */
async createTravel() {
this.setData({ isSaving: true });
@ -238,9 +238,7 @@ Page({
await TravelApi.create({
title: this.data.title.trim(),
content: this.data.content.trim(),
travelAt: this.data.travelAtUndecided
? null
: new Date(`${this.data.date}T${this.data.time}:00`).getTime(),
travelAt: this.data.travelAtUndecided ? null : Time.now(),
days: this.data.daysUndecided ? null : this.data.days,
transportationType: this.data.transportationType,
status: this.data.status
@ -256,7 +254,7 @@ Page({
this.setData({ isSaving: false });
}
},
/** 更新行 */
/** 更新行 */
async updateTravel() {
this.setData({ isSaving: true });
try {
@ -283,7 +281,7 @@ Page({
this.setData({ isSaving: false });
}
},
/** 删除行 */
/** 删除行 */
deleteTravel() {
this.setData({
deleteDialogVisible: true,

View File

@ -1,9 +1,9 @@
<!--pages/main/travel-editor/index.wxml-->
<t-navbar title="{{mode === 'create' ? '新建行' : '编辑行'}}">
<t-navbar title="{{mode === 'create' ? '新建行' : '编辑行'}}">
<text slot="left" bindtap="cancel">取消</text>
</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 wx:if="{{isLoading}}" class="loading">
<t-loading theme="dots" size="40rpx" />
@ -11,12 +11,12 @@
</view>
<block wx:else>
<t-cell-group class="section">
<view slot="title" class="title">基本信息</view>
<t-input
class="input"
placeholder="请输入行标题"
placeholder="请输入行标题"
model:value="{{title}}"
maxlength="50"
borderless
>
<text slot="label">标题</text>
</t-input>
@ -31,6 +31,7 @@
</t-textarea>
</t-cell-group>
<t-cell-group class="section">
<view slot="title" class="title">详细信息</view>
<t-cell class="travel-at" title="出行时间">
<view slot="right-icon" class="travel-at-content">
<picker wx:if="{{!travelAtUndecided}}" class="picker" mode="date" model:value="{{date}}">
@ -51,13 +52,13 @@
/>
</view>
</t-cell>
<t-cell title="行天数" t-class="days-cell">
<t-cell title="行天数" class="days {{daysUndecided ? 'undecided' : 'decided'}}">
<view slot="right-icon" class="days-content">
<t-stepper
wx:if="{{!daysUndecided}}"
theme="filled"
model:value="{{days}}"
size="medium"
size="large"
min="{{1}}"
max="{{999}}"
t-class="stepper"
@ -74,40 +75,28 @@
/>
</view>
</t-cell>
<t-cell title="交通方式">
<view slot="right-icon">
<picker
class="picker"
mode="selector"
range="{{transportationTypes}}"
range-key="label"
value="{{transportationTypeIndex}}"
bindchange="onChangeTransportationType"
>
<view class="slot">
<text>{{transportationTypes[transportationTypeIndex].label}}</text>
<t-icon name="chevron-right" size="20px" class="icon" />
</view>
</picker>
</view>
<t-cell title="交通方式" arrow>
<view slot="note" class="note">{{transportationTypes[transportationTypeIndex].label}}</view>
</t-cell>
<t-cell title="状态">
<view slot="right-icon">
</picker>
<picker
class="picker"
mode="selector"
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 title="状态" arrow>
<view slot="note" class="note">{{statuses[statusIndex].label}}</view>
</t-cell>
</picker>
</t-cell-group>
<view wx:if="{{mode === 'create'}}" class="submit-section">
<t-button
@ -117,7 +106,7 @@
bind:tap="submit"
disabled="{{isSaving}}"
>
创建
创建
</t-button>
</view>
<view wx:else class="submit-section horizontal">
@ -148,7 +137,7 @@
<!-- 删除确认对话框 -->
<t-dialog
visible="{{deleteDialogVisible}}"
title="删除行计划"
title="删除行计划"
confirm-btn="{{ {content: '删除', variant: 'text', theme: 'danger'} }}"
cancel-btn="取消"
bind:confirm="confirmDelete"

View File

@ -1,7 +1,6 @@
{
"component": true,
"usingComponents": {
"t-tag": "tdesign-miniprogram/tag/tag",
"t-cell": "tdesign-miniprogram/cell/cell",
"t-rate": "tdesign-miniprogram/rate/rate",
"t-icon": "tdesign-miniprogram/icon/icon",

View File

@ -2,7 +2,6 @@
.travel-location-detail {
width: 100vw;
min-height: 100vh;
background: var(--theme-bg-page);
box-sizing: border-box;
.status-card {
@ -25,12 +24,6 @@
line-height: 64rpx;
}
&.status {
display: flex;
margin-top: 24rpx;
justify-content: center;
}
&.title {
color: var(--theme-text-primary);
padding: 24rpx;
@ -68,6 +61,26 @@
width: 100%;
height: 520rpx;
}
.custom-callout {
width: fit-content;
max-width: 400rpx;
background: var(--theme-bg-card-secondary);
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, .15);
border-radius: 8rpx;
.callout-content {
padding: 12rpx 20rpx;
.callout-text {
color: var(--theme-text-primary);
overflow: hidden;
font-size: 28rpx;
white-space: nowrap;
text-overflow: ellipsis;
}
}
}
}
&.media {
@ -113,12 +126,13 @@
&.navigate {
padding: 0 16rpx;
margin-top: 90rpx;
}
&.action {
gap: 24rpx;
display: flex;
padding: 24rpx 16rpx 0 16rpx;
padding: 0 16rpx;
.edit {
flex: 2;

View File

@ -1,18 +1,13 @@
// pages/main/travel-location-detail/index.ts
import Time from "../../../utils/Time";
import config from "../../../config/index";
import { TravelLocationApi } from "../../../api/TravelLocationApi";
import { TravelLocation, TravelLocationTypeIcon, TravelLocationTypeLabel } from "../../../types/Travel";
import { MediaAttachExt, MediaAttachType } from "../../../types/Attachment";
import { MediaItem, MediaItemType } from "../../../types/UI";
import { MapMarker, MediaItem, MediaItemType } from "../../../types/UI";
import Toolkit from "../../../utils/Toolkit";
interface TravelLocationView extends TravelLocation {
/** 首次出行时间 */
firstTravelTime?: string;
/** 最近出行时间 */
lastTravelTime?: string;
/** 媒体列表 */
mediaItems?: MediaItem[];
}
@ -22,7 +17,7 @@ interface TravelLocationDetailData {
location: TravelLocationView | null;
/** 地点 ID */
locationId: string;
/** 行 ID */
/** 行 ID */
travelId: string;
/** 是否正在加载 */
isLoading: boolean;
@ -35,7 +30,7 @@ interface TravelLocationDetailData {
/** 媒体类型枚举 */
mediaItemTypeEnum: typeof MediaItemType;
/** 地图标记 */
mapMarkers: WechatMiniprogram.MapMarker[];
mapMarkers: MapMarker[];
/** 删除对话框可见性 */
deleteDialogVisible: boolean;
/** 删除确认文本 */
@ -100,11 +95,7 @@ Page({
thumbItems.forEach((thumbItem) => {
try {
const extStr = thumbItem.ext ? thumbItem.ext.toString() : "";
if (!extStr) {
return;
}
const ext = JSON.parse(extStr) as MediaAttachExt;
const ext = JSON.parse(thumbItem.ext!.toString()) as MediaAttachExt;
const thumbURL = `${config.url}/attachment/read/${thumbItem.mongoId}`;
const sourceURL = `${config.url}/attachment/read/${ext.sourceMongoId}`;
mediaItems.push({
@ -120,23 +111,18 @@ Page({
});
// 构建地图标记
const mapMarkers: WechatMiniprogram.MapMarker[] = [];
const mapMarkers: MapMarker[] = [];
if (location.lat !== undefined && location.lng !== undefined) {
mapMarkers.push({
id: 0,
latitude: location.lat,
longitude: location.lng,
width: 30,
width: 24,
height: 30,
callout: {
content: location.title || "地点",
display: "ALWAYS",
padding: 10,
borderRadius: 5,
bgColor: "#FFFFFF",
color: "#333333",
fontSize: 12,
textAlign: "center"
customCallout: {
anchorY: 0,
anchorX: 0,
display: "ALWAYS"
}
});
}
@ -146,9 +132,7 @@ Page({
this.setData({
location: {
...location,
mediaItems,
firstTravelTime: location.firstTraveledAt ? Time.toDateTime(location.firstTraveledAt) : "",
lastTravelTime: location.lastTraveledAt ? Time.toDateTime(location.lastTraveledAt) : ""
mediaItems
},
travelId: location.travelId ? String(location.travelId) : this.data.travelId,
mapMarkers
@ -214,7 +198,7 @@ Page({
const sources = location.mediaItems.map(item => ({
url: item.sourceURL,
type: MediaItemType[item.type].toLowerCase()
type: item.type
}));
const total = sources.length;

View File

@ -20,12 +20,6 @@
<t-empty icon="location" description="暂无地点信息" />
</view>
<view wx:else class="content">
<!-- 类型标签 -->
<view class="section status">
<t-tag size="large" theme="primary" variant="light" icon="{{locationTypeIcons[location.type]}}">
{{locationTypeLabels[location.type]}}
</t-tag>
</view>
<!-- 标题 -->
<view class="section title">
<text class="title-text">{{location.title || '未命名地点'}}</text>
@ -33,6 +27,11 @@
<!-- 位置信息 -->
<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"
@ -42,7 +41,15 @@
markers="{{mapMarkers}}"
scale="15"
show-location
></map>
>
<cover-view slot="callout">
<cover-view class="custom-callout" marker-id="0">
<cover-view class="callout-content">
<cover-view class="callout-text">{{location.title || '地点'}}</cover-view>
</cover-view>
</cover-view>
</cover-view>
</map>
</t-cell>
<t-cell
left-icon="location"
@ -57,13 +64,13 @@
<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="需要身份证">
<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 ? 'warning' : ''}}">
<t-cell left-icon="calendar" title="预约">
<view slot="note" class="{{location.requireAppointment ? 'red' : ''}}">
{{location.requireAppointment ? '需要' : '无需'}}
</view>
</t-cell>
@ -78,19 +85,6 @@
</view>
</t-cell>
</t-cell-group>
<!-- 出行记录 -->
<t-cell-group class="section">
<view slot="title" class="title">出行记录</view>
<t-cell left-icon="flag" title="首次出行">
<view slot="note">{{location.firstTravelTime || '未记录'}}</view>
</t-cell>
<t-cell left-icon="calendar-1" title="最近出行">
<view slot="note">{{location.lastTravelTime || '未记录'}}</view>
</t-cell>
<t-cell left-icon="chart" title="累计次数">
<view slot="note">{{location.travelCount || 0}} 次</view>
</t-cell>
</t-cell-group>
<!-- 详细说明 -->
<t-cell-group wx:if="{{location.description}}" class="section">
<view slot="title" class="title">详细说明</view>

View File

@ -3,7 +3,6 @@
.travel-location-editor {
width: 100vw;
min-height: 100vh;
background: var(--theme-bg-secondary);
.content {
padding-bottom: 64rpx;
@ -31,17 +30,18 @@
line-height: 64rpx;
}
.location {
&.location {
.note {
color: var(--theme-text-primary);
}
.value {
.title {
width: 2em;
}
}
.picker .slot {
gap: 16rpx;
display: flex;
align-items: center;
}
&.media {
@ -128,75 +128,8 @@
}
}
}
}
.media-section {
margin-top: 48rpx;
padding: 32rpx;
background: var(--theme-bg-card);
.section-title {
color: var(--theme-text-primary);
margin-bottom: 24rpx;
font-size: 32rpx;
font-weight: bold;
}
.media-grid {
gap: 24rpx;
display: grid;
grid-template-columns: repeat(3, 1fr);
.media-item {
width: 100%;
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 {
width: 100%;
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 {
&.upload {
gap: 16rpx;
display: flex;
padding: 24rpx 32rpx;
@ -205,17 +138,16 @@
border-radius: 12rpx;
background: var(--theme-bg-card);
.upload-text {
.text {
color: var(--theme-text-secondary);
font-size: 28rpx;
}
}
.submit-section {
&.action {
gap: 24rpx;
display: flex;
padding: 24rpx 16rpx 48rpx 16rpx;
margin-top: 64rpx;
.delete-btn {
flex: .6;
@ -227,6 +159,7 @@
}
}
}
}
.delete-dialog {
padding: 16rpx 0;

View File

@ -10,9 +10,9 @@ import { MediaItem, MediaItemType } from "../../../types/UI";
interface TravelLocationEditorData {
/** 模式create 或 edit */
mode: "create" | "edit";
/** 行地点 ID编辑模式 */
/** 行地点 ID编辑模式 */
id?: number;
/** 关联的行计划 ID */
/** 关联的行计划 ID */
travelId: number;
/** 地点类型 */
type: TravelLocationType;
@ -32,12 +32,6 @@ interface TravelLocationEditorData {
requireIdCard: boolean;
/** 是否需要预约 */
requireAppointment: boolean;
/** 首次出行时间戳 */
firstTraveledAt: number;
/** 上次出行时间戳 */
lastTraveledAt: number;
/** 出行次数 */
travelCount: number;
/** 评分 */
score: number;
/** 重要程度 */
@ -55,11 +49,11 @@ interface TravelLocationEditorData {
/** 上传进度信息 */
uploadInfo: string;
/** 地点类型选项 */
locationTypes: { label: string; value: TravelLocationType }[];
locationTypes: string[];
/** 地点类型值数组 */
locationTypeValues: TravelLocationType[];
/** 地点类型选中索引 */
locationTypeIndex: number;
/** 地点类型选择器可见性 */
locationTypePickerVisible: boolean;
/** 删除对话框可见性 */
deleteDialogVisible: boolean;
/** 删除确认文本 */
@ -82,9 +76,6 @@ Page({
amount: 0,
requireIdCard: false,
requireAppointment: false,
firstTraveledAt: 0,
lastTraveledAt: 0,
travelCount: 0,
score: 3,
importance: 1,
mediaList: [],
@ -96,16 +87,17 @@ Page({
mediaItemTypeEnum: {
...MediaItemType
},
locationTypes: [
{ label: "景点", value: TravelLocationType.ATTRACTION },
{ label: "酒店", value: TravelLocationType.HOTEL },
{ label: "餐厅", value: TravelLocationType.RESTAURANT },
{ label: "交通站点", value: TravelLocationType.TRANSPORT },
{ label: "购物", value: TravelLocationType.SHOPPING },
{ label: "其他", value: TravelLocationType.OTHER }
locationTypes: ["美食", "酒店", "交通", "景点", "购物", "玩乐", "生活"],
locationTypeValues: [
TravelLocationType.FOOD,
TravelLocationType.HOTEL,
TravelLocationType.TRANSPORT,
TravelLocationType.ATTRACTION,
TravelLocationType.SHOPPING,
TravelLocationType.PLAY,
TravelLocationType.LIFE
],
locationTypeIndex: 0,
locationTypePickerVisible: false,
deleteDialogVisible: false,
deleteConfirmText: ""
},
@ -115,7 +107,7 @@ Page({
const travelId = options.travelId ? parseInt(options.travelId) : 0;
if (!travelId) {
wx.showToast({
title: "缺少行计划 ID",
title: "缺少行计划 ID",
icon: "error"
});
setTimeout(() => {
@ -155,8 +147,8 @@ Page({
// 计算地点类型索引
const type = location.type || TravelLocationType.ATTRACTION;
const locationTypeIndex = this.data.locationTypes.findIndex(
item => item.value === type
const locationTypeIndex = this.data.locationTypeValues.findIndex(
item => item === type
);
const items = location.items || [];
@ -186,9 +178,6 @@ Page({
amount: location.amount || 0,
requireIdCard: location.requireIdCard || false,
requireAppointment: location.requireAppointment || false,
firstTraveledAt: location.firstTraveledAt || 0,
lastTraveledAt: location.lastTraveledAt || 0,
travelCount: location.travelCount || 0,
score: location.score !== undefined ? location.score : 3,
importance: location.importance !== undefined ? location.importance : 1,
mediaList,
@ -212,30 +201,10 @@ Page({
const index = e.detail.value;
this.setData({
locationTypeIndex: index,
type: this.data.locationTypes[index].value
type: this.data.locationTypeValues[index]
});
},
/** 显示地点类型选择器 */
showLocationTypePicker() {
this.setData({ locationTypePickerVisible: true });
},
/** Picker 确认 */
onPickerConfirm(e: any) {
const index = e.detail.value;
this.setData({
locationTypeIndex: index,
type: this.data.locationTypes[index].value,
locationTypePickerVisible: false
});
},
/** Picker 取消 */
onPickerCancel() {
this.setData({ locationTypePickerVisible: false });
},
/** 改变是否需要身份证 */
onChangeRequireIdCard(e: any) {
this.setData({ requireIdCard: e.detail.value });
@ -355,7 +324,7 @@ Page({
// 创建模式:只有 mediaList
const sources = (this.data.mediaList as WechatMediaItem[]).map(item => ({
url: item.path,
type: MediaItemType[item.type].toLowerCase()
type: item.type!.toLowerCase()
}));
const total = sources.length;
@ -371,11 +340,11 @@ Page({
// 编辑模式mediaList + newMediaList
const sources = (this.data.mediaList as MediaItem[]).map(item => ({
url: item.sourceURL,
type: MediaItemType[item.type].toLowerCase()
type: item.type.toLowerCase()
}));
const newSources = this.data.newMediaList.map(item => ({
url: item.path,
type: MediaItemType[item.type].toLowerCase()
type: item.type!.toLowerCase()
}));
const allSources = [...sources, ...newSources];
const itemIndex = isNewMedia ? this.data.mediaList.length + index : index;
@ -514,9 +483,6 @@ Page({
amount: this.data.amount,
requireIdCard: this.data.requireIdCard,
requireAppointment: this.data.requireAppointment,
firstTraveledAt: this.data.firstTraveledAt,
lastTraveledAt: this.data.lastTraveledAt,
travelCount: this.data.travelCount,
score: this.data.score,
importance: this.data.importance,
tempFileIds
@ -573,9 +539,6 @@ Page({
amount: this.data.amount,
requireIdCard: this.data.requireIdCard,
requireAppointment: this.data.requireAppointment,
firstTraveledAt: this.data.firstTraveledAt,
lastTraveledAt: this.data.lastTraveledAt,
travelCount: this.data.travelCount,
score: this.data.score,
importance: this.data.importance,
attachmentIds,

View File

@ -3,21 +3,23 @@
<text slot="left" bindtap="cancel">取消</text>
</t-navbar>
<scroll-view class="travel-location-editor" 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 wx:if="{{isLoading}}" class="loading">
<t-loading theme="dots" size="40rpx" />
<text class="text">加载中...</text>
</view>
<block wx:else>
<t-cell-group class="section">
<t-cell-group class="section location">
<view slot="title" class="title">位置信息</view>
<t-cell title="地点类型" arrow bind:click="showLocationTypePicker">
<view slot="note" class="black">{{locationTypes[locationTypeIndex].label}}</view>
<picker mode="selector" range="{{locationTypes}}" value="{{locationTypeIndex}}" bindchange="onChangeLocationType">
<t-cell title="地点类型" arrow>
<view slot="note" class="note">{{locationTypes[locationTypeIndex]}}</view>
</t-cell>
<t-cell class="location" required arrow bind:click="chooseLocation">
</picker>
<t-cell class="value" required arrow bind:click="chooseLocation">
<view slot="title" class="title">位置</view>
<view slot="note" class="black">{{location}}</view>
<view slot="note" class="note">{{location}}</view>
</t-cell>
</t-cell-group>
<t-cell-group class="section">
@ -46,6 +48,7 @@
placeholder="0"
label="费用"
suffix="元"
type="digit"
align="right"
/>
<t-cell title="需要身份证">
@ -207,16 +210,16 @@
</view>
<!-- 上传进度提示 -->
<view wx:if="{{isUploading}}" class="upload-info">
<view wx:if="{{isUploading}}" class="section upload">
<t-loading theme="circular" size="32rpx" />
<text class="upload-text">{{uploadInfo}}</text>
<text class="text">{{uploadInfo}}</text>
</view>
<!-- 按钮 -->
<view class="submit-section">
<view class="section action">
<t-button
wx:if="{{mode === 'edit'}}"
class="delete-btn"
class="delete"
theme="danger"
variant="outline"
size="large"
@ -226,7 +229,7 @@
删除
</t-button>
<t-button
class="submit-btn"
class="submit"
theme="primary"
size="large"
bind:tap="submit"
@ -240,18 +243,6 @@
</view>
</scroll-view>
<!-- 地点类型选择器 -->
<t-picker
visible="{{locationTypePickerVisible}}"
value="{{locationTypeIndex}}"
cancelBtn="取消"
confirmBtn="确认"
bind:confirm="onPickerConfirm"
bind:cancel="onPickerCancel"
>
<t-picker-item options="{{locationTypes}}" />
</t-picker>
<!-- 删除确认对话框 -->
<t-dialog
visible="{{deleteDialogVisible}}"

View File

@ -8,7 +8,6 @@
.map {
width: 100%;
height: 100%;
}
.custom-callout {
width: fit-content;
@ -16,7 +15,7 @@
display: flex;
min-width: 300rpx;
max-width: 400rpx;
background: #fff;
background: var(--theme-bg-card-secondary);
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, .15);
border-radius: 6rpx;
flex-direction: column;
@ -26,14 +25,10 @@
padding: 6rpx 0;
align-items: center;
&:not(:last-child) {
border-bottom: 1px solid #eee;
}
.type {
color: #fff;
padding: 2rpx 8rpx;
font-size: 24rpx;
padding: 4rpx 12rpx 6rpx 12rpx;
font-size: 28rpx;
flex-shrink: 0;
background: var(--theme-wx, #07c160);
margin-right: 12rpx;
@ -42,7 +37,7 @@
.title {
flex: 1;
color: #333;
color: var(--theme-text-primary, #333);
overflow: hidden;
font-size: 28rpx;
font-weight: bold;
@ -51,6 +46,7 @@
}
}
}
}
.loading {
top: 50%;
@ -60,9 +56,9 @@
transform: translate(-50%, -50%);
.loading-text {
color: #666;
color: var(--theme-text-secondary, #666);
padding: 24rpx 48rpx;
background: #FFF;
background: var(--theme-bg-card, #fff);
border-radius: 8rpx;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, .15);
}

View File

@ -66,7 +66,7 @@
}
.meta {
gap: 16rpx;
gap: 32rpx;
display: flex;
flex-wrap: wrap;

View File

@ -2,13 +2,13 @@
import Time from "../../../utils/Time";
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 {
/** 分页参数 */
page: TravelPage;
/** 行列表 */
/** 行列表 */
list: Travel[];
/** 当前筛选状态 */
currentStatus: TravelStatus | "ALL";
@ -27,6 +27,8 @@ interface TravelData {
statusIcons: typeof TravelStatusIcon;
/** 交通类型标签映射 */
transportLabels: typeof TransportationTypeLabel;
/** 交通类型图标映射 */
transportIcons: typeof TransportationTypeIcon;
}
Page({
@ -47,11 +49,18 @@ Page({
menuLeft: 0,
statusLabels: TravelStatusLabel,
statusIcons: TravelStatusIcon,
transportLabels: TransportationTypeLabel
transportLabels: TransportationTypeLabel,
transportIcons: TransportationTypeIcon
},
onLoad() {
this.resetAndFetch();
},
onShow() {
// 页面显示时刷新数据(从编辑页返回时)
if (0 < this.data.list.length) {
this.resetAndFetch();
}
},
onHide() {
this.setData({
isShowFilterMenu: false
@ -83,7 +92,7 @@ Page({
});
this.fetch();
},
/** 获取行列表 */
/** 获取行列表 */
async fetch() {
if (this.data.isFetching || this.data.isFinished) {
return;
@ -117,7 +126,7 @@ Page({
isFinished: list.length < this.data.page.size
});
} catch (error) {
console.error("获取行列表失败:", error);
console.error("获取行列表失败:", error);
} finally {
this.setData({ isFetching: false });
}
@ -158,7 +167,7 @@ Page({
});
this.resetAndFetch();
},
/** 新建行 */
/** 新建行 */
toCreate() {
wx.navigateTo({
url: "/pages/main/travel-editor/index"

View File

@ -1,6 +1,6 @@
<!--pages/main/travel/index.wxml-->
<view class="custom-navbar">
<t-navbar title="行计划">
<t-navbar title="行计划">
<view slot="left" class="filter-btn" bind:tap="toggleFilterMenu">
<t-icon name="filter" size="24px" />
</view>
@ -46,13 +46,13 @@
</t-cell-group>
</view>
<!-- 行列表 -->
<!-- 行列表 -->
<view class="travels">
<!-- 空状态 -->
<t-empty
wx:if="{{!isFetching && list.length === 0}}"
icon="travel"
description="暂无行计划"
description="暂无行计划"
/>
<!-- 列表内容 -->
<view
@ -74,19 +74,19 @@
</t-tag>
</view>
<view class="body">
<view class="title">{{travel.title || '未命名行'}}</view>
<view class="title">{{travel.title || '未命名行'}}</view>
<view wx:if="{{travel.content}}" class="content">{{travel.content}}</view>
<view class="meta">
<view class="item">
<view wx:if="{{travel.travelDate}}" class="item">
<t-icon name="time" size="16px" class="icon" />
<text class="text">{{travel.travelDate}} {{travel.travelTime}}</text>
<text class="text">{{travel.travelDate}}</text>
</view>
<view wx:if="{{travel.days}}" class="item">
<t-icon name="calendar" size="16px" class="icon" />
<text class="text">{{travel.days}} 天</text>
</view>
<view wx:if="{{travel.transportationType}}" class="item">
<t-icon name="{{travel.transportationType === 'PLANE' ? 'flight-takeoff' : travel.transportationType === 'TRAIN' ? 'map-route' : travel.transportationType === 'SELF_DRIVING' ? 'control-platform' : 'location'}}" size="16px" class="icon" />
<t-icon name="{{transportIcons[travel.transportationType]}}" size="16px" class="icon" />
<text class="text">{{transportLabels[travel.transportationType]}}</text>
</view>
</view>

View File

@ -256,10 +256,10 @@ page {
--td-font-size-l: var(--td-font-size-title-large);
--td-font-size-xl: var(--td-font-size-title-extra-large);
--td-font-size-xxl: var(--td-font-size-headline-large);
--td-radius-small: 2px;
--td-radius-default: 4px;
--td-radius-large: 6px;
--td-radius-extraLarge: 7px;
--td-radius-round: 999px;
--td-radius-small: 8rpx;
--td-radius-default: 16rpx;
--td-radius-large: 24px;
--td-radius-extraLarge: 32rpx;
--td-radius-round: 9999rpx;
--td-radius-circle: 50%;
}

View File

@ -13,6 +13,7 @@ page {
--theme-bg-primary: #FFF;
--theme-bg-secondary: #F5F5F5;
--theme-bg-card: #FFF;
--theme-bg-card-secondary: #F4F4F4;
--theme-bg-journal: #FFF2C8;
--theme-bg-overlay: rgba(0, 0, 0, .1);
--theme-bg-menu: rgba(255, 255, 255, .95);
@ -68,7 +69,8 @@ page {
--theme-bg-primary: #1A1A1A;
--theme-bg-secondary: #2A2A2A;
--theme-bg-card: #2C2C2C;
--theme-bg-journal: #3A3A2E;
--theme-bg-card-secondary: #404040;
--theme-bg-journal: #404040;
--theme-bg-overlay: rgba(0, 0, 0, .3);
--theme-bg-menu: rgba(40, 40, 40, .95);

View File

@ -22,28 +22,38 @@ export const TransportationTypeLabel: Record<TransportationType, string> = {
[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 {
PLANNING = "PLANNING",
ONGOING = "ONGOING",
COMPLETED = "COMPLETED"
}
/** 行状态中文映射 */
/** 行状态中文映射 */
export const TravelStatusLabel: Record<TravelStatus, string> = {
[TravelStatus.PLANNING]: "计划中",
[TravelStatus.ONGOING]: "进行中",
[TravelStatus.COMPLETED]: "已完成"
};
/** 行状态图标映射 */
/** 行状态图标映射 */
export const TravelStatusIcon: Record<TravelStatus, string> = {
[TravelStatus.PLANNING]: "calendar",
[TravelStatus.ONGOING]: "play-circle",
[TravelStatus.COMPLETED]: "check-circle"
};
/** 行计划实体 */
/** 行计划实体 */
export interface Travel extends Model {
/** 交通类型 */
transportationType?: TransportationType;
@ -55,10 +65,10 @@ export interface Travel extends Model {
content?: string;
/** 出行时间戳 */
travelAt?: number;
travelAt?: number | null;
/** 天数 */
days?: number;
days?: number | null;
/** 状态 */
status?: TravelStatus;
@ -70,7 +80,7 @@ export interface Travel extends Model {
travelTime?: string;
}
/** 行分页查询 */
/** 行分页查询 */
export interface TravelPage extends QueryPage {
/** 条件过滤 */
equalsExample?: {
@ -80,37 +90,40 @@ export interface TravelPage extends QueryPage {
/** 地点类型 */
export enum TravelLocationType {
ATTRACTION = "ATTRACTION",
FOOD = "FOOD",
HOTEL = "HOTEL",
RESTAURANT = "RESTAURANT",
TRANSPORT = "TRANSPORT",
ATTRACTION = "ATTRACTION",
SHOPPING = "SHOPPING",
OTHER = "OTHER"
PLAY = "PLAY",
LIFE = "LEFE"
}
/** 地点类型中文映射 */
export const TravelLocationTypeLabel: Record<TravelLocationType, string> = {
[TravelLocationType.ATTRACTION]: "景点",
[TravelLocationType.FOOD]: "美食",
[TravelLocationType.HOTEL]: "酒店",
[TravelLocationType.RESTAURANT]: "餐厅",
[TravelLocationType.TRANSPORT]: "交通站点",
[TravelLocationType.TRANSPORT]: "交通",
[TravelLocationType.ATTRACTION]: "点",
[TravelLocationType.SHOPPING]: "购物",
[TravelLocationType.OTHER]: "其他"
[TravelLocationType.PLAY]: "玩乐",
[TravelLocationType.LIFE]: "生活"
};
/** 地点类型图标映射 */
export const TravelLocationTypeIcon: Record<TravelLocationType, string> = {
[TravelLocationType.ATTRACTION]: "location",
[TravelLocationType.HOTEL]: "home",
[TravelLocationType.RESTAURANT]: "shop",
[TravelLocationType.TRANSPORT]: "map-route",
[TravelLocationType.SHOPPING]: "cart",
[TravelLocationType.OTHER]: "ellipsis"
[TravelLocationType.FOOD]: "chicken",
[TravelLocationType.HOTEL]: "city-8",
[TravelLocationType.TRANSPORT]: "map-route-planning",
[TravelLocationType.ATTRACTION]: "image-1",
[TravelLocationType.SHOPPING]: "shop",
[TravelLocationType.PLAY]: "ferris-wheel",
[TravelLocationType.LIFE]: "cart"
};
/** 行地点实体 */
/** 行地点实体 */
export interface TravelLocation extends Model {
/** 关联的行计划 ID */
/** 关联的行计划 ID */
travelId?: number;
/** 地点类型 */
@ -140,15 +153,6 @@ export interface TravelLocation extends Model {
/** 是否需要预约 */
requireAppointment?: boolean;
/** 首次出行时间戳 */
firstTraveledAt?: number;
/** 上次出行时间戳 */
lastTraveledAt?: number;
/** 出行次数 */
travelCount?: number;
/** 评分 */
score?: number;

View File

@ -55,10 +55,10 @@ export type WechatMediaItem = {
export enum MediaItemType {
/** 图片 */
IMAGE,
IMAGE = "image",
/** 视频 */
VIDEO
VIDEO = "video"
}
/** 位置 */
@ -80,3 +80,16 @@ export enum JournalDetailType {
LOCATION = "LOCATION"
}
export interface MapMarker {
id: number;
latitude: number;
longitude: number;
width: number;
height: number;
customCallout: {
anchorY: number;
anchorX: number;
display: string;
};
}

View File

@ -1,5 +1,6 @@
import config from "../config/index";
import { Response, QueryPage, QueryPageResult, TempFileResponse } from "../types/Model";
import { MediaItemType } from "../types/UI";
/** 微信媒体项(用于上传) */
export interface WechatMediaItem {
@ -13,7 +14,7 @@ export interface WechatMediaItem {
size?: number;
/** 媒体类型 */
type?: string;
type?: MediaItemType;
}
/** 请求选项 */