<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@ page isELIgnored="false" %>
<%@page import="com.sino.rrs.entity.RcRescueVehiclePO"%>
<html>
<head>
<meta charset="utf-8">
<title>个人信息</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="format-detection" content="email=no">
<link rel="stylesheet" href="/SinoGYS/css/salesManInfo.css" type="text/css"></link>
<link rel="stylesheet" href="/SinoGYS/weixincss/weui.min.css">
<link rel="stylesheet" href="/SinoGYS/weixincss/jquery-weui.css">
<link rel="stylesheet" href="/SinoGYS/css/newCss/reset.css" />
<link rel="stylesheet" href="/SinoGYS/css/newCss/option.css" />
<link rel="stylesheet" href="/SinoGYS/css/newCss/myInfo.css" />
<script src="/SinoGYS/js/jquery-1.7.2.js" type="text/javascript"></script>
<script src="/SinoGYS/js/jquery-weui.js"></script>

 <script type="text/javascript">
        var ohtml=document.documentElement;
        function getWidth(){
            var screenWidth=ohtml.clientWidth;
            if(screenWidth<320){
                ohtml.style.fontSize="13.3333px";
            }else if(screenWidth>1080){
                ohtml.style.fontSize="45px";
            }else{
                ohtml.style.fontSize=screenWidth/(1080/45)+"px";
            }
        }
        getWidth();
        window.onresize=function(){
            getWidth();
        };
    </script>
</head>

<%
	String weixinUserId=request.getParameter("weixinUserId");
	String openId=request.getParameter("openId");
	String acceptFlag=request.getParameter("flag"); %>

<body>
	<input type="hidden" id="rescueCode" name="rescueCode" value="${vehicleInfo.comapny_login_name}">
	<input type="hidden" id="id" name="id" value="${vehicleInfo.id}">
	<div class="infoWrapper">
  		<ul class="myInfo">
  			<li>
  				司机姓名
  				<div class="rightInfo">
  					<a href="#" class="infoItem">${vehicleInfo.staff_name }</a>
  				</div>
  			</li>
  			<li>
  				手机号码
  				<div class="rightInfo">
	  				<a href="/SinoGYS/supplier/updatePhone.jsp?phone=${vehicleInfo.staff_phone }&id=${vehicleInfo.id }" class="infoItem">${vehicleInfo.staff_phone }</a>
	  				<a class="arrowPosition">
						<img class="arrow" src="/SinoGYS/images/newImage/arrow.png" alt="">
					</a>
  				</div>
  				
  			</li>
  			<li class="selectCar">
  				车辆名称
  				<div class="rightInfo">
	  				<a href="#" class="infoItem vehicle_name">${vehicleInfo.vehicle_name }</a>
	  				<a class="arrowPosition">
						<img class="arrow" src="/SinoGYS/images/newImage/arrow.png" alt="">
					</a>
  				</div>
  				
  			</li>
  			<li>
  				接受通知
  				<%if(Integer.parseInt(acceptFlag)==0){ %>
				        <div class="rightInfo">
				          <input class="weui_switch" style='margin-top:0.7rem' type="checkbox" onclick="checkbox(this,'${vehicleInfo.staff_name}')" checked>
				        </div>
				<%}else{ %>
				        <div class="rightInfo">
				          <input class="weui_switch" style='margin-top:0.7rem' type="checkbox" onclick="checkbox(this,'${vehicleInfo.staff_name}')">
				        </div>
				<%} %>
  			</li>
  		</ul>
  		
  		<div class="inputWrapper" onclick="modifyIdentity('<%=weixinUserId%>')">
  			<input class="loginFormSubmit loginBtnActive" type="button" value="退       出">
  		</div>	
  	</div>
  	
  	<div class="optionDialog" style="display: none;">
    	<div class="dialog_con dialog">
    		<p class="dialogTitle">请选择车辆</p>
    		<ul class="dialogList">
    			<!-- <label for="mobike">
	    			<li class="carType_list">
	    				车辆1 
		            	<div class="check-item carType check-item-bg">
		        			<input id="mobike" type="radio" name="type" value="车辆1">
		        		</div>
	    			</li>
    			</label> -->
    		</ul>
    		<div class="buttonWrap clearfix">
    			<a href="#" class="cancelBtn hideBtn">取&nbsp;&nbsp;&nbsp;&nbsp;消</a>
    			<a href="#" class="confirmBtn hideBtn">确&nbsp;&nbsp;&nbsp;&nbsp;认</a>
    		</div>
    	</div>
    </div>
    
