|
|
@@ -257,12 +257,7 @@
|
|
|
|
|
|
<u-form-item label="请假地点">
|
|
|
<view class="location-row">
|
|
|
- <u-input
|
|
|
- v-model="form.leaveLocation"
|
|
|
- placeholder="点击右侧按钮自动获取当前位置或手动输入"
|
|
|
- maxlength="100"
|
|
|
- style="flex: 1"
|
|
|
- />
|
|
|
+ <!-- 微信定位按钮单独一行 -->
|
|
|
<u-button type="primary" size="mini" plain @click="handleGetLocation">
|
|
|
<u-icon name="map-fill" size="20" color="#2979ff" />
|
|
|
<text style="margin-left: 8rpx">
|
|
|
@@ -270,20 +265,34 @@
|
|
|
</text>
|
|
|
</u-button>
|
|
|
</view>
|
|
|
- <view v-if="geoLatitude && geoLongitude" class="location-info">
|
|
|
- <text class="location-coords">
|
|
|
- 坐标: {{ geoLatitude.toFixed(6) }}, {{ geoLongitude.toFixed(6) }}
|
|
|
- </text>
|
|
|
- <u-button
|
|
|
- size="mini"
|
|
|
- type="success"
|
|
|
- plain
|
|
|
- @click="openLocationInMap"
|
|
|
- style="margin-left: 10rpx"
|
|
|
- >
|
|
|
- <u-icon name="eye" size="16" />
|
|
|
- <text style="margin-left: 4rpx">查看位置</text>
|
|
|
- </u-button>
|
|
|
+ <!-- <view v-if="form.leaveLocation" class="location-info">
|
|
|
+ <view class="location-coords-container">
|
|
|
+ <text class="location-coords">
|
|
|
+ 坐标: {{ form.leaveLocation || '未获取' }}
|
|
|
+ </text>
|
|
|
+ </view>
|
|
|
+ <view class="location-action-container">
|
|
|
+ <u-button size="mini" type="success" plain @click="openLocationInMap">
|
|
|
+ <u-icon name="eye" size="16" />
|
|
|
+ <text style="margin-left: 4rpx">查看位置</text>
|
|
|
+ </u-button>
|
|
|
+ </view>
|
|
|
+ </view> -->
|
|
|
+ </u-form-item>
|
|
|
+ <u-form-item label="坐标">
|
|
|
+ <view v-if="form.leaveLocation" class="location-info">
|
|
|
+ <!-- 坐标和查看位置按钮在同一行 -->
|
|
|
+ <view class="location-coords-container">
|
|
|
+ <text class="location-coords">
|
|
|
+ 经纬度: {{ form.leaveLocation || '未获取' }}
|
|
|
+ </text>
|
|
|
+ </view>
|
|
|
+ <view class="location-action-container">
|
|
|
+ <u-button size="mini" type="success" plain @click="openLocationInMap">
|
|
|
+ <u-icon name="eye" size="16" />
|
|
|
+ <text style="margin-left: 20rpx">查看位置</text>
|
|
|
+ </u-button>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</u-form-item>
|
|
|
</view>
|
|
|
@@ -301,7 +310,7 @@
|
|
|
v-for="(image, index) in imageFiles"
|
|
|
:key="image.uid || index"
|
|
|
class="image-item"
|
|
|
- @click="handleImagePreview(image, index)"
|
|
|
+ @click="handleImageClick(image, index, $event)"
|
|
|
>
|
|
|
<!-- 图片容器 -->
|
|
|
<view class="image-container">
|
|
|
@@ -341,22 +350,25 @@
|
|
|
</view>
|
|
|
|
|
|
<!-- 图片操作按钮 -->
|
|
|
- <view class="image-actions">
|
|
|
- <u-button
|
|
|
+ <view class="image-actions" @click.stop>
|
|
|
+ <!-- <u-button
|
|
|
v-if="image.status === 'success'"
|
|
|
size="mini"
|
|
|
type="primary"
|
|
|
plain
|
|
|
- @click.stop="handleImageDownload(image)"
|
|
|
+ @tap="handleImageDownload(image)"
|
|
|
+ @click.stop.prevent="
|
|
|
+ handleImageDownloadClick(image, $event)
|
|
|
+ "
|
|
|
>
|
|
|
下载
|
|
|
- </u-button>
|
|
|
+ </u-button> -->
|
|
|
<u-button
|
|
|
v-if="image.status === 'error'"
|
|
|
size="mini"
|
|
|
type="warning"
|
|
|
plain
|
|
|
- @click.stop="retryUploadFile(image)"
|
|
|
+ @click.stop.prevent="retryUploadFile(image, $event)"
|
|
|
>
|
|
|
重试
|
|
|
</u-button>
|
|
|
@@ -364,7 +376,10 @@
|
|
|
size="mini"
|
|
|
type="error"
|
|
|
plain
|
|
|
- @click.stop="handleImageDelete(image, index)"
|
|
|
+ @tap="handleImageDelete(image, index)"
|
|
|
+ @click.stop.prevent="
|
|
|
+ handleImageDeleteClick(image, index, $event)
|
|
|
+ "
|
|
|
>
|
|
|
删除
|
|
|
</u-button>
|
|
|
@@ -441,30 +456,31 @@
|
|
|
</view>
|
|
|
|
|
|
<!-- 文件信息 -->
|
|
|
- <view class="file-info-card">
|
|
|
+ <!-- <view class="file-info-card">
|
|
|
<view class="file-ext-badge">{{ getFileExt(file.name) }}</view>
|
|
|
<view v-if="file.size > 0" class="file-size">
|
|
|
{{ formatFileSize(file.size) }}
|
|
|
</view>
|
|
|
- </view>
|
|
|
+ </view> -->
|
|
|
|
|
|
<!-- 文件操作按钮 -->
|
|
|
- <view class="image-actions">
|
|
|
- <u-button
|
|
|
+ <view class="image-actions" @click.stop>
|
|
|
+ <!-- <u-button
|
|
|
v-if="file.status === 'success'"
|
|
|
size="mini"
|
|
|
type="primary"
|
|
|
plain
|
|
|
- @click="handleDownloadFile(file)"
|
|
|
+ @tap="handleDownloadFile(file)"
|
|
|
+ @click.stop.prevent="handleDownloadFileClick(file, $event)"
|
|
|
>
|
|
|
下载
|
|
|
- </u-button>
|
|
|
+ </u-button> -->
|
|
|
<u-button
|
|
|
v-if="file.status === 'error'"
|
|
|
size="mini"
|
|
|
type="warning"
|
|
|
plain
|
|
|
- @click="retryUploadFile(file)"
|
|
|
+ @click.stop.prevent="retryUploadFile(file, $event)"
|
|
|
>
|
|
|
重试
|
|
|
</u-button>
|
|
|
@@ -472,12 +488,13 @@
|
|
|
size="mini"
|
|
|
type="error"
|
|
|
plain
|
|
|
- @click="
|
|
|
+ @click.stop.prevent="
|
|
|
handleRemoveFile(
|
|
|
file,
|
|
|
index +
|
|
|
attachmentList.filter((f) => isImageFile(f))
|
|
|
.length,
|
|
|
+ $event,
|
|
|
)
|
|
|
"
|
|
|
>
|
|
|
@@ -1153,7 +1170,7 @@ export default {
|
|
|
|
|
|
// 打开地图查看位置
|
|
|
async openLocationInMap() {
|
|
|
- if (!this.geoLatitude || !this.geoLongitude) {
|
|
|
+ if (!this.form.leaveLocation) {
|
|
|
uni.showToast({
|
|
|
title: '暂无位置信息',
|
|
|
icon: 'none',
|
|
|
@@ -1161,12 +1178,33 @@ export default {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ // 从 form.leaveLocation 解析经纬度
|
|
|
+ const coords = this.form.leaveLocation.split(',');
|
|
|
+ if (coords.length !== 2) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '位置信息格式错误',
|
|
|
+ icon: 'none',
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const latitude = parseFloat(coords[0]);
|
|
|
+ const longitude = parseFloat(coords[1]);
|
|
|
+
|
|
|
+ if (isNaN(latitude) || isNaN(longitude)) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '位置信息无效',
|
|
|
+ icon: 'none',
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
if (this.isWechatBrowser && this.wechatSDK.isInitialized) {
|
|
|
try {
|
|
|
this.addWechatLog('使用微信打开地图...', 'info');
|
|
|
await this.wechatSDK.openLocation({
|
|
|
- latitude: this.geoLatitude,
|
|
|
- longitude: this.geoLongitude,
|
|
|
+ latitude: latitude,
|
|
|
+ longitude: longitude,
|
|
|
name: '请假地点',
|
|
|
address: this.form.leaveLocation || '当前位置',
|
|
|
scale: 16,
|
|
|
@@ -1174,18 +1212,16 @@ export default {
|
|
|
this.addWechatLog('微信地图打开成功', 'success');
|
|
|
} catch (error) {
|
|
|
this.addWechatLog(`微信地图打开失败: ${error.message}`, 'error');
|
|
|
- this.fallbackOpenMap();
|
|
|
+ this.fallbackOpenMap(latitude, longitude);
|
|
|
}
|
|
|
} else {
|
|
|
- this.fallbackOpenMap();
|
|
|
+ this.fallbackOpenMap(latitude, longitude);
|
|
|
}
|
|
|
},
|
|
|
|
|
|
// 备用地图打开方式
|
|
|
- fallbackOpenMap() {
|
|
|
- const url = `https://apis.map.qq.com/uri/v1/marker?marker=coord:${this.geoLatitude},${
|
|
|
- this.geoLongitude
|
|
|
- };title:请假地点;addr:${encodeURIComponent(
|
|
|
+ fallbackOpenMap(latitude, longitude) {
|
|
|
+ const url = `https://apis.map.qq.com/uri/v1/marker?marker=coord:${latitude},${longitude};title:请假地点;addr:${encodeURIComponent(
|
|
|
this.form.leaveLocation || '当前位置',
|
|
|
)}&referer=智慧校园`;
|
|
|
|
|
|
@@ -2265,10 +2301,28 @@ export default {
|
|
|
},
|
|
|
|
|
|
// 图片下载
|
|
|
- async handleImageDownload(image) {
|
|
|
- console.log('图片下载:', image);
|
|
|
+ async handleImageDownload(image, event) {
|
|
|
+ this.addWechatLog('=== 图片下载方法开始执行 ===', 'info');
|
|
|
+ this.addWechatLog(
|
|
|
+ '图片信息',
|
|
|
+ 'info',
|
|
|
+ JSON.stringify(
|
|
|
+ {
|
|
|
+ uid: image.uid,
|
|
|
+ ossId: image.ossId,
|
|
|
+ name: image.name,
|
|
|
+ url: image.url,
|
|
|
+ status: image.status,
|
|
|
+ },
|
|
|
+ null,
|
|
|
+ 2,
|
|
|
+ ),
|
|
|
+ );
|
|
|
+
|
|
|
+ // 事件阻止已由handleImageDownloadClick方法处理
|
|
|
|
|
|
if (image.status !== 'success') {
|
|
|
+ this.addWechatLog('⚠️ 图片尚未上传完成,无法下载', 'warning');
|
|
|
uni.showToast({
|
|
|
title: '图片尚未上传完成',
|
|
|
icon: 'none',
|
|
|
@@ -2276,6 +2330,7 @@ export default {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ this.addWechatLog('📤 开始准备下载图片...', 'info');
|
|
|
uni.showLoading({
|
|
|
title: '准备下载...',
|
|
|
mask: true,
|
|
|
@@ -2285,6 +2340,7 @@ export default {
|
|
|
// 如果有ossId,通过API下载
|
|
|
if (image.ossId) {
|
|
|
const downloadUrl = `/api/resource/oss/download/${image.ossId}`;
|
|
|
+ this.addWechatLog(`📥 使用API下载图片,URL: ${downloadUrl}`, 'info');
|
|
|
|
|
|
// 在H5环境中,直接打开下载链接
|
|
|
// #ifdef H5
|
|
|
@@ -2295,6 +2351,7 @@ export default {
|
|
|
link.click();
|
|
|
document.body.removeChild(link);
|
|
|
|
|
|
+ this.addWechatLog('✅ H5环境图片下载已开始', 'success');
|
|
|
uni.hideLoading();
|
|
|
uni.showToast({
|
|
|
title: '下载已开始',
|
|
|
@@ -2326,7 +2383,11 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
fail: (error) => {
|
|
|
- console.error('下载失败:', error);
|
|
|
+ this.addWechatLog(
|
|
|
+ '❌ 图片下载失败',
|
|
|
+ 'error',
|
|
|
+ error.message || error.toString(),
|
|
|
+ );
|
|
|
uni.showToast({
|
|
|
title: '下载失败',
|
|
|
icon: 'none',
|
|
|
@@ -2379,7 +2440,11 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
fail: (error) => {
|
|
|
- console.error('下载失败:', error);
|
|
|
+ this.addWechatLog(
|
|
|
+ '❌ 图片下载失败',
|
|
|
+ 'error',
|
|
|
+ error.message || error.toString(),
|
|
|
+ );
|
|
|
uni.showToast({
|
|
|
title: '下载失败',
|
|
|
icon: 'none',
|
|
|
@@ -2393,25 +2458,111 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
} catch (error) {
|
|
|
- console.error('下载过程出错:', error);
|
|
|
+ this.addWechatLog(
|
|
|
+ '❌ 图片下载过程出错',
|
|
|
+ 'error',
|
|
|
+ error.message || error.toString(),
|
|
|
+ );
|
|
|
uni.hideLoading();
|
|
|
uni.showToast({
|
|
|
title: '下载失败',
|
|
|
icon: 'none',
|
|
|
});
|
|
|
}
|
|
|
+ this.addWechatLog('=== 图片下载方法执行完成 ===', 'success');
|
|
|
+ },
|
|
|
+
|
|
|
+ // 图片点击处理(智能判断是预览还是操作按钮)
|
|
|
+ handleImageClick(image, index, event) {
|
|
|
+ // 检查点击目标是否是操作按钮区域
|
|
|
+ const target = event.target;
|
|
|
+ const isActionButton =
|
|
|
+ target.closest('.image-actions') ||
|
|
|
+ target.closest('u-button') ||
|
|
|
+ target.tagName === 'BUTTON';
|
|
|
+
|
|
|
+ // 如果点击的是操作按钮区域,不触发预览
|
|
|
+ if (!isActionButton) {
|
|
|
+ this.handleImagePreview(image, index);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 删除按钮点击处理(更强的事件处理)
|
|
|
+ handleImageDeleteClick(image, index, event) {
|
|
|
+ console.log('删除按钮被点击:', image, index);
|
|
|
+
|
|
|
+ // 强制阻止事件冒泡和默认行为
|
|
|
+ if (event) {
|
|
|
+ event.stopPropagation();
|
|
|
+ event.preventDefault();
|
|
|
+ event.stopImmediatePropagation();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 调用实际的删除方法
|
|
|
+ this.handleImageDelete(image, index);
|
|
|
+ },
|
|
|
+
|
|
|
+ // 图片下载按钮点击处理(更强的事件处理)
|
|
|
+ handleImageDownloadClick(image, event) {
|
|
|
+ this.addWechatLog('🔽 图片下载按钮被点击', 'info');
|
|
|
+ this.addWechatLog(`图片信息: ${JSON.stringify(image)}`, 'info');
|
|
|
+
|
|
|
+ // 强制阻止事件冒泡和默认行为
|
|
|
+ if (event) {
|
|
|
+ event.stopPropagation();
|
|
|
+ event.preventDefault();
|
|
|
+ event.stopImmediatePropagation();
|
|
|
+ this.addWechatLog(
|
|
|
+ '✅ 事件冒泡已阻止 (stopPropagation + preventDefault + stopImmediatePropagation)',
|
|
|
+ 'success',
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ // 调用实际的下载方法
|
|
|
+ this.handleImageDownload(image, event);
|
|
|
},
|
|
|
|
|
|
// 图片删除
|
|
|
- handleImageDelete(image, index) {
|
|
|
- console.log('删除图片:', image, index);
|
|
|
+ handleImageDelete(image, index, event) {
|
|
|
+ this.addWechatLog('=== 图片删除方法开始执行 ===', 'info');
|
|
|
+ this.addWechatLog(`删除图片参数 - 索引: ${index}`, 'info');
|
|
|
+ this.addWechatLog(
|
|
|
+ '图片信息',
|
|
|
+ 'info',
|
|
|
+ JSON.stringify(
|
|
|
+ {
|
|
|
+ uid: image.uid,
|
|
|
+ ossId: image.ossId,
|
|
|
+ name: image.name,
|
|
|
+ url: image.url,
|
|
|
+ status: image.status,
|
|
|
+ },
|
|
|
+ null,
|
|
|
+ 2,
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ this.addWechatLog(`当前附件列表数量: ${this.attachmentList.length}`, 'info');
|
|
|
+
|
|
|
+ // 强制阻止事件冒泡和默认行为
|
|
|
+ if (event) {
|
|
|
+ this.addWechatLog('阻止事件冒泡和默认行为', 'info');
|
|
|
+ event.stopPropagation();
|
|
|
+ event.preventDefault();
|
|
|
+ }
|
|
|
|
|
|
+ this.addWechatLog('准备显示删除确认对话框', 'info');
|
|
|
uni.showModal({
|
|
|
title: '确认删除',
|
|
|
content: '确定要删除这张图片吗?删除后无法恢复。',
|
|
|
confirmColor: '#ff5722',
|
|
|
success: (res) => {
|
|
|
+ this.addWechatLog(
|
|
|
+ `删除确认对话框回调 - 用户选择: ${res.confirm ? '确认' : '取消'}`,
|
|
|
+ 'info',
|
|
|
+ );
|
|
|
if (res.confirm) {
|
|
|
+ this.addWechatLog('用户确认删除,开始执行删除操作', 'success');
|
|
|
+
|
|
|
// 从附件列表中删除
|
|
|
const attachmentIndex = this.attachmentList.findIndex(
|
|
|
(file) =>
|
|
|
@@ -2420,12 +2571,44 @@ export default {
|
|
|
(file.url && file.url === image.url),
|
|
|
);
|
|
|
|
|
|
+ this.addWechatLog(`查找到的附件索引: ${attachmentIndex}`, 'info');
|
|
|
+ this.addWechatLog(
|
|
|
+ '匹配条件',
|
|
|
+ 'info',
|
|
|
+ `uid: ${image.uid}, ossId: ${image.ossId}, url: ${image.url}`,
|
|
|
+ );
|
|
|
+
|
|
|
if (attachmentIndex >= 0) {
|
|
|
+ this.addWechatLog(
|
|
|
+ '删除前附件列表',
|
|
|
+ 'info',
|
|
|
+ JSON.stringify(
|
|
|
+ this.attachmentList.map((f) => ({ uid: f.uid, name: f.name })),
|
|
|
+ null,
|
|
|
+ 2,
|
|
|
+ ),
|
|
|
+ );
|
|
|
this.attachmentList.splice(attachmentIndex, 1);
|
|
|
+ this.addWechatLog(
|
|
|
+ '删除后附件列表',
|
|
|
+ 'info',
|
|
|
+ JSON.stringify(
|
|
|
+ this.attachmentList.map((f) => ({ uid: f.uid, name: f.name })),
|
|
|
+ null,
|
|
|
+ 2,
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ this.addWechatLog('✅ 图片从附件列表中删除成功', 'success');
|
|
|
+ } else {
|
|
|
+ this.addWechatLog(
|
|
|
+ '⚠️ 警告:未找到要删除的附件,可能已被删除或索引错误',
|
|
|
+ 'warning',
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
// 清理blob URL,防止内存泄漏
|
|
|
if (image.blobUrl && image.blobUrl.startsWith('blob:')) {
|
|
|
+ this.addWechatLog(`清理blob URL: ${image.blobUrl}`, 'info');
|
|
|
URL.revokeObjectURL(image.blobUrl);
|
|
|
}
|
|
|
|
|
|
@@ -2434,9 +2617,22 @@ export default {
|
|
|
icon: 'success',
|
|
|
});
|
|
|
|
|
|
- console.log('图片删除完成,当前附件数量:', this.attachmentList.length);
|
|
|
+ this.addWechatLog(
|
|
|
+ `图片删除完成,当前附件数量: ${this.attachmentList.length}`,
|
|
|
+ 'success',
|
|
|
+ );
|
|
|
+ this.addWechatLog('=== 图片删除方法执行完成 ===', 'success');
|
|
|
+ } else {
|
|
|
+ this.addWechatLog('用户取消删除操作', 'warning');
|
|
|
}
|
|
|
},
|
|
|
+ fail: (err) => {
|
|
|
+ this.addWechatLog(
|
|
|
+ '❌ 删除确认对话框显示失败',
|
|
|
+ 'error',
|
|
|
+ err.message || err.toString(),
|
|
|
+ );
|
|
|
+ },
|
|
|
});
|
|
|
},
|
|
|
|
|
|
@@ -2480,9 +2676,15 @@ export default {
|
|
|
},
|
|
|
|
|
|
// 重试上传文件
|
|
|
- async retryUploadFile(file) {
|
|
|
+ async retryUploadFile(file, event) {
|
|
|
console.log('=== 重试上传文件 ===', file);
|
|
|
|
|
|
+ // 强制阻止事件冒泡和默认行为
|
|
|
+ if (event) {
|
|
|
+ event.stopPropagation();
|
|
|
+ event.preventDefault();
|
|
|
+ }
|
|
|
+
|
|
|
// 重置文件状态
|
|
|
file.status = 'uploading';
|
|
|
file.progress = 0;
|
|
|
@@ -2538,14 +2740,15 @@ export default {
|
|
|
|
|
|
// 显示选择文件类型的操作菜单
|
|
|
uni.showActionSheet({
|
|
|
- itemList: ['选择图片', '选择文档', '微信选择图片'],
|
|
|
+ // itemList: ['选择图片', '选择文档', '微信选择图片'],
|
|
|
+ itemList: ['选择图片'],
|
|
|
success: (res) => {
|
|
|
switch (res.tapIndex) {
|
|
|
case 0:
|
|
|
- this.chooseImages();
|
|
|
+ this.chooseDocuments();
|
|
|
break;
|
|
|
case 1:
|
|
|
- this.chooseDocuments();
|
|
|
+ this.chooseImages();
|
|
|
break;
|
|
|
case 2:
|
|
|
if (this.isWechatBrowser) {
|
|
|
@@ -3019,8 +3222,14 @@ export default {
|
|
|
},
|
|
|
|
|
|
// 手动删除文件
|
|
|
- handleRemoveFile(file, index) {
|
|
|
+ handleRemoveFile(file, index, event) {
|
|
|
console.log('=== 手动删除文件 ===', file, index);
|
|
|
+
|
|
|
+ // 强制阻止事件冒泡和默认行为
|
|
|
+ if (event) {
|
|
|
+ event.stopPropagation();
|
|
|
+ event.preventDefault();
|
|
|
+ }
|
|
|
uni.showModal({
|
|
|
title: '确认删除',
|
|
|
content: '确定要删除这个文件吗?',
|
|
|
@@ -3049,23 +3258,57 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ // 文件下载按钮点击处理(更强的事件处理)
|
|
|
+ handleDownloadFileClick(file, event) {
|
|
|
+ this.addWechatLog('📁 文件下载按钮被点击', 'info');
|
|
|
+ this.addWechatLog(`文件信息: ${JSON.stringify(file)}`, 'info');
|
|
|
+
|
|
|
+ // 强制阻止事件冒泡和默认行为
|
|
|
+ if (event) {
|
|
|
+ event.stopPropagation();
|
|
|
+ event.preventDefault();
|
|
|
+ event.stopImmediatePropagation();
|
|
|
+ this.addWechatLog(
|
|
|
+ '✅ 事件冒泡已阻止 (stopPropagation + preventDefault + stopImmediatePropagation)',
|
|
|
+ 'success',
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ // 调用实际的下载方法
|
|
|
+ this.handleDownloadFile(file, event);
|
|
|
+ },
|
|
|
+
|
|
|
// 文件下载(微信小程序专用版本)
|
|
|
- async handleDownloadFile(file) {
|
|
|
- console.log('=== 开始下载文件 ===');
|
|
|
- console.log('文件信息:', JSON.stringify(file, null, 2));
|
|
|
- console.log('当前时间:', new Date().toISOString());
|
|
|
+ async handleDownloadFile(file, event) {
|
|
|
+ this.addWechatLog('=== 文件下载方法开始执行 ===', 'info');
|
|
|
+ this.addWechatLog('文件信息', 'info', JSON.stringify(file, null, 2));
|
|
|
+ this.addWechatLog(`当前时间: ${new Date().toISOString()}`, 'info');
|
|
|
+
|
|
|
+ // 事件阻止已由handleDownloadFileClick方法处理
|
|
|
|
|
|
// 检查环境信息
|
|
|
const systemInfo = uni.getSystemInfoSync();
|
|
|
- console.log('运行环境信息:', {
|
|
|
- platform: systemInfo.platform,
|
|
|
- version: systemInfo.version,
|
|
|
- model: systemInfo.model,
|
|
|
- brand: systemInfo.brand,
|
|
|
- });
|
|
|
+ this.addWechatLog(
|
|
|
+ '运行环境信息',
|
|
|
+ 'info',
|
|
|
+ JSON.stringify(
|
|
|
+ {
|
|
|
+ platform: systemInfo.platform,
|
|
|
+ version: systemInfo.version,
|
|
|
+ model: systemInfo.model,
|
|
|
+ brand: systemInfo.brand,
|
|
|
+ },
|
|
|
+ null,
|
|
|
+ 2,
|
|
|
+ ),
|
|
|
+ );
|
|
|
|
|
|
if (!file.ossId) {
|
|
|
- console.warn('❌ 下载失败:文件ossId为空', file);
|
|
|
+ this.addWechatLog(
|
|
|
+ '❌ 下载失败:文件ossId为空',
|
|
|
+ 'warning',
|
|
|
+ JSON.stringify(file, null, 2),
|
|
|
+ );
|
|
|
uni.showToast({
|
|
|
title: '文件未上传完成',
|
|
|
icon: 'none',
|
|
|
@@ -3074,7 +3317,7 @@ export default {
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
- console.log('📤 开始显示下载Loading...');
|
|
|
+ this.addWechatLog('📤 开始显示下载Loading...', 'info');
|
|
|
uni.showLoading({
|
|
|
title: `正在下载${file.name}...`,
|
|
|
mask: true,
|
|
|
@@ -3082,22 +3325,29 @@ export default {
|
|
|
|
|
|
// 构建下载URL
|
|
|
const downloadUrl = `/resource/oss/download/${file.ossId}`;
|
|
|
- console.log('下载URL:', downloadUrl);
|
|
|
+ this.addWechatLog(`下载URL: ${downloadUrl}`, 'info');
|
|
|
|
|
|
// 根据文件类型选择处理方式
|
|
|
- console.log('🔍 检查文件类型:', file.name, '是否为图片:', this.isImageFile(file));
|
|
|
+ this.addWechatLog(
|
|
|
+ `🔍 检查文件类型: ${file.name}, 是否为图片: ${this.isImageFile(file)}`,
|
|
|
+ 'info',
|
|
|
+ );
|
|
|
|
|
|
if (this.isImageFile(file)) {
|
|
|
// 图片文件:下载并保存到相册
|
|
|
- console.log('🖼️ 图片文件,下载并保存到相册');
|
|
|
+ this.addWechatLog('🖼️ 图片文件,下载并保存到相册', 'info');
|
|
|
await this.downloadAndSaveImage(downloadUrl, file.name);
|
|
|
} else {
|
|
|
// 非图片文件:下载并直接打开预览
|
|
|
- console.log('📄 非图片文件,下载并打开预览');
|
|
|
+ this.addWechatLog('📄 非图片文件,下载并打开预览', 'info');
|
|
|
await this.downloadAndOpenDocument(downloadUrl, file.name);
|
|
|
}
|
|
|
} catch (error) {
|
|
|
- console.error('❌ 下载过程发生异常:', error);
|
|
|
+ this.addWechatLog(
|
|
|
+ '❌ 下载过程发生异常',
|
|
|
+ 'error',
|
|
|
+ error.message || error.toString(),
|
|
|
+ );
|
|
|
uni.hideLoading();
|
|
|
|
|
|
let errorMsg = '下载失败,请重试';
|
|
|
@@ -3125,7 +3375,7 @@ export default {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- console.log('=== handleDownloadFile方法执行完成 ===');
|
|
|
+ this.addWechatLog('=== 文件下载方法执行完成 ===', 'success');
|
|
|
},
|
|
|
|
|
|
// 下载图片并保存到相册
|
|
|
@@ -4165,15 +4415,33 @@ export default {
|
|
|
.location-info {
|
|
|
margin-top: 10rpx;
|
|
|
padding: 10rpx;
|
|
|
- background-color: #f8f9fa;
|
|
|
+ /* background-color: #f8f9fa; */
|
|
|
border-radius: 6rpx;
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ gap: 10rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.location-coords-container {
|
|
|
+ flex: 1;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ min-width: 0;
|
|
|
}
|
|
|
|
|
|
.location-coords {
|
|
|
font-size: 24rpx;
|
|
|
color: #666;
|
|
|
+ word-break: break-all;
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+}
|
|
|
+
|
|
|
+.location-action-container {
|
|
|
+ flex-shrink: 0;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
}
|
|
|
|
|
|
/* 微信SDK调试样式 */
|
|
|
@@ -4566,6 +4834,8 @@ export default {
|
|
|
overflow: hidden;
|
|
|
border: 2rpx solid #f0f0f0;
|
|
|
transition: all 0.3s ease;
|
|
|
+ /* 确保图片容器的点击事件不影响按钮 */
|
|
|
+ cursor: pointer;
|
|
|
}
|
|
|
|
|
|
.image-item:active {
|
|
|
@@ -4579,6 +4849,7 @@ export default {
|
|
|
height: 200rpx;
|
|
|
border-radius: 8rpx;
|
|
|
overflow: hidden;
|
|
|
+ cursor: pointer;
|
|
|
}
|
|
|
|
|
|
.attachment-image {
|
|
|
@@ -4646,12 +4917,20 @@ export default {
|
|
|
border-top: 1rpx solid #f0f0f0;
|
|
|
flex-wrap: nowrap;
|
|
|
justify-content: space-between;
|
|
|
+ /* 确保按钮区域能正确处理点击事件 */
|
|
|
+ position: relative;
|
|
|
+ z-index: 10;
|
|
|
+ pointer-events: auto;
|
|
|
}
|
|
|
|
|
|
.image-actions .u-button {
|
|
|
flex: 1;
|
|
|
min-width: 60rpx;
|
|
|
font-size: 24rpx !important;
|
|
|
+ /* 确保按钮可点击 */
|
|
|
+ pointer-events: auto;
|
|
|
+ position: relative;
|
|
|
+ z-index: 11;
|
|
|
}
|
|
|
|
|
|
.image-name {
|
|
|
@@ -4691,4 +4970,15 @@ export default {
|
|
|
padding: 6rpx 12rpx;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+.location-coords-container {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+}
|
|
|
+
|
|
|
+.location-action-container {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ margin-left: 10rpx;
|
|
|
+}
|
|
|
</style>
|