refactor pages struct

This commit is contained in:
Timi
2026-01-28 14:11:54 +08:00
parent 8adc28ae9c
commit 965743be38
73 changed files with 234 additions and 176 deletions

View File

@ -0,0 +1,17 @@
{
"component": true,
"usingComponents": {
"t-cell": "tdesign-miniprogram/cell/cell",
"t-icon": "tdesign-miniprogram/icon/icon",
"t-rate": "tdesign-miniprogram/rate/rate",
"t-input": "tdesign-miniprogram/input/input",
"t-button": "tdesign-miniprogram/button/button",
"t-dialog": "tdesign-miniprogram/dialog/dialog",
"t-navbar": "tdesign-miniprogram/navbar/navbar",
"t-loading": "tdesign-miniprogram/loading/loading",
"t-stepper": "tdesign-miniprogram/stepper/stepper",
"t-textarea": "tdesign-miniprogram/textarea/textarea",
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group"
},
"styleIsolation": "shared"
}

View File

@ -0,0 +1,201 @@
// pages/main/travel/location-editor/index.less
.travel-location-editor {
width: 100vw;
min-height: 100vh;
.content {
padding-bottom: 64rpx;
.loading {
display: flex;
padding: 128rpx 0;
align-items: center;
flex-direction: column;
.text {
color: var(--theme-text-secondary);
margin-top: 24rpx;
font-size: 28rpx;
}
}
.section {
margin-top: 48rpx;
.rate-cell {
&.decided {
.rate {
display: block;
gap: 16rpx;
display: flex;
align-items: center;
}
.text {
display: none;
}
}
&.undecided {
.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;
}
}
}
&.media {
.gallery {
gap: 10rpx;
padding: 0 6rpx;
display: grid;
grid-template-columns: repeat(3, 1fr);
.item {
width: 220rpx;
height: 220rpx;
position: relative;
overflow: hidden;
background: var(--theme-bg-card);
box-shadow: 1px 1px 6px var(--theme-shadow-light);
border-radius: 2rpx;
&.add {
color: var(--theme-wx);
margin: 0;
font-size: 80rpx;
background: transparent;
&::after {
border-radius: 0;
}
}
.thumbnail {
width: 240rpx;
height: 240rpx;
display: block;
}
.video-container {
position: relative;
.play-icon {
top: 50%;
left: 50%;
color: rgba(255, 255, 255, .8);
z-index: 2;
position: absolute;
font-size: 128rpx;
transform: translate(-50%, -50%);
text-shadow: 4rpx 4rpx 0 rgba(0, 0, 0, .5);
pointer-events: none;
}
}
.delete {
top: 10rpx;
right: 10rpx;
color: rgba(255, 255, 255, .6);
z-index: 3;
position: absolute;
font-size: 45rpx;
&::after {
content: "";
top: 0;
width: 100%;
height: 100%;
z-index: -1;
position: absolute;
background: rgba(0, 0, 0, .6);
border-radius: 50%;
}
}
.new-badge {
top: 10rpx;
left: 10rpx;
color: var(--theme-wx);
z-index: 3;
display: flex;
position: absolute;
font-size: 45rpx;
text-shadow: 4rpx 4rpx 0 rgba(0, 0, 0, .5);
}
}
}
}
&.upload {
gap: 16rpx;
display: flex;
padding: 24rpx 32rpx;
margin-top: 24rpx;
align-items: center;
border-radius: 12rpx;
background: var(--theme-bg-card);
.text {
color: var(--theme-text-secondary);
font-size: 28rpx;
}
}
&.action {
gap: 24rpx;
display: flex;
padding: 24rpx 16rpx 48rpx 16rpx;
.delete {
flex: .6;
}
.submit {
flex: 1;
}
}
}
}
}
.delete-dialog {
padding: 16rpx 0;
.tips {
color: var(--theme-text-secondary);
font-size: 28rpx;
line-height: 1.5;
margin-bottom: 24rpx;
}
}

View File

