Jonlin 6 years ago
parent
commit
3b430a970f

+ 4 - 0
application/admin/controller/Accounts.php

@@ -158,6 +158,10 @@ class Accounts extends Base
                 }
             }
 
+            if($param['label_id'] == 0){
+                return json(['code' => -10, 'data' => '', 'msg' => '请选择用户标签']);
+            }
+
             $info['nick_name'] = $param['nick_name'];
             $info['account_email'] = $param['account_email'];
             $info['account_phone'] = $param['account_phone'];

+ 25 - 1
application/admin/controller/Material.php

@@ -6,6 +6,10 @@
  */
 namespace app\admin\controller;
 
+use think\Loader;
+use think\Controller;
+use think\Db;
+
 class Material extends Base
 {
     // 素材列表
@@ -122,7 +126,27 @@ class Material extends Base
                 return json(['code' => -2, 'data' => '', 'msg' => $e->getMessage()]);
             }
 
-            return json(['code' => 1, 'data' => url('material/index'), 'msg' => '删除素材成功']);
+            return json(['code' => 1, 'data' => url('material/index'), 'msg' => '删除图片成功']);
+        }
+    }
+
+    // 删除全部素材
+    public function delAll()
+    {
+        if(request()->isAjax()){
+            $material = db('material')->select();
+            try{
+                for($i=0;$i<count($material);$i++){
+                    $name = './'.$material[$i]['url'];
+                    if (file_exists($name)) {
+                        unlink($name);
+                    }
+                }
+                Db::execute("truncate table ws_material");
+            }catch(\Exception $e){
+                return json(['code' => -2, 'data' => '', 'msg' => $e->getMessage()]);
+            }
+            return json(['code' => 1, 'data' => url('material/index'), 'msg' => '删除全部图片成功']);
         }
     }
 

+ 25 - 21
application/admin/view/material/index.html

@@ -45,27 +45,13 @@
                 </button>
             </a>
             <!--搜索框开始-->
-            <!--<form id='commentForm' role="form" method="post" class="form-inline pull-right">-->
-                <!--<div class="content clearfix m-b">-->
-                    <!--<div class="form-group">-->
-                        <!--<div class="input-group col-sm-4 layui-form" style="width: 70px;">-->
-                            <!--<input type="hidden" id="user" value="user_account"/>-->
-                            <!--<select lay-verify="required" lay-filter="user">-->
-                                <!--<option value="user_account">账号</option>-->
-                                <!--<option value="user_name">名称</option>-->
-                            <!--</select>-->
-                        <!--</div>-->
-                    <!--</div>-->
-                    <!--<div class="form-group">-->
-                        <!--&lt;!&ndash;<label>客服名:</label>&ndash;&gt;-->
-                        <!--<input type="text" class="form-control" id="username" name="user_name">-->
-                    <!--</div>-->
-                    <!--<div class="form-group">-->
-                        <!--<button class="btn btn-primary" type="button" style="margin-top:5px" id="search"><strong>搜 索</strong>-->
-                        <!--</button>-->
-                    <!--</div>-->
-                <!--</div>-->
-            <!--</form>-->
+            <form id='commentForm' role="form" method="post" class="form-inline pull-right">
+                <div class="content clearfix m-b" style="margin-top:5px">
+                    <div class="form-group" style="margin-left: 20px;">
+                        <a href="javascript:allDel()" class="" style="margin-top:5px;" ><button type="button" class="btn btn-danger btn-sm">全部删除</button></a>
+                    </div>
+                </div>
+            </form>
             <!--搜索框结束-->
             <!--<div style="margin-bottom: 20px;">{$allmaterial}1</div>-->
             <div style="margin-top: 20px;">
@@ -191,6 +177,24 @@
         })
 
     }
+    function allDel(){
+        layer.confirm('确认删除全部图片?', {icon: 3, title:'提示'}, function(index){
+            //do something
+            $.getJSON("{:url('material/delAll')}", function(res){
+                if(1 == res.code){
+                    layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
+                        window.location.href = '/admin/material/index.html';
+                    });
+                }else if(111 == res.code){
+                    window.location.reload();
+                }else{
+                    layer.alert(res.msg, {title: '友情提示', icon: 2});
+                }
+            });
+            layer.close(index);
+        })
+    }
+
 </script>
 </body>
 </html>