<php>$JSARR[]=THEME_PATH."common/js/get_cloud_store.js";</php>
<php>$CSSARR[]=$TEMPLATE_PATH."common/css/store_index.css"</php>
<php>$CSSARR[]=THEME_PATH."common/css/group.css";</php>
<php>$CSSARR[]=THEME_PATH."common/css/goods_sevice.css";</php>
<hc:loadcssjs type="map"/>
<script type="text/javascript">var queryurl = APP+"Mobile/Goods/get_goods_list";</script>
<script src="{$Think.TPL_PATH}common/js/indexmap.js"></script>
<script src="{$Think.TPL_PATH}common/js/sign.js"></script>
<script type="text/javascript">
$(document).ready(function() {
        $("#owl-demo").owlCarousel({
            autoPlay: 3000,
            navigation : true,
            slideSpeed : 300,
            paginationSpeed : 400,
            singleItem : true
        });
    });
	// 领取卡券
	wx.config({
		debug: false,
		appId: '<?php echo $getSignPackage["appId"];?>',
		timestamp: '<?php echo $getSignPackage["timestamp"];?>',
		signature: '<?php echo $getSignPackage["signature"];?>',
		nonceStr: '<?php echo $getSignPackage["nonceStr"];?>',
		jsApiList: [
		  // 所有要调用的 API 都要加到这个列表中
		  'addCard',
		]
	});

	function showind_wx(id){
		var query = new Object();
		query.id = id;
		$.ajax({
			type:'GET',
			url: APP+"Mobile/Index/get_coupons_wx.html",
			data:query,
			success:function(data){
				if(data.status == 0){
					window.location.href = data.url;
				}
				if(data.wx == 1){
					wx.addCard({
					    cardList: [
					    {
					        cardId : data.cardId,
					        cardExt: '{"timestamp":"'+data.cardExt.timestamp+'","signature":"'+data.cardExt.signature+'","code":"'+data.cardExt.code+'","nonce_str":"'+data.cardExt.nonce_str+'"}'
					    }
					    ], // 需要添加的卡券列表
					    success: function (res) {
					        // alert('已添加卡券：' + JSON.stringify(res.errMsg)); // 添加的卡券列表信息
					        if(res.errMsg == 'addCard:ok'){
					        	showind(id,data.cardExt.code)
					        }
					    }
					});
				}else{
					showind(id)
				}
			}
		});	
	}

	function showind(id,code){
		hidewind();
		var obj = '#sub_'+id;
		if($(obj).hasClass('submitting_'+id)){return;}
		$(obj).addClass('submitting_'+id);
		var num = $(obj).val();
		var query = new Object();
		query.id = id;
		if(code){
			query.code = code;
		}
		$.ajax({
			type:'GET',
			url: APP+"Mobile/Index/get_coupons.html",
			data:query,
			success:function(data){
				if(data.status == 1){
					$('#get_coupons_'+id).html(
						"<div class='wm_yhq yel'><a href='{:U('collection/get_coupons')}' class='clearfix'><div class='wm_yhq_yel'><p>已领取</p><span>去使用</span></div></div>"
					);
				}else if(data.status == 0){
					window.location.href = data.url;
				}else if(data.status == 2){
					$.showSuccess(data.msg,3,'hc');
				}
			}
		});		
		$(obj).removeClass('submitting_'+id);
	}
	function xswind(){
		$(".mask").hide();
		$("#weilq").hide();	
	}
	function lqwind(id){
		var query = new Object();
		query.id = id;
		$.ajax({
			type:'GET',
			url: APP+"Mobile/Index/employ.html",
			data:query,
			success:function(data){
				if(data.status == 0){
					$.showSuccess(data.msg,3,'hc');
				}else if(data.status == 1){
					$('#description').html(data.data.description);
					$('#notice').html(data.data.notice);
					if(data.data.type == 1){
						$('#type').html(data.data.begin_timestamp+'-'+data.data.end_timestamp+'&nbsp;周一至周日');					
					}else{
						$('#type').html("领取后"+data.data.fixed_term+"天后生效,有效期"+data.data.fixed_begin_term+"天");	
					}
					if(data.data.coupons_get == 1){
						$(".wintop").html(
							"<h2>"+data.data.title+"</h2><p>请到店后使用</p><a id='yilq' href='#'>已领取</a>"
						);
					}else{
						$(".wintop").html(
							"<h2>"+data.data.title+"</h2><p>请到店后使用</p><a href='#'><span onClick='showind_wx("+id+")'>立即领取<span/></a>"
						);
					}
					
				$(".mask").show();
				$("#lingqu").show();
				}
			}
		});	
	}
	function hidewind(){
		$("#back").hide();
		$("#lingqu").hide();	
	}
	function closed(){
		$("#back").hide();
		$("#lingqu").hide();
		$("#weilq").hide();	
	}
