// 静默登录
wx.login({
success (res) {
uni.request({
url: ts.$tools.path+"/api/jiexi/openid",
method: "post",
data: {
code:res.code
},
success: function (e) {
console.log(e)
}
})
}
})
public function JiexiOpenid () {
$param = $this->request->param();
$code = $param["code"];
$appid = "xxx";
$secret = "xxx";
$res = getCurl("https://api.weixin.qq.com/sns/jscode2session?appid={$appid}&secret={$secret}&js_code={$code}&grant_type=authorization_code");
$openid = $res["openid"];
return $openid;
}