获取用户信息
global $_W,$_GPC;
//$_W['uniacid'];是我们当前绑定的公众号的ID
$userinfo = mc_oauth_userinfo($_W['uniacid']);
var_dump($userinfo);
自定义分享好友
public function doMobileIndex() {
//这个操作被定义用来呈现 功能封面
global $_W,$_GPC;
$account_api = WeAccount::create();
$jssdk = $account_api->getJssdkConfig();
include $this->template('index');
}
<script>
wx.config({
debug: false,
appId: '{$jssdk['appId']}',
timestamp: '{$jssdk['timestamp']}',
nonceStr: '{$jssdk['nonceStr']}',
signature: '{$jssdk['signature']}',
jsApiList: [
'checkJsApi',
'onMenuShareTimeline',
'onMenuShareAppMessage'
]
});
wx.ready(function () {
var shareData = {
title: '学习吧',
desc: '有好多经常的课程哦',
link: 'https://minbang.bendilaosiji.com/',
imgUrl: "{php echo MODULE_URL;}template/mobile/getheadimg.jpeg",
success: function (res) {
alert('已分享');
},
cancel: function (res) {
}
};
wx.onMenuShareAppMessage({
title: '学习吧',
desc: '好多经常的课程哦',
link: 'https://minbang.bendilaosiji.com/',
imgUrl: "{php echo MODULE_URL;}template/mobile/getheadimg.jpeg",
trigger: function (res) {
// alert('用户点击发送给朋友');
},
success: function (res) {
alert('已分享');
},
cancel: function (res) {
alert('已取消');
},
fail: function (res) {
alert(JSON.stringify(res));
}
});
wx.onMenuShareTimeline(shareData);
});
wx.error(function (res) {
alert("error: " + res.errMsg);
});
</script>