<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort() + path+"/";
	request.setAttribute("contextPath", basePath);
	
	String redirectUrl= request.getParameter("redirectUrl");
	request.setAttribute("redirectUrl", redirectUrl);
%>
<!DOCTYPE html>
<html lang="en">
<head>
	<base href="<%=basePath%>">
	<meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <title>意向购买</title>
    <script src="<%=basePath %>app/lib/flexible.js"></script>
    <script type="text/javascript" src="<%=basePath %>res/js/jquery.min.js"></script>
    <script type="text/javascript" src="<%=basePath %>res/js/layer/layer.min.js"></script>
    <link rel="stylesheet" href="<%=basePath %>app/lib/flexible.css">
	<link rel="stylesheet" href="<%=basePath %>app/css/basem.css">
	<link rel="stylesheet" href="<%=basePath %>app/css/logome.css">
</head>
<body>
	<div class="titbox blubg">
		<a class="titreturn left" href="javascript:void(0)" onclick="back()"><img src="<%=basePath %>app/img/fanhui16@2x.png" alt=""></a>
		<script type="text/javascript">
		function back(){
			window.history.go(-1);
		}
		</script>
		<h1>意向购买</h1>
	</div>
	<div class="whbg top50">
		<div class="safe">
		<input id="productId" value="${productId }" type="hidden"/>
			<ul>
				<li class="merecli">
					<p class="meaddle left">客户姓名：</p>
					<input class="meaddinpu left" id="customerName" value="${user.name }" type="text" placeholder="（必填）请输入客户姓名">
				</li>
				<li class="merecli">
					<p class="meaddle left">联系电话：</p>
					<input class="meaddinpu left blutxt" id="customerPhone" value="${user.phone }" type="text" placeholder="（必填）请输入客户联系电话">
				</li>
				<li class="merecli">
					<p class="meaddle left">工号：</p>
					<input class="meaddinpu left" type="text" id="jobNumber" readonly="readonly" value="${user.personnelcode }" placeholder="请输入您的工号">
				</li>
				<li class="merecli meaddlila">
					<p class="meaddle left">备注：</p>
					<textarea class="meaddinpu left" name="productIntent" id="productIntent" placeholder="请输入您的意向产品类型/价格/数量等"></textarea>
				</li>
			</ul> 
		</div>
	</div>
	<a class="redbtn" id="tjia" href="javascript:void(0)" onclick="add()">完成</a>
			<script type="text/javascript">
			var tjia = 0;
			function add(){
				if($("#productId").val() == ""){
					layer.msg("未获取到产品信息");
					return false;
				}
				if($("#customerPhone").val() == ""){
					layer.msg("请输入客户手机号");
					return false;
				}
				if($("#customerName").val() == ""){
					layer.msg("请输入客户名称");
					return false;
				}
				/* if($("#jobNumber").val() == ""){
					layer.msg("请输入您的工号");
					return false;
				} */
				if($("#productIntent").val() == ""){
					layer.msg("请输入客户的产品意向");
					return false;
				}
				if(tjia == 1){
					return false;
				}
				tjia = 1; 
				
				$.ajax({
		             type: "POST",
		             url: "<%=basePath%>web/mgmProduct/bnadd.cs",
		             data: {
		            	 productId:$("#productId").val(), 
		            	 customerPhone:$("#customerPhone").val(), 
		            	 jobNumber:$("#jobNumber").val(), 
		            	 productIntent:$("#productIntent").val(), 
		            	 customerName:$("#customerName").val()
		             },
		             dataType: "json",
		             success: function(data){
		                         if(data.ret == 0){
		                        	 layer.msg(data.msg);
		                        	 tjia = 0;
		                         }else if(data.ret == 1){
		                        	 layer.msg("保存成功");
		                        	 window.history.go(-1);
		                         }
		                      }
		         });
			}
			</script>
</body>
</html>