|
|
@@ -82,7 +82,7 @@ import productMins from "@/mixins/cgPlantProduct";
|
|
|
import AppDeliveryModule from "@/components/app-delivery";
|
|
|
import { createOrder } from "@/api/order";
|
|
|
import { mapGetters } from "vuex";
|
|
|
-import { getUserDistance } from "@/api/express";
|
|
|
+import { delImage } from "@/api/pic-text";
|
|
|
import { getAllKind } from "@/api/kind";
|
|
|
//图片上传插件来源:https://ext.dcloud.net.cn/plugin?id=2922 已改造,不能再升级 shish 20211228
|
|
|
import htzImageUpload from '@/components/htz-image-upload/htz-image-upload.vue'
|
|
|
@@ -150,6 +150,14 @@ export default {
|
|
|
imgDeleteFn(res){
|
|
|
const index = res.index
|
|
|
this.form.cover.splice(index,1)
|
|
|
+ const shortDelPath = this.normalizeImgPath(res.del).replace(/^\//, '') // 因为 oss 接收的短路径不带 /
|
|
|
+ if (shortDelPath != '') {
|
|
|
+ delImage({ filePath: shortDelPath }).then(() => {
|
|
|
+ console.log('图片删除成功');
|
|
|
+ }).catch(err => {
|
|
|
+ console.error('图片删除失败:', err);
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
init() {
|
|
|
this.getKindDataFn()
|
|
|
@@ -227,7 +235,31 @@ export default {
|
|
|
that.pageTo({url: '/admin/order/workOrderResult',type:2,query:{id:res.data.id}})
|
|
|
})
|
|
|
})
|
|
|
- }
|
|
|
+ },
|
|
|
+ // 规范化图片路径:去除域名与查询参数,保留以/开头的相对路径
|
|
|
+ normalizeImgPath(url){
|
|
|
+ if (!url || typeof url !== 'string') return ''
|
|
|
+ try {
|
|
|
+ // 去掉查询参数
|
|
|
+ const qIndex = url.indexOf('?')
|
|
|
+ const noQuery = qIndex >= 0 ? url.substring(0, qIndex) : url
|
|
|
+ // 提取以/开头的路径
|
|
|
+ const match = noQuery.match(/:\/\/[\w.-]+(\:\d+)?(\/[^?#]+)$/)
|
|
|
+ if (match && match[2]) {
|
|
|
+ return match[2]
|
|
|
+ }
|
|
|
+ // 若本身就是相对路径则直接返回
|
|
|
+ if (noQuery.startsWith('/')) return noQuery
|
|
|
+ // 若是无协议域名形式 //domain/path
|
|
|
+ if (noQuery.startsWith('//')) {
|
|
|
+ const idx = noQuery.indexOf('/', 2)
|
|
|
+ return idx > 0 ? noQuery.substring(idx) : ''
|
|
|
+ }
|
|
|
+ return noQuery
|
|
|
+ } catch (e) {
|
|
|
+ return ''
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|