diff --git a/app/Admin/Actions/Tree/CategoryTie.php b/app/Admin/Actions/Tree/CategoryTie.php new file mode 100644 index 0000000..2a07335 --- /dev/null +++ b/app/Admin/Actions/Tree/CategoryTie.php @@ -0,0 +1,75 @@ +response() + ->success('Processed successfully.') + ->redirect('/category'); + } + + /** + * @return string|void + */ + public function href() + { + // return admin_url('category/tie'); + } + + /** + * @return string|array|void + */ + public function confirm() + { + // return ['Confirm?', 'contents']; + } + + /** + * 添加JS + * + * @return string + */ + protected function script() + { + return <<branch(function ($branch) { + // 查询分类ssdb + $src = $branch['cover_img_url']; $logo = ""; - $actions = '绑定'; - + $actions = ''; + $actions = ($branch['parent_id'] == 0) ?'已绑定':$actions; + return "{$branch['id']} - {$branch['title']} $logo $actions"; }); + $tree->tools(function (Tree\Tools $tools) { + $tools->add(new CategoryTie()); + }); $row->column(12, $tree); }); @@ -51,7 +60,15 @@ class CategoryController extends AdminController }); } - + public function CategoryTieForm(Content $content) + { + + return $content + ->title('绑定分类到首页') + ->body(new Card(new CategoryTieForm()), function (Form $form) { + }); + } + /** * Make a show builder. * diff --git a/app/Admin/Controllers/v3/StoreController.php b/app/Admin/Controllers/v3/StoreController.php index ff08d63..ef66301 100644 --- a/app/Admin/Controllers/v3/StoreController.php +++ b/app/Admin/Controllers/v3/StoreController.php @@ -166,6 +166,11 @@ class StoreController extends AdminController $form->saved(function (Form $form){ $id = $form->getKey(); + $store = StoreModel::find($id); + // 添加商户钱包 + if($form->isCreating()){ + + } // $form->isCreating() && if(!empty($id)){ $qrCode = new StoreQRCode(); @@ -176,14 +181,13 @@ class StoreController extends AdminController $pRes = $qrCode->SetPayWeChatCode($id); // 保存图片 - $store = StoreModel::find($id); $store->store_applet_img = $sRes['status'] ? $sRes['path'] : ''; - $store->cash_code_img = $pRes['status'] ? $pRes['path'] : '';; + $store->cash_code_img = $pRes['status'] ? $pRes['path'] : ''; $store->save(); - // 剪裁图片 // $form->image('cash_code_img')->crop(270, 270, [5, 5]); } + }); $form->disableResetButton(); diff --git a/app/Admin/Forms/CategoryTieForm.php b/app/Admin/Forms/CategoryTieForm.php new file mode 100644 index 0000000..5a9dc05 --- /dev/null +++ b/app/Admin/Forms/CategoryTieForm.php @@ -0,0 +1,74 @@ + $input['activity'], + 'forward' => $input['forward'], + 'repay' => $input['repay'], + ]; + + $coupon = $this->ssdb->client()->multi_hset('coupon_rebate_activity',$data); + if($coupon === false){ + return $this->error('修改失败'); + } + + return $this->success('修改成功', '/couponTie'); + } + + /** + * Build a form here. + */ + public function form() + { + // $this->ssdb = new SsdbClient(); + // $coupon = $this->ssdb->client()->hgetall('coupon_rebate_activity'); + // if(empty($coupon)){ + // $coupon = [ + // 'activity'=> 0, + // 'forward'=> '', + // 'repay' => '' + // ]; + // } + + $this->text('id')->required(); + $this->image('cover_img')->required(); + $this->text('title')->required(); + } + + /** + * The data of the form. + * + * @return array + */ + public function default() + { + return [ + 'activity' => '2', + 'forward' => '', + 'repay' => '', + ]; + } + +} diff --git a/app/Admin/routes.php b/app/Admin/routes.php index 2f4919f..8e1c9ce 100644 --- a/app/Admin/routes.php +++ b/app/Admin/routes.php @@ -46,7 +46,7 @@ Route::group([ // 分类 $router->resource('/category', 'v3\CategoryController'); - $router->get('/category/TieForm', 'v3\CategoryTieController@CategoryTieForm'); + $router->get('/category/tie', 'v3\CategoryController@CategoryTieForm'); // 店铺 $router->resource('/store', 'v3\StoreController');