diff --git a/beike/Admin/Http/Controllers/MarketingController.php b/beike/Admin/Http/Controllers/MarketingController.php index 129cf4e9..075b748d 100644 --- a/beike/Admin/Http/Controllers/MarketingController.php +++ b/beike/Admin/Http/Controllers/MarketingController.php @@ -11,6 +11,7 @@ namespace Beike\Admin\Http\Controllers; +use Beike\Repositories\PluginRepo; use ZanySoft\Zip\Zip; use Illuminate\Http\Request; use Illuminate\Support\Facades\Storage; @@ -24,9 +25,14 @@ class MarketingController */ public function index(Request $request) { - $plugins = MarketingService::getList(); + $filters = [ + 'type' => $request->get('type'), + 'keyword' => $request->get('keyword'), + ]; + $plugins = MarketingService::getList($filters); $data = [ 'plugins' => $plugins, + 'types' => PluginRepo::getTypes(), ]; if ($request->expectsJson()) { diff --git a/beike/Admin/Services/MarketingService.php b/beike/Admin/Services/MarketingService.php index 6f8fc5fb..0429c5d3 100644 --- a/beike/Admin/Services/MarketingService.php +++ b/beike/Admin/Services/MarketingService.php @@ -15,9 +15,12 @@ use Illuminate\Support\Facades\Http; class MarketingService { - public static function getList() + public static function getList($filters = []) { $url = config('beike.api_url') . '/api/plugins'; + if (!empty($filters)) { + $url .= '?' . http_build_query($filters); + } return Http::get($url)->json(); } diff --git a/beike/Models/Plugin.php b/beike/Models/Plugin.php index cda90e4f..f9030cb1 100644 --- a/beike/Models/Plugin.php +++ b/beike/Models/Plugin.php @@ -13,5 +13,13 @@ namespace Beike\Models; class Plugin extends Base { + const TYPES = [ + 'shipping', // 配送方式 + 'payment', // 支付方式 + 'total', // 订单金额 + 'social', // 第三方登录 + 'view' // 其他UI更改 + ]; + protected $fillable = ['type', 'code']; } diff --git a/beike/Repositories/PluginRepo.php b/beike/Repositories/PluginRepo.php index 6afa18bf..de6bd959 100644 --- a/beike/Repositories/PluginRepo.php +++ b/beike/Repositories/PluginRepo.php @@ -12,15 +12,28 @@ namespace Beike\Repositories; use Beike\Models\Plugin; -use Beike\Plugin\Manager; use Beike\Plugin\Plugin as BPlugin; -use Illuminate\Database\Eloquent\Collection; use Illuminate\Support\Facades\File; +use Illuminate\Database\Eloquent\Collection; class PluginRepo { public static $installedPlugins; + + public static function getTypes(): array + { + $types = []; + foreach (Plugin::TYPES as $item) { + $types[] = [ + 'value' => $item, + 'label' => trans("admin/plugin.{$item}") + ]; + } + return $types; + } + + /** * 安装插件到系统: 插入数据 * @param BPlugin $bPlugin