diff --git a/app/api/controller/food/User.php b/app/api/controller/food/User.php index 8b3f37a..bf11e33 100644 --- a/app/api/controller/food/User.php +++ b/app/api/controller/food/User.php @@ -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, '成功'); } @@ -196,13 +194,16 @@ class User extends Controller if (isset($result['access_token'])) { $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('授权失败');