<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
	</head>
	<body>
		<div class="top"></div>
		<div class="center" style="width:300px; margin: 0 auto;">
			<h3 id="movePopuWin">
				<a href="javascript:;" title="关闭" class="message_close"
					id="closePopuWin"></a>
				<span>发送TTS命令</span>
			</h3>
			<div class="popuWinMessage_main">
				<ul>
					<li style="text-align: center;">
						<span id="carOwnerMsg" style="color:red;">&nbsp;</span>
					</li>
				</ul>
				<table width="100%" border="0" style="line-height:25px;table-layout:fixed">
					<tr>
						<td style="width:60px; text-align:center; padding-right: 15px;">
							描&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp述:
						</td>
						<td>
							向车载设备下发消息
						</td>
					</tr>
					<tr>
						<td style="width:60px; text-align:center; padding-right: 15px;">
							提示方式:
						</td>
						<td>
							<span>终端TTS播读</span>
						</td>
					</tr>
					<tr>
						<td style="width:60px; text-align: center; padding-right: 15px;">
							内&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp容:
						</td>
						<td style="align:left;">
							<input id="content_tts" type="text" onfocus="resetWarning();"/>
						</td>
					</tr>
					<tr>
						<td style="width:60px; text-align: center; padding-right: 15px;">
							密&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp码:
						</td>
						<td style="align:left;">
							<input id="tts_pass" type="text" onfocus="resetWarning();">
						</td>
					</tr>
					<tr>
						<td style="width:60px; text-align: right; padding-right: 15px;">
							<input type="button" value="发送" onclick="ttsSend();" style="width: 80px; height: 30px; margin-left: 90px; margin-top: 20px;" />
						</td>
					</tr>
				</table>
			</div>
		</div>
		<input type="hidden" id="terCode" value="<%=request.getParameter("terCode")%>"/>
		<div class="bot"></div>
		<script>
		var pass="";
		var isloadPass = false;
	$(function(){
		//获取TTS命令密码
		$.ajax({
			type : "POST",
			dataType : "json",
			url : "json/driverAction_getCmdPass.action",
			data : {
				"mobileid":105,"mask":7020
			},
			success : function(json){
				console.info(JSON.stringify(json));
				if(json && json.flag){
					isloadPass = true;
					pass = json.data[0].pass;
				}else{
					$("#carOwnerMsg").html(json.msg);
				}
			},
			error:function(){
				$("#carOwnerMsg").html("获取数据异常");
			}
		});
		function isTiYanUser(){
			return $("#userId").val() == "-1000" ? true : false;
		}
	});
	function ttsSend(){
		//console.info(isloadPass);
		if(!isloadPass){
			$("#carOwnerMsg").html("获取命令密码异常,请联系技术支持");
			return;
		}
		var terCode = $("#terCode").val();
		var content = $("#content_tts").val();
		if(content.length==0){
			$("#carOwnerMsg").html("命令内容不能为空");
			return;
		}

		var inpass = $("#tts_pass").val();
		if(inpass!=pass){
			$("#carOwnerMsg").html("密码错误");
			return;
		}
		$.ajax({
			type : "POST",
			dataType : "json",
			url: "json/cmdAction_ttsSend.action",
			data : {
				"content":content,"terCode":terCode,"pass":pass
			},
			success : function(json){
				if(json && json.success){
					isloadPass = true;
					pass = json.data[0].pass;
				}else{
					$("#carOwnerMsg").html(json.msg);
				}
			},
			error:function(){
				$("#carOwnerMsg").html("获取数据异常");
			}
		});
	}
	function resetWarning(){
		$("#carOwnerMsg").html("&nbsp;");
	}
</script>
	</body>
</html>
