|
@@ -47,20 +47,6 @@ class WechatOfficialController extends HttpBaseController
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public function index3()
|
|
|
|
- {
|
|
|
|
- $this->app->template_message->send([
|
|
|
|
- 'touser' => 'oML8X6YkbviDESdya_RCfgdmUtSQ',
|
|
|
|
- 'template_id' => 'demGYbEZInVgvwO1ClJNuz2Hc-0FYWZp_duv7HSgdmw',
|
|
|
|
- 'url' => 'https://easywechat.com',
|
|
|
|
- 'data' => [
|
|
|
|
- 'thing2' => '黄先生(1002)',
|
|
|
|
- 'thing3' => '湖南友投CMIDERP',
|
|
|
|
- 'time6' => '2024-02-21 9:58:23'
|
|
|
|
- ]
|
|
|
|
- ]);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
public function index2()
|
|
public function index2()
|
|
{
|
|
{
|
|
$this->app->server->push(function ($message) {
|
|
$this->app->server->push(function ($message) {
|
|
@@ -195,11 +181,16 @@ class WechatOfficialController extends HttpBaseController
|
|
}
|
|
}
|
|
|
|
|
|
if ($isSuccess) {
|
|
if ($isSuccess) {
|
|
|
|
+ $oauthUrl = 'https://www.xingyousoft.com';
|
|
|
|
+ if ($sceneStr) {
|
|
|
|
+ $oauthUrl = $this->app->oauth->withState(base64_encode($sceneStr))->redirect();
|
|
|
|
+ }
|
|
|
|
+
|
|
// 发送登录成功消息
|
|
// 发送登录成功消息
|
|
$this->app->template_message->send([
|
|
$this->app->template_message->send([
|
|
'touser' => $openid,
|
|
'touser' => $openid,
|
|
'template_id' => 'demGYbEZInVgvwO1ClJNuz2Hc-0FYWZp_duv7HSgdmw',
|
|
'template_id' => 'demGYbEZInVgvwO1ClJNuz2Hc-0FYWZp_duv7HSgdmw',
|
|
- 'url' => 'https://www.xingyousoft.com',
|
|
|
|
|
|
+ 'url' => $oauthUrl,
|
|
'data' => [
|
|
'data' => [
|
|
'thing2' => $nickname,
|
|
'thing2' => $nickname,
|
|
'thing3' => $productTitle,
|
|
'thing3' => $productTitle,
|
|
@@ -228,7 +219,7 @@ class WechatOfficialController extends HttpBaseController
|
|
case 'subscribe': // 1. 用户未关注时,进行关注后的事件推送
|
|
case 'subscribe': // 1. 用户未关注时,进行关注后的事件推送
|
|
case 'SCAN': // 2. 用户已关注时的事件推送
|
|
case 'SCAN': // 2. 用户已关注时的事件推送
|
|
if (empty($sceneStr)) {
|
|
if (empty($sceneStr)) {
|
|
- return "欢迎你关注助友办公软件";
|
|
|
|
|
|
+ return "欢迎你关注办公软件";
|
|
} else {
|
|
} else {
|
|
$oauthUrl = $this->app->oauth->withState(base64_encode($sceneStr))->redirect();
|
|
$oauthUrl = $this->app->oauth->withState(base64_encode($sceneStr))->redirect();
|
|
//$oauthUrl = str_replace('https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx1edb103f32029099&redirect_uri=https%3A%2F%2Fwww.xingyousoft.com%2Fapi%2Fwechat%2FoauthCallback&response_type=code&scope=snsapi_userinfo&state=WHdCeXhSMW5vUHgzOjUyNDEzYTY3MWVjNzAzNDc4M2FhMWEzMDMyNmRlMjNk&connect_redirect=1#wechat_redirect', '', $oauthUrl);
|
|
//$oauthUrl = str_replace('https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx1edb103f32029099&redirect_uri=https%3A%2F%2Fwww.xingyousoft.com%2Fapi%2Fwechat%2FoauthCallback&response_type=code&scope=snsapi_userinfo&state=WHdCeXhSMW5vUHgzOjUyNDEzYTY3MWVjNzAzNDc4M2FhMWEzMDMyNmRlMjNk&connect_redirect=1#wechat_redirect', '', $oauthUrl);
|
|
@@ -387,13 +378,14 @@ class WechatOfficialController extends HttpBaseController
|
|
} else {
|
|
} else {
|
|
// 插入数据
|
|
// 插入数据
|
|
$isSuccess = DB::transaction(function () use ($openid, $nickname, $avatar, $unionid, $wxInfo) {
|
|
$isSuccess = DB::transaction(function () use ($openid, $nickname, $avatar, $unionid, $wxInfo) {
|
|
|
|
+ $mid = Str::random(12);
|
|
$userData = [
|
|
$userData = [
|
|
'username' => $nickname,
|
|
'username' => $nickname,
|
|
'avatar' => $avatar,
|
|
'avatar' => $avatar,
|
|
'roles' => json_encode([1]),
|
|
'roles' => json_encode([1]),
|
|
'unionid' => $unionid,
|
|
'unionid' => $unionid,
|
|
'status' => 1,
|
|
'status' => 1,
|
|
- 'mid' => Str::random(12),
|
|
|
|
|
|
+ 'mid' => $mid,
|
|
'created_at' => time(),
|
|
'created_at' => time(),
|
|
'updated_at' => time(),
|
|
'updated_at' => time(),
|
|
];
|
|
];
|
|
@@ -406,7 +398,7 @@ class WechatOfficialController extends HttpBaseController
|
|
'nick' => $nickname,
|
|
'nick' => $nickname,
|
|
'wx_avatar' => $avatar,
|
|
'wx_avatar' => $avatar,
|
|
'wx_info' => json_encode($wxInfo),
|
|
'wx_info' => json_encode($wxInfo),
|
|
- 'mid' => Str::random(12),
|
|
|
|
|
|
+ 'mid' => $mid,
|
|
'created_at' => time(),
|
|
'created_at' => time(),
|
|
'updated_at' => time(),
|
|
'updated_at' => time(),
|
|
];
|
|
];
|