<!--{include file="<!--{$shoptplpath}--><!--{$shop.skin}-->/block_header.tpl"}--> 
<!--{include file="<!--{$shoptplpath}--><!--{$shop.skin}-->/block_top.tpl"}--> 
<script src="<!--{$urlpath}-->tpl/shop/<!--{$shop.skin}-->/js/goodsSlide.js"></script>
<div class="oem_product_top">
  <div class="oem_product_top_left">
    <dl>
      <dt class="oe_goods_drawimg"><img src="<!--{$goods.drawimg}-->" /></dt>
      <dd>
        <div class="oe_goods_preview">
          <div class="oe_goods_premd"> <a class="prev" href="javascript:;"></a> <a class="next" href="javascript:;"></a>
            <div class="thumbnail">
              <ul>
                <li><img src="<!--{$goods.thumbimg}-->" data-img="<!--{$goods.drawimg}-->" /></li>
                <!--{if !empty($goods.gallerylist)}--> 
                <!--{foreach $goods.gallerylist as $val}-->
                <li><img src="<!--{$val.imgthumb}-->" data-img="<!--{$val.imgurl}-->" /></li>
                <!--{/foreach}--> 
                <!--{/if}-->
              </ul>
            </div>
          </div>
          <!--//oe_goods_premd End-->
          <div class="clear"></div>
        </div>
        <!--//oe_goods_preview End--> 
        <script type="text/javascript">
          $(function(){
            oeGoodsSlide();
          });
        </script> 
      </dd>
      <div class="clear"></div>
    </dl>
  </div>
  <div class="oe_product_top_right">
    <h1><!--{$goods.goodsname}--></h1>
    <div class="oe_prd_price"> <span>价&#12288;&#12288;格：</span>
      <label f="goods_price">￥<!--{doubleval($goods.price)}--></label>
      <s>原价：￥<!--{doubleval($goods.oldprice)}--></s> </div>
    <input type="hidden" name="oe_priceid" class="oe_priceid" value="0" f="oe_priceid" />
    <!--{if !empty($goods.pricelist)}-->
    <div class="oe_prd_choice"> <span><!--{$goods.pricename}--></span> 
      <!--{foreach $goods.pricelist as $val}-->
      <label f="oe_pricelist" gid="<!--{$val.priceid}-->" price="<!--{$val.price}-->"><!--{$val.name}--></label>
      <!--{/foreach}--> 
    </div>
    <script type="text/javascript">
        $("[f='oe_pricelist']").live("click",function(){
            $price = $(this).attr('price');
            $gid = $(this).attr('gid');
            $("[f='oe_priceid']").val($gid);
            $("[f='oe_pricelist']").removeClass("current");
            $(this).addClass("current");
            $("[f='goods_price']").html("￥"+$price);
        });
      </script> 
    <!--{/if}-->
    <div class="oe_prd_button">
      <!--{if $goods.onsale==1 && $goods.canbuy == 1 && $goods.flag == 1}-->
      <div class="oe_prd_num">
          <input type="text" class="oe_prd_nm" name="oe_prd_nm" value="1" f="oe_prd_nm" readonly />
        <i class="oe_prd_add" f="oe_update_num" act="+">+</i> <i class="oe_prd_minus" f="oe_update_num" act="-">-</i>
      </div>
      <span class="oe_prd_cart" f="oe_add_cart">加入购物车</span> <span class="oe_prd_buy" f="oe_buy_goods">立即购买</span>
      <form action="<!--{$urlpath}-->index.php?c=cart&a=buygoods" method="post" id="myform" name="myform">
        <input type="hidden" name="goodsid" id="goodsid" value="<!--{$goods.goodsid}-->">
        <input type="hidden" name="shopid" id="shopid" value="<!--{$goods.shopid}-->">
        <input type="hidden" name="priceid" id="priceid" >
        <input type="hidden" name="goodsnum" id="goodsnum" >
      </form>
      <!--{/if}-->
      <!--{if $goods.canbespoke == '1'}--> 
      <br>
      <span class="oe_prd_yy"  f="goodsbespoke" data-id="<!--{$goods.goodsid}-->" data-title="<!--{$goods.goodsname}-->"> 免费预约 </span> <span class="oe_prd_ten"><img src="<!--{$urlpath}-->tpl/shop/<!--{$shop.skin}-->/images/a6.png" /></span> 
      <!--{/if}--> 
    </div>
    <div class="oe_product_nums"> <span class="oe_shop_collect" f="collectgoods" data-id="<!--{$goods.goodsid}-->">收藏宝贝</span>
      <label>已经预约：</label>
      <i><!--{$goods.bespokes}--></i>人 
	  <!--
      <!--{if !empty($goods.score)}--> 
      &#12288;&#12288;
      <label>评分：</label>
      <i><!--{$goods.score}--></i>分 
      <!--{/if}--> 
	  -->
    </div>
  </div>
  <div class="clear"></div>
