From 406ce3b673d459a9c04487d781468eaee40033d0 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 11:30:45 +0800 Subject: [PATCH] 1 --- extend/hema/wechat/Index.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/extend/hema/wechat/Index.php b/extend/hema/wechat/Index.php index 2c224e4..e878edc 100644 --- a/extend/hema/wechat/Index.php +++ b/extend/hema/wechat/Index.php @@ -66,8 +66,8 @@ class Index $wx_url = 'https://api.weixin.qq.com/cgi-bin/user/info?access_token=' . $access_token . '&openid=' . $openid . '&lang=zh_CN'; $info = Http::get($wx_url); - $info=json_decode($info,true); - + $info = json_decode($info, true); + $unionid = $info['unionid']; @@ -101,17 +101,19 @@ class Index Db::name('food_coupon_user_wx')->insert($data1); Db::name('food_coupon_user_wx')->insert($data2); Db::commit(); - + } catch (\Exception $e) { Db::rollback(); write_log(json_encode($e->getMessage()), __DIR__); } } - - - + $appid='wx89c12dd426a55a2e'; + $wx_redirect_uri = 'https://app.cxhxy.dev.1nww.com/api/food.user/wxLogin'; + $redirect_uri = "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"; + + //发送公众号消息 $url = 'https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=' . $access_token; $queryarr = [ @@ -122,7 +124,7 @@ class Index [ 'title' => '您有一张新的优惠券,请及时领取', 'description' => '黄辛一新人优惠,首次关注赠送优惠券', - 'url' => 'https://www.baidu.com', + 'url' => $redirect_uri, 'picurl' => 'https://www.baidu.com', ] ]