From 3ba907dd6dd141c7d40d49cddb8263cb99786396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=96=E5=8F=AB?= <392494244@qq.com> Date: Fri, 8 Dec 2023 15:56:15 +0800 Subject: [PATCH] 1 --- app/api/controller/food/User.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/api/controller/food/User.php b/app/api/controller/food/User.php index 6901cf5..b77924c 100644 --- a/app/api/controller/food/User.php +++ b/app/api/controller/food/User.php @@ -183,10 +183,10 @@ class User extends Controller public function wxCode() { - $coupon_id = $this->request->get('id'); + $coupon_id = $this->request->get('coupon_id') ?? ''; $appid = 'wx89c12dd426a55a2e'; - $redirect_uri = 'https://app.cxhxy.dev.1nww.com/#/pages/details/detail?coupon=' . $coupon_id; - $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"; + $wx_redirect_uri = 'https://app.cxhxy.dev.1nww.com/api/food.user/wxLogin?coupon_id=' . $coupon_id; + $url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=$appid&redirect_uri={$wx_redirect_uri}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect"; return $this->renderSuccess($url, '成功'); } @@ -198,6 +198,8 @@ class User extends Controller if (empty($get['code'])) { return $this->renderError('授权失败'); } + $coupon_id = $get['coupon_id'] ?? ''; + $appid = 'wx89c12dd426a55a2e'; $app_secret = '33e66bcf944f9810abbb5ddd7825403d'; $url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=$appid&secret=$app_secret&code={$get['code']}&grant_type=authorization_code"; @@ -214,8 +216,7 @@ class User extends Controller 'openid' => $openid, 'redirect_uri' => 'https://app.cxhxy.dev.1nww.com/#/pages/details/details' ]; - - return redirect(urlencode('https://app.cxhxy.dev.1nww.com/#/pages/details/details?openid=' . $openid)); + return redirect(urlencode('https://app.cxhxy.dev.1nww.com/#/pages/details/details?openid=' . $openid . '&coupon_id=' . $coupon_id)); } } return $this->renderError('授权失败');