Commit f6a3d8a2 by lizhilin

更新

parent 1d5d5949
...@@ -90,12 +90,12 @@ protected function form() ...@@ -90,12 +90,12 @@ protected function form()
return $v ?? 0; return $v ?? 0;
}); });
$form->text('title'); $form->text('title');
$form->image('icon', '分类图标') // $form->image('icon', '分类图标')
->accept('jpg,jpeg,png') // ->accept('jpg,jpeg,png')
->maxSize(4096) // ->maxSize(4096)
->url('upload/category') // ->url('upload/category')
->help('仅支持jpg、jpeg、png格式图片上传(750px * 420px)') // ->help('仅支持jpg、jpeg、png格式图片上传(750px * 420px)')
->autoUpload(); // ->autoUpload();
$form->text('order')->help('越小越靠前'); $form->text('order')->help('越小越靠前');
$form->switch('show', '状态')->default(1); $form->switch('show', '状态')->default(1);
......
...@@ -164,6 +164,30 @@ protected function form() ...@@ -164,6 +164,30 @@ protected function form()
return $sku; return $sku;
})->required(); })->required();
})->tab('文字标签', function (Form $form) {
$fieldArr = [
'field1' => '',
'field2' => '',
'field3' => '',
'field4' => '',
'field5' => '',
'field6' => '',
'field7' => '',
'field8' => '',
'field9' => '',
'field10' => '',
'field11' => '',
'field12' => '',
'field13' => '',
'field14' => '',
'field15' => '',
'field16' => '',
];
$form->keyValue('tags', '标签')->default($fieldArr)
->setKeyLabel('键 (field开头拼上数字)')
->setValueLabel('值');
//->disableCreateButton();
//->disableDelete();
})->tab('详情', function (Form $form) { })->tab('详情', function (Form $form) {
$form->editor('goods_desc'); $form->editor('goods_desc');
......
...@@ -46,7 +46,7 @@ protected function grid() ...@@ -46,7 +46,7 @@ protected function grid()
$grid->actions(function (Grid\Displayers\Actions $actions) { $grid->actions(function (Grid\Displayers\Actions $actions) {
// 添加一个按钮,并设置其属性 // 添加一个按钮,并设置其属性
$actions->append('<a href="/user-share?id=' . $this->id . '" alt="查看下级" target="_blank">查看详情</a>'); $actions->append('<a href="/user-share?id=' . $this->id . '" alt="查看下级" target="_blank">查看下级</a>');
// 或者使用 RowAction 来添加按钮 // 或者使用 RowAction 来添加按钮
//$actions->append(RowAction::make('自定义按钮')->route('custom.route')); //$actions->append(RowAction::make('自定义按钮')->route('custom.route'));
......
<?php
namespace App\Http\Controllers\Api;
use App\Command\Log;
use App\Models\Article;
use Illuminate\Http\Request;
class ArticleController extends BaseController
{
public function getList()
{
$page = $request->page ?? 1;
$limit = $request->limit ?? 10;
$cat_id = $request->cat_id ?? 0;
$where = ['is_show' => 1];
if ($cat_id) {
$where['cat_id'] = $cat_id;
}
$sql = Article::where($where);
$data = [
'total' => $sql->count(),
'total_page' => ceil($sql->count() / $limit),
'list' => []
];
$listData = $sql->offset(($page - 1) * $limit)->limit($limit)->orderBy('created_at', 'DESC')->get();
if ($listData->toArray()) {
foreach ($listData as $item) {
$data['list'][] = [
'id' => $item->id,
'title' => $item->title,
'cover' => $item->cover ? env('IMAGE_URL') . $item->cover : '',
'content' => $item->content,
'created_at' => $item->created_at,
];
}
}
return $this->JsonResponse($data);
}
public function getDetail(Request $request)
{
$aid = $request->aid ?? null;
$aObj = Article::find($aid);
if (!$aObj) {
return $this->JsonResponse('', '参数错误', 201);
}
$data = [
'id' => $aid,
'title' => $aObj->title,
'content' => $aObj->content,
'created_at' => $aObj->created_at ? date("Y-m-d H:i:s", strtotime($aObj->created_at)) : '',
];
return $this->JsonResponse($data);
}
}
...@@ -26,10 +26,11 @@ public function getList(Request $request) ...@@ -26,10 +26,11 @@ public function getList(Request $request)
'id' => $item->id, 'id' => $item->id,
'parent_id' => $item->parent_id, 'parent_id' => $item->parent_id,
'title' => $item->title, 'title' => $item->title,
'icon' => (isset($item->icon) ? env('IMAGE_URL') . $item->icon : '') //'icon' => (isset($item->icon) ? env('IMAGE_URL') . $item->icon : '')
]; ];
} }
} }
array_unshift($data['list'], ['id' => 0, 'parent_id' => 0, 'title' => '全部']);
return $this->JsonResponse($data); return $this->JsonResponse($data);
} }
......
<?php
namespace App\Http\Controllers\Api;
use App\Command\Log;
use App\Handlers\FileUploadHandler;
use App\Models\Comment;
use App\Models\CommentTpl;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
class CommentController extends BaseController
{
public function add(Request $request)
{
$useObj = $request->user();
$gid = $request->gid ?? 0;
$star = $request->star ?? 0;
$content = $request->content ?? '';
DB::beginTransaction();
try {
$comObj = new Comment();
$comObj->goods_id = $gid;
$comObj->star = $star;
$comObj->content = $content;
$comObj->nickname = $useObj->name;
$comObj->avatar = $useObj->avatar ?? '';
$comObj->phone = $useObj->phone;
$comObj->save();
DB::commit();
return $this->JsonResponse('');
} catch (\Exception $exception) {
Log::add('添加评论失败', $exception->getMessage());
DB::rollBack();
return $this->JsonResponse('', '添加评论失败', 201);
}
}
public function getList(Request $request)
{
$gid = $request->gid ?? 0;
$page = $request->page ?? 1;
$limit = $request->limit ?? 10;
$sql = Comment::where(['goods_id' => $gid, 'deleted_at' => null])
->select('id', 'nickname', 'avatar', 'content', 'addtime');
$data = [
'total' => $sql->count(),
'total_page' => ceil($sql->count() / $limit),
'list' => []
];
$listData = $sql->offset(($page - 1) * $limit)->limit($limit)->orderBy('created_at', 'DESC')->get();
if ($listData->toArray()) {
foreach ($listData as $item) {
$data['list'][] = [
'id' => $item->id,
'nickname' => $item->nickname,
'avatar' => $item->avatar ? env('IMAGE_URL') . $item->avatar : '',
'content' => $item->content,
'addtime' => $item->addtime,
];
}
}
return $this->JsonResponse($data);
}
}
<?php
namespace App\Http\Controllers\Api;
use App\Command\Log;
use App\Handlers\FileUploadHandler;
use App\Models\CommentTpl;
use Illuminate\Http\Request;
class CommentTplController extends BaseController
{
public function getList()
{
$list = (new CommentTpl())->select("id", "title", "content")
->orderBy("id", "desc")
->limit(30)
->get();
return $this->JsonResponse($list);
}
}
...@@ -39,11 +39,16 @@ ...@@ -39,11 +39,16 @@
Route::get('carousel', 'CarouselController@getList'); //轮播列表 Route::get('carousel', 'CarouselController@getList'); //轮播列表
Route::get('comment-tpl', 'CommentTplController@getList'); //评价模板
Route::get('get-cate-list', 'CategoryController@getList'); //一级分类列表 Route::get('get-cate-list', 'CategoryController@getList'); //一级分类列表
Route::get('get-seccate-list', 'CategoryController@getSecList'); //二级分类列表 Route::get('article-list', 'ArticleController@getList'); //文章列表
Route::get('article-detail', 'ArticleController@getDetail'); //文章详情
// Route::get('get-seccate-list', 'CategoryController@getSecList'); //二级分类列表
Route::get('get-third-list', 'CategoryController@getThirdList'); //三级分类列表 // Route::get('get-third-list', 'CategoryController@getThirdList'); //三级分类列表
Route::get('recommend-good', 'GoodController@getIndexGoods'); //首页商品列表 Route::get('recommend-good', 'GoodController@getIndexGoods'); //首页商品列表
...@@ -61,6 +66,8 @@ ...@@ -61,6 +66,8 @@
Route::get('get-good-detail', 'GoodController@getDetail'); //商品详情 Route::get('get-good-detail', 'GoodController@getDetail'); //商品详情
Route::get('comment-list', 'CommentController@getList'); //评价列表
Route::get('send/config/update', 'SystemController@update'); Route::get('send/config/update', 'SystemController@update');
Route::middleware('auth:sanctum')->group(function () { Route::middleware('auth:sanctum')->group(function () {
...@@ -126,5 +133,9 @@ ...@@ -126,5 +133,9 @@
Route::post('upload-img', 'UserController@uploadImg'); //图片统一上传接口 Route::post('upload-img', 'UserController@uploadImg'); //图片统一上传接口
Route::post('edit-user', 'UserController@editUser'); //更新用户 Route::post('edit-user', 'UserController@editUser'); //更新用户
Route::post('add-comment', 'CommentController@add'); //去评价
}); });
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment