<!VDNDOC "PageBase":"nvo_cookie","IniEvent":"PageIni">
<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Cookie</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<!--标准mui.css-->
		<link rel="stylesheet" href="css/mui.min.css">
		<!--App自定义的css-->
		<link rel="stylesheet" type="text/css" href="css/app.css" />
		<style>
			h5 {
				margin: 5px 7px;
			}
		</style>
	</head>

	<body>
		<!--header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">cookie</h1>
		</header-->
		<div class="mui-content-padded">
			<p style="text-indent: 22px;">cookie是存储在客户端的值.在PB后台可以通过wa_setcookie和wa_getcookie函数进行操作。</p>
			<p style="text-indent: 22px;">
				cookie-1的值是当前有效，当关闭浏览器或者微信后再次打开该值就超时失效.
			</p>
			<p style="text-indent: 22px;">
				cookie-2的值设置超时时间为1天.详见后台代码nvo_cookie.
			</p>
			<p style="text-indent: 22px;">
				存储中文信息时,先使用guo_vdn.base64Encode编码，再保存
			</p>
		</div>
		<div class="mui-content">
			<div class="mui-content-padded" style="margin: 5px;">
				<form id="form1" method="post" class="mui-input-group">
					<div class="mui-input-row">
						<label>Cookie-1</label>
						<input name="t_value_1" id="t_value_1" type="text" class="mui-input-clear" placeholder="请输入Cookie值">
					</div>
					<div class="mui-input-row">
						<label>Cookie-2</label>
						<input name="t_value_2" id="t_value_2" type="text" class="mui-input-clear" placeholder="请输入Cookie值">
					</div>
					<div class="mui-input-row">
						<label>Cookie-3</label>
						<input name="t_value_3" id="t_value_3" type="text" class="mui-input-clear" placeholder="请输入Cookie值">
					</div>
					<div class="mui-button-row">
						<button name="b_set" class="mui-btn mui-btn-primary">保存到Cookie</button>&nbsp;&nbsp;
						<button type="button" id="b_submit" class="mui-btn mui-btn-green">保存(Ajax)</button>&nbsp;&nbsp;
					</div>
					<div class="mui-button-row">
						<button type="button" id="b_get" class="mui-btn mui-btn-royal">前台获取</button>&nbsp;&nbsp;
						<a href="cookie.html" class="mui-btn mui-btn-warning">重新加载</a>&nbsp;&nbsp;
						<a class="mui-btn mui-btn-danger" href="main.html">返回</a>
					</div>
					<script src="js/mui.min.js"></script>
					<script type="text/javascript" src="js/jquery-2.2.3.min.js"></script>
					<script type="text/javascript" src="js/vdn.js"></script>
					<script type="text/javascript" src="js/jquery.cookie.js" ></script>
					<script>
						mui.init();
						//Ajax提交 
						mui("#form1").on('click', '#b_submit', function() {
							vdn.submit("form1", {
									"method": "nvo_cookie.savecookie",
								}, function(data) {
									mui.toast("cookie保存成功(ajax)");
								},
								function(err) {
									alert(err.Message + "(" + err.Code.toString() + ")");
								},
								function() {
									//2019年10月21日 新增验证函数，可以在这里增加验证代码
									//返回true为验证通过，否则返回错误信息，将会触发 function(err)错误函数
									return true;
									//return "验证失败:无效的用户名"
								}
							);
						});
						//前台获取
						mui("#form1").on('click', '#b_get', function() {
							//myCookie_1\myCookie_2这里获取不到，因为后台设置的不允许JS访问，但是myCookie_3可以
							alert("Cookie-3值:"+$.cookie("myCookie_3"));
						});
					</script>
				</form>
			</div>
		</div>
	</body>

</html>