<{import file="common.html" title='拼团分享'}>
<link rel="stylesheet" type="text/css" href="<{$__APP__}>public/css/share.css?v=<{$js_version}>"> 
<link rel="stylesheet" type="text/css" href="<{$__APP__}>public/css/goods_sku.css?v=<{$js_version}>"> 
<div class="cnav">
	<a class="back">&nbsp;</a>拼团分享<a href="javascript:;" class="thome">主页</a>
</div>
<{uqcms m="goods_act" c="group_share:share_id=smarty.get.share_id" v="row"}>
<div class="hot_box">
	<div class="goods_box">
		<div class="img"><img src="<{$__IMG__}><{$row.goods.images|img_size:180x0}>"></div>
		<div class="title">
			<div class="ttl"><a href="wap.php?m=goods&a=detail&id=<{$row.goods.id}>"><{$row.goods.title}></a></div>
			<div class="pr">￥<{$row.goods.price}></div>
		</div>		
	</div>
	<{if $row.status == '4'}>
		<div class="tgurl">   
			<div class="info"> 拼团失败 </div> 
		</div>
	<{elseif $row.status == '1'}>
		<div class="tgurl">   
			<div class="info"> 拼团成功 </div> 
		</div>		
	<{elseif $row.status == '0'}>
		<div class="tgurl">   
			<div class="time"><div class="time_box"><div class="djs_box" data-diff="<{$row.next_diff}>"></div></div></div>
			<div class="info"> 还差<{$row.num_cha}>人，人满才算拼单成功</div> 
			<!--推广链接-->
			<div class="link">
				<input type="hidden" id="buy_num" value="1"/>
				<a href="javascript:;" class="down_order">直接下单</a>  
			</div>
		</div> 
	<{/if}> 
	<!--SKU的选择-->
	<div class="buyContainer">
		<div class="sku_show">
			<div class="img"><img src="<{$__IMG__}><{$row.goods.images|img_size:160x160}>"/></div>
			<div class="info"> 
				<div class="pr"><em>¥ </em><span class="value_price"><{$row.goods.price}></span></div> 
				<div class="stock_num"><em>库存：</em><span><{$row.goods.stock}></span></div>
				<div class="ck_val"></div>
				<div class="skuClose">×</div>
			</div>
		</div>
		<!----产品的SKU----->
		<{uqcms m="goods_sku" v="sku" c="get_list:"|cat:$row.goods.id}>
		<{if $sku.list}>
			<div class="sku"> 
				<{foreach item=i from=$sku.list}>			
				<dl>
					<dt><span class="sku_name_key" data-value="<{$i.name}>"><{$i.name}></span></dt>
					<dd> 
						<{foreach item=v from=$i.detail}>									
							<a data-id="<{$v.id}>" title="<{if $v.img_name}><{$v.img_name}><{else}><{$v.name}><{/if}>" href="javascript:;">
								<{if $v.img_url}><img src="<{$__IMG__}><{$v.img_url|img_size:60x60}>" data-img="<{$__IMG__}><{$v.img_url|img_size:160x160}>" width="35"/><{/if}>
								<em><{if $v.img_name}><{$v.img_name}><{else}><{$v.name}><{/if}></em>
							</a>
						<{/foreach}>   
					</dd> 
				</dl>
				<{/foreach}>
			</div> 
			<input type="hidden" autocomplete="off" id="sku_id" data-sku="1" value=""> 
		<{else}> 
			<input type="hidden" autocomplete="off" id="sku_id" data-sku="0" value="<{$sku.id}>">
		<{/if}>
		<div class="buynum">
			<dl>
				<dt><span>数量</span></dt>
				<dd>
					<div class="Gnum"> 
						<span class="lt"><a href="javascript:;" id="minus_button">-</a></span> 
						<input type="text" value="1" id="buy_num" autocomplete="off"/>
						<span class="rt"><a href="javascript:;" id="plus_button" max-num="<{$row.stock}>">+</a></span>
					</div>
				</dd>
			</dl>
		</div>
		<div class="add_sure">
			<a href="javascript:;" class="sure_order" data-type="2">确定</a>
		</div>
	</div>	
	<div class="buyContainerBg"></div> 	
	
	<!--好友列表-->
	<div class="ginfo">	
		<div class="avatar">
			<div class="avatar_bar">
				<{foreach item=i from=$row.user}>
					<div class="avabox">
						<{if $i.uid != '0'}>
							<{if $i.avatar !=''}>
								<a href="javascript:;"><img src="<{$__IMG__}><{$i.avatar|img_size:30x30}>"/></a>
							<{else}>
								<a href="javascript:;"><img src="<{$__PUBLIC__}>images/avatar.png"/></a> 
							<{/if}>
							<i><{if $i.uid == $row.uid}>拼主<{/if}></i>
						<{else}>
							<a href="javascript:;"></a> 
						<{/if}> 
					</div>
				<{/foreach}>
			</div>
		</div>  
		
	</div>
</div>
<{import file="footer.html"}>
<script>
var PUBLIC_PATH	= '<{$__PUBLIC__}>';
var APP_PATH	= '<{$__APP__}>';
var IMG_HOST 	= '<{$__IMG__}>';
<{if $sku.json}> 
var SKU_DATA = <{$sku.json}>;
<{/if}>	
</script>
<script type="text/javascript" src="<{$__APP__}>public/js/cart.js?v=<{$js_version}>"></script>
<script type="text/javascript"> 
countDown('.djs_box'); 
$(function(){
	$(document).on("click", 'a.down_order,a.sure_order', function(e){ 
		post_method = 'group'; 
		sku_id = $('#sku_id').val();  
		buy_num = $("#buy_num").val(); 
		share_id = '<{$smarty.get.share_id}>';
		if(sku_id == '' || sku_id == 'undefind'){ 
			if($(".buyContainerBg").is(':hidden')){ 
				$(".buyContainer").show().css({'bottom':'0'});
				$(".buyContainerBg").show();
			}else{
				$.alert('请选择规格'); 	
			}
		}else{
			$.ajax({
				type:'post',
				url:'index.php?m=ajax&a=check_user_status',
				async:false,
				success:function(result){ 
					data = jQuery.parseJSON(result); 
					if(data.status == '1'){
						$.postPage('wap.php?m=cart&a=settle', {post_method:post_method, sku_id:sku_id, buy_num:buy_num, share_id:share_id}, function(){
							
						}); 
					}else{	// 未登录
						location.href="wap.php?m=member&a=login&returnUrl="+encodeURIComponent(window.location.href);
					}
				} 
			});
		} 
	});
	
}); 
</script>