//v1.5 if (typeof jQuery != "undefined") {minisiteBuyPrice();} else { console.log("Please Include jQuery 1.x"); } function minisiteBuyPrice() { jQuery(document).ready(function() { var _type = "Minisite"; var _minisite_event_title = typeof document.title != "undefined" && document.title != "" ? document.title :_type; var _buy_country = "cn"; var _buy_icon_url = "//dxgwqc.com/"; _buy_icon_url = _buy_icon_url.replace(/\/$/, ""); var G_locale = "zh_CN"; var G_exclude = ""; //"0,1,2"; var G_prices = {}; var G_currencyFormat = ""; var G_exclude = ""; var G_products = []; var G_type = "cat"; var G_country = { "jp" : "税别", "vn" : "Bao gồm VAT" } var G_api = "//dxgwqc.com/_js/api_minisite-buy-data/cn/"; var G_errors = "- 赁E暂时无法读取,请稍后再证E :P."; var G_currency = "CNY"; jQuery(".g_products").each(function() { var _this_sn = jQuery(this).data("sn"); if (_this_sn == "000-00000-00") {jQuery(this).remove();} else { G_products.push(_this_sn); jQuery(this).hide(); } }); jQuery.ajax({ type: "GET", url: G_api, dataType: "jsonp", jsonp:"callback", jsonpCallback:"callback", data: { gpns: G_products.toString(), country: _buy_country, type: G_type }, cache:true, success:function(data) { var _isOK = data.status; if (_isOK) { // Reset/Empty Price; jQuery('#spec .classic-price').text( jQuery('#model .premium-rose-gold-gray .price').text() ); jQuery('#spec .sports-price').text( jQuery('#model .sport-seafoam-silver .price').text() ); //get All Prices jQuery.each(data.products, function(i, item) { var _t = item.title; var _g = item.gpn; var _p = item.price; var _pp = item.pricePromotion; var _cry = item.currencyFormat; // Price if (typeof _g != "undefined" && _g ) { if (typeof _p != "undefined" && _p ) { if (typeof _pp != "undefined" && _pp ){ G_prices[_g] = parseFloat(_pp).toLocaleString(); } else { G_prices[_g] = parseFloat(_p).toLocaleString(); } } if (typeof _cry != "undefined" ) { G_currencyFormat = _cry; } } else { console.log("missing data : " + i); } }) jQuery("#device [data-nav]>*").each(function() { var thisSn = jQuery(this).find(".pd-color-con>*.active").attr("data-sn"); var pPrice = G_currencyFormat + " " + G_prices[thisSn]; var G_suffix = ''; if ( thisSn in G_prices ){ switch (_buy_country) { case 'jp': G_suffix = G_country.jp; break; case 'vn': G_suffix = G_country.vn; break; } G_suffix = G_suffix ? " ("+G_suffix+")" : ""; jQuery(this).find('p.price').html( pPrice + G_suffix); } else {jQuery(this).find('p.price').text("");} }) jQuery("#device .pd-color-con>*").click(function() { var thisSn = jQuery(this).attr("data-sn"); var pPrice = G_currencyFormat + " " + G_prices[thisSn]; var G_suffix = ''; if ( thisSn in G_prices ){ switch (_buy_country) { case 'jp': G_suffix = G_country.jp; break; case 'vn': G_suffix = G_country.vn; break; } G_suffix = G_suffix ? " ("+G_suffix+")" : ""; jQuery("#device [data-nav].active>div.active .price").html( pPrice + G_suffix); } else {jQuery(this).parents().eq(3).find("p.price").text("");} }) jQuery.each(data.products, function(i, item) { var _t = item.title; var _g = item.gpn; var _u = item.url; var _p = item.price; var _pp = item.pricePromotion; var _cry = item.currencyFormat; // Distributors if (typeof item.distributors != "undefined") { var _parms = "&t="+_t+"&p="+_p+"&c="+ _type + "%2F"+ _minisite_event_title.replace(/ \| /g, '%2F') + "&d=" + G_currency; if (item.distributors.length == 1) { if (item.buy == true && item.url != "") { var _this = jQuery(".g_products[data-sn='" + item.gpn + "']"); if (_this.length == 0) { console.log("No set data-sn!!!"); } else { jQuery(_this).show().css("display", "inline-block").attr({ href:_u + _parms, target:"_blank" }).on("click", function() { ga("send", "event", _type, " | " + _minisite_event_title + " | " + _t + " | " + _g); }); } } } else if (item.distributors.length > 1) { if (item.buy == true && item.url != "") { var _this = jQuery(".g_products[data-sn='" + item.gpn + "']"); if (_this.length == 0) { console.log("No set data-sn!!!"); } else { jQuery(_this).show().css("display", "inline-block").attr("href", _u + _parms).on("click", function() { ga("send", "event", "Minisite", " | " + _minisite_event_title+ " | " + _t + " | " + _g); }); } } } else { // zero if (item.buy == true && item.url != "") { var _this = jQuery(".g_products[data-sn='" + item.gpn + "']"); if (_this.length == 0) { console.log("No set data-sn!!!"); } else { jQuery(_this).show().css("display", "inline-block").attr({ href:_u + _parms, target:"_blank" }).on("click", function() { ga("send", "event", _type, " | " + _minisite_event_title + " | " + _t + " | " + _g); }); } } } } }); } else { console.log("- No Data :P"); } }, error:function(xhr) { console.log("- 赁E暂时无法读取,请稍后再证E :P"); }, timeout:6e4 }); // fancybox if (typeof jQuery.fancybox == "function") { // fancy box loaded; jQuery(".button-play, .btn3, a.g_products").fancybox({ width:"80%", height:"80%", type:"iframe", iframe:{ scrolling:"auto", preload:true }, scrolling:"no", padding:0, margin:0 }); } else { console.log("Please Include fancy box plugin !"); } }); }