1.下载微信JS-SDK,官方文档https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115
2.后端引入文件,核心代码如下:

require_once APP_PATH."/common/library/wx_share_sdk/jssdk.php";
$pub = config('keys.pubConfig');
$jssdk = new \JSSDK($pub['appid'],$pub['appsecret']);
$signPackage = $jssdk->GetSignPackage();
$this->assign('signPackage',$signPackage);

3.前端代码如下