<?php
	session_start();
	if(!isset($_SESSION['admin'])){
		header("location:/page/login.php");
		die();
	}
?>
<?php
include_once("jssdk.php");
include_once("../config.php");
//$appId='wxa9ede96755f3575c';
//$appSecret='f01307340605639e7024c380c4a23273';
$jssdk = new JSSDK($appId, $appSecret);
$sp = $jssdk->GetSignPackage();



?>
<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
		<title>文登税务资产管理系统</title>
		<script src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
		<script src="/lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
<script type="text/javascript">
	wx.config({
		debug: false,
		appId: '<?php echo $sp["appId"];?>',
		timestamp: <?php echo $sp["timestamp"];?>,
		nonceStr: '<?php echo $sp["nonceStr"];?>',
		signature: '<?php echo $sp["signature"];?>',
		jsApiList: [
			'checkJsApi',
			'onMenuShareAppMessage',
			'onMenuShareTimeline',
			'chooseImage',
			'uploadImage',
			'previewImage',
			'scanQRCode'
		]
	});

	wx.ready(function () {
	    /*
		wx.onMenuShareAppMessage({
			title: '拍照识植物',
			desc: '威海市文登区实验中学初二六班  毕琬誉作品', 
			link: 'https://tao.bmki.cn/fanyi/index.php', 
			imgUrl: 'https://tao.bmki.cn/fanyi/fx.jpg',
			type: 'link', 
			dataUrl: '', 
			success: function () {
			}
		});
		wx.onMenuShareTimeline({
			title: '拍照识植物-威海市文登区实验中学初二六班毕琬誉作品',
			link: 'https://tao.bmki.cn/fanyi/index.php',
			imgUrl: 'https://tao.bmki.cn/fanyi/fx.jpg',
			success: function () {
			}
		});
        */
		document.querySelector('#chooseImage').onclick = function () {
			wx.scanQRCode({
			  needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
			  scanType: ["qrCode","barCode"], // 可以指定扫二维码还是一维码，默认二者都有
			  success: function (res) {
				var result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
			    var r=JSON.stringify(res);
				//alert(r);
				result = result.replace("CODE_128,","");
				result = result.replace("CODE_25,","");
				result = result.replace("EAN_13,","");
				result = result.replace("UPC_E,","");
				//alert(result);
				$.post("../action.php",{mode:"wxscancha",code:result},function(res){
					var r = JSON.parse(res);
					if(r.id!=0){
					    window.location.href="/page/editxxzichan.php?id=" + r.id
					}else{
					    document.querySelector('#mdiv').innerText = "无效码";
					}
					//document.querySelector('#mdiv').innerText = res;
			    })
				//document.querySelector('#mdiv').innerText = result;
			  }
			});
		};
  
  

	});

</script>
</head>
<body style="margin:0;padding:0;width:100vw;height:100vh;">
<div style="position:fixed;bottom:0;z-index:9998;width:100%;height:100px;background-color:rgba(200,200,200,0.5);">
	<div style="width:100%;height:80px;">
		<div style="width:calc(50vw - 41px);height:100%;float:left;">
			<div style="width:100%;height:39px;border-bottom:1px solid #555;"></div>
		</div>
		
		<div id="chooseImage" style="text-align:center;width:80px;height:100%;float:left;border:1px solid #555;border-radius:40px;">
			<img src="c.png" width="50px" height="50px" style="margin-top:15px;" />
		</div>
		<div style="width:calc(50vw - 41px);height:100%;float:left;">
			<div style="width:100%;height:39px;border-bottom:1px solid #555;"></div>
		</div>
	</div>
	<div style="position:fixed;bottom:0;z-index:9999;text-align:center;width:100%;font-size:12px;height:20px;line-height:20px;color:#555;">
	国家税务总局威海市文登区税务局 信息中心
	</div>
</div>
<div id="mdiv" style="width:100%;height:calc(100vh - 100px);position:static;">

</div>


</body>
</html>