</body>

<script type="text/javascript">
	function checkbox(o,staffName){
			if(o.checked){
				//被选中，打开(接受通知，可以收到模板消息)
				$.getJSON("/SinoGYS/CompanyOrVehicleNoticeAction.do?CMD=updateVehicleNotice",{acceptFlag:0,staffName:staffName});  //更改状态为0
			}else{
				//关闭(不接受模板消息)
				$.getJSON("/SinoGYS/CompanyOrVehicleNoticeAction.do?CMD=updateVehicleNotice",{acceptFlag:1,staffName:staffName});  //更改状态为1
			}
		}
		
		function modifyIdentity(weixinUserId){
		$.confirm("您确定要退出当前用户吗？",function(){
			$.getJSON("/SinoGYS/RescueVehicleAction.do?CMD=modifyIdentity",{weixinUserId:weixinUserId},function(data){
  				if(data.code==false){    //司机退出
  					window.location.href="/SinoGYS/supplier/userRegister.jsp?weixinUserId="+weixinUserId;
  				}
  												
		 	});  					 
  			},function(){
  				//取消操作
  		 });
	}

		function chooseVehicle(){
			$.getJSON("/SinoGYS/RescueVehicleAction.do?CMD=queryRescueVehicle",
						{rescueCode : $("#rescueCode").val()},
						function(datas) {
							var list = datas.vehicleList;
							if(list!=null&&list.length>0){
								for ( var i in list) {
								console.log(list[i].ID);
								$(".dialogList").append(
									'<label for="mobike"><li class="carType_list" vehicle_name="'+list[i].NAME+'">'+list[i].NAME+
									'<div class="check-item carType check-item-bg"><input id="mobike" type="radio" name="type" value="'+list[i].ID+'">'+
									'</div></li></label>');
								}
							}else{
								alert("该服务商没添加车辆");
								return;
							}
						});
						return true;
		}
				
		// 单选
    	$(document).on("click",".carType_list",function(){
    		$('.carType_list').find("div.check-item").removeClass('check-item-bg2').addClass('check-item-bg');
			$(this).find("div.check-item").removeClass('check-item-bg').addClass('check-item-bg2');
		});
		
    	// 选择车辆  点击事件
    	$(".selectCar").click(function(){
    		if(chooseVehicle()){
    			setTimeout('$(".optionDialog").show()',300);
    		}else{
    			alert("该服务商没添加车辆");
    		}
    	});
    	
    	// 取消点击事件
    	$(".cancelBtn").click(function(){
    		$(".optionDialog").hide();
    	});
    	
    	//确认按钮
		$(".confirmBtn").click(function(){
			//判断选择的车辆是否被绑定
			$.getJSON("/SinoGYS/RescueVehicleAction.do?CMD=choosedVehicleName",
			{vehicleID:$(".check-item-bg2").children().val()}, function(data){
				if(data.code>0){  //被选择过
					alert("该车辆已被绑定，请重新选择！");	
				}else{
					$.getJSON("/SinoGYS/RescueVehicleAction.do?CMD=updateVehicle",{id : $("#id").val() ,vehicleID:$(".check-item-bg2").children().val(),vehicle_name:$(".check-item-bg2").parent().attr("vehicle_name")},function(data) {
						if(data.code==true)	{
							alert("车辆信息修改成功");
							$(".vehicle_name").text($(".check-item-bg2").parent().attr("vehicle_name"));
							$(".optionDialog").hide();
						}					
					});
				}
			});
    	});
</script>
</html>

