fix travel style

This commit is contained in:
Timi
2025-12-16 16:57:49 +08:00
parent e650571563
commit f0f2815971
32 changed files with 1238 additions and 594 deletions

View File

@ -30,8 +30,18 @@ interface TravelLocationEditorData {
amount: number;
/** 是否需要身份证 */
requireIdCard: boolean;
/** 必要评分 */
/** 是否需要预约 */
requireAppointment: boolean;
/** 首次出行时间戳 */
firstTraveledAt: number;
/** 上次出行时间戳 */
lastTraveledAt: number;
/** 出行次数 */
travelCount: number;
/** 评分 */
score: number;
/** 重要程度 */
importance: number;
/** 媒体列表(创建和编辑模式使用) */
mediaList: (MediaItem | WechatMediaItem)[];
/** 新媒体列表(编辑模式使用) */
@ -48,6 +58,12 @@ interface TravelLocationEditorData {
locationTypes: { label: string; value: TravelLocationType }[];
/** 地点类型选中索引 */
locationTypeIndex: number;
/** 地点类型选择器可见性 */
locationTypePickerVisible: boolean;
/** 删除对话框可见性 */
deleteDialogVisible: boolean;
/** 删除确认文本 */
deleteConfirmText: string;
/** 媒体类型枚举 */
mediaItemTypeEnum: any;
}
@ -65,7 +81,12 @@ Page({
lng: 0,
amount: 0,
requireIdCard: false,
requireAppointment: false,
firstTraveledAt: 0,
lastTraveledAt: 0,
travelCount: 0,
score: 3,
importance: 1,
mediaList: [],
newMediaList: [],
isLoading: false,
@ -83,7 +104,10 @@ Page({
{ label: "购物", value: TravelLocationType.SHOPPING },
{ label: "其他", value: TravelLocationType.OTHER }
],
locationTypeIndex: 0
locationTypeIndex: 0,
locationTypePickerVisible: false,
deleteDialogVisible: false,
deleteConfirmText: ""
},
onLoad(options: any) {
@ -161,7 +185,12 @@ Page({
lng: location.lng || 0,
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,
isLoading: false
});
@ -187,21 +216,51 @@ Page({
});
},
/** 显示地点类型选择器 */
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 });
},
/** 改变是否需要预约 */
onChangeRequireAppointment(e: any) {
this.setData({ requireAppointment: e.detail.value });
},
/** 改变评分 */
onChangeScore(e: any) {
this.setData({ score: e.detail.value });
},
/** 改变重要程度 */
onChangeImportance(e: any) {
this.setData({ importance: e.detail.value });
},
/** 选择位置 */
chooseLocation() {
wx.chooseLocation({
success: (res) => {
const locationName = res.address || res.name;
const locationName = res.name || res.address;
const updateData: any = {
location: locationName,
lat: res.latitude,
@ -340,31 +399,60 @@ Page({
/** 删除地点 */
deleteLocation() {
wx.showModal({
title: "确认删除",
content: "确定要删除这个地点吗?删除后无法恢复。",
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"
});
}
}
}
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.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() {
// 验证必填字段
@ -425,7 +513,12 @@ Page({
lng: this.data.lng,
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
});
wx.showToast({
@ -479,7 +572,12 @@ Page({
lng: this.data.lng,
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,
tempFileIds
});