Merge branch 'master' of http://app.git.1nww.com:8188/gitlab-instance-db4ab2e7/cxhxy
This commit is contained in:
commit
18a09605e2
@ -174,11 +174,9 @@ class User extends Controller
|
||||
public function wxCode()
|
||||
{
|
||||
$appid = 'wx89c12dd426a55a2e';
|
||||
$app_secret = '33e66bcf944f9810abbb5ddd7825403d';
|
||||
$redirect_uri=$this->request->host().'api/food.user/getWxUserCoupon';
|
||||
$redirect_uri = $this->request->host() . 'api/food.user/wxLogin';
|
||||
$url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=$appid&redirect_uri={$redirect_uri}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
|
||||
|
||||
|
||||
return $this->renderSuccess($url, '成功');
|
||||
}
|
||||
|
||||
|
||||
@ -197,12 +195,15 @@ class User extends Controller
|
||||
$access_token = $result['access_token'];
|
||||
$openid = $result['openid'];
|
||||
|
||||
|
||||
$wx_url = "https://api.weixin.qq.com/sns/userinfo?access_token=$access_token&openid=$openid&lang=zh_CN";
|
||||
$data = json_decode(Http::get($wx_url), true);
|
||||
if (isset($data['headimgurl'])) {
|
||||
Db::name('user_wx')->where(['wx_openid' => $openid])->update(['headimgurl' => $data['headimgurl'], 'nickname' => $data['nickname']]);
|
||||
return $this->renderSuccess($data, '成功');
|
||||
$arr = [
|
||||
'openid' => $openid,
|
||||
'redirect_uri' => 'https://app.cxhxy.dev.1nww.com/#/pages/details/details'
|
||||
];
|
||||
return $this->renderSuccess($arr, '成功');
|
||||
}
|
||||
}
|
||||
return $this->renderError('授权失败');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user