This commit is contained in:
尖叫 2023-12-08 15:56:15 +08:00
parent 5e9b69dc0f
commit 3ba907dd6d

View File

@ -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('授权失败');