|
@@ -1,4 +1,5 @@
|
|
|
<?php
|
|
<?php
|
|
|
|
|
+
|
|
|
namespace app\admin\controller\user;
|
|
namespace app\admin\controller\user;
|
|
|
|
|
|
|
|
use app\admin\controller\AuthController;
|
|
use app\admin\controller\AuthController;
|
|
@@ -13,10 +14,12 @@ use crmeb\services\{ExpressService,
|
|
|
FormBuilder as Form,
|
|
FormBuilder as Form,
|
|
|
CacheService,
|
|
CacheService,
|
|
|
UtilService as Util,
|
|
UtilService as Util,
|
|
|
- JsonService as Json};
|
|
|
|
|
|
|
+ JsonService as Json
|
|
|
|
|
+};
|
|
|
use app\admin\model\system\{SystemAdmin,
|
|
use app\admin\model\system\{SystemAdmin,
|
|
|
SystemAttachment as SystemAttachmentModel,
|
|
SystemAttachment as SystemAttachmentModel,
|
|
|
- SystemAttachmentCategory as Category};
|
|
|
|
|
|
|
+ SystemAttachmentCategory as Category
|
|
|
|
|
+};
|
|
|
use think\Db;
|
|
use think\Db;
|
|
|
use think\facade\Route as Url;
|
|
use think\facade\Route as Url;
|
|
|
use think\facade\Validate;
|
|
use think\facade\Validate;
|
|
@@ -60,6 +63,7 @@ class Out extends AuthController
|
|
|
$f[] = Form::input('name', '名称')->col(12);
|
|
$f[] = Form::input('name', '名称')->col(12);
|
|
|
$f[] = Form::textarea('info', '简介');
|
|
$f[] = Form::textarea('info', '简介');
|
|
|
$f[] = Form::number('number', '达标额度')->col(12);
|
|
$f[] = Form::number('number', '达标额度')->col(12);
|
|
|
|
|
+ $f[] = Form::frameFiles('pics', '轮播图', Url::buildUrl('admin/widget.images/index', array('fodder' => 'images')))->maxLength(5)->icon('image')->width('100%')->height('500px');
|
|
|
$f[] = Form::radio('status', '状态', 1)->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]]);
|
|
$f[] = Form::radio('status', '状态', 1)->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]]);
|
|
|
$form = Form::make_post_form('添加', $f, Url::buildUrl('save'));
|
|
$form = Form::make_post_form('添加', $f, Url::buildUrl('save'));
|
|
|
$this->assign(compact('form'));
|
|
$this->assign(compact('form'));
|
|
@@ -69,12 +73,13 @@ class Out extends AuthController
|
|
|
|
|
|
|
|
public function save()
|
|
public function save()
|
|
|
{
|
|
{
|
|
|
- $mode = new model;
|
|
|
|
|
|
|
+ $mode = new model;
|
|
|
$data = Util::postMore([
|
|
$data = Util::postMore([
|
|
|
'name',
|
|
'name',
|
|
|
'info',
|
|
'info',
|
|
|
'number',
|
|
'number',
|
|
|
'status',
|
|
'status',
|
|
|
|
|
+ ['pics', []]
|
|
|
]);
|
|
]);
|
|
|
$validate = Validate::rule('name', 'require')->rule([
|
|
$validate = Validate::rule('name', 'require')->rule([
|
|
|
'name' => 'require',
|
|
'name' => 'require',
|
|
@@ -84,13 +89,14 @@ class Out extends AuthController
|
|
|
'name.require' => '名称不能为空',
|
|
'name.require' => '名称不能为空',
|
|
|
'number.require' => '达标额度不能为空',
|
|
'number.require' => '达标额度不能为空',
|
|
|
]);
|
|
]);
|
|
|
|
|
+ $data['pics'] = implode(',', $data['pics']);
|
|
|
if (!$validate->check($data)) {
|
|
if (!$validate->check($data)) {
|
|
|
return Json::fail($validate->getError());
|
|
return Json::fail($validate->getError());
|
|
|
}
|
|
}
|
|
|
$res = $mode->save($data);
|
|
$res = $mode->save($data);
|
|
|
- if ($res){
|
|
|
|
|
|
|
+ if ($res) {
|
|
|
return Json::success('添加成功!');
|
|
return Json::success('添加成功!');
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
|
|
return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -108,9 +114,9 @@ class Out extends AuthController
|
|
|
$model = new model;
|
|
$model = new model;
|
|
|
|
|
|
|
|
$res = $model->where('id', $id)->delete();
|
|
$res = $model->where('id', $id)->delete();
|
|
|
- if ($res){
|
|
|
|
|
|
|
+ if ($res) {
|
|
|
return Json::success('删除成功!');
|
|
return Json::success('删除成功!');
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
|
|
return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -120,12 +126,12 @@ class Out extends AuthController
|
|
|
public function set_status($id, $status)
|
|
public function set_status($id, $status)
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
- if (empty($id))return Json::fail('修改失败');
|
|
|
|
|
|
|
+ if (empty($id)) return Json::fail('修改失败');
|
|
|
|
|
|
|
|
$res = model::update(['status' => $status, 'id' => $id]);
|
|
$res = model::update(['status' => $status, 'id' => $id]);
|
|
|
- if ($res){
|
|
|
|
|
|
|
+ if ($res) {
|
|
|
return Json::success('修改成功!');
|
|
return Json::success('修改成功!');
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
|
|
return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -135,8 +141,9 @@ class Out extends AuthController
|
|
|
if (!$id) Json::fail('数据不存在');
|
|
if (!$id) Json::fail('数据不存在');
|
|
|
$data = model::find($id);
|
|
$data = model::find($id);
|
|
|
$f = [];
|
|
$f = [];
|
|
|
- $f[] = Form::input('name', '名称',$data->getData('name'))->col(12);
|
|
|
|
|
- $f[] = Form::textarea('info', '介绍',$data->getData('info'));
|
|
|
|
|
|
|
+ $f[] = Form::input('name', '名称', $data->getData('name'))->col(12);
|
|
|
|
|
+ $f[] = Form::textarea('info', '介绍', $data->getData('info'));
|
|
|
|
|
+ $f[] = Form::frameFiles('pics', '轮播图', Url::buildUrl('admin/widget.images/index', array('fodder' => 'images')), explode(',', $data->getData('pics')))->maxLength(5)->icon('image')->width('100%')->height('500px');
|
|
|
$f[] = Form::number('number', '达标额度', $data->getData('number'))->col(12);
|
|
$f[] = Form::number('number', '达标额度', $data->getData('number'))->col(12);
|
|
|
$f[] = Form::radio('status', '状态', $data->getData('status'))->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]]);
|
|
$f[] = Form::radio('status', '状态', $data->getData('status'))->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]]);
|
|
|
|
|
|
|
@@ -154,6 +161,7 @@ class Out extends AuthController
|
|
|
'info',
|
|
'info',
|
|
|
'status',
|
|
'status',
|
|
|
'number',
|
|
'number',
|
|
|
|
|
+ ['pics', []]
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
$validate = Validate::rule('name', 'require')->rule([
|
|
$validate = Validate::rule('name', 'require')->rule([
|
|
@@ -165,17 +173,44 @@ class Out extends AuthController
|
|
|
'number.require' => '达标数量不能为空',
|
|
'number.require' => '达标数量不能为空',
|
|
|
|
|
|
|
|
]);
|
|
]);
|
|
|
|
|
+ $data['pics'] = implode(',', $data['pics']);
|
|
|
if (!$validate->check($data)) {
|
|
if (!$validate->check($data)) {
|
|
|
return Json::fail($validate->getError());
|
|
return Json::fail($validate->getError());
|
|
|
}
|
|
}
|
|
|
$res = model::update($data);
|
|
$res = model::update($data);
|
|
|
- if ($res){
|
|
|
|
|
|
|
+ if ($res) {
|
|
|
return Json::success('修改成功!');
|
|
return Json::success('修改成功!');
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
|
|
return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function edit_content($id)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (!$id) return $this->failed('数据不存在');
|
|
|
|
|
+ $seckill = model::get($id);
|
|
|
|
|
+ if (!$seckill) return Json::fail('数据不存在!');
|
|
|
|
|
+ $this->assign([
|
|
|
|
|
+ 'content' => htmlspecialchars_decode($seckill['content']),
|
|
|
|
|
+ 'field' => 'description',
|
|
|
|
|
+ 'action' => Url::buildUrl('change_field', ['id' => $id, 'field' => 'content'])
|
|
|
|
|
+ ]);
|
|
|
|
|
+ return $this->fetch('public/edit_content');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function change_field($id)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (!$id) return $this->failed('数据不存在');
|
|
|
|
|
+ $seckill = model::get($id);
|
|
|
|
|
+ if (!$seckill) return Json::fail('数据不存在!');
|
|
|
|
|
+ $data['content'] = request()->post('content');
|
|
|
|
|
+ $res = model::edit($data, $id);
|
|
|
|
|
+ if ($res)
|
|
|
|
|
+ return Json::successful('添加成功');
|
|
|
|
|
+ else
|
|
|
|
|
+ return Json::fail('添加失败');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|