
initClickCarousel(".image-carousel", 5);
// 点击切换主图
$(document).on("click", ".image-carousel .carousel .item", function () {
const src = $(this).find("img").attr("src");
$(".img-main").attr("src", src);
});
// // 页面加载时首次获取价格
$(document).ready(function() {
const currency_code = "USD";
const model = "RY1S-CL-A220"
if(model.trim().length > 0){
let detail_price = document.getElementById('detail-price');
let no_price = document.getElementById('no-price');
$.ajax({
url: '/get_prices.php', // 接口路径
method: 'GET',
data: { model: model ,currency_code:currency_code},
dataType: 'json',
success: function(data) {
// 更新当前行的价格
var current_price = '';
if(data.cny_price == undefined){
current_price = 'Subscribe to get prices'
}else if(currency_code == 'CNY'){
current_price = data.cny_price;
}else if(currency_code == 'HKD'){
current_price = data.hkd_price;
}else if(currency_code == 'EUR'){
current_price = data.eur_price;
}else{
current_price = data.usd_price;
}
//detail_price.textContent= current_price
if(data.cny_price == undefined){
no_price.textContent= current_price
no_price.style.display = "block";
detail_price.style.display = "none";
}else{
detail_price.textContent= current_price
detail_price.style.display = "block";
no_price.style.display = "none";
}
},
error: function() {
// 请求失败时的处理
showMessage("Error fetching price for model: " + model);
}
});
}
});