1.获取微信公众号信息
public function getlocation(){$wechatInfo = D('Mp')->find(3);$options = array('token' => $wechatInfo['valid_token'],'encodingaeskey' => $wechatInfo['encodingaeskey'],'appid' => $wechatInfo['appid'],'appsecret' => $wechatInfo['appsecret']);$wechatObj = new Wechat($options);$data = $wechatObj->getJsSign(I('get.url'));$this->ajaxReturn($data);}
2.
//调用微信sdk//<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>function setWechatJSSDK(res){wx.config({debug: false,appId: res.appId,timestamp: res.timestamp,nonceStr: res.nonceStr,signature: res.signature,jsApiList: ['getLocation','scanQRCode']});/*微信扫一扫author:咔咔time:6.11*/$('.getqrcode').click(function(){wx.scanQRCode({needResult: 1,scanType : [ "qrCode"],desc: 'scanQRCode desc',success: function (res) {var id = res.resultStr.split('=')[1];}});})}function loadWechatJSSDK() {$.get("{:U('addon/WeiuidDeit/Mobile/getlocation')}",{url:location.href}, function (res) {setWechatJSSDK(res);});}setTimeout(loadWechatJSSDK, 500);
