Jonlin 6 lat temu
rodzic
commit
190c0d7a64

+ 18 - 3
application/admin/controller/Users.php

@@ -172,6 +172,19 @@ class Users extends Base
         return $this->fetch();
     }
 
+    public function resetPwd(){
+        if(request()->isAjax()){
+            $id = input('param.id/d');
+            $password = md5('123456' . config('salt'));
+            try{
+                db('users')->where('id', $id)->update(['user_pwd' => $password]);
+            }catch(\Exception $e){
+                return json(['code' => -1, 'data' => '', 'msg' => $e->getMessage()]);
+            }
+            return json(['code' => 1, 'data' => 'accounts/index', 'msg' => '重置密码成功']);
+        }
+    }
+
     // 删除客服
     public function delUser()
     {
@@ -211,10 +224,12 @@ class Users extends Base
     // 生成按钮
     private function makeBtn($id)
     {
-        $operate = '<a href="' . url('users/edituser', ['id' => $id]) . '">';
-        $operate .= '<button type="button" class="btn btn-primary btn-sm"><i class="fa fa-paste"></i> 编辑</button></a> ';
+//        $operate = '<a href="' . url('users/edituser', ['id' => $id]) . '">';
+//        $operate .= '<button type="button" class="btn btn-primary btn-sm"><i class="fa fa-paste"></i> 编辑</button></a> ';
+
+        $operate = '<a href="javascript:resetPwd(' . $id . ')"><button type="button" class="btn btn-primary btn-sm"><i class="fa fa-paste"></i> 重置密码</button></a>';
 
-        $operate .= '<a href="javascript:userDel(' . $id . ')"><button type="button" class="btn btn-danger btn-sm">';
+        $operate .= '<a style="margin-left:5px;" href="javascript:userDel(' . $id . ')"><button type="button" class="btn btn-danger btn-sm">';
         $operate .= '<i class="fa fa-trash-o"></i> 删除</button></a> ';
 
         //$operate .= '<a href="javascript:;">';

+ 20 - 0
application/admin/view/users/index.html

@@ -129,6 +129,26 @@
         })
 
     }
+
+    function resetPwd(id){
+        layer.confirm('确认重置密码?', {icon: 3, title:'提示'}, function(index){
+            //do something
+            $.getJSON("{:url('users/resetPwd')}", {'id' : id}, function(res){
+                if(1 == res.code){
+                    layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
+                        initTable();
+                    });
+                }else if(111 == res.code){
+                    window.location.reload();
+                }else{
+                    layer.alert(res.msg, {title: '友情提示', icon: 2});
+                }
+            });
+
+            layer.close(index);
+        })
+
+    }
 </script>
 </body>
 </html>

+ 3 - 0
application/service/controller/Services.php

@@ -38,6 +38,7 @@ class Services extends Base
             $user_job_number = input("param.user_job_number/s");
             $user_email = input("param.user_email/s");
             $phone = input("param.phone/s");
+            $user_avatar = input("param.user_avatar/s");
 
             $username = db('users')->where('user_name', $user_name)->where('id', '<>', $user_id)->find();
             if(!empty($username)){
@@ -54,11 +55,13 @@ class Services extends Base
                 return json(['code' => -3, 'data' => '', 'msg' => '该邮箱已经存在']);
             }
 
+
             // 更新客服信息
             $param = [
                 'user_name' => $user_name,
                 'user_job_number' => $user_job_number,
                 'user_email' => $user_email,
+                'user_avatar' => $user_avatar,
                 'phone' => $phone
             ];
             db('users')->where('id', $user_id)->update($param);