@ -0,0 +1,605 @@
// pages/main/travel/location-editor/index.ts
import { Network, WechatMediaItem } from "../../../../utils/Network";
import { TravelLocationApi } from "../../../../api/TravelLocationApi";
import { TravelLocationType, TravelLocationTypeLabel } from "../../../../types/Travel";
import { MediaAttachType, PreviewImageMetadata } from "../../../../types/Attachment";
import config from "../../../../config/index";
import { MediaItem, MediaItemType } from "../../../../types/UI";
interface TravelLocationEditorData {
/** 模式create 或 edit */
mode: "create" | "edit";
/** 出行地点 ID编辑模式 */
id?: number;
/** 关联的出行计划 ID */
travelId: number;
/** 地点类型 */
type: TravelLocationType;
/** 标题 */
title: string;
/** 说明 */
description: string;
/** 位置描述 */
location: string;
/** 纬度 */
lat: number;
/** 经度 */
lng: number;
/** 费用 */
amount: number;
/** 是否需要身份证 */
requireIdCard: boolean;
/** 是否需要预约 */
requireAppointment: boolean;
/** 评分 */
score: number;
/** 评分是否未定 */
scoreUndecided: boolean;
/** 重要程度 */
importance: number;
/** 重要程度是否未定 */
importanceUndecided: boolean;
/** 媒体列表(创建和编辑模式使用) */
mediaList: (MediaItem | WechatMediaItem)[];
/** 新媒体列表(编辑模式使用) */
newMediaList: WechatMediaItem[];
/** 是否正在加载(编辑模式) */
isLoading: boolean;
/** 是否正在保存 */
isSaving: boolean;
/** 是否正在上传 */
isUploading: boolean;
/** 上传进度信息 */
uploadInfo: string;
/** 地点类型选项 */
locationTypes: string[];
/** 地点类型值数组 */
locationTypeValues: TravelLocationType[];
/** 地点类型选中索引 */
locationTypeIndex: number;
/** 删除对话框可见性 */
deleteDialogVisible: boolean;
/** 删除确认文本 */
deleteConfirmText: string;
/** 媒体类型枚举 */
mediaItemTypeEnum: any;
}
Page({
data: <TravelLocationEditorData>{
mode: "create",
id: undefined,
travelId: 0,
type: TravelLocationType.FOOD,
title: "",
description: "",
location: "",
lat: 0,
lng: 0,
amount: 0,
requireIdCard: false,
requireAppointment: false,
score: 3,
scoreUndecided: true,
importance: 1,
importanceUndecided: true,
mediaList: [],
newMediaList: [],
isLoading: false,
isSaving: false,
isUploading: false,
uploadInfo: "",
mediaItemTypeEnum: {
...MediaItemType
},
locationTypes: Object.values(TravelLocationTypeLabel),
locationTypeValues: [
TravelLocationType.FOOD,
TravelLocationType.HOTEL,
TravelLocationType.TRANSPORT,
TravelLocationType.ATTRACTION,
TravelLocationType.SHOPPING,
TravelLocationType.PLAY,
TravelLocationType.LIFE
],
locationTypeIndex: 0,
deleteDialogVisible: false,
deleteConfirmText: ""
},
onLoad(options: any) {
// 获取 travelId必填
const travelId = options.travelId ? parseInt(options.travelId) : 0;
if (!travelId) {
wx.showToast({
title: "缺少出行计划 ID",
icon: "error"
});
setTimeout(() => {
wx.navigateBack();
}, 1500);
return;
}
// 判断模式:有 ID 是编辑,无 ID 是创建
const id = options.id ? parseInt(options.id) : undefined;
if (id) {
// 编辑模式
this.setData({
mode: "edit",
id,
travelId,
isLoading: true
});
this.loadLocationDetail(id);
} else {
// 创建模式
this.setData({
mode: "create",
travelId,
isLoading: false
});
}
},
/** 加载地点详情(编辑模式) */
async loadLocationDetail(id: number) {
wx.showLoading({ title: "加载中...", mask: true });
try {
const location = await TravelLocationApi.getDetail(id);
// 计算地点类型索引
const type = location.type || TravelLocationType.ATTRACTION;
const locationTypeIndex = this.data.locationTypeValues.findIndex(
item => item === type
);
const items = location.items || [];
const thumbItems = items.filter((item) => item.attachType === MediaAttachType.THUMB);
const mediaList: MediaItem[] = thumbItems.map((thumbItem) => {
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
} 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({
type,
locationTypeIndex: locationTypeIndex >= 0 ? locationTypeIndex : 0,
title: location.title || "",
description: location.description || "",
location: location.location || "",
lat: location.lat || 0,
lng: location.lng || 0,
amount: location.amount || 0,
requireIdCard: location.requireIdCard || false,
requireAppointment: location.requireAppointment || false,
score,
scoreUndecided,
importance,
importanceUndecided,
mediaList,
isLoading: false
});
} catch (error) {
wx.showToast({
title: "加载失败",
icon: "error"
});
setTimeout(() => {
wx.navigateBack();
}, 1500);
} finally {
wx.hideLoading();
}
},
/** 改变地点类型 */
onChangeLocationType(e: any) {
const index = e.detail.value;
this.setData({
locationTypeIndex: index,
type: this.data.locationTypeValues[index]
});
},
/** 改变是否需要身份证 */
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 });
},
/** 清除评分 */
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() {
wx.chooseLocation({
success: (res) => {
const locationName = res.name || res.address;
const updateData: any = {
location: locationName,
lat: res.latitude,
lng: res.longitude
};
// 如果标题为空,使用选择的地点名称作为标题
if (!this.data.title.trim()) {
updateData.title = res.name || locationName;
}
this.setData(updateData);
},
fail: (err) => {
if (err.errMsg.includes("auth deny")) {
wx.showToast({
title: "请授权位置权限",
icon: "error"
});
}
}
});
},
/** 添加媒体 */
addMedia() {
const that = this;
wx.chooseMedia({
mediaType: ["mix"],
sourceType: ["album", "camera"],
camera: "back",
success(res) {
wx.showLoading({
title: "加载中..",
mask: true
});
const tempFiles = res.tempFiles;
const newMedia = tempFiles.map(item => {
return {
type: (<any>MediaItemType)[item.fileType.toUpperCase()],
path: item.tempFilePath,
thumbPath: item.thumbTempFilePath,
size: item.size,
duration: item.duration,
raw: item
} as WechatMediaItem;
});
if (that.data.mode === "create") {
that.setData({
mediaList: [...that.data.mediaList, ...newMedia]
});
} else {
that.setData({
newMediaList: [...that.data.newMediaList, ...newMedia]
});
}
wx.hideLoading();
}
});
},
/** 删除媒体(创建模式) */
deleteMedia(e: any) {
const { index } = e.currentTarget.dataset;
const mediaList = this.data.mediaList;
mediaList.splice(index, 1);
this.setData({ mediaList });
},
/** 删除新媒体(编辑模式) */
deleteNewMedia(e: any) {
const { index } = e.currentTarget.dataset;
const newMediaList = this.data.newMediaList;
newMediaList.splice(index, 1);
this.setData({ newMediaList });
},
/** 删除已有媒体(编辑模式) */
deleteExistingMedia(e: any) {
const { index } = e.currentTarget.dataset;
const existingMedia = this.data.mediaList;
existingMedia.splice(index, 1);
this.setData({ existingMedia });
},
/** 预览媒体 */
preview(e: WechatMiniprogram.BaseEvent) {
const isNewMedia = e.currentTarget.dataset.newMedia;
const index = e.currentTarget.dataset.index;
if (this.data.mode === "create") {
// 创建模式:只有 mediaList
const sources = (this.data.mediaList as WechatMediaItem[]).map(item => ({
url: item.path,
type: item.type!.toLowerCase()
}));
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[]
});
} else {
// 编辑模式mediaList + newMediaList
const sources = (this.data.mediaList as MediaItem[]).map(item => ({
url: item.sourceURL,
type: item.type.toLowerCase()
}));
const newSources = this.data.newMediaList.map(item => ({
url: item.path,
type: item.type!.toLowerCase()
}));
const allSources = [...sources, ...newSources];
const itemIndex = isNewMedia ? this.data.mediaList.length + index : index;
const total = allSources.length;
const startIndex = Math.max(0, itemIndex - 25);
const endIndex = Math.min(total, startIndex + 50);
const newCurrentIndex = itemIndex - startIndex;
wx.previewMedia({
current: newCurrentIndex,
sources: allSources.slice(startIndex, endIndex) as WechatMiniprogram.MediaSource[]
});
}
},
/** 取消 */
cancel() {
wx.navigateBack();
},
/** 删除地点 */
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.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() {
// 验证必填字段
if (!this.data.title.trim()) {
wx.showToast({
title: "请输入标题",
icon: "error"
});
return;
}
if (!this.data.location || !this.data.lat || !this.data.lng) {
wx.showToast({
title: "请选择位置",
icon: "error"
});
return;
}
if (this.data.mode === "create") {
this.createLocation();
} else {
this.updateLocation();
}
},
/** 创建地点 */
async createLocation() {
this.setData({ isSaving: true });
try {
// 上传媒体文件
this.setData({
isUploading: true,
uploadInfo: "正在上传 0%"
});
const tempFileIds = await Network.uploadFiles({
mediaList: this.data.mediaList as WechatMediaItem[],
onProgress: ({ percent }) => {
this.setData({
uploadInfo: `正在上传 ${percent}%`
});
}
});
this.setData({
isUploading: false,
uploadInfo: ""
});
// 创建地点
await TravelLocationApi.create({
travelId: this.data.travelId,
type: this.data.type,
title: this.data.title.trim(),
description: this.data.description.trim(),
location: this.data.location,
lat: this.data.lat,
lng: this.data.lng,
amount: this.data.amount,
requireIdCard: this.data.requireIdCard,
requireAppointment: this.data.requireAppointment,
score: this.data.scoreUndecided ? null : this.data.score,
importance: this.data.importanceUndecided ? null : this.data.importance,
tempFileIds
});
wx.showToast({
title: "创建成功",
icon: "success"
});
setTimeout(() => {
wx.navigateBack();
}, 1000);
} catch (error) {
this.setData({
isSaving: false,
isUploading: false,
uploadInfo: ""
});
}
},
/** 更新地点 */
async updateLocation() {
this.setData({ isSaving: true });
try {
// 保留的附件 ID 列表
const attachmentIds = (this.data.mediaList as MediaItem[]).map(item => item.attachmentId);
// 上传新媒体文件
this.setData({
isUploading: true,
uploadInfo: "正在上传 0%"
});
const tempFileIds = await Network.uploadFiles({
mediaList: this.data.newMediaList,
onProgress: ({ percent }) => {
this.setData({
uploadInfo: `正在上传 ${percent}%`
});
}
});
this.setData({
isUploading: false,
uploadInfo: ""
});
// 更新地点
await TravelLocationApi.update({
id: this.data.id!,
travelId: this.data.travelId,
type: this.data.type,
title: this.data.title.trim(),
description: this.data.description.trim(),
location: this.data.location,
lat: this.data.lat,
lng: this.data.lng,
amount: this.data.amount,
requireIdCard: this.data.requireIdCard,
requireAppointment: this.data.requireAppointment,
score: this.data.scoreUndecided ? null : this.data.score,
importance: this.data.importanceUndecided ? null : this.data.importance,
attachmentIds,
tempFileIds
});
wx.showToast({
title: "保存成功",
icon: "success"
});
setTimeout(() => {
wx.navigateBack();
}, 1000);
} catch (error) {
this.setData({
isSaving: false,
isUploading: false,
uploadInfo: ""
});
}
}
});

