hrjy 3 år sedan
förälder
incheckning
9856e2e87d

+ 59 - 1
app/admin/controller/system/SystemStore.php

@@ -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('上传失败');
+    }
+
 }

+ 15 - 1
app/admin/view/system/system_store/add.php

@@ -36,6 +36,18 @@
                                     </i-Col>
                                 </Row>
                             </Form-Item>
+                            <Form-Item>
+                                <Row>
+                                    <i-Col span="13">
+                                        <span>门店分类:</span>
+                                        <i-Select placeholder="门店分类" v-model="form.cate_id" style="width: 80%" type="text">
+                                            {volist name="cate" id="vo"}
+                                            <i-option  :value="{$vo.id}">{$vo.cate_name}</i-option>
+                                            {/volist}
+                                        </i-Select>
+                                    </i-Col>
+                                </Row>
+                            </Form-Item>
                             <Form-Item>
                                 <Row>
                                     <i-Col span="13">
@@ -160,6 +172,7 @@
                         latlng:storeData.latlng || '',
                         valid_time:storeData.valid_time || [],
                         day_time:storeData.day_time || [],
+                        cate_id:storeData.cate_id || '',
                     },
                     visible:false,
                 }
@@ -211,13 +224,14 @@
                     var that = this;
                     if(!that.form.name) return  $eb.message('error','请填写门店行名称');
                     if(!that.form.phone) return  $eb.message('error','请输入手机号码');
-                    if(!that.isPhone(that.form.phone)) return  $eb.message('error','请输入正确的手机号码');
+                    // if(!that.isPhone(that.form.phone)) return  $eb.message('error','请输入正确的手机号码');
                     if(!that.form.address) return  $eb.message('error','请选择门店地址');
                     if(!that.form.detailed_address) return  $eb.message('error','请填写门店详细地址');
                     if(!that.form.image) return  $eb.message('error','请选择门店logo');
                     if(!that.form.valid_time) return  $eb.message('error','请选择核销时效');
                     if(!that.form.day_time) return  $eb.message('error','请选择门店营业时间');
                     if(!that.form.latlng) return  $eb.message('error','请选择门店经纬度!');
+                    if(!that.form.cate_id) return  $eb.message('error','请选择门店分类');
                     var index = layer.load(1, {
                         shade: [0.5,'#fff']
                     });

+ 8 - 0
app/admin/view/system/system_store/index.php

@@ -67,6 +67,9 @@
                         <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" lay-event='edit'>
                             编辑门店
                         </button>
+                        <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" lay-event='image'>
+                            店内图片
+                        </button>
                         <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" lay-event='del'>
                             {{# if(d.is_del){ }}
                             恢复门店
@@ -90,8 +93,10 @@
             {field: 'id', title: 'ID', sort: true, event: 'id', width: '4%'},
             {field: 'image', title: '门店图片', templet: '#headimgurl', width: '6%'},
             {field: 'name', title: '门店名称', width: '10%'},
+            {field: 'cate_name', title: '分类', width: '10%'},
             {field: 'phone', title: '门店电话', width: '10%'},
             {field: 'address', title: '地址', templet: '#address'},
+            {field: 'count', title: '销量'},
             {field: 'day_time', title: '营业时间', width: '15%'},
             // {field: 'valid_time', title: '核销有效日期', width: '11%'},
             {field: 'status', title: '是否显示', templet: "#checkboxstatus", width: '8%'},
@@ -157,6 +162,9 @@
             case 'edit':
                 $eb.createModalFrame(data.name + '-编辑', layList.U({a: 'add', q: {id: data.id}}), {h: 700, w: 1100});
                 break;
+            case 'image':
+                $eb.createModalFrame(data.name + '-上传图片', layList.U({a: 'up', q: {id: data.id}}), {h: 700, w: 1100});
+                break;
         }
     })
 </script>

+ 20 - 0
app/api/controller/PublicController.php

@@ -4,7 +4,9 @@ namespace app\api\controller;
 
 use app\admin\model\system\SystemAttachment;
 use app\models\store\StoreCategory;
+use app\models\store\StoreCoupon;
 use app\models\store\StoreCouponIssue;
+use app\models\store\StoreOrder;
 use app\models\store\StoreProduct;
 use app\models\store\StoreService;
 use app\models\system\Express;
@@ -352,4 +354,22 @@ class PublicController
 
     }
 
+
+    /**
+     * 门店详情
+     * @param $id
+     * @return mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function store_details($id)
+    {
+        $data = SystemStore::find($id);
+        $data = empty($data) ? [] : $data->toArray();
+        $data['slider_image'] = json_decode($data['slider_image']);
+        $data['images'] = json_decode($data['gatehead']);
+        return app('json')->successful($data);
+    }
+
 }

+ 1 - 0
route/api/route.php

@@ -259,6 +259,7 @@ Route::group(function () {
 
     //门店列表
     Route::get('store_list', 'PublicController/store_list')->name('storeList');
+    Route::get('store_details/:id', 'PublicController/store_details')->name('store_details');
     //获取城市列表
     Route::get('city_list', 'PublicController/city_list')->name('cityList');
     Route::get('version', 'PublicController/version')->name('version'); // 版本更新