quguofeng 1 year ago
parent
commit
2c1ee77a78

+ 7 - 5
.idea/workspace.xml

@@ -3,6 +3,8 @@
   <component name="ChangeListManager">
     <list default="true" id="1a36929e-c054-4875-a943-593a74e55fa4" name="Default Changelist" comment="">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/application/nutrition/controller/TopSearch.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/nutrition/controller/TopSearch.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/application/nutrition/view/top_search/form.html" beforeDir="false" afterPath="$PROJECT_DIR$/application/nutrition/view/top_search/form.html" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -462,7 +464,7 @@
       <workItem from="1698193315048" duration="3089000" />
       <workItem from="1698278978424" duration="6616000" />
       <workItem from="1698366118916" duration="3362000" />
-      <workItem from="1698402098788" duration="371000" />
+      <workItem from="1698402098788" duration="3004000" />
     </task>
     <servers />
   </component>
@@ -592,10 +594,10 @@
       <screen x="0" y="0" width="2560" height="1400" />
     </state>
     <state x="1245" y="552" key="#com.intellij.fileTypes.FileTypeChooser/0.0.2560.1400@0.0.2560.1400" timestamp="1695006721171" />
-    <state x="948" y="400" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog" timestamp="1697003431551">
+    <state x="948" y="400" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog" timestamp="1698629360841">
       <screen x="0" y="0" width="2194" height="1194" />
     </state>
-    <state x="948" y="400" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog/0.0.2194.1194@0.0.2194.1194" timestamp="1697003431551" />
+    <state x="948" y="400" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog/0.0.2194.1194@0.0.2194.1194" timestamp="1698629360841" />
     <state x="1106" y="469" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog/0.0.2560.1400@0.0.2560.1400" timestamp="1694673363941" />
     <state x="360" y="413" width="1942" height="1088" key="DiffContextDialog" timestamp="1694419923508">
       <screen x="0" y="0" width="2560" height="1400" />
@@ -618,10 +620,10 @@
       <screen x="0" y="0" width="2194" height="1194" />
     </state>
     <state x="999" y="516" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2/0.0.2194.1194@0.0.2194.1194" timestamp="1696929992529" />
-    <state x="588" y="133" width="1206" height="901" key="find.popup" timestamp="1698135113221">
+    <state x="588" y="133" width="1206" height="901" key="find.popup" timestamp="1698627737634">
       <screen x="0" y="0" width="2194" height="1194" />
     </state>
-    <state x="588" y="133" width="1206" height="901" key="find.popup/0.0.2194.1194@0.0.2194.1194" timestamp="1698135113221" />
+    <state x="588" y="133" width="1206" height="901" key="find.popup/0.0.2194.1194@0.0.2194.1194" timestamp="1698627737634" />
     <state x="686" y="156" width="1407" height="1056" key="find.popup/0.0.2560.1400@0.0.2560.1400" timestamp="1694499272246" />
     <state x="1282" y="549" key="ftp.server.browser" timestamp="1693012785412">
       <screen x="0" y="0" width="2560" height="1400" />

+ 28 - 37
application/nutrition/controller/TopSearch.php

@@ -1,6 +1,7 @@
 <?php
 namespace app\nutrition\controller;
 use library\Controller;
+use think\Db;
 
 /**
  * 商品热搜管理
@@ -15,7 +16,21 @@ class TopSearch extends Controller
      * @var string
      */
     protected $table = 'TopSearch';
-
+    protected $module;
+    function initialize()
+    {
+        $this->module = array(
+            'video'=>'视频',
+            'article'=>'图文',
+            'datum'=>'资料',
+            'press'=>'新闻',
+            'demand'=>'需求',
+            'forum'=>'问答',
+            'goods'=>'商品',
+            'recruit'=>'招聘',
+            'supplier_goods'=>'供应商产品',
+        );
+    }
     /**
      * 商品热搜列表
      * @auth true
@@ -29,19 +44,7 @@ class TopSearch extends Controller
     public function index()
     {
         $this->title = '热搜列表';
-        $this->type_desc = $type_desc = [
-            0=>"全部",
-            1=>'视频',
-            2=>'图文',
-            3=>'资料',
-            4=>'新闻',
-            5=>'需求',
-            6=>'问答',
-            7=>'商品',
-            8=>'招聘',
-            9=>'供应商',
-            10=>'供应商产品',
-        ];
+        $this->type_desc = $this->module;
         $query = $this->_query($this->table)->where('is_deleted',0);
         $query->like('title');
         $query->order('hot_num desc, sort desc,id desc')->page();
@@ -60,13 +63,6 @@ class TopSearch extends Controller
     {
 
     }
-
-
-
-
-
-
-
     /**
      * 添加商品热搜
      * @auth true
@@ -83,7 +79,6 @@ class TopSearch extends Controller
         $this->_form($this->table, 'form');
     }
 
-
     /**
      * 编辑商品热搜
      * @auth true
@@ -99,9 +94,17 @@ class TopSearch extends Controller
         $this->title = '编辑';
         $this->_form($this->table, 'form');
     }
-
-
-
+    /**
+     * 表单数据处理
+     * @auth true
+     * @menu true
+     * @param array $data
+     */
+    protected function _form_filter(&$data)
+    {
+        $data['create_at'] = date('Y-m-d H:i:s');
+        $this->type_desc = $this->module;
+    }
     /**
      * 启用
      * @auth true
@@ -142,16 +145,4 @@ class TopSearch extends Controller
         $this->_save($this->table, ['is_deleted' => 1]);
     }
 
-
-    /**
-     * 表单数据处理
-     * @auth true
-     * @menu true
-     * @param array $data
-     */
-    protected function _form_filter(&$data)
-    {
-        $data['create_at'] = date('Y-m-d H:i:s');
-    }
-
 }

+ 18 - 1
application/nutrition/view/top_search/form.html

@@ -8,6 +8,23 @@
                     <input name="title" maxlength="60"  value='{$vo.title|default=""}' placeholder="请输入标题" class="layui-input">
                 </div>
             </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label label-required">模块</label>
+                <div class="layui-input-inline">
+                    <select name="module" lay-filter ="module">
+                        {foreach $type_desc as $ck=>$cv}
+                        {if  isset($vo.module) && $vo.module == $cv}
+                        <option selected  value="{$ck}">{$cv}</option>
+                        {else}
+                        <option value="{$ck}">{$cv}</option>
+                        {/if}
+                        {/foreach}
+                    </select>
+                </div>
+
+            </div>
+
             <div class="layui-form-item">
                 <label class="layui-form-label label-required">排序</label>
                 <div class="layui-input-block">
@@ -30,4 +47,4 @@
     <script>
         window.form.render();
     </script>
-</div>
+</div>