
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).on('click', '#no_price_subscribe', function () {
$(".subscribe-model").fadeIn();
})
// // 页面加载时首次获取价格
$(document).ready(function() {
const currency_code = "USD";
const model = "RY1S-CL-D24"
if(model.trim().length > 0){
const detail_price = document.getElementById('detail-price');
const no_price_box = document.getElementById('no_price_subscribe');
const no_price_text = no_price_box.querySelector(".text");
$.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_text.textContent= current_price
no_price_box.style.display = "inline-flex";
detail_price.style.display = "none";
}else{
detail_price.textContent= current_price
detail_price.style.display = "inline-flex";
no_price_box.style.display = "none";
}
},
error: function() {
// 请求失败时的处理
showMessage("Error fetching price for model: " + model);
}
});
}
});