Anyon 5 rokov pred
rodič
commit
adf29036b6

+ 32 - 31
app/admin/controller/Login.php

@@ -45,38 +45,39 @@ class Login extends Controller
                 $this->devmode = SystemService::instance()->checkRunMode('dev');
                 $this->fetch();
             }
+        } else {
+            $data = $this->_vali([
+                'username.require' => '登录账号不能为空!',
+                'username.min:4'   => '登录账号长度不能少于4位有效字符!',
+                'password.require' => '登录密码不能为空!',
+                'password.min:4'   => '登录密码长度不能少于4位有效字符!',
+                'verify.require'   => '图形验证码不能为空!',
+                'uniqid.require'   => '图形验证标识不能为空!'
+            ]);
+            if (!CaptchaService::instance()->check($data['verify'], $data['uniqid'])) {
+                $this->error('图形验证码验证失败,请重新输入!');
+            }
+            // 用户信息验证
+            $map = ['username' => $data['username'], 'is_deleted' => '0'];
+            $user = $this->app->db->name('SystemUser')->where($map)->order('id desc')->find();
+            if (empty($user)) {
+                $this->error('登录账号或密码错误,请重新输入!');
+            }
+            if (md5("{$user['password']}{$data['uniqid']}") !== $data['password']) {
+                $this->error('登录账号或密码错误,请重新输入!');
+            }
+            if (empty($user['status'])) {
+                $this->error('账号已经被禁用,请联系管理员!');
+            }
+            $this->app->db->name('SystemUser')->where(['id' => $user['id']])->update([
+                'login_ip'  => $this->app->request->ip(),
+                'login_at'  => $this->app->db->raw('now()'),
+                'login_num' => $this->app->db->raw('login_num+1'),
+            ]);
+            $this->app->session->set('user', $user);
+            sysoplog('用户登录', "用户登录系统后台成功");
+            $this->success('登录成功', url('@admin')->build());
         }
-        $data = $this->_vali([
-            'username.require' => '登录账号不能为空!',
-            'username.min:4'   => '登录账号长度不能少于4位有效字符!',
-            'password.require' => '登录密码不能为空!',
-            'password.min:4'   => '登录密码长度不能少于4位有效字符!',
-            'verify.require'   => '图形验证码不能为空!',
-            'uniqid.require'   => '图形验证标识不能为空!'
-        ]);
-        if (!CaptchaService::instance()->check($data['verify'], $data['uniqid'])) {
-            $this->error('图形验证码验证失败,请重新输入!');
-        }
-        // 用户信息验证
-        $map = ['username' => $data['username'], 'is_deleted' => '0'];
-        $user = $this->app->db->name('SystemUser')->where($map)->order('id desc')->find();
-        if (empty($user)) {
-            $this->error('登录账号或密码错误,请重新输入!');
-        }
-        if (md5("{$user['password']}{$data['uniqid']}") !== $data['password']) {
-            $this->error('登录账号或密码错误,请重新输入!');
-        }
-        if (empty($user['status'])) {
-            $this->error('账号已经被禁用,请联系管理员!');
-        }
-        $this->app->db->name('SystemUser')->where(['id' => $user['id']])->update([
-            'login_ip'  => $this->app->request->ip(),
-            'login_at'  => $this->app->db->raw('now()'),
-            'login_num' => $this->app->db->raw('login_num+1'),
-        ]);
-        $this->app->session->set('user', $user);
-        sysoplog('用户登录', "用户登录系统后台成功");
-        $this->success('登录成功', url('@admin')->build());
     }
 
     /**

+ 4 - 9
app/wechat/view/news/form.html

@@ -99,7 +99,8 @@
 
             function apply(list) {
                 if (list.length < 1) list.push({
-                    title: '新建图文', author: '管理员', content: '文章内容', read_num: 0, local_url: '__ROOT__/static/theme/img/image.png',
+                    title: '新建图文', author: '管理员', content: '文章内容',
+                    read_num: 0, local_url: '__ROOT__/static/theme/img/image.png',
                 });
                 for (var i in list) {
                     list[i].active = false;
@@ -110,10 +111,11 @@
                 $rootScope.setItemValue('active', true);
                 $('.layui-card-body.layui-hide').removeClass('layui-hide');
                 setTimeout(function () {
+                    if (editor) editor.destroy();
                     editor = window.createEditor('[name="content"]');
                     editor.setData($rootScope.item.content);
                     $vali.checkAllInput();
-                }, 200);
+                }, 100);
             }
 
             $rootScope.upItem = function (index, $event) {
@@ -126,7 +128,6 @@
                 }
                 apply(tmp);
             };
-
             $rootScope.dnItem = function (index, $event) {
                 $event.stopPropagation();
                 var tmp = [], cur = $rootScope.list[index];
@@ -137,14 +138,12 @@
                 }
                 apply(tmp);
             };
-
             $rootScope.delItem = function (index, $event) {
                 $event.stopPropagation();
                 var list = $rootScope.list, temp = [];
                 for (var i in list) (parseInt(i) !== parseInt(index)) && temp.push(list[i]);
                 apply(temp);
             };
-
             $rootScope.setItem = function (index, $event) {
                 $event.stopPropagation();
                 $vali.checkAllInput();
@@ -161,12 +160,10 @@
                     $rootScope.setItemValue('active', true);
                 }
             };
-
             $rootScope.setItemValue = function (name, value) {
                 $rootScope.item[name] = value;
                 $rootScope.item.style = "background-image:url('" + $rootScope.item.local_url + "')";
             };
-
             $rootScope.addItem = function () {
                 if ($rootScope.list.length > 7) {
                     return $.msg.tips('最多允许增加7篇文章哦!');
@@ -180,7 +177,6 @@
                     style: "background-image:url('__ROOT__/static/theme/img/image.png')"
                 });
             };
-
             $rootScope.submit = function () {
                 $vali.checkAllInput();
                 if ($form.find('.validate-error').size() > 0) {
@@ -201,7 +197,6 @@
                 });
                 $.form.load('{:request()->url()}', {data: data}, "post");
             };
-
             $('[name="local_url"]').on('change', function (value) {
                 value = this.value;
                 $rootScope.$apply(function () {