</div>
<div class="oem_product_detail">
  <h3 class="oe_contenttitle"><span class="current" f="detail">商品详情</span><span f="comment">商品评论</span></h3>
  <div class="oem_product_content"> 
    <!--{$goods.content}--> 
  </div>


  <div class="oe_comment" style="display:none;">
	<input type="hidden" name="page" id="page" value="1" />
	<input type="hidden" name="s_cmscore" id="s_cmscore" value="0" />
    <div class="oe_com_top"> 
      <ul>
        <li>
		  <span f="sel_score" data-val="0" class="_comment_score current">全部</span>
		  <span f="sel_score" data-val="5" class="_comment_score">5星(<!--{$goods.commentscore.score_5}-->)</span>
		  <span f="sel_score" data-val="4" class="_comment_score">4星(<!--{$goods.commentscore.score_4}-->)</span>
		  <span f="sel_score" data-val="3" class="_comment_score">3星(<!--{$goods.commentscore.score_3}-->)</span>
		  <span f="sel_score" data-val="2" class="_comment_score">2星(<!--{$goods.commentscore.score_2}-->)</span>
		  <span f="sel_score" data-val="1" class="_comment_score">1星(<!--{$goods.commentscore.score_1}-->)</span>
		</li>
      </ul>
	  <div class="clear"></div>
    </div>

	<div id="comment_data">
		
	</div>

	<div class="oe_comment_more_page" style="margin-top:10px;display:none;" id="more_btn">
      <span id="but_more_comment">加载更多</span>
    </div>

  </div>
</div>


<script type="text/javascript">
$(function(){
	$("[f='sel_score']").bind("click", function(){
		$_val = $(this).attr("data-val");
		$("#s_cmscore").val($_val);
		$("._comment_score").removeClass("current");
		$(this).addClass("current");
		$("#comment_data").html("");
		$("#more_btn").hide();
		getGoodsCommentList();
	});


	//加载更多数据
	$("#but_more_comment").bind("click", function(){
		$(this).html("加载中...");
		getGoodsCommentList();
	});
	
	getGoodsCommentList();
});

function getGoodsCommentList() {
	$_id = "<!--{$goods.goodsid}-->";
	$_s_cmscore = $("#s_cmscore").val();
	$_page = $("#page").val();
	$.ajax({
		type: "POST",
		url: "<!--{$oefile}-->",
		cache: false,
		data: {c:"goodscomment", a:"list", s_goodsid:$_id, s_cmscore:$_s_cmscore, page:$_page, r:get_rndnum(8)},
		dataType: "json",
		success: function($data) {
			$json = eval($data);
			$response = $json.response;
			$nextpage = $json.nextpage;
			$result = $json.result;
			$("#page").val($nextpage);
			if ($response == 1) {
				if ($result.length > 0) {
					if ($nextpage > 0) {
						$("#more_btn").show();
					}
					else {
						$("#more_btn").hide();
					}
					//加入数据
					if ($_page == "1") {
						$("#comment_data").html($result);
					}
					else {
						$("#comment_data").append($result);
					}
					if ($nextpage > 0) {
						$("#but_more_comment").html("点击加载下一页");
					}
				}
			}
		},
		error: function() {

		}
	});
}

