Skip to content

Commit a8c3cde

Browse files
committed
Add shop buttons for various products and implement Amazon ASIN retrieval in common.js. Update product pages to include new shop button functionality for E02, E02H24, G200, GM100, S400, and W01, while excluding S300.
1 parent 91158a1 commit a8c3cde

File tree

8 files changed

+35
-1
lines changed

8 files changed

+35
-1
lines changed

components/common.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,40 @@ function createProductCard(productModel) {
180180
<img src="products/pics/${productModel}/${productModel}${['S400', 'S300', 'GM100'].includes(productModel) ? 'CB' : ''}-1.jpg" class="card-img-top" alt="${productModel}">
181181
<div class="card-body">
182182
<h5 class="card-title">${productModel}</h5>
183-
<a href="products/${productModel.toLowerCase()}.html" class="btn btn-primary">Learn More</a>
183+
<div class="d-flex gap-2">
184+
<a href="products/${productModel.toLowerCase()}.html" class="btn btn-primary">Learn More</a>
185+
${ productModel != 'S300' ? `<a href="https://amazon.com/dp/${getAmazonASIN(productModel)}" target="_blank" class="btn btn-success">Shop</a>` : ''}
186+
</div>
184187
</div>
185188
</div>
186189
</div>
187190
`;
188191
}
189192

193+
// 创建商店按钮
194+
function createShopButton(productModel) {
195+
return `
196+
<div class="text-center mb-4">
197+
<a href="https://amazon.com/dp/${getAmazonASIN(productModel)}" target="_blank" class="btn btn-success btn-lg">
198+
Shop ${productModel} on Amazon
199+
</a>
200+
</div>
201+
`;
202+
}
203+
204+
// 获取Amazon ASIN
205+
function getAmazonASIN(productModel) {
206+
const asinMap = {
207+
'S400': 'B0F24CL2YZ',
208+
209+
'GM100': 'B0CSX8W1SD',
210+
'E02': 'B0CT3KH4L4',
211+
'E02H24': 'B0D69J9HDQ',
212+
'W01': 'B0CT3SFYY9'
213+
};
214+
return asinMap[productModel] || 'B0XXXXXXXXX';
215+
}
216+
190217
// 修改暗黑模式切换按钮
191218
function loadDarkModeToggle() {
192219
const darkModeToggle = document.createElement('div');

products/e02.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
loadImageHandlers();
1010

1111
const container = document.querySelector('.container');
12+
container.innerHTML += createShopButton('E02');
1213
container.innerHTML += createGallerySection('E02', '', 12);
1314
container.innerHTML += createManualSection('E02');
1415
container.innerHTML += createInstallGuideSection('YOUR_E02_VIDEO_ID');

products/e02h24.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
loadImageHandlers();
1010

1111
const container = document.querySelector('.container');
12+
container.innerHTML += createShopButton('E02H24');
1213
container.innerHTML += createGallerySection('E02H24', '', 7);
1314
container.innerHTML += createManualSection('E02H24');
1415
container.innerHTML += createInstallGuideSection('YOUR_E02H24_VIDEO_ID');

products/g200.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
loadImageHandlers();
1010

1111
const container = document.querySelector('.container');
12+
container.innerHTML += createShopButton('G200');
1213
container.innerHTML += createGallerySection('G200', 'Black', 10);
1314
container.innerHTML += createGallerySection('G200', 'White', 9);
1415
container.innerHTML += createManualSection('G200');

products/gm100.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
loadImageHandlers();
1010

1111
const container = document.querySelector('.container');
12+
container.innerHTML += createShopButton('GM100');
1213
container.innerHTML += createGallerySection('GM100', 'Black', 6);
1314
container.innerHTML += createGallerySection('GM100', 'White', 3);
1415
container.innerHTML += createManualSection('GM100');

products/s300.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
loadImageHandlers();
1010

1111
const container = document.querySelector('.container');
12+
// container.innerHTML += createShopButton('S300');
1213
container.innerHTML += createGallerySection('S300', 'Black', 8);
1314
container.innerHTML += createGallerySection('S300', 'White', 8);
1415
container.innerHTML += createManualSection('S300');

products/s400.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
loadImageHandlers();
1010

1111
const container = document.querySelector('.container');
12+
container.innerHTML += createShopButton('S400');
1213
container.innerHTML += createGallerySection('S400', 'Black', 13);
1314
container.innerHTML += createGallerySection('S400', 'White', 13);
1415
container.innerHTML += createManualSection('S400');

products/w01.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
loadImageHandlers();
1010

1111
const container = document.querySelector('.container');
12+
container.innerHTML += createShopButton('W01');
1213
container.innerHTML += createGallerySection('W01', '', 8);
1314
container.innerHTML += createManualSection('W01');
1415
container.innerHTML += createInstallGuideSection('YOUR_W01_VIDEO_ID');

0 commit comments

Comments
 (0)