<!--{include file="<!--{$shoptplpath}--><!--{$shop.skin}-->/block_header.tpl"}-->
<style>
body {background:#fff;}
</style>
<div class="oe_bespoke">
  <dl>
	<dt>
	  <div class="_shop_logo">
		<em>以下商家将收到你的预约信息 </em>
		<span><img src="<!--{$shop.logourl}-->" /></span>
	  </div>
	  <div class="_shop_logo_right">
		<span><!--{$shop.shopname}--></span> 
		地址：
		  <!--{area type="text" value=$shop.area1}--> <!--{area type="text" value=$shop.area2}-->
		  <!--{area type="text" value=$shop.area3}--> <!--{area type="text" value=$shop.area4}-->
		  <!--{$shop.address}-->
	  </div>
	  <div class="clear"></div>
	  
	  <div class="_shop_logo_dec">
	  </div>
	</dt>

	<dd>
	  <h4>填写预约信息</h4>
	  <ul>
		<li>
		  <span><font color="red">*</font> 联 系 人：</span>
		  <input type="text" id="shop_contname" value="<!--{$login.user.realname}-->" />
		</li>
		<li>
		  <span><font color="red">*</font> 手机号码：</span>
		  <input type="text" id="shop_mobile" value="<!--{$login.user.mobile}-->" />
		</li>
		<li>
		  <span>预约留言：</span>
		  <textarea id="shop_words"></textarea>
		</li>

		<!--{if $config.bespokecode == '1'}-->
		<li>
		  <span>验证码：</span>
		  <input class="checkcode" type="text" id="shop_checkcode" />
		  <img style="cursor:pointer;" title="点击换一个" id="shop_img_checkcode" src="<!--{$urlpath}-->source/include/imagecode.php?act=verifycode" />
		</li>
		<!--{/if}-->

		<li>
		  <input type="hidden" id="shop_id" value="<!--{$shop.shopid}-->" />
		  <span></span>
		  <i class="_i_btn" id="btn_shop_bespoke">提交预约</i>
		  <i class="_i_tips" id="tips_shop_bespoke"></i>
		</li>
	  </ul>
	</dd>
	<div class="clear"></div>
  </dl>
</div>

</body>
</html>

<script type="text/javascript">
$(function(){

	<!--{if $config.bespokecode == '1'}-->
	$("#shop_img_checkcode").bind("click", function(){
		$(this).attr("src", _ROOT_PATH+"source/include/imagecode.php?act=verifycode&"+Math.random());
	});
	<!--{/if}-->

	$("#btn_shop_bespoke").bind("click", function(){ //提交预约
		$tips_obj = $("#tips_shop_bespoke");

		$contname = $("#shop_contname").val();
		$mobile = $("#shop_mobile").val();
		$words = $("#shop_words").val();
		$checkcode = "";
		if ($contname.length == 0) {
			$tips_obj.html("<font color='red'>请填写联系人</font>");
			return false;
		}
		if ($mobile.length == 0) {
			$tips_obj.html("<font color='red'>请填写手机号码</font>");
			return false;
		}
		else {
			if (!isMobile($mobile)) {
				$tips_obj.html("<font color='red'>手机号码格式不正确</font>");
				return false;
			}
		}
		<!--{if $config.bespokecode == '1'}-->
		$checkcode = $("#shop_checkcode").val();
		if ($checkcode.length == 0) {
			$tips_obj.html("<font color='red'>请输入验证码</font>");
			return false;
		}
		<!--{/if}-->

		$.ajax({
			type: "POST",
			url: _ROOT_PATH + "index.php",
			cache: false,
			data: {c:"bespoke", a:"bespokeshop", contname:$contname, mobile:$mobile, words:$words, checkcode:$checkcode, shopid:"<!--{$shop.shopid}-->", 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(){
						$tips_obj.html("");parent.location.reload();
					}, 1000);
				}
				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>