前端:
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
wx.config({
appId: '<{$signPackage_xw.appId}>',
timestamp: <{$signPackage_xw.timestamp}>,
nonceStr: '<{$signPackage_xw.nonceStr}>',
signature: '<{$signPackage_xw.signature}>',
jsApiList: [
'scanQRCode',
'closeWindow',
]
});
function scanQRCode0() {
wx.scanQRCode({
needResult: 1,
desc: 'scanQRCode desc',
success: function (res) {
var result = res.resultStr;
window.location.href= result;
}
});
};
wx.error(function (res) {
alert(res.errMsg);
});
</script>
后端:
//文章微信分享 2017/10/17 start
$AppID = "************";
$AppSecret = "**************";
$jssdk = new JSSDK("$AppID", "$AppSecret");
$signPackage = $jssdk->GetSignPackage();
//将或得的结果数据返回给前端
$this->pagedata['signPackage_xw'] = $signPackage;
//文章微信分享 2017/10/17 end