|
|
@@ -6,7 +6,7 @@
|
|
6
|
6
|
</u-col>
|
|
7
|
7
|
<u-col span="3.5">
|
|
8
|
8
|
<u-button size="small" @click="copyAllImages"
|
|
9
|
|
- style="border-radius: 20rpx;border-color: #007AFF;color: #007AFF;">复制全部图片</u-button>
|
|
|
9
|
+ style="border-radius: 20rpx;border-color: #007AFF;color: #007AFF;">保存全部图片</u-button>
|
|
10
|
10
|
</u-col>
|
|
11
|
11
|
</u-row>
|
|
12
|
12
|
|
|
|
@@ -149,26 +149,19 @@ export default {
|
|
149
|
149
|
console.log('电话卡片被点击', '电话号码:', this.orderDetail.phone)
|
|
150
|
150
|
if (this.orderDetail.phone) {
|
|
151
|
151
|
//拨打电话
|
|
152
|
|
- // uni.makePhoneCall({
|
|
153
|
|
- // phoneNumber: this.orderDetail.phone,
|
|
154
|
|
- // success: () => {
|
|
155
|
|
- // this.$store.commit("call/SET_FORM", {
|
|
156
|
|
- // clueId: this.orderDetail.clueId,
|
|
157
|
|
- // type: "3",
|
|
158
|
|
- // callee: this.orderDetail.phone,
|
|
159
|
|
- // });
|
|
160
|
|
- // },
|
|
161
|
|
- // });
|
|
|
152
|
+ uni.makePhoneCall({
|
|
|
153
|
+ phoneNumber: this.orderDetail.phone
|
|
|
154
|
+ });
|
|
162
|
155
|
//先暂时复制电话号码
|
|
163
|
|
- uni.setClipboardData({
|
|
164
|
|
- data: this.orderDetail.phone,
|
|
165
|
|
- success: () => {
|
|
166
|
|
- uni.showToast({
|
|
167
|
|
- title: '电话号码已复制',
|
|
168
|
|
- icon: 'none'
|
|
169
|
|
- })
|
|
170
|
|
- }
|
|
171
|
|
- })
|
|
|
156
|
+ // uni.setClipboardData({
|
|
|
157
|
+ // data: this.orderDetail.phone,
|
|
|
158
|
+ // success: () => {
|
|
|
159
|
+ // uni.showToast({
|
|
|
160
|
+ // title: '电话号码已复制',
|
|
|
161
|
+ // icon: 'none'
|
|
|
162
|
+ // })
|
|
|
163
|
+ // }
|
|
|
164
|
+ // })
|
|
172
|
165
|
} else {
|
|
173
|
166
|
uni.showToast({
|
|
174
|
167
|
title: '该订单暂时没有电话号码',
|
|
|
@@ -226,17 +219,21 @@ export default {
|
|
226
|
219
|
const allImages = [...this.trueUploadList, ...this.chatRecordsUploadList];
|
|
227
|
220
|
//取出所有图的url
|
|
228
|
221
|
const allUrls = allImages.map(item => item.fileUrl);
|
|
229
|
|
- console.log('所有图片:', allUrls)
|
|
230
|
|
- console.log('合并后的图片列表:', allUrls)
|
|
231
|
222
|
if (allUrls.length > 0) {
|
|
232
|
|
- // 复制到剪贴板
|
|
233
|
|
- uni.setClipboardData({
|
|
234
|
|
- data: JSON.stringify(allUrls),
|
|
235
|
|
- success: () => {
|
|
236
|
|
- uni.showToast({
|
|
237
|
|
- title: '所有图片已复制',
|
|
238
|
|
- icon: 'none'
|
|
239
|
|
- })
|
|
|
223
|
+ // 显示保存图片确认弹窗
|
|
|
224
|
+ uni.showModal({
|
|
|
225
|
+ title: '保存图片',
|
|
|
226
|
+ content: `是否将 ${allUrls.length} 张图片保存到本地相册?`,
|
|
|
227
|
+ confirmText: '保存',
|
|
|
228
|
+ // cancelText: '仅复制链接',
|
|
|
229
|
+ success: (res) => {
|
|
|
230
|
+ if (res.confirm) {
|
|
|
231
|
+ // 用户选择保存图片
|
|
|
232
|
+ this.saveImagesToLocal(allUrls);
|
|
|
233
|
+ } else if (res.cancel) {
|
|
|
234
|
+ // 用户选择仅复制链接
|
|
|
235
|
+ this.copyImageUrls(allUrls);
|
|
|
236
|
+ }
|
|
240
|
237
|
}
|
|
241
|
238
|
})
|
|
242
|
239
|
} else {
|
|
|
@@ -247,6 +244,127 @@ export default {
|
|
247
|
244
|
}
|
|
248
|
245
|
},
|
|
249
|
246
|
|
|
|
247
|
+ // 保存图片到本地相册
|
|
|
248
|
+ async saveImagesToLocal(imageUrls) {
|
|
|
249
|
+ try {
|
|
|
250
|
+ uni.showLoading({
|
|
|
251
|
+ title: '正在保存图片...',
|
|
|
252
|
+ mask: true
|
|
|
253
|
+ });
|
|
|
254
|
+
|
|
|
255
|
+ const savedImages = [];
|
|
|
256
|
+ const failedImages = [];
|
|
|
257
|
+
|
|
|
258
|
+ // 逐个保存图片
|
|
|
259
|
+ for (let i = 0; i < imageUrls.length; i++) {
|
|
|
260
|
+ const url = imageUrls[i];
|
|
|
261
|
+ try {
|
|
|
262
|
+ await this.saveSingleImage(url);
|
|
|
263
|
+ savedImages.push(url);
|
|
|
264
|
+ } catch (error) {
|
|
|
265
|
+ console.error(`保存图片失败: ${url}`, error);
|
|
|
266
|
+ failedImages.push(url);
|
|
|
267
|
+ }
|
|
|
268
|
+
|
|
|
269
|
+ // 更新进度
|
|
|
270
|
+ uni.showLoading({
|
|
|
271
|
+ title: `正在保存图片... (${i + 1}/${imageUrls.length})`,
|
|
|
272
|
+ mask: true
|
|
|
273
|
+ });
|
|
|
274
|
+ }
|
|
|
275
|
+
|
|
|
276
|
+ uni.hideLoading();
|
|
|
277
|
+
|
|
|
278
|
+ // 显示结果
|
|
|
279
|
+ let message = `成功保存 ${savedImages.length} 张图片`;
|
|
|
280
|
+ if (failedImages.length > 0) {
|
|
|
281
|
+ message += `,${failedImages.length} 张保存失败`;
|
|
|
282
|
+ }
|
|
|
283
|
+
|
|
|
284
|
+ uni.showToast({
|
|
|
285
|
+ title: message,
|
|
|
286
|
+ icon: 'none',
|
|
|
287
|
+ duration: 3000
|
|
|
288
|
+ });
|
|
|
289
|
+
|
|
|
290
|
+ // 如果有失败的图片,也复制链接作为备选
|
|
|
291
|
+ if (failedImages.length > 0) {
|
|
|
292
|
+ const allUrls = [...savedImages, ...failedImages];
|
|
|
293
|
+ this.copyImageUrls(allUrls);
|
|
|
294
|
+ }
|
|
|
295
|
+
|
|
|
296
|
+ } catch (error) {
|
|
|
297
|
+ uni.hideLoading();
|
|
|
298
|
+ console.error('保存图片过程中发生错误:', error);
|
|
|
299
|
+ uni.showToast({
|
|
|
300
|
+ title: '保存图片失败',
|
|
|
301
|
+ icon: 'error'
|
|
|
302
|
+ });
|
|
|
303
|
+ }
|
|
|
304
|
+ },
|
|
|
305
|
+
|
|
|
306
|
+ // 保存单张图片
|
|
|
307
|
+ saveSingleImage(url) {
|
|
|
308
|
+ return new Promise((resolve, reject) => {
|
|
|
309
|
+ // 先下载图片
|
|
|
310
|
+ uni.downloadFile({
|
|
|
311
|
+ url: url,
|
|
|
312
|
+ success: (res) => {
|
|
|
313
|
+ if (res.statusCode === 200) {
|
|
|
314
|
+ // 保存到相册
|
|
|
315
|
+ uni.saveImageToPhotosAlbum({
|
|
|
316
|
+ filePath: res.tempFilePath,
|
|
|
317
|
+ success: () => {
|
|
|
318
|
+ console.log('图片保存成功:', url);
|
|
|
319
|
+ resolve();
|
|
|
320
|
+ },
|
|
|
321
|
+ fail: (err) => {
|
|
|
322
|
+ console.error('保存到相册失败:', err);
|
|
|
323
|
+ // 如果是权限问题,尝试请求权限
|
|
|
324
|
+ if (err.errMsg.includes('auth denied')) {
|
|
|
325
|
+ uni.showModal({
|
|
|
326
|
+ title: '权限不足',
|
|
|
327
|
+ content: '需要访问相册权限来保存图片,是否去设置?',
|
|
|
328
|
+ success: (modalRes) => {
|
|
|
329
|
+ if (modalRes.confirm) {
|
|
|
330
|
+ // 打开设置页面
|
|
|
331
|
+ uni.openSetting({
|
|
|
332
|
+ success: (settingRes) => {
|
|
|
333
|
+ console.log('设置页面结果:', settingRes);
|
|
|
334
|
+ }
|
|
|
335
|
+ });
|
|
|
336
|
+ }
|
|
|
337
|
+ }
|
|
|
338
|
+ });
|
|
|
339
|
+ }
|
|
|
340
|
+ reject(err);
|
|
|
341
|
+ }
|
|
|
342
|
+ });
|
|
|
343
|
+ } else {
|
|
|
344
|
+ reject(new Error('下载失败'));
|
|
|
345
|
+ }
|
|
|
346
|
+ },
|
|
|
347
|
+ fail: (err) => {
|
|
|
348
|
+ console.error('下载图片失败:', err);
|
|
|
349
|
+ reject(err);
|
|
|
350
|
+ }
|
|
|
351
|
+ });
|
|
|
352
|
+ });
|
|
|
353
|
+ },
|
|
|
354
|
+
|
|
|
355
|
+ // 复制图片链接
|
|
|
356
|
+ copyImageUrls(urls) {
|
|
|
357
|
+ uni.setClipboardData({
|
|
|
358
|
+ data: JSON.stringify(urls),
|
|
|
359
|
+ success: () => {
|
|
|
360
|
+ uni.showToast({
|
|
|
361
|
+ title: '图片链接已复制',
|
|
|
362
|
+ icon: 'none'
|
|
|
363
|
+ })
|
|
|
364
|
+ }
|
|
|
365
|
+ })
|
|
|
366
|
+ },
|
|
|
367
|
+
|
|
250
|
368
|
},
|
|
251
|
369
|
|
|
252
|
370
|
}
|