cs.php
<?php
header("Content-type:text/html;charset=utf-8");
error_reporting(0);
$a=$_GET["a"];
$pici=$_GET["pici"];
require_once "jssdk.php";
$jssdk = new JSSDK("你的公众号AppID", "你的公众号AppSecret");
$signPackage = $jssdk->GetSignPackage();
?>
<!DOCTYPE>
<html>
<head>
<meta name="viewport" content="width=320.1,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
<link rel="stylesheet" href="style.css"/>
<script src="http://res.wx.qq.com/open/js/jweixin-1.1.0.js"> </script>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
</head>
<body>
<input type="text" name="" value="<?php echo $pici?>">
<input type="text" name="" value="<?php echo $a?>">
<button class="btn btn_primary" id="scanQRCode1">扫码</button>
<script type="text/javascript">
wx.config({
debug: false,
appId: '<?php echo $signPackage["appId"];?>',
timestamp: '<?php echo $signPackage["timestamp"];?>',
nonceStr: '<?php echo $signPackage["nonceStr"];?>',
signature: '<?php echo $signPackage["signature"];?>',
jsApiList: ['checkJsApi',
'scanQRCode'
]
});
wx.ready(function(){
wx.hideOptionMenu();
document.querySelector('#scanQRCode1').onclick = function () {
wx.scanQRCode({
needResult: 1,
desc: 'scanQRCode desc',
success: function (res) {
str=JSON.stringify(res);
str = str.substr(0, str.indexOf('","e'));
str=str.substring(14);
var pici="<?php echo $pici;?>"
location.href='你的域名+路径/cs.php?pici='+pici+ '&a=' + str;
}
});
};
});
wx.error(function (res) {
alert("调用微信jsapi返回的状态:"+res.errMsg);
});
</script>
</body>
</html>
|