<div class="oe_words_addto">
  <h2>填写手机号码，领取优惠券</h2>
  <dl>
    <dt><font color="red"></font> 优惠券：</dt>
	<dd><!--{$coupon.title}--></dd>
	<div class="clear"></div>
  </dl>
  <!--{if $coupon.fee > 0}-->
  <dl>
    <dt><font color="red"></font> 价格：</dt>
	<dd><font color="#ff6666">¥<!--{$coupon.fee}--> （需支付才能成功领取）</font></dd>
	<div class="clear"></div>
  </dl>
  <!--{/if}-->
  <dl>
    <dt><font color="red"></font> 所属店铺：</dt>
	<dd><!--{$shop.shopname}--></dd>
	<div class="clear"></div>
  </dl>
  <dl>
    <dt><font color="red">*</font> 手机号码：</dt>
	<dd><input type="text" id="getcoupon_mobile" style="width:200px;" value="<!--{$login.user.mobile}-->" /></dd>
	<div class="clear"></div>
  </dl>
  <dl>
    <dt>&nbsp;</dt>
	<dd><i f="getcoupon_post">确定领取</i>&nbsp;&nbsp;&nbsp;<span id="getcoupon_tips"></span></dd>
	<div class="clear"></div>
  </dl>
</div>
<script type="text/javascript">
$(function(){
	
	$("[f='getcoupon_post']").bind("click", function(){ //提交
		$tips_obj = $("#getcoupon_tips");
		$mobile = $("#getcoupon_mobile").val();
		if ($mobile.length == 0) {
			$tips_obj.html("<font color='red'>请填写手机号码</font>");
			return false;
		}
		if (!isMobile($mobile)) {
			$tips_obj.html("<font color='red'>手机号码格式不正确</font>");
			return false;
		}

		$.ajax({

			type: "POST",
			url: _ROOT_PATH + "index.php",
			cache: false,
			data: {c:"coupon", a:"post", shopid:"<!--{$shopid}-->", id:"<!--{$coupid}-->", mobile:$mobile, r:get_rndnum(8)},
			dataType: "json",
			success: function($data) {
				$json = eval($data);
				$response = $json.response;
				$result = $json.result;

				if ($response == "1") {
					$tips_obj.html("<font color='green'>恭喜你，领取成功</font>");
					setTimeout(function(){
						window.location.reload();
					}, 800);
				}
				else if ($response == "2") {
					window.location.href = _ROOT_PATH+"index.php?c=pay&paynum="+$result;
				}
				else {

					if ($result.length > 0) {
						$tips_obj.html("<font color='red'>"+$result+"</font>");
					}
					else {
						$tips_obj.html("<font color='red'>领取失败</font>");
					}

				}

			},
			error: function() {
				$tips_obj.html("<font color='red'>领取失败，请检查网络！</font>");
			}
		});

	});

});
</script>