|
|
@@ -3,10 +3,13 @@
|
|
|
namespace app\admin\controller\system;
|
|
|
|
|
|
use app\admin\controller\AuthController;
|
|
|
+use app\admin\model\store\StoreCate;
|
|
|
use crmeb\services\JsonService;
|
|
|
use crmeb\services\JsonService as Json;
|
|
|
use app\admin\model\system\SystemStore as SystemStoreModel;
|
|
|
use crmeb\services\UtilService;
|
|
|
+use crmeb\services\FormBuilder as Form;
|
|
|
+use think\facade\Route as Url;
|
|
|
|
|
|
/**
|
|
|
* 门店管理控制器
|
|
|
@@ -55,7 +58,8 @@ class SystemStore extends AuthController
|
|
|
public function add($id = 0)
|
|
|
{
|
|
|
$store = SystemStoreModel::getStoreDispose($id);
|
|
|
- $this->assign(compact('store'));
|
|
|
+ $cate = StoreCate::select();
|
|
|
+ $this->assign(compact('store', 'cate'));
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
|
|
|
@@ -127,6 +131,7 @@ class SystemStore extends AuthController
|
|
|
['latlng', ''],
|
|
|
['valid_time', []],
|
|
|
['day_time', []],
|
|
|
+ ['cate_id', '']
|
|
|
]);
|
|
|
SystemStoreModel::beginTrans();
|
|
|
try {
|
|
|
@@ -166,4 +171,57 @@ class SystemStore extends AuthController
|
|
|
return JsonService::fail($e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 上传店内图片
|
|
|
+ * @param $id
|
|
|
+ * @return string
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
+ public function up($id)
|
|
|
+ {
|
|
|
+ if (!$id) Json::fail('数据不存在');
|
|
|
+ $data = SystemStoreModel::where('id', $id)->find();
|
|
|
+ $f = [];
|
|
|
+ if ($data['slider_image'] and $data['gatehead']){
|
|
|
+ $f[] = Form::frameImages('gatehead', '门头图(640*640px)', Url::buildUrl('admin/widget.images/index', array('fodder' => 'gatehead')), json_decode($data->getData('gatehead'), 1))->maxLength(5)->icon('images')->width('100%')->height('500px');
|
|
|
+ $f[] = Form::frameImages('slider_image', '店内图片(640*640px)', Url::buildUrl('admin/widget.images/index', array('fodder' => 'slider_image')), json_decode($data->getData('slider_image'), 1))->maxLength(5)->icon('images')->width('100%')->height('500px');
|
|
|
+ }else{
|
|
|
+ $f[] = Form::frameImages('gatehead', '门头图(640*640px)', Url::buildUrl('admin/widget.images/index', array('fodder' => 'gatehead')))->maxLength(5)->icon('images')->width('100%')->height('500px');
|
|
|
+ $f[] = Form::frameImages('slider_image', '店内图片(640*640px)', Url::buildUrl('admin/widget.images/index', array('fodder' => 'slider_image')))->maxLength(5)->icon('images')->width('100%')->height('500px');
|
|
|
+ }
|
|
|
+ $f[] = Form::hidden('id', $id);
|
|
|
+ $form = Form::make_post_form('修改', $f, Url::buildUrl('image_save', compact('id')));
|
|
|
+ $this->assign(compact('form'));
|
|
|
+ return $this->fetch('public/form-builder');
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加接口
|
|
|
+ * @return void
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
+ public function image_save()
|
|
|
+ {
|
|
|
+
|
|
|
+ $data = UtilService::postMore([
|
|
|
+ ['gatehead', ''],
|
|
|
+ ['slider_image', ''],
|
|
|
+ ['id']
|
|
|
+ ]);
|
|
|
+ if (empty($data['gatehead']) or empty($data['slider_image'])) return JsonService::fail('门头图或店内图不能为空');
|
|
|
+ $store = SystemStoreModel::find($data['id']);
|
|
|
+ $store['gatehead'] = json_encode($data['gatehead']);
|
|
|
+ $store['slider_image'] = json_encode($data['slider_image']);
|
|
|
+
|
|
|
+ $res = $store->save();
|
|
|
+ if ($res) return JsonService::success('上传成功');
|
|
|
+ return JsonService::fail('上传失败');
|
|
|
+ }
|
|
|
+
|
|
|
}
|