</script>


<script type="text/javascript">
$(function(){
    $('[f="detail"]').click(function(){
        $(".oem_product_content").css("display","block");
        $(".oe_comment").css("display","none");
        $('[f="comment"]').removeClass("current");
        $('[f="detail"]').addClass("current");
    });
    $('[f="comment"]').click(function(){
        $(".oem_product_content").css("display","none");
        $(".oe_comment").css("display","block");
        $('[f="detail"]').removeClass("current");
        $('[f="comment"]').addClass("current");
    });

    $("[f='oe_update_num']").live("click",function(){
        $num = parseInt($("[f='oe_prd_nm']").val());
        if($(this).attr("act")=='+'){
            $("[f='oe_prd_nm']").val($num+1);
        }else{
            if($num>1)
                $("[f='oe_prd_nm']").val($num-1);
        }
    });

    $('[f="oe_buy_goods"]').click(function(){
        <!--{if $login.status == '0'}-->
        oe_varpop_loginbox();
        <!--{/if}-->
        $priceid = $("[f='oe_priceid']").val();
        $goodsnum = $("[f='oe_prd_nm']").val();
        <!--{if !empty($goods.pricelist)}-->
        if($priceid==0){
            ToastShow("请选择好商品属性！");
            return false;
        }
        <!--{/if}-->
        $("#priceid").val($priceid);
        $("#goodsnum").val($goodsnum);
        $("#myform").submit();
    });

    $("[f='oe_add_cart']").live("click",function(){
        <!--{if $login.status == '0'}-->
        oe_varpop_loginbox();
        <!--{/if}-->
        $priceid = $("[f='oe_priceid']").val();
        $goodsid = $("[f='collectgoods']").attr("data-id");
        $goodsnum = $("[f='oe_prd_nm']").val();
        $shopid = <!--{$goods.shopid}-->;
        <!--{if !empty($goods.pricelist)}-->
        if($priceid==0){
            ToastShow("请选择好商品属性！");
            return false;
        }
        <!--{/if}-->
        $.ajax({
            type: "POST",
            url: _ROOT_PATH + "index.php",
            cache: false,
            data: {c:"cart", a:"add", goodsid:$goodsid, priceid:$priceid, shopid:$shopid, nums:$goodsnum},
            dataType: "json",
            success: function($data){
                $json = eval($data);
                $response = $json.response;
                $result = $json.result;
                if ($response == "1") { //成功
                    $("[f='cartgoodsnums']").html($json.nums);
                    ToastShow("添加成功");
                }
                else {
                    if ($result.length > 0) {
                        ToastShow($result)
                    }
                    else {
                        ToastShow("添加失败");
                    }
                }
            },
            error: function(){
                ToastShow("添加失败，请检查网络！");
            }
        });
    });

	$("span[f='collectgoods']").bind("click", function(){ //收藏商品
		<!--{if $login.status == '0'}-->
		oe_varpop_loginbox();
		return false;
		<!--{/if}-->

		$goods_id = $(this).attr("data-id");
		$.ajax({
			type: "POST",
			url: _ROOT_PATH + "index.php",
			cache: false,
			data: {c:"collect", a:"collectgoods", id:$goods_id, r:get_rndnum(8)},
			dataType: "json",
			success: function($data) {
				$json = eval($data);
				$response = $json.response;
				$result = $json.result;
				if ($response == "1") { //成功
					ToastShow("收藏成功");
				}
				else {
					if ($result.length > 0) {
						ToastShow($result)
					}
					else {
						ToastShow("收藏失败");
					}
				}
			},
			error: function() {
				ToastShow("收藏失败，请检查网络！");
			}
		});
	});


});
</script> 
<!--{if $goods.canbespoke == "1"}--> 
<!--{include file="<!--{$shoptplpath}--><!--{$shop.skin}-->/goods_bespoke.tpl"}--> 
<!--{/if}--> 

<!--{include file="<!--{$shoptplpath}--><!--{$shop.skin}-->/block_footer.tpl"}-->