From e328bab699d35d827480b34a55d8769f33d55509 Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 14 Sep 2021 15:28:50 +0800 Subject: [PATCH 1/7] =?UTF-8?q?$channel=5Fids=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/IndexController.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Api/IndexController.php b/app/Http/Controllers/Api/IndexController.php index 3878b13..836b29b 100644 --- a/app/Http/Controllers/Api/IndexController.php +++ b/app/Http/Controllers/Api/IndexController.php @@ -38,9 +38,11 @@ class IndexController extends Controller # 我的频道 if ($this->user_id) { $channel_ids = UserChannel::where('user_id', $this->user_id)->value('channels'); - $my_channels = Channel::where('agent_id', $this->agent_id) - ->whereIn('id', $channel_ids) - ->get(['id', 'name', 'icon']); + if ($channel_ids) { + $my_channels = Channel::where('agent_id', $this->agent_id) + ->whereIn('id', $channel_ids) + ->get(['id', 'name', 'icon']); + } } else { $my_channels = Channel::where('agent_id', $this->agent_id) ->where('pid', '<>', 0) From dfa7f0f8da5a8f57a9d56b3502e6b73d46929040 Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 14 Sep 2021 15:30:28 +0800 Subject: [PATCH 2/7] =?UTF-8?q?$channel=5Fids=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/IndexController.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Api/IndexController.php b/app/Http/Controllers/Api/IndexController.php index 836b29b..844d7bb 100644 --- a/app/Http/Controllers/Api/IndexController.php +++ b/app/Http/Controllers/Api/IndexController.php @@ -37,12 +37,10 @@ class IndexController extends Controller # 我的频道 if ($this->user_id) { - $channel_ids = UserChannel::where('user_id', $this->user_id)->value('channels'); - if ($channel_ids) { - $my_channels = Channel::where('agent_id', $this->agent_id) - ->whereIn('id', $channel_ids) - ->get(['id', 'name', 'icon']); - } + $channel_ids = UserChannel::where('user_id', $this->user_id)->value('channels') ?? []; + $my_channels = Channel::where('agent_id', $this->agent_id) + ->whereIn('id', $channel_ids) + ->get(['id', 'name', 'icon']); } else { $my_channels = Channel::where('agent_id', $this->agent_id) ->where('pid', '<>', 0) From 75a9db9b3833b43f4452bc84ea2a2e1cba458b1c Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 14 Sep 2021 16:19:32 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E5=B7=B2=E5=8F=91=E5=B8=83(=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/AgentController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Admin/Controllers/AgentController.php b/app/Admin/Controllers/AgentController.php index ba95ecd..87f5e32 100644 --- a/app/Admin/Controllers/AgentController.php +++ b/app/Admin/Controllers/AgentController.php @@ -72,7 +72,7 @@ class AgentController extends AdminController } else if (empty($this->miniUpload)) { $column->append((new MiniProgramUpload(null, 1))->setKey($this->id)); } else if ($this->miniUpload->is_success == 0) { - $column->append("已发布{$this->miniUpload->template_id}"); + $column->append("已发布(模板:{$this->miniUpload->template_id})"); } else { $column->append((new MiniProgramAuditStatus(null, 1))->setKey($this->id)); } From ff8f1a17fec68d9483c397212e710495c3ece073 Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 14 Sep 2021 16:20:19 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=8A=A0=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E6=96=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/LoginController.php | 33 +++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/Api/LoginController.php b/app/Http/Controllers/Api/LoginController.php index 3c80b7b..5467583 100644 --- a/app/Http/Controllers/Api/LoginController.php +++ b/app/Http/Controllers/Api/LoginController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Api; use App\Http\Controllers\Controller; +use App\Models\AdminSetting; use App\Models\Agent; use App\Models\Channel; use App\Models\User; @@ -34,12 +35,25 @@ class LoginController extends Controller return $this->error('code参数缺失'); } - $config = config('wechat.mini_program.default'); - $config = array_merge($config, [ - 'app_id' => $agent['appid'], - 'secret' => $agent['appsecret'], - ]); - $app = Factory::miniProgram($config); + // 如果有appsecret,使用原来的登录逻辑,否则使用第三方登录逻辑 + if ($agent['appsecret']) { + $config = config('wechat.mini_program.default'); + $config = array_merge($config, [ + 'app_id' => $agent['appid'], + 'secret' => $agent['appsecret'], + ]); + $app = Factory::miniProgram($config); + } else { + $setting = AdminSetting::val(['service_appid', 'service_appsecret', 'service_token', 'service_aeskey']); + $config = [ + 'app_id' => $setting['service_appid'], + 'secret' => $setting['service_appsecret'], + 'token' => $setting['service_token'], + 'aes_key' => $setting['service_aeskey'], + ]; + + $app = Factory::openPlatform($config); + } try { $res = $app->auth->session($code); @@ -72,11 +86,8 @@ class LoginController extends Controller $channel_ids = Channel::where([ ['agent_id', '=', $this->agent_id], ['pid', '<>', 0], - ]) - ->orderBy('id') - ->limit(8) - ->pluck('id') - ->toArray(); + ])->orderBy('id')->limit(8)->pluck('id')->toArray(); + //存入user_channel UserChannel::where('user_id', $userModel->id) ->insert([ From 3aa5666b203c51cd368524359cb9b5b4376fb8cf Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 14 Sep 2021 16:22:43 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/LoginController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Http/Controllers/Api/LoginController.php b/app/Http/Controllers/Api/LoginController.php index 5467583..9fed667 100644 --- a/app/Http/Controllers/Api/LoginController.php +++ b/app/Http/Controllers/Api/LoginController.php @@ -53,6 +53,7 @@ class LoginController extends Controller ]; $app = Factory::openPlatform($config); + dd($app); } try { From c9b7088688d22d58e6e59f78aa7a6d39faf48313 Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 14 Sep 2021 16:24:12 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/LoginController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/LoginController.php b/app/Http/Controllers/Api/LoginController.php index 9fed667..4e6153b 100644 --- a/app/Http/Controllers/Api/LoginController.php +++ b/app/Http/Controllers/Api/LoginController.php @@ -55,7 +55,7 @@ class LoginController extends Controller $app = Factory::openPlatform($config); dd($app); } - +dd($agent->toArray()); try { $res = $app->auth->session($code); if (!empty($res['errcode']) || empty($res['openid']) && empty($res['unionid'])) { From 4db66d1a60067a644a0ed102e39adc359748d13f Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 14 Sep 2021 16:30:29 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/LoginController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Api/LoginController.php b/app/Http/Controllers/Api/LoginController.php index 4e6153b..a734a7a 100644 --- a/app/Http/Controllers/Api/LoginController.php +++ b/app/Http/Controllers/Api/LoginController.php @@ -53,9 +53,9 @@ class LoginController extends Controller ]; $app = Factory::openPlatform($config); - dd($app); + dd($app['auth']); } -dd($agent->toArray()); + try { $res = $app->auth->session($code); if (!empty($res['errcode']) || empty($res['openid']) && empty($res['unionid'])) {