绿满眶商城微信小程序-uniapp
peng
2025-10-16 6a20878b9b1e3460531b055d72d5d671f761abc3
定制商品
1个文件已修改
9 ■■■■■ 已修改文件
pages/product/m-buy/goods.vue 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/product/m-buy/goods.vue
@@ -250,6 +250,7 @@
            cosClient: null, // COS客户端
            bucket: '', // 存储桶
            region: '', // 地域
            endpoint: '', // COS访问endpoint
            previewUrls: {} // 文件预览地址缓存
        };
    },
@@ -390,6 +391,7 @@
                });
                this.bucket = res.data.data.bucket;
                this.region = res.data.data.region;
                this.endpoint = res.data.data.endpoint; // 获取endpoint
            }).catch(err => {
                console.error('初始化COS失败', err);
                // 使用setTimeout延迟显示提示,避免影响弹窗
@@ -958,6 +960,13 @@
            if (this.previewUrls && this.previewUrls[fileKey]) {
                return this.previewUrls[fileKey];
            }
            // 如果没有http前缀,需要拼接endpoint进行显示
            if (fileKey && !fileKey.startsWith('http://') && !fileKey.startsWith('https://')) {
                // 使用endpoint拼接完整的URL
                if (this.endpoint) {
                    return this.endpoint + '/' + fileKey;
                }
            }
            // 否则返回原始值
            return fileKey;
        },