<div class="oevar_m_body" style="display:none;" id="goods_bespoke_box">
  <div class="oevar_m_layout" id="goods_bespoke_box_lay">
    <div class="oevar_m_box" style="width:760px;">
	  
	  <div class="oevar_m_title">
	    <h3>
	      预约商品 <a href="javascript:;" id="goods_closebox"></a>
	    </h3>
	  </div>
	  <div class="oevar_m_cont">
	  
		<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">
			    <em class="oe_bespoke_yh">商品展示</em>
				<span id="goods_title"></span>
			  </div>
			</dt>

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

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

				<li>
				  <input type="hidden" id="goods_id" value="" />
				  <span></span>
				  <i class="_i_btn" id="btn_goods_bespoke">提交预约</i>
				  <i class="_i_tips" id="tips_goods_bespoke"></i>
				</li>
			  </ul>
			</dd>
			<div class="clear"></div>
		  </dl>
		</div>


	  </div>
	  <!--//oevar_m_cont End-->


    </div>
	<!--//oevar_m_box End-->
  </div>
  <!--//oevar_m_layout End-->
</div>
<!--//oevar_m_body End-->

<script type="text/javascript">
$(function(){
	
	$("[f='goodsbespoke']").bind("click", function(){ //弹出预约界面

		$("#goods_bespoke_box").show();
		varPopMarginAuto("goods_bespoke_box_lay");
		$("#goods_id").val($(this).attr("data-id"));
		$("#goods_title").html($(this).attr("data-title"));
	});

	$("#goods_closebox").bind("click", function(){ //关闭窗口
		$("#goods_bespoke_box").hide();
	});

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

	$("#btn_goods_bespoke").bind("click", function(){ //提交预约
		$tips_obj = $("#tips_goods_bespoke");
		
		$goodsid = $("#goods_id").val();
		$contname = $("#goods_contname").val();
		$mobile = $("#goods_mobile").val();
		$words = $("#goods_words").val();
		$checkcode = "";
		if ($goodsid.length == 0) {
			$tips_obj.html("<font color='red'>参数错误</font>");
			return false;
		}
		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 = $("#goods_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:"goods", a:"savebespoke", contname:$contname, mobile:$mobile, words:$words, checkcode:$checkcode, goodsid:$goodsid, 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("");$("#goods_bespoke_box").hide();
					}, 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>