From b23d6f31a812e782715a33816628ef63c2500708 Mon Sep 17 00:00:00 2001 From: liapples Date: Wed, 8 Sep 2021 12:58:12 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E4=BA=A7=E5=93=81=E7=B1=BB=E5=9E=8Btype?= =?UTF-8?q?=E9=87=8D=E6=96=B0=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/ProductController.php | 129 +++++++----------- 1 file changed, 50 insertions(+), 79 deletions(-) diff --git a/app/AdminSupplier/Controllers/ProductController.php b/app/AdminSupplier/Controllers/ProductController.php index 0a54671..20d6ab6 100644 --- a/app/AdminSupplier/Controllers/ProductController.php +++ b/app/AdminSupplier/Controllers/ProductController.php @@ -6,7 +6,6 @@ use App\AdminSupplier\Repositories\Product; use App\Common\ProductStatus; use App\Models\AgentProduct; use App\Models\AgentProductItem; -use App\Models\AgentSetting; use App\Models\Category; use Dcat\Admin\Admin; use Dcat\Admin\Form; @@ -18,7 +17,6 @@ use Dcat\Admin\Widgets\Alert; use Dcat\Admin\Widgets\Card; use Dcat\Admin\Widgets\Table; use Illuminate\Support\Facades\DB; -use Illuminate\Support\Facades\Log; class ProductController extends AdminController { @@ -31,21 +29,10 @@ class ProductController extends AdminController protected function grid() { return Grid::make(new Product(['category:id,name']), function (Grid $grid) { - $type = request()->input('type'); - - if (isset($type) && isset(admin_trans('product.options.publish_type')[$type])) { - $grid->model()->where(['supplier_id' => Admin::user()->id, 'type' => $type]); - Admin::script('$(function(){ - $(".pull-right a").each(function() { - var href = $(this).attr("href"); - $(this).attr("href", href + "?type='.$type.'") - }); - });'); - } else { - $grid->model()->where('supplier_id', Admin::user()->id); - } + $grid->model()->where('supplier_id', Admin::user()->id); $grid->column('id')->sortable(); + $grid->column('type')->using(admin_trans('product.options.publish_type')); $grid->column('category.name', '产品分类'); $grid->column('title'); $grid->column('picture')->image('', 60, 60); @@ -62,6 +49,7 @@ class ProductController extends AdminController $filter->panel(); $filter->equal('id')->width(2); + $filter->equal('type')->select(admin_trans('product.options.publish_type'))->width(2); }); }); } @@ -76,13 +64,6 @@ class ProductController extends AdminController protected function detail($id) { return Show::make($id, new Product(), function (Show $show) { - Admin::script('$(function(){ - $(".pull-right a").each(function() { - var href = $(this).attr("href"); - $(this).attr("href", href + "?type='.request()->input('type').'") - }); - });'); - $show->field('id'); $show->field('supplier_id'); $show->field('category_id'); @@ -126,22 +107,12 @@ class ProductController extends AdminController { Admin::user()->publish_type = json_decode(Admin::user()->publish_type, true); return Form::make(new Product(), function (Form $form) { - Admin::script('$(function(){ - $(".pull-right a").each(function() { - var href = $(this).attr("href"); - $(this).attr("href", href + "?type='.request()->input('type').'") - }); - });'); - //不允许编辑非自己数据 if ($form->isEditing() && $form->model()->supplier_id != Admin::user()->id) { return $form->response()->error('数据不存在'); } - $type = request()->input('type'); - $form->display('id'); - $form->hidden('type')->value($type); $options = Category::selectOptions(fn($query) => $query->where('agent_id', 0)); $form->select('category_id')->options(array_slice($options, 1, null, true))->required(); @@ -155,64 +126,64 @@ class ProductController extends AdminController $form->text('verify_mobile','核销员手机'); //扩展字段 - if ($type == 0) { //旅游线路 - $form->table('extends.project', '包含项目', function (NestedForm $table) { - $table->text('name', '项目名称'); - $table->text('num', '数量'); - $table->text('price', '费用'); - }); - $form->dateRange('extends.date.start', 'extends.date.end', '行程时间'); - } else if ($type == 1) { //酒店 - $default = ['行李寄存', '24小时前台', '前台保险柜', '唤醒服务', '早餐', '送餐服务', '电梯', '空调', - '新风系统', '24小时热水', '吹风机', '加湿器', '自动售货机', '健身房', '桌球室', '洗衣服务']; - $form->table('extends.tags', '酒店设施', function (NestedForm $table) { - $table->text('tag', '包含项目')->placeholder('如:24小时热水、干洗服务等'); - }); - } else if ($type == 2) { //景区 - $form->table('extends.open_time', '开放时间', function (NestedForm $table) { - $table->text('week', '星期')->placeholder('如:周一至周五'); - $table->text('section', '时段')->placeholder('如:上午/下午'); - $table->text('time', '时间')->placeholder('如:08:00~18:00'); - }); - $form->table('extends.project', '包含项目', function (NestedForm $table) { - $table->text('name', '项目名称'); - $table->text('num', '数量'); - $table->text('price', '费用'); - }); - } else if ($type == 3) { //餐厅 - $form->table('extends.open_time', '开放时间', function (NestedForm $table) { - $table->text('week', '星期')->placeholder('如:周一至周五'); - $table->text('section', '时段')->placeholder('如:上午/下午'); - $table->text('time', '时间')->placeholder('如:08:00~18:00'); - }); - $form->table('extends.package', '包含套餐', function (NestedForm $table) { - $table->text('name', '名称')->placeholder('如:清蒸鱿鱼'); - $table->text('num', '数量')->placeholder('如:1条'); - $table->text('price', '价格')->placeholder('如:99元'); + $publish_type = array_intersect_key( + admin_trans('product.options.publish_type'), + array_flip(Admin::user()->publish_type) + ); + $form->radio('type', '产品类型') + ->options($publish_type) + ->default(current(Admin::user()->publish_type)) + ->when(0, function (Form $form) { //旅游线路 + $form->table('extends.field_0.project', '包含项目', function (NestedForm $table) { + $table->text('name', '项目名称'); + $table->text('num', '数量'); + $table->text('price', '费用'); + }); + $form->dateRange('extends.field_0.date.start', 'extends.field_0.date.end', '行程时间'); + })->when(1, function (Form $form) { //酒店 + $default = [ + ['tag' => '行李寄存'], ['tag' => '24小时前台'], ['tag' => '前台保险柜'], ['tag' => '唤醒服务'], + ['tag' => '早餐'], ['tag' => '送餐服务'], ['tag' => '电梯'], ['tag' => '空调'], + ['tag' => '新风系统'], ['tag' => '24小时热水'], ['tag' => '吹风机'], ['tag' => '加湿器'], + ['tag' => '自动售货机'], ['tag' => '健身房'], ['tag' => '桌球室'], ['tag' => '洗衣服务'] + ]; + $form->table('extends.field_1.tags', '酒店设施', function (NestedForm $table) { + $table->text('tag', '包含项目')->placeholder('如:24小时热水、干洗服务等'); + })->value($default); + })->when(2, function (Form $form) { //景区 + $form->table('extends.field_2.open_time', '开放时间', function (NestedForm $table) { + $table->text('week', '星期')->placeholder('如:周一至周五'); + $table->text('section', '时段')->placeholder('如:上午/下午'); + $table->text('time', '时间')->placeholder('如:08:00~18:00'); + }); + $form->table('extends.field_2.project', '包含项目', function (NestedForm $table) { + $table->text('name', '项目名称'); + $table->text('num', '数量'); + $table->text('price', '费用'); + }); + })->when(3, function (Form $form) { //餐厅 + $form->table('extends.field_3.open_time', '开放时间', function (NestedForm $table) { + $table->text('week', '星期')->placeholder('如:周一至周五'); + $table->text('section', '时段')->placeholder('如:上午/下午'); + $table->text('time', '时间')->placeholder('如:08:00~18:00'); + }); + $form->table('extends.field_3.package', '包含套餐', function (NestedForm $table) { + $table->text('name', '名称')->placeholder('如:清蒸鱿鱼'); + $table->text('num', '数量')->placeholder('如:1条'); + $table->text('price', '价格')->placeholder('如:99元'); + }); }); - } if ($form->isEditing()) { $form->confirm('提示', '修改标题、价格、产品图片、旅游须知、产品详情需要重新审核,同时下架所有关联的代理商产品,是否继续?'); } - })->creating(function (Form $form) { - $type = request()->input('type'); - if ($form->isCreating()) { - if ($type == null) { - Admin::exit('请选择要发布的产品类型'); - } - if (!Admin::user()->publish_type || !in_array($type, Admin::user()->publish_type)) { - Admin::exit(Alert::make('对不起,你没有此类产品的发布权限', '权限不足')->danger()); - } - } })->saving(function (Form $form) { //不允许编辑非自己数据 if ($form->isEditing() && $form->model()->supplier_id != Admin::user()->id) { return $form->response()->error('数据不存在'); } - $type = $form->isCreating() ? $form->type : $form->model()->type; - if (!Admin::user()->publish_type || !in_array($type, Admin::user()->publish_type)) { + if (!Admin::user()->publish_type || !in_array($form->type, Admin::user()->publish_type)) { return $form->response()->error('对不起,你没有此类产品的发布、编辑权限'); } From f7b7b4091827fb8bc1dd6d3158ac1d5980d4213a Mon Sep 17 00:00:00 2001 From: liapples Date: Wed, 8 Sep 2021 13:00:19 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E5=88=86=E6=88=90=E6=AF=94=E4=BE=8B->?= =?UTF-8?q?=E6=8A=BD=E6=88=90=E6=AF=94=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/AgentController.php | 4 ++-- app/Admin/Controllers/GuideController.php | 4 ++-- resources/lang/zh_CN/agent.php | 2 +- resources/lang/zh_CN/guide.php | 2 +- resources/lang/zh_CN/supplier.php | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Admin/Controllers/AgentController.php b/app/Admin/Controllers/AgentController.php index d5f5299..8fb23bb 100644 --- a/app/Admin/Controllers/AgentController.php +++ b/app/Admin/Controllers/AgentController.php @@ -169,9 +169,9 @@ class AgentController extends AdminController } } - //分成比例 + //抽成比例 if ($form->rate < 0 || $form->rate > 100) { - return $form->response()->error('分成比例在 0 ~ 100 之间'); + return $form->response()->error('抽成比例在 0 ~ 100 之间'); } //不允许编辑的字段 diff --git a/app/Admin/Controllers/GuideController.php b/app/Admin/Controllers/GuideController.php index fd90af5..071ac00 100644 --- a/app/Admin/Controllers/GuideController.php +++ b/app/Admin/Controllers/GuideController.php @@ -123,9 +123,9 @@ class GuideController extends AdminController } } - //分成比例 + //抽成比例 if ($form->rate < 0 || $form->rate > 100) { - return $form->response()->error('分成比例在 0 ~ 100 之间'); + return $form->response()->error('抽成比例在 0 ~ 100 之间'); } //不允许编辑的字段 diff --git a/resources/lang/zh_CN/agent.php b/resources/lang/zh_CN/agent.php index 5027c61..d48df6f 100644 --- a/resources/lang/zh_CN/agent.php +++ b/resources/lang/zh_CN/agent.php @@ -21,7 +21,7 @@ return [ 'license_pic' => '营业执照', 'director' => '负责人', 'contact_phone' => '联系电话', - 'rate' => '分成比例', + 'rate' => '抽成比例', 'agentInfo' => trans('agent-info.fields'), ], 'options' => [ diff --git a/resources/lang/zh_CN/guide.php b/resources/lang/zh_CN/guide.php index 29d3889..a5eb6f6 100644 --- a/resources/lang/zh_CN/guide.php +++ b/resources/lang/zh_CN/guide.php @@ -13,7 +13,7 @@ return [ 'license_pic' => '地接资格证件', 'contact_phone' => '联系电话', 'status' => '状态', - 'rate' => '分成比例', + 'rate' => '抽成比例', ], 'options' => [ ], diff --git a/resources/lang/zh_CN/supplier.php b/resources/lang/zh_CN/supplier.php index fbaab4f..ec5030b 100644 --- a/resources/lang/zh_CN/supplier.php +++ b/resources/lang/zh_CN/supplier.php @@ -15,7 +15,7 @@ return [ 'license_pic' => '营业执照', 'director' => '负责人', 'contact_phone' => '联系电话', - 'rate' => '分成比例', + 'rate' => '抽成比例', 'publish_type' => '可发布产品类型', ], 'options' => [ From f3c105893e0cf470ebfbcbef041d2a24670d0702 Mon Sep 17 00:00:00 2001 From: liapples Date: Wed, 8 Sep 2021 13:01:48 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9help=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/SupplierController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Admin/Controllers/SupplierController.php b/app/Admin/Controllers/SupplierController.php index 3f0efd0..0dbe5dc 100644 --- a/app/Admin/Controllers/SupplierController.php +++ b/app/Admin/Controllers/SupplierController.php @@ -130,7 +130,7 @@ class SupplierController extends AdminController $form->select('status', '状态') ->options(UserStatus::array()) ->default(UserStatus::NORMAL) - ->help('如果禁用供应商将同时下架供应商的所有产品,需要供应商手动上架后才能销售,请谨慎!') + ->help('如果禁用供应商,其下的所有产品都会跟着下架,包括代理商在售的产品') ->required(); $form->text('company_name'); $form->image('logo')->removable(false)->uniqueName(); From 77d504cacc9069d3974c5e2cdd29f878fa5a8b4a Mon Sep 17 00:00:00 2001 From: liapples Date: Wed, 8 Sep 2021 14:39:33 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E5=A2=9E=E5=8A=A0whereDoesntHave?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AdminAgent/Controllers/AgentProductController.php | 6 +++++- app/AdminAgent/Renderable/SelectAgentCloudProduct.php | 7 ++++++- app/AdminAgent/Renderable/SelectAgentProduct.php | 7 ++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/AdminAgent/Controllers/AgentProductController.php b/app/AdminAgent/Controllers/AgentProductController.php index a3c04dc..9d600ef 100644 --- a/app/AdminAgent/Controllers/AgentProductController.php +++ b/app/AdminAgent/Controllers/AgentProductController.php @@ -413,7 +413,11 @@ class AgentProductController extends AdminController ['is_cloud', '=', 1], ['type', '=', 1], ['agent_id', '<>', Admin::user()->id], - ])->find($form->agent_cloud_pid); + ])->whereDoesntHave('agentProductItem', function ($query) { + return $query->whereHas('product', function ($query) { + return $query->where('stock', '<=', 0)->orWhere('status', '<>', ProductStatus::ON_SALE); + }); + })->find($form->agent_cloud_pid); if (!$cloud_product) { return $form->response()->error('你选择的组团云产品库存不足或已下架,请重新选择'); diff --git a/app/AdminAgent/Renderable/SelectAgentCloudProduct.php b/app/AdminAgent/Renderable/SelectAgentCloudProduct.php index 18cf4fb..acb45fe 100644 --- a/app/AdminAgent/Renderable/SelectAgentCloudProduct.php +++ b/app/AdminAgent/Renderable/SelectAgentCloudProduct.php @@ -30,7 +30,12 @@ class SelectAgentCloudProduct extends LazyRenderable ['is_cloud', '=', 1], ['type', '=', 1], ['agent_id', '<>', Admin::user()->id], - ]); + ])->whereDoesntHave('agentProductItem', function ($query) { + return $query->whereHas('product', function ($query) { + return $query->where('stock', '<=', 0)->orWhere('status', '<>', ProductStatus::ON_SALE); + }); + }); + $grid->quickSearch(['title'])->placeholder('搜索产品名称'); diff --git a/app/AdminAgent/Renderable/SelectAgentProduct.php b/app/AdminAgent/Renderable/SelectAgentProduct.php index d29861f..51f7807 100644 --- a/app/AdminAgent/Renderable/SelectAgentProduct.php +++ b/app/AdminAgent/Renderable/SelectAgentProduct.php @@ -25,7 +25,12 @@ class SelectAgentProduct extends LazyRenderable $grid->disableBatchActions(); $grid->model()->where('stock', '>', 0) - ->where(['agent_id' => Admin::user()->id, 'status' => ProductStatus::ON_SALE]); + ->where(['agent_id' => Admin::user()->id, 'status' => ProductStatus::ON_SALE]) + ->whereDoesntHave('agentProductItem', function ($query) { + return $query->whereHas('product', function ($query) { + return $query->where('stock', '<=', 0)->orWhere('status', '<>', ProductStatus::ON_SALE); + }); + }); $grid->quickSearch(['title'])->placeholder('搜索产品名称'); $grid->column('id'); From 63fb3d53d1247dacaf634b5a5f9c99fe8083e25a Mon Sep 17 00:00:00 2001 From: liapples Date: Wed, 8 Sep 2021 15:30:05 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E5=A2=9E=E5=8A=A0extends=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/AgentProductController.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Api/AgentProductController.php b/app/Http/Controllers/Api/AgentProductController.php index f13be9c..4390758 100644 --- a/app/Http/Controllers/Api/AgentProductController.php +++ b/app/Http/Controllers/Api/AgentProductController.php @@ -5,6 +5,7 @@ use App\Common\ProductStatus; use App\Http\Controllers\Controller; use App\Models\Advertising; use App\Models\AgentProduct; +use App\Models\Product; use App\Models\UserFav; use Illuminate\Support\Facades\Storage; @@ -59,8 +60,7 @@ class AgentProductController extends Controller // TODO 优惠券查询待优化 $agent_product = AgentProduct::query() - ->with('coupon:tag,agent_product_id') - ->with('fav:agent_product_id') + ->with(['coupon:tag,agent_product_id', 'fav:agent_product_id']) ->whereDoesntHave('agentProductItem', function ($query) { return $query->whereHas('product', function ($query) { return $query->where('stock', '<=', 0)->orWhere('status', '<>', ProductStatus::ON_SALE); @@ -85,6 +85,13 @@ class AgentProductController extends Controller $agent_product->cost = ''; } + //如果是单品销售,显示附加信息字段,组合产品和组团产品不显示 + if ($agent_product->type == 0) { + $agent_product->product = Product::query()->where('id', $agent_product->product_id)->first(['type', 'extends']); + } else { + $agent_product->product = null; + } + unset($agent_product->agent_id, $agent_product->status, $agent_product->deleted_at); return $this->success($agent_product); } From f362c5ae87042907c2ee18824f6bcedb92f4c18a Mon Sep 17 00:00:00 2001 From: liapples Date: Wed, 8 Sep 2021 16:33:13 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9extends=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AdminSupplier/Controllers/ProductController.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/AdminSupplier/Controllers/ProductController.php b/app/AdminSupplier/Controllers/ProductController.php index 20d6ab6..d2c9b69 100644 --- a/app/AdminSupplier/Controllers/ProductController.php +++ b/app/AdminSupplier/Controllers/ProductController.php @@ -152,9 +152,9 @@ class ProductController extends AdminController })->value($default); })->when(2, function (Form $form) { //景区 $form->table('extends.field_2.open_time', '开放时间', function (NestedForm $table) { - $table->text('week', '星期')->placeholder('如:周一至周五'); - $table->text('section', '时段')->placeholder('如:上午/下午'); - $table->text('time', '时间')->placeholder('如:08:00~18:00'); + $table->text('node', '节点')->placeholder('如:周一至周五'); + $table->text('summer', '夏季')->placeholder('如:08:00~19:00'); + $table->text('winter', '冬季')->placeholder('如:08:00~18:00'); }); $form->table('extends.field_2.project', '包含项目', function (NestedForm $table) { $table->text('name', '项目名称'); @@ -174,6 +174,8 @@ class ProductController extends AdminController }); }); + $form->map('latitude', 'longitude', '位置'); + if ($form->isEditing()) { $form->confirm('提示', '修改标题、价格、产品图片、旅游须知、产品详情需要重新审核,同时下架所有关联的代理商产品,是否继续?'); } From 1431ebd92946be24740d6614783ef8daefe930d4 Mon Sep 17 00:00:00 2001 From: liapples Date: Wed, 8 Sep 2021 16:46:51 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AdminSupplier/Controllers/ProductController.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/AdminSupplier/Controllers/ProductController.php b/app/AdminSupplier/Controllers/ProductController.php index d2c9b69..8126d08 100644 --- a/app/AdminSupplier/Controllers/ProductController.php +++ b/app/AdminSupplier/Controllers/ProductController.php @@ -13,7 +13,6 @@ use Dcat\Admin\Form\NestedForm; use Dcat\Admin\Grid; use Dcat\Admin\Show; use Dcat\Admin\Http\Controllers\AdminController; -use Dcat\Admin\Widgets\Alert; use Dcat\Admin\Widgets\Card; use Dcat\Admin\Widgets\Table; use Illuminate\Support\Facades\DB; @@ -105,6 +104,7 @@ class ProductController extends AdminController */ protected function form() { + Form\Field\Map::requireAssets(); //地图 Admin::user()->publish_type = json_decode(Admin::user()->publish_type, true); return Form::make(new Product(), function (Form $form) { //不允许编辑非自己数据 @@ -150,6 +150,7 @@ class ProductController extends AdminController $form->table('extends.field_1.tags', '酒店设施', function (NestedForm $table) { $table->text('tag', '包含项目')->placeholder('如:24小时热水、干洗服务等'); })->value($default); + $form->map('extends.field_1.latitude', 'extends.field_1.longitude', '位置'); })->when(2, function (Form $form) { //景区 $form->table('extends.field_2.open_time', '开放时间', function (NestedForm $table) { $table->text('node', '节点')->placeholder('如:周一至周五'); @@ -161,6 +162,7 @@ class ProductController extends AdminController $table->text('num', '数量'); $table->text('price', '费用'); }); + $form->map('extends.field_2.latitude', 'extends.field_2.longitude', '位置'); })->when(3, function (Form $form) { //餐厅 $form->table('extends.field_3.open_time', '开放时间', function (NestedForm $table) { $table->text('week', '星期')->placeholder('如:周一至周五'); @@ -172,10 +174,9 @@ class ProductController extends AdminController $table->text('num', '数量')->placeholder('如:1条'); $table->text('price', '价格')->placeholder('如:99元'); }); + $form->map('extends.field_3.latitude', 'extends.field_3.longitude', '位置'); }); - $form->map('latitude', 'longitude', '位置'); - if ($form->isEditing()) { $form->confirm('提示', '修改标题、价格、产品图片、旅游须知、产品详情需要重新审核,同时下架所有关联的代理商产品,是否继续?'); } From 9716df22af9e3492383abf353d6a4e8150d9e90a Mon Sep 17 00:00:00 2001 From: liapples Date: Wed, 8 Sep 2021 16:46:51 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AdminSupplier/Controllers/ProductController.php | 7 ++++--- config/admin-supplier.php | 8 ++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/AdminSupplier/Controllers/ProductController.php b/app/AdminSupplier/Controllers/ProductController.php index d2c9b69..8126d08 100644 --- a/app/AdminSupplier/Controllers/ProductController.php +++ b/app/AdminSupplier/Controllers/ProductController.php @@ -13,7 +13,6 @@ use Dcat\Admin\Form\NestedForm; use Dcat\Admin\Grid; use Dcat\Admin\Show; use Dcat\Admin\Http\Controllers\AdminController; -use Dcat\Admin\Widgets\Alert; use Dcat\Admin\Widgets\Card; use Dcat\Admin\Widgets\Table; use Illuminate\Support\Facades\DB; @@ -105,6 +104,7 @@ class ProductController extends AdminController */ protected function form() { + Form\Field\Map::requireAssets(); //地图 Admin::user()->publish_type = json_decode(Admin::user()->publish_type, true); return Form::make(new Product(), function (Form $form) { //不允许编辑非自己数据 @@ -150,6 +150,7 @@ class ProductController extends AdminController $form->table('extends.field_1.tags', '酒店设施', function (NestedForm $table) { $table->text('tag', '包含项目')->placeholder('如:24小时热水、干洗服务等'); })->value($default); + $form->map('extends.field_1.latitude', 'extends.field_1.longitude', '位置'); })->when(2, function (Form $form) { //景区 $form->table('extends.field_2.open_time', '开放时间', function (NestedForm $table) { $table->text('node', '节点')->placeholder('如:周一至周五'); @@ -161,6 +162,7 @@ class ProductController extends AdminController $table->text('num', '数量'); $table->text('price', '费用'); }); + $form->map('extends.field_2.latitude', 'extends.field_2.longitude', '位置'); })->when(3, function (Form $form) { //餐厅 $form->table('extends.field_3.open_time', '开放时间', function (NestedForm $table) { $table->text('week', '星期')->placeholder('如:周一至周五'); @@ -172,10 +174,9 @@ class ProductController extends AdminController $table->text('num', '数量')->placeholder('如:1条'); $table->text('price', '价格')->placeholder('如:99元'); }); + $form->map('extends.field_3.latitude', 'extends.field_3.longitude', '位置'); }); - $form->map('latitude', 'longitude', '位置'); - if ($form->isEditing()) { $form->confirm('提示', '修改标题、价格、产品图片、旅游须知、产品详情需要重新审核,同时下架所有关联的代理商产品,是否继续?'); } diff --git a/config/admin-supplier.php b/config/admin-supplier.php index da01013..8a9c1fc 100644 --- a/config/admin-supplier.php +++ b/config/admin-supplier.php @@ -343,4 +343,12 @@ return [ | Whether enable default breadcrumb for every page content. */ 'enable_default_breadcrumb' => true, + + //地图配置 + 'map_provider' => 'tencent', + 'map' => [ + 'keys' => [ + 'tencent' => env('TENCENT_MAP_KEY','') + ] + ] ];