From d68fb476c248c6c3ab974ea6b18d6bba638f12d8 Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期四, 06 十一月 2025 12:35:37 +0800
Subject: [PATCH] 页面优化
---
pages/product/m-buy/goods.vue | 28 +++++++++++++++++++++++++---
1 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/pages/product/m-buy/goods.vue b/pages/product/m-buy/goods.vue
index 6af3cf0..fdf0f55 100644
--- a/pages/product/m-buy/goods.vue
+++ b/pages/product/m-buy/goods.vue
@@ -4,8 +4,8 @@
<!-- 鍟嗗搧 -->
<view class="goods-box bottom">
<view class="goods-header">
- <view class="goods-img">
- <!-- <u-image width="200rpx" border-radius="20" class="uimage" height="200rpx" :src="selectedSpecImg ? selectedSpecImg : goodsDetail.thumbnail"></u-image> -->
+ <view class="goods-img" v-if="goodsDetail.specList && goodsDetail.specList.length > 0 && goodsDetail.specList[0].specImage.length > 0" @click="previewImageSpec">
+ <u-image width="200rpx" border-radius="20" class="uimage" height="200rpx" :src="selectedSpecImg ? selectedSpecImg : goodsDetail.thumbnail"></u-image>
</view>
<view class="goods-skus">
<!-- 鏈夋椿鍔ㄥ晢鍝佷环鏍� -->
@@ -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('鍒濆鍖朇OS澶辫触', err);
// 浣跨敤setTimeout寤惰繜鏄剧ず鎻愮ず锛岄伩鍏嶅奖鍝嶅脊绐�
@@ -958,6 +960,13 @@
if (this.previewUrls && this.previewUrls[fileKey]) {
return this.previewUrls[fileKey];
}
+ // 濡傛灉娌℃湁http鍓嶇紑锛岄渶瑕佹嫾鎺ndpoint杩涜鏄剧ず
+ if (fileKey && !fileKey.startsWith('http://') && !fileKey.startsWith('https://')) {
+ // 浣跨敤endpoint鎷兼帴瀹屾暣鐨刄RL
+ if (this.endpoint) {
+ return this.endpoint + '/' + fileKey;
+ }
+ }
// 鍚﹀垯杩斿洖鍘熷鍊�
return fileKey;
},
@@ -977,7 +986,20 @@
this.selectedImages = [];
}
},
-
+ // 棰勮妯℃澘鍥剧墖
+ previewImageSpec() {
+ // 鍙瑙堝綋鍓嶉�変腑鐨勫浘鐗�
+ const url = this.selectedSpecImg ? this.selectedSpecImg : this.goodsDetail.thumbnail
+ const urls = [url];
+
+ // 璋冪敤uniapp鍘熺敓API棰勮鍥剧墖
+ uni.previewImage({
+ current: 0, // 褰撳墠鏄剧ず鍥剧墖鐨勭储寮曪紙鍙湁涓�寮犲浘鐗囷紝鎵�浠ユ槸0锛�
+ urls: urls, // 闇�瑕侀瑙堢殑鍥剧墖閾炬帴鍒楄〃
+ indicator: 'default', // 鏄剧ず绱㈠紩鎸囩ず鍣�
+ loop: false // 鍙湁涓�寮犲浘鐗囷紝涓嶉渶瑕佸惊鐜瑙�
+ });
+ },
// 棰勮妯℃澘鍥剧墖
previewImage(imgObject, index) {
// 鍙瑙堝綋鍓嶉�変腑鐨勫浘鐗�
--
Gitblit v1.8.0