View File

@ -0,0 +1,288 @@
<!--pages/main/travel/location-editor/index.wxml-->
<t-navbar title="{{mode === 'create' ? '添加地点' : '编辑地点'}}" placeholder>
<text slot="left" bindtap="cancel">取消</text>
</t-navbar>
<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 location">
<view slot="title" class="title">位置信息</view>
<picker mode="selector" range="{{locationTypes}}" value="{{locationTypeIndex}}" bindchange="onChangeLocationType">
<t-cell title="地点类型" arrow>
<view slot="note" class="note">{{locationTypes[locationTypeIndex]}}</view>
</t-cell>
</picker>
<t-cell class="value" required arrow bind:click="chooseLocation">
<view slot="title" class="title">位置</view>
<view slot="note" class="note">{{location}}</view>
</t-cell>
</t-cell-group>
<t-cell-group class="section">
<view slot="title" class="title">基本信息</view>
<t-input
class="input"
placeholder="请输入地点名称"
model:value="{{title}}"
label="标题"
maxlength="50"
/>
<t-textarea
class="textarea"
placeholder="添加地点说明(选填)"
model:value="{{description}}"
maxlength="500"
indicator
>
<text slot="label">说明</text>
</t-textarea>
</t-cell-group>
<t-cell-group class="section">
<view slot="title" class="title">详细信息</view>
<t-input
model:value="{{amount}}"
placeholder="0"
label="费用"
suffix="元"
type="digit"
align="right"
/>
<t-cell title="需要身份证">
<view slot="right-icon">
<switch checked="{{requireIdCard}}" bindchange="onChangeRequireIdCard" />
</view>
</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 class="section media">
<view slot="title" class="title">图片视频</view>
<t-cell>
<view slot="title" class="gallery">
<!-- 创建模式mediaList 显示新选择的媒体 -->
<block wx:if="{{mode === 'create'}}">
<block wx:for="{{mediaList}}" wx:key="index">
<view class="item">
<!-- 图片 -->
<image
wx:if="{{item.type === mediaItemTypeEnum.IMAGE}}"
src="{{item.path}}"
class="thumbnail"
mode="aspectFill"
bindtap="preview"
data-index="{{index}}"
data-new-media="{{true}}"
></image>
<!-- 视频 -->
<view wx:if="{{item.type === mediaItemTypeEnum.VIDEO}}" class="video-container">
<image
src="{{item.thumbPath}}"
class="thumbnail"
mode="aspectFill"
bindtap="preview"
data-index="{{index}}"
data-new-media="{{true}}"
></image>
<t-icon class="play-icon" name="play" />
</view>
<!-- 删除 -->
<t-icon
class="delete"
name="close"
bindtap="deleteMedia"
data-index="{{index}}"
data-new-media="{{true}}"
/>
</view>
</block>
</block>
<!-- 编辑模式mediaList 显示现有附件newMediaList 显示新添加的附件 -->
<block wx:else>
<!-- 现有附件 -->
<block wx:for="{{mediaList}}" wx:key="attachmentId">
<view class="item">
<!-- 图片 -->
<image
wx:if="{{item.type === mediaItemTypeEnum.IMAGE}}"
src="{{item.thumbURL}}"
class="thumbnail"
mode="aspectFill"
bindtap="preview"
data-index="{{index}}"
data-new-media="{{false}}"
></image>
<!-- 视频 -->
<view wx:if="{{item.type === mediaItemTypeEnum.VIDEO}}" class="video-container">
<image
src="{{item.thumbURL}}"
class="thumbnail"
mode="aspectFill"
bindtap="preview"
data-index="{{index}}"
data-new-media="{{false}}"
></image>
<t-icon class="play-icon" name="play" />
</view>
<!-- 删除 -->
<t-icon
class="delete"
name="close"
bindtap="deleteMedia"
data-index="{{index}}"
data-new-media="{{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
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>
</block>
</block>
<!-- 添加按钮 -->
<t-button
class="item add"
theme="primary"
plain="true"
disabled="{{isSaving}}"
bind:tap="addMedia"
>
<t-icon name="add" />
</t-button>
</view>
</t-cell>
</t-cell-group>
<!-- 上传进度提示 -->
<view wx:if="{{isUploading}}" class="section upload">
<t-loading theme="circular" size="32rpx" />
<text class="text">{{uploadInfo}}</text>
</view>
<!-- 按钮 -->
<view class="section action">
<t-button
wx:if="{{mode === 'edit'}}"
class="delete"
theme="danger"
variant="outline"
size="large"
bind:tap="deleteLocation"
disabled="{{isSaving || isUploading}}"
>
删除
</t-button>
<t-button
class="submit"
theme="primary"
size="large"
bind:tap="submit"
loading="{{isSaving}}"
disabled="{{isSaving || isUploading}}"
>
{{mode === 'create' ? '创建地点' : '保存修改'}}
</t-button>
</view>
</block>
</view>
</scroll-view>
<!-- 删除确认对话框 -->
<t-dialog
visible="{{deleteDialogVisible}}"
title="删除地点"
confirm-btn="{{ {content: '删除', variant: 'text', theme: 'danger'} }}"
cancel-btn="取消"
bind:confirm="confirmDelete"
bind:cancel="cancelDelete"
>
<view slot="content" class="delete-dialog">
<view class="tips">
<text>此地点的图片和视频也会同步删除,删除后无法恢复,请输入 "</text>
<text style="color: var(--theme-error)">确认删除</text>
<text>" 以继续</text>
</view>
<t-input placeholder="请输入:确认删除" model:value="{{deleteConfirmText}}" />
</view>
</t-dialog>