function selinfo(result){
$("#price").html('锟�' + result.info.price);
// $("#fprice").html('锟�' + result.info.fprice);
$("#fprice").html('锟�' + result.info.old_price);
// if(!result.islogin){
// $("#fprice").html('锟�' + result.info.price);
// }
$('#goods_store').text(result.store);
var old_price = parsefloat(result.info.old_price);
if (old_price > 0 && old_price > parsefloat(result.info.price)) {
$("#old_price").html('鍘熶环锛氾骏' + result.info.old_price).show();
} else {
$("#old_price").hide();
}
if(result.info.image){
$("#vertical").find("img").attr("src",result.info.image+'?imagemogr/v2/thumbnail/420x420');
$("#bigview").find("img").attr("src",result.info.image);
}else{
$("#imagemenu").find("li").eq(0).hide();
}
if(result.parts){
var imgstr = '';
for(var i=0;i';
if((i+1) != result.parts.length){
imgstr += '+';
}
}
$("#parts").html(imgstr);
}
}
function checknum(num){
var combo_id = $("#selcombo").find(".selected").find("a").data("cid");
var spec_item = [];
$(".goods-taocan").find("li.selected").each(function(){
spec_item.push($(this).find("a").attr("item"));
})
$.post(get_stock_url,{goods_id:goods_id,combo_id:combo_id,spec:spec_item,num:num},function(result){
if(result.status == 'n'){
layer.alert(result.info);
}else{
var info = result.data;
//$("#price").text('锟�'+ (parsefloat(info.price) * parseint(info.store)).tofixed(2));
$('input[name=num]').val(info.store)
}
})
}
// 鍔犲叆璐墿杞︺€佺珛鍗宠喘涔�
function addcart(go){
var num = $("#buy_goods_count").val();
var combo_id = $("#selcombo").find(".selected").find("a").data("cid");
var spec_item = [];
$(".goods-taocan").find("li.selected").each(function(){
spec_item.push($(this).find("a").attr("item"));
})
$.post(cart_url,{goods_id:goods_id,combo_id:combo_id,spec:spec_item,num:num},function(result){
if(result.status == 'n'){
layer.alert(result.info);
}else{
if(go){
location.href = cart_index_url;
}else{
layer.alert("鍔犲叆璐墿杞︽垚鍔�");
}
}
})
}
$(document).ready(function() {
$("#parts").on("click",".pro_li",function(){
var img = $(this).find("img").attr('src');
var con=$(this).find("a").attr('att');
var href=$(this).find("a").attr('atthref');
$(".wddz_boom img").attr('src',img);
$(".wddz_boom p").html(con);
if(href==null){
$(".wddz_boom .det").hide();
}else{
$(".wddz_boom .det").attr('href',href).show();
}
$('.wddz_boom').fadein(100);
$('.boom_bg').slidedown(200);
});
$('.boom_bg,.wddz_close').click(function(){
$('.boom_bg').fadeout(100);
$('.wddz_boom').slideup(200);
})
// 鍥剧墖涓婁笅婊氬姩
var count = $("#imagemenu li").length - 3; /* 鏄剧ず 4 涓� li鏍囩鍐呭 */
var interval = $("#imagemenu li:first").width()+5;
var curindex = 0;
$('.scrollbutton').click(function(){
if( $(this).hasclass('disabled') ) return false;
if ($(this).hasclass('smallimgup')) --curindex;
else ++curindex;
$('.scrollbutton').removeclass('disabled');
if (curindex == 0) $('.smallimgup').addclass('disabled');
if (curindex == count-1) $('.smallimgdown').addclass('disabled');
$("#imagemenu ul").stop(false, true).animate({"marginleft" : -curindex*interval + "px"}, 600);
});
// 瑙e喅 ie6 select妗� 闂
$.fn.decorateiframe = function(options) {
if ($.browser.msie && $.browser.version < 7) {
var opts = $.extend({}, $.fn.decorateiframe.defaults, options);
$(this).each(function() {
var $mythis = $(this);
//鍒涘缓涓€涓狪frame
var diviframe = $("");
diviframe.attr("id", opts.iframeid);
diviframe.css("position", "absolute");
diviframe.css("display", "none");
diviframe.css("display", "block");
diviframe.css("z-index", opts.iframezindex);
diviframe.css("border");
diviframe.css("top", "0");
diviframe.css("left", "0");
if (opts.width == 0) {
diviframe.css("width", $mythis.width() + parseint($mythis.css("padding")) * 2 + "px");
}
if (opts.height == 0) {
diviframe.css("height", $mythis.height() + parseint($mythis.css("padding")) * 2 + "px");
}
diviframe.css("filter", "mask(color=#fff)");
$mythis.append(diviframe);
});
}
}
$.fn.decorateiframe.defaults = {
iframeid: "decorateiframe1",
iframezindex: -1,
width: 0,
height: 0
}
//鏀惧ぇ闀滆绐�
$("#bigview").decorateiframe();
//鐐瑰嚮鍒颁腑鍥�
var midchangehandler = null;
$("#imagemenu li").bind("click", function(){
if ($(this).attr("id") != "onlickimg") {
midchange($(this).find('img').attr("src").replace("80x80", "420x420"));
$("#imagemenu li").removeattr("id");
$(this).attr("id", "onlickimg");
}
}).bind("mouseover", function(){
if ($(this).attr("id") != "onlickimg") {
window.cleartimeout(midchangehandler);
midchange($(this).find('img').attr("src").replace("80x80", "420x420"));
}
}).bind("mouseout", function(){
if($(this).attr("id") != "onlickimg"){
midchangehandler = window.settimeout(function(){
$("#onlickimg img").attr("src") && midchange($("#onlickimg img").attr("src").replace("80x80", "420x420"));
},100);
}
});
function midchange(src) {
$("#midimg").attr("src", src).load(function() {
changeviewimg();
});
}
//澶ц绐楃湅鍥�
function mouseover(e) {
$imgwidth = $("#midimg").width(); //涓浘瀹藉害
$imgheight = $("#midimg").height(); //涓浘楂樺害
if ($("#winselector").css("display") == "none") {
$("#winselector,#bigview").show();
}
$("#winselector").css(fixedposition(e));
e.stoppropagation();
}
function mouseout(e) {
$imgwidth = $("#midimg").width(); //涓浘瀹藉害
$imgheight = $("#midimg").height(); //涓浘楂樺害
if ($("#winselector").css("display") != "none") {
$("#winselector,#bigview").hide();
}
e.stoppropagation();
}
$("#midimg").mouseover(mouseover); //涓浘浜嬩欢
$("#midimg,#winselector").mousemove(mouseover).mouseout(mouseout); //閫夋嫨鍣ㄤ簨浠�
var $divwidth = $("#winselector").width(); //閫夋嫨鍣ㄥ搴�
var $divheight = $("#winselector").height(); //閫夋嫨鍣ㄩ珮搴�
var $imgwidth = $("#midimg").width(); //涓浘瀹藉害
var $imgheight = $("#midimg").height(); //涓浘楂樺害
var $viewimgwidth = $viewimgheight = $height = null; //ie鍔犺浇鍚庢墠鑳藉緱鍒� 澶у浘瀹藉害 澶у浘楂樺害 澶у浘瑙嗙獥楂樺害
function changeviewimg() {
$("#bigview img").attr("src", $("#midimg").attr("src").replace("420x420", "800x800"));
}
changeviewimg();
$("#bigview").scrollleft(0).scrolltop(0);
function fixedposition(e) {
if (e == null) {
return;
}
var $imgleft = $("#midimg").offset().left; //涓浘宸﹁竟璺�
var $imgtop = $("#midimg").offset().top; //涓浘涓婅竟璺�
var $middivl = $(".bigimg").offset().left; //涓浘宸﹁竟璺�
var $middivt = $(".bigimg").offset().top; //涓浘涓婅竟璺�
x = e.pagex - $imgleft - $divwidth / 2; //selector椤剁偣鍧愭爣 x
y = e.pagey - $imgtop - $divheight / 2; //selector椤剁偣鍧愭爣 y
x = x < 0 ? 0 : x;
y = y < 0 ? 0 : y;
x = x + $divwidth > $imgwidth ? $imgwidth - $divwidth : x;
y = y + $divheight > $imgheight ? $imgheight - $divheight : y;
x = x < 0 ? 0 : x;
y = y < 0 ? 0 : y;
$viewimgwidth = $("#bigview img").outerwidth();
$viewimgheight = $("#bigview img").height();
$height = $divheight * $viewimgheight / $imgheight;
$("#bigview").width($divwidth * $viewimgwidth / $imgwidth);
$("#bigview").height($height);
var scrollx = x * $viewimgwidth / $imgwidth;
var scrolly = y * $viewimgheight / $imgheight;
$("#bigview img").css({ "left": scrollx * -1, "top": scrolly * -1 });
// $("#bigview").css({ "top": 0, "left": $(".preview").offset().left + $(".preview").width() + 15 });
$("#bigview").css({ "top": '30px', "left": '600px'});
return { left:($imgleft-$middivl)+x , top: ($imgtop-$middivt)+y };
}
$(function(){
/*椤烘椂閽堝拰閫嗘椂閽堟棆杞�*/
var num = 0;
$(".input1").click(function(){
num ++;
$(this).parent().parent().find("#image").css("transform",'rotate('+(90*num)+'deg)');
if(num>4){
num=1;
};
$(this).parent().parent().find("#image").css("filter",'progid:dximagetransform.microsoft.basicimage(rotation='+num+')');
if(num%2==0){
$(this).parent().parent().find("#image").removeclass("verimg");
}else{
$(this).parent().parent().find("#image").addclass("verimg");
}
});
$(".input2").click(function(){
num ++;
$(this).parent().parent().find("#image").css("transform",'rotate('+(-90*num)+'deg)');
if(num>4){
num=1;
};
$(this).parent().parent().find("#image").css("filter",'progid:dximagetransform.microsoft.basicimage(rotation='+num+')');
if(num%2==0){
$(this).parent().parent().find("#image").removeclass("verimg");
}else{
$(this).parent().parent().find("#image").addclass("verimg");
}
});
})
//澶у浘鍒囨崲
$(function(){
var bigbox = $(".viewbigimg");
var smallbox = $(".smallbox");
smallbox.find("li").live('click',function(){
$(".jqzoom").find("#image").css("transform",'rotate(0deg)');
$(".jqzoom").find("#image").css("filter",'progid:dximagetransform.microsoft.basicimage(rotation=0)');
$(".jqzoom").find("#image").removeclass("verimg");
var imgaddr = $(this).find("img").attr("bigimg");
var smll_imgaddr= $(this).find("img").attr("src");
$(this).parent().find("a").removeclass("selected");
$(this).find("a").addclass("selected");
$(this).parent().parent().next().find("#image").attr("src",smll_imgaddr);
$(this).parent().parent().next(".viewbigimg").show();
});
});
/*鐐瑰嚮鏀惰捣*/
$(function(){
$(".viewbigimg").find(".shouqi").live('click',function(){
$(".smallbox li").find("a").removeclass("selected");
$(this).parent().parent().hide();
})
$(".viewbigimg").find("#image").live('click',function(){
$(".smallbox li").find("a").removeclass("selected");
$(this).parent().parent().hide();
})
})
});