hrjy 2 years ago
parent
commit
152d2b7106

+ 17 - 0
app/admin/controller/system/SystemStore.php

@@ -103,6 +103,23 @@ class SystemStore extends AuthController
         }
     }
 
+    /**
+     * 设置单个门店是否显示
+     * @param string $is_show
+     * @param string $id
+     * @return json
+     */
+    public function set_period($period = '', $id = '')
+    {
+        ($period == '' || $id == '') && JsonService::fail('缺少参数');
+        $res = SystemStoreModel::where(['id' => $id])->update(['period' => (int)$period]);
+        if ($res) {
+            return JsonService::successful($period == 1 ? '设置推荐成功' : '设置取消成功');
+        } else {
+            return JsonService::fail($period == 1 ? '设置显示失败' : '设置隐藏失败');
+        }
+    }
+
     /**
      * 位置选择
      * @return string|void

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

@@ -63,6 +63,10 @@
                         <input type='checkbox' name='id' lay-skin='switch' value="{{d.id}}" lay-filter='is_show'
                                lay-text='显示|隐藏' {{ d.is_show== 1 ? 'checked' : '' }}>
                     </script>
+                    <script type="text/html" id="period">
+                        <input type='checkbox' name='id' lay-skin='switch' value="{{d.id}}" lay-filter='period'
+                               lay-text='是|否' {{ d.period== 1 ? 'checked' : '' }}>
+                    </script>
                     <script type="text/html" id="act">
                         <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" lay-event='edit'>
                             编辑门店
@@ -100,6 +104,7 @@
             {field: 'day_time', title: '营业时间', width: '15%'},
             // {field: 'valid_time', title: '核销有效日期', width: '11%'},
             {field: 'status', title: '是否显示', templet: "#checkboxstatus", width: '8%'},
+            {field: 'period', title: '本期推荐', templet: "#period", width: '8%'},
             {field: 'right', title: '操作', align: 'center', toolbar: '#act', width: '14%'},
         ];
     });
@@ -136,6 +141,30 @@
             });
         }
     });
+    //门店是否显示
+    layList.switch('period', function (odj, value) {
+        if (odj.elem.checked == true) {
+            layList.baseGet(layList.Url({
+                c: 'system.system_store',
+                a: 'set_period',
+                p: {period: 1, id: value}
+            }), function (res) {
+                layList.msg(res.msg, function () {
+                    layList.reload();
+                });
+            });
+        } else {
+            layList.baseGet(layList.Url({
+                c: 'system.system_store',
+                a: 'set_period',
+                p: {period: 0, id: value}
+            }), function (res) {
+                layList.msg(res.msg, function () {
+                    layList.reload();
+                });
+            });
+        }
+    });
     //点击事件绑定
     layList.tool(function (event, data, obj) {
         switch (event) {

+ 4 - 3
app/api/controller/PublicController.php

@@ -290,7 +290,7 @@ class PublicController
      */
     public function store_list(Request $request)
     {
-        list($latitude, $longitude, $page, $limit, $cate_id, $name, $sales,$address) = UtilService::getMore([
+        list($latitude, $longitude, $page, $limit, $cate_id, $name, $sales,$address,$period) = UtilService::getMore([
             ['latitude', ''],
             ['longitude', ''],
             ['page', 1],
@@ -298,7 +298,8 @@ class PublicController
             ['cate_id'],
             ['name', ''],
             ['sales', ''],
-            ['address']
+            ['address'],
+            ['period']
         ], $request, true);
 //        if (!empty($address)){
 //            // 地址获取经纬度
@@ -308,7 +309,7 @@ class PublicController
 //            $longitude = $location->lng;
 //        }
         if ($address) $address = urldecode($address);
-        $list = SystemStore::lst($latitude, $longitude, $page, $limit, $cate_id,$name, $sales,$address);
+        $list = SystemStore::lst($latitude, $longitude, $page, $limit, $cate_id,$name, $sales,$address,$period);
         if (!$list){
             $list = [];
         } else{

+ 2 - 1
app/models/system/SystemStore.php

@@ -144,7 +144,7 @@ class SystemStore extends BaseModel
      * 门店列表
      * @return mixed
      */
-    public static function lst($latitude, $longitude, $page, $limit,$cate_id, $name, $sales, $address)
+    public static function lst($latitude, $longitude, $page, $limit,$cate_id, $name, $sales, $address, $period)
     {
         $model = new self();
         $model = $model->where('is_del', 0);
@@ -156,6 +156,7 @@ class SystemStore extends BaseModel
         if ($sales) $model = $model->order('sales DESC');
         if ($cate_id) $model = $model->where('cate_id', $cate_id);
         if ($address) $model = $model->where('address', 'like', '%'.$address.'%');
+        if ($period) $model = $model->where('period', 1);
         $list = $model->page((int)$page, (int)$limit)
             ->select()
             ->hidden(['is_show', 'is_del'])