101 lines
2.7 KiB
PHP
101 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace app\admin\controller;
|
|
|
|
use app\admin\logic\goods\GoodsLogic;
|
|
use app\admin\logic\MallNewsLogic;
|
|
use app\common\basics\AdminBase;
|
|
use app\common\server\JsonServer;
|
|
|
|
class MallNews extends AdminBase
|
|
{
|
|
public function lists()
|
|
{
|
|
if ($this->request->isAjax()) {
|
|
$get = $this->request->get();
|
|
$lists = MallNewsLogic::lists($get);
|
|
return JsonServer::success('', $lists);
|
|
}
|
|
return view('');
|
|
}
|
|
|
|
public function add()
|
|
{
|
|
if ($this->request->isAjax()) {
|
|
$post = $this->request->post();
|
|
$result = MallNewsLogic::create($post);
|
|
if ($result['code'] == 1) {
|
|
return JsonServer::success('添加成功');
|
|
}
|
|
return JsonServer::error($result['msg']);
|
|
}
|
|
|
|
return view('', [
|
|
'max_upload_size' => MallNewsLogic::$MAX_UPLOAD_SIZE . 'Mb',
|
|
'max_upload_file' => MallNewsLogic::$MAX_UPLOAD_FILE,
|
|
]);
|
|
}
|
|
|
|
public function audit()
|
|
{
|
|
if ($this->request->isAjax()) {
|
|
$post = $this->request->post();
|
|
$result = MallNewsLogic::edit($post);
|
|
if ($result['code'] == 1) {
|
|
return JsonServer::success('修改成功');
|
|
}
|
|
return JsonServer::error($result['msg']);
|
|
}
|
|
|
|
$id = $this->request->get('id');
|
|
return view('', [
|
|
'detail' => MallNewsLogic::detail($id),
|
|
'max_upload_size' => MallNewsLogic::$MAX_UPLOAD_SIZE . 'Mb',
|
|
'max_upload_file' => MallNewsLogic::$MAX_UPLOAD_FILE,
|
|
]);
|
|
}
|
|
|
|
// 上传视频到OSS
|
|
public function uploadVideo()
|
|
{
|
|
$result = MallNewsLogic::uploadVideo();
|
|
if ($result['code'] == 1) {
|
|
return JsonServer::success('', $result['data']);
|
|
}
|
|
return JsonServer::error('', $result['msg']);
|
|
}
|
|
|
|
// 删除视频
|
|
public function delVideo()
|
|
{
|
|
if ($this->request->isAjax()) {
|
|
$file = $this->request->post('videoFile');
|
|
MallNewsLogic::delVideo($file);
|
|
}
|
|
}
|
|
|
|
// 删除文章
|
|
public function del()
|
|
{
|
|
if ($this->request->isAjax()) {
|
|
$post = $this->request->post();
|
|
$result = MallNewsLogic::del($post['id']);
|
|
if ($result) {
|
|
return JsonServer::success('删除成功');
|
|
}
|
|
|
|
return JsonServer::error('删除失败');
|
|
}
|
|
}
|
|
|
|
// 选择商品
|
|
public function goods()
|
|
{
|
|
if ($this->request->isAjax()) {
|
|
$get = $this->request->get();
|
|
return JsonServer::success('', GoodsLogic::lists($get));
|
|
}
|
|
|
|
return view();
|
|
}
|
|
} |