</script>
<include file="Public/common_header" />
<div class="page-group">
	<div class="page page-current">
		<!--头部-->
		<!--<include file="Public/index_header" />-->
		<header class="bar bar-nav">
			<a class="iconfont f_r" href="{:geturl('Search/index')}">&#xe65c;</a>
			<h1 class="title" onclick="window.location.href='{:geturl('ShopsTakeout/change_geo',array('type'=>3))}'">送至：{$temp_name}</h1>
		</header>
		<div class="content">
			<!--轮播图-->
			<div id="banner">
			  <div id="demo">
				<div class="containers">
				  <div class="row">
					<div class="span12">
					  <div id="owl-demo" class="owl-carousel">
						  {:showads(13)}
					  </div>
					</div>
				  </div>
				</div>
			  </div>
			</div>
			<!--导航-->
			<div class="index_nav">
				<ul class="clearfix">
					<volist name="navlist" id="vo">
                          <li>
                              <a href="{:geturl($vo['url'])}" title="{$vo.name}">
                                  <img src="{$vo.icon|format_url}" alt="{$vo.name}"/>
                                  <p>{$vo.name}</p>
                              </a>
                          </li>
                     </volist>
				</ul>
			</div>
			<!--广告位-->
			<div class="advice mt10">
				<div class="adg">
					<div class="one">
						{:showads(14)}
					</div>
					<div class="two">
						<p class="clearfix">
							{:showads(15)}
						</p>
						<p  class="clearfix">
							{:showads(59)}
						</p>
					</div>
				</div>
			</div>
			<!-- 广告位下面长图 -->
			<div>
				{:showads(16)}
			</div>
			<!-- 代金券 -->
			<div class="comments bg_write mt10 qqqq">
				<div class="Tobox">
					<div class="Totle">
						<span>线下卡券</span>
					</div>
				</div>
				<div class="wm_merchant_lqlist" id="guessList">
					<volist name="coupons_list" id="vo" offset="0" length='4'>
						<dl>
							<dt><img src="{$vo.logo_url|thumb=76,78}"></dt>
							<dd>
								<div class="q_price" onClick="lqwind({$vo.id})" id="sub_{$vo.id}">
									<h4 class="color_qt font_wr"><span class="f_20 f_weight"></span>
										<eq name="vo.rank_id" value="GENERAL_COUPON">优惠券</eq>
										<eq name="vo.rank_id" value="DISCOUNT">折扣券</eq>
										<eq name="vo.rank_id" value="GIFT">礼品券</eq>
										<eq name="vo.rank_id" value="CASH">代金券</eq>
										<eq name="vo.rank_id" value="GROUPON">团购券</eq>
									</h4>
									<p class="mercant_introduce">{$vo.notice}</p>
									<if condition="$vo['type'] eq 1">
										<span class="riqi">
											{$vo['begin_timestamp']|time_format='Y-m-d'}~{$vo['end_timestamp']|time_format='Y-m-d'}
										</span>
									<else/>
										<span class="riqi">领取后{$vo.fixed_term}天后生效,有效期{$vo.fixed_begin_term}天</span>
									</if>
								</div>
								<span id="get_coupons_{$vo.id}">
									<if condition="$vo['coupons_get'] eq 0">
										<div class="wm_yhq" onClick="showind_wx({$vo.id})">
											<div class="wm_yhq_red"><span>免费领取</span></div>
										</div>
									<else/>
										<div class="wm_yhq yel">
										<a href="{:U('collection/get_coupons')}" class="clearfix">
											<div class="wm_yhq_yel"><p>已领取</p><span>去使用</span></div>
										</a>
										</div>
									</if>
								</span>
							</dd>
						</dl>
					</volist>
				</div>
				<section id="lingqu" class="winbox" >
					<div class="gbwid" onClick="hidewind()">X</div>
					<div class="wintop">
						<h2>必胜客</h2>
						<p>请到店后使用</p>
						<a id="yilq" href="#">已领取</a>
					</div>
					<p>
						<label>使用门店：</label>
						<span>必胜客</span>
					</p>	
					<p>
						<label>使用提醒 ：</label>
						<span id="notice"></span>
					</p>	
					<p>
						<label>使用说明：</label>
						<span id="description"></span>
					</p>
					<p>
						<label>可用时间：</label>
						<span id="type"></span>
					</p>		
				</section>
				<!--遮罩-->
				<div id="back" class="mask"></div>
				<div class="load_mores"><a href="{:U('Index/kaquan')}">加载更多</a></div>
			</div>
		<include file="Public/footer" />
	</div>
	<input type="hidden" id="loc" value="{$location}">
</div>
</body>
</html>
