This commit is contained in:
test_service 2023-12-08 15:56:32 +08:00
commit b2db6d7c97

View File

@ -183,10 +183,10 @@ class User extends Controller
public function wxCode() public function wxCode()
{ {
$coupon_id = $this->request->get('id'); $coupon_id = $this->request->get('coupon_id') ?? '';
$appid = 'wx89c12dd426a55a2e'; $appid = 'wx89c12dd426a55a2e';
$redirect_uri = 'https://app.cxhxy.dev.1nww.com/#/pages/details/detail?coupon=' . $coupon_id; $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={$redirect_uri}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect"; $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, '成功'); return $this->renderSuccess($url, '成功');
} }
@ -198,6 +198,8 @@ class User extends Controller
if (empty($get['code'])) { if (empty($get['code'])) {
return $this->renderError('授权失败'); return $this->renderError('授权失败');
} }
$coupon_id = $get['coupon_id'] ?? '';
$appid = 'wx89c12dd426a55a2e'; $appid = 'wx89c12dd426a55a2e';
$app_secret = '33e66bcf944f9810abbb5ddd7825403d'; $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"; $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, 'openid' => $openid,
'redirect_uri' => 'https://app.cxhxy.dev.1nww.com/#/pages/details/details' '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 . '&coupon_id=' . $coupon_id));
return redirect(urlencode('https://app.cxhxy.dev.1nww.com/#/pages/details/details?openid=' . $openid));
} }
} }
return $this->renderError('授权失败'); return $this->renderError('授权失败');