huwhois пре 3 година
родитељ
комит
f8273779f3

+ 8 - 0
app/common.php

@@ -65,3 +65,11 @@ function month_frist_and_last_day($y = "", $m = ""){
     return [ "firstday" => $firstday, "lastday" => $lastday];
 }
 
+/**
+ * 生成随机字符串
+ */
+function generate_stochastic_string($length = 16)
+{
+    $permitted_chars = '0123456789abcdefghijklmnopqrstuvwxyz';
+    return substr(str_shuffle($permitted_chars), 0, $length);
+}

+ 1 - 1
app/common/model/Base.php

@@ -22,7 +22,7 @@ class Base extends model
     }
 
     // 状态修改 1,正常; 2,非正常
-    public static function state($id)
+    public static function state(int $id)
     {
         try {
             $info         = self::find($id);

+ 10 - 19
app/common/model/SysUser.php

@@ -3,34 +3,25 @@
 namespace app\common\model;
 
 // 引入框架内置类
-use think\Model;
-use think\facade\Db;
 use think\facade\Request;
-use think\facade\Event;
+use think\facade\Session;
 
 use app\common\model\SysLoginFail;
 use app\common\model\SysLogin;
-use app\common\model\SysRole;
-use think\facade\Session;
+use app\common\model\Base;
 
-class SysUser extends Model
+class SysUser extends Base
 {
     protected $pk = 'userid';
 
-    public static function queryList($roleid)
+    public function sysRole()
     {
-        if ($roleid == 1) {
-            return Db::table('phome_sys_user')->alias('u')
-                ->join('phome_sys_role r', 'u.roleid = r.roleid')
-                ->field('u.userid,u.username,u.nickname,u.truename,u.email,u.status,u.per_time,u.per_ip,u.login_num,u.create_time,r.name as rolename')
-                ->select();
-        } else {
-            return Db::table('phome_sys_user')->alias('u')
-                ->join('phome_sys_role r', 'u.roleid = r.roleid')
-                ->where('u.roleid', '<>', 1)
-                ->field('u.userid,u.username,u.nickname,u.truename,u.email,u.status,u.per_time,u.per_ip,u.login_num,u.create_time,r.name as rolename')
-                ->select();
-        }
+        return $this->belongsTo('SysRole', 'roleid')->bind(['rolename' => 'name']);
+    }
+
+    public static function queryList()
+    {
+        return self::field('userid,roleid,username,nickname,truename,email,status,per_time,per_ip,login_num,create_time')->with('sysRole')->select();
     }
 
     public function getUsernames($role_id = null)

+ 3 - 3
app/sys/controller/Base.php

@@ -374,9 +374,9 @@ abstract class Base
         if (Request::isPost()) {
             $model = '\app\common\model\\' . $this->modelName;
             if ($model ::destroy($id)) {
-                return ['code' => 1,'msg'=>'删除成功'];
+                return ['code' => 0,'msg'=>'删除成功'];
             } else {
-                return ['code' => 0,'msg'=>'删除失败'];
+                return ['code' => 1,'msg'=>'删除失败'];
             }
         }
     }
@@ -394,7 +394,7 @@ abstract class Base
     }
 
     // 状态变更
-    public function status(string $id)
+    public function status(int $id)
     {
         if (Request::isPost()) {
             $model = '\app\common\model\\' . $this->modelName;

+ 2 - 11
app/sys/controller/SysLogin.php

@@ -14,6 +14,8 @@ use app\common\model\SysLogin as SysLoginModel;
 
 class SysLogin extends Base
 {
+    protected $modelName = 'SysLogin';
+
     public function index($limit = 30)
     {
         $list = SysLoginModel::queryPage($limit, 0);
@@ -22,15 +24,4 @@ class SysLogin extends Base
 
         return View::fetch();
     }
-
-    public function delete($id)
-    {
-        if ($this->app->request->isPost()) {
-            if (SysLoginModel::destroy($id)) {
-                return ['code' => 1,'msg'=>'删除成功'];
-            } else {
-                return ['code' => 0,'msg'=>'删除失败'];
-            }
-        }
-    }
 }

+ 1 - 1
app/sys/controller/SysRole.php

@@ -67,7 +67,7 @@ class SysRole extends Base
             // var_dump($data);
             // exit;
             $sysMenu = new sysMenu();
-            $dataPermission = obj_tree($sysMenu->select());
+            $dataPermission = list_tree($sysMenu->select());
             return View::fetch('save', [
                 'data' => $data,
                 'rolePowers' => $rolePowers,

+ 6 - 21
app/sys/controller/SysUser.php

@@ -16,11 +16,11 @@ use app\common\model\SysRole as SysRoleModel;
 
 class SysUser extends Base
 {
+    protected $modelName = "SysUser";
+
     public function index()
     {
-        $roleid = $this->getSysUser()->roleid;
-
-        $list = SysUserModel::queryList($roleid);
+        $list = SysUserModel::queryList();
 
         View::assign('list', $list);
 
@@ -79,10 +79,10 @@ class SysUser extends Base
             if ($id != 0) {
                 $data = SysUserModel::find($id);
             } else {
-                $data = null;
+                $data = new SysUserModel();
             }
-    
-            $dataRole = SysRole::column('name','roleid');
+
+            $dataRole = SysRoleModel::column('name','roleid');
 
             View::assign('data', $data);
 
@@ -124,21 +124,6 @@ class SysUser extends Base
         }
     }
 
-    // 停用or启用管理员
-    public function status($id, $status)
-    {
-        if ($this->app->request->isAjax()) {
-            if ($id == session('uid')) {
-                return ['code'=>0,'msg'=>'当前登录用户无法停用'];
-            }
-            if ($this->model->save(['status' => $status], ['id' => $id])) {
-                return ['code'=>1,'msg'=>'操作成功'];
-            } else {
-                return ['code'=>0,'msg'=>'操作失败'];
-            }
-        }
-    }
-
     // 修改密码
     public function password()
     {

+ 14 - 8
app/sys/controller/System.php

@@ -16,21 +16,27 @@ class System extends Base
 {
     public function index()
     {
-        $list = SystemModel::select();
+        $data = SystemModel::find(1);
 
-        View::assign('list', $list);
+        View::assign('data', $data);
 
         return View::fetch();
     }
 
-    public function delete($id)
+    public function save($id = 0)
     {
-        if ($this->app->request->isPost()) {
-            if (SystemModel::destroy($id)) {
-                return ['code' => 1,'msg'=>'删除成功'];
-            } else {
-                return ['code' => 0,'msg'=>'删除失败'];
+        if ($this->request->isPost()) {
+
+            $params = $this->request->param();
+
+            try {
+                SystemModel::update($params, ['id' => 1]);
+            } catch (\Exception $e) {
+                $msg = $e->getMessage();
+
+                $this->error("错误提示:" . $msg);
             }
+            $this->success('操作成功', 'sys/system/index');
         }
     }
 }

+ 4 - 4
public/static/sys/js/admin.js

@@ -74,7 +74,7 @@ function status(obj, id) {
     $.post('status', {
         'id': parseInt(id)
     }, function (res) {
-        if (res.code == 1) {
+        if (res.code == 0) {
             topalert({
                 type: 0,
                 content: res.msg,
@@ -107,7 +107,7 @@ $(".input-sort").change(function () {
         'id': id,
         'sort': sort
     }, function (data) {
-        if (data.code == 1) {
+        if (data.code == 0) {
             topalert({
                 type: 0,
                 content: data.msg,
@@ -130,7 +130,7 @@ function del(obj, id) {
         $.post('delete', {
             'id': id
         }, function (res) {
-            if (res.code == 1) {
+            if (res.code == 0) {
                 $(obj).parents("tr").remove();
                 topalert({
                     type: 0,
@@ -172,7 +172,7 @@ function del_all() {
         $.post('delete', {
             'id': ids
         }, function (data) {
-            if (data.code == 1) {
+            if (data.code == 0) {
                 layer.msg(data.msg, {
                     icon: 1,
                     time: 2000

+ 1 - 1
view/sys/article/index.html

@@ -35,7 +35,7 @@
             <thead>
                 <tr class="text-c">
                     <th width="25px;">
-                        <input type="checkbox" name="" value="">
+                        <input type="checkbox" name="allcheck" value="">
                     </th>
                     <th width="80px;">ID</th>
                     <th style="min-width: 260px;">标题</th>

+ 4 - 4
view/sys/category/index.html

@@ -109,11 +109,11 @@
         $.post('sort', {
             'id': id,
             'sort': sort
-        }, function (data) {
-            if (data.code == 1) {
-                topalert({ type: 0, content: data.msg, speed: 2000 });
+        }, function (res) {
+            if (res.code == 0) {
+                topalert({ type: 0, content: res.msg, speed: 2000 });
             } else {
-                topalert({ type: 1, content: data.msg, speed: 2000 });
+                topalert({ type: 1, content: res.msg, speed: 2000 });
                 return false;
             }
         }, 'json');

+ 7 - 7
view/sys/category/save.html

@@ -167,18 +167,18 @@
                 dataType: 'json',
                 success: function (res) {
                     // console.log(res);
-                    if (res.code = 0) {
-                        layer.msg(data.msg, {
-                            icon: 5,
-                            time: 1000
-                        });
-                        return false;
-                    } else {
+                    if (res.code == 0) {
                         layer.msg(res.msg, { icon: 1 }, function () {
                             parent.location.reload(); // 父页面刷新
                             var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                             parent.layer.close(index);
                         });
+                    } else {
+                        layer.msg(data.msg, {
+                            icon: 5,
+                            time: 1000
+                        });
+                        return false;
                     }
                 }
             })

+ 11 - 9
view/sys/guest_book/index.html

@@ -12,16 +12,17 @@
             <thead>
                 <tr class="text-c">
                     <th width="25">
-                        <input type="checkbox" value="" name="">
+                        <input type="checkbox" value="" name="allcheck">
                     </th>
-                    <th style="min-width: 40px;">ID</th>
-                    <th style="min-width: 80px;">名称</th>
-                    <th style="min-width: 100px;">电话</th>
-                    <th style="min-width: 360px;">留言内容</th>
-                    <th style="min-width: 120px;">时间</th>
-                    <th>标记</th>
-                    <th style="min-width: 200px;">备注</th>
-                    <th>操作</th>
+                    <th style="width: 40px;">ID</th>
+                    <th style="width: 80px;">名称</th>
+                    <th style="width: 100px;">电话</th>
+                    <th>留言内容</th>
+                    <th>主页</th>
+                    <th style="width: 120px;">时间</th>
+                    <th style="width: 60px;">标记</th>
+                    <th style="width: 200px;">备注</th>
+                    <th style="width: 60px;">操作</th>
                 </tr>
             </thead>
             <tbody>
@@ -34,6 +35,7 @@
                     <td>{$val.name}</td>
                     <td>{$val.contact}</td>
                     <td class="text-l">{$val.content}</td>
+                    <td class="text-l">{$val.url}</td>
                     <td>{$val.time|date="Y-m-d H:i:s"}</td>
                     <td class="td-status">
                         <a href="javascript:;" onclick="mark(this,'{$val.id}')" style="text-decoration: none;"

+ 5 - 63
view/sys/sys_login/index.html

@@ -11,7 +11,7 @@
             <thead>
                 <tr class="text-c">
                     <th width="25">
-                        <input type="checkbox" value="" name="selectAll">
+                        <input type="checkbox" value="" name="allcheck">
                     </th>
                     <th width="100px">ID</th>
                     <th width="100px">userid</th>
@@ -27,9 +27,9 @@
                 {foreach $list as $val}
                 <tr class="text-c">
                     <td>
-                        <input type="checkbox" value="{$val.loginid}" name="checkbox[]">
+                        <input type="checkbox" value="{$val.id}" name="checkbox[]">
                     </td>
-                    <td>{$val.loginid}</td>
+                    <td>{$val.id}</td>
                     <td>{$val.userid}</td>
                     <td>{$val.username}</td>
                     <td>{$val.logintime|date="Y-m-d H:i:s"}</td>
@@ -40,10 +40,9 @@
                         {case 2}<span class="label radius label-default">禁用用户</span>{/case}
                         {default /}<span class="label radius label-success">成功</span>
                     {/switch}
-                       
                     </td>
                     <td class="td-manage">
-                        <a title="删除" href="javascript:;" onclick="del(this,'{$val.loginid}')" class="ml-5"
+                        <a title="删除" href="javascript:;" onclick="del(this,'{$val.id}')" class="ml-5"
                             style="text-decoration:none">
                             <i class="Hui-iconfont">&#xe6e2;</i>
                         </a>
@@ -57,61 +56,4 @@
     <div class="cl pd-5 bg-1 bk-gray mt-20 ">
         <span class="r">{notempty name="data"}{$data->render()|raw}{/notempty}</span>
     </div>
-</article>
-
-<!--请在下方写此页面业务相关的脚本-->
-<script type="text/javascript">
-    // 删除条目
-    function del(obj, id) {
-        layer.confirm('确认要删除吗?', function (index) {
-            $.post('delete', {
-                'id': id
-            }, function (data) {
-                if (data.code == 1) {
-                    $(obj).parents("tr").remove();
-                    layer.msg(data.msg, {
-                        icon: 1,
-                        time: 1000
-                    });
-                } else {
-                    layer.msg(data.msg, {
-                        icon: 5,
-                        time: 2000
-                    });
-                    return false;
-                }
-            }, 'json');
-        });
-    }
-
-    // 批量删除
-    function del_all() {
-        var checkbox = $('.text-c input[name="checkbox[]"]');
-        var ids = new Array();
-        checkbox.each(function (x) {
-            if (this.checked)
-                ids.push(this.value);
-        })
-        console.log(ids);
-
-        layer.confirm('确认要删除吗?', function (index) {
-            $.post('delete', {
-                'id': ids
-            }, function (data) {
-                if (data.code == 1) {
-                    layer.msg(data.msg, {
-                        icon: 1,
-                        time: 1000
-                    });
-                    window.location.reload();
-                } else {
-                    layer.msg(data.msg, {
-                        icon: 5,
-                        time: 1000
-                    });
-                }
-            }, 'json')
-        });
-    }
-</script>
-<!--请在上方写此页面业务相关的脚本-->
+</article>

+ 8 - 8
view/sys/sys_menu/save.html

@@ -58,7 +58,7 @@
             <div class="formControls col-xs-2 col-sm-2">
                 预览:<i class="Hui-iconfont">{$data.icon|raw}</i>
             </div>
-            <span style="color:red;">* 图标示例 <a href="/static/plugins/lib/Hui-iconfont/1.0.8/demo.html" target="_blank"
+            <span style="color:red;">* 图标示例 <a href="/static/plugins/Hui-iconfont/1.0.8/demo.html" target="_blank"
                     style="color:blue;" rel="noopener noreferrer"> demo</a></span>
         </div>
         <div class="row cl">
@@ -83,18 +83,18 @@
                 dataType: 'json',
                 success: function(res) {
                     // console.log(res);
-                    if (res.code=0) {
-                        layer.msg(data.msg, {
-                            icon: 5,
-                            time: 1000
-                        });
-                        return false;
-                    } else {
+                    if (res.code==0) {
                         layer.msg(res.msg,{icon:1},function(){
                             parent.location.reload(); // 父页面刷新
                             var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                             parent.layer.close(index);
                         });
+                    } else {
+                        layer.msg(data.msg, {
+                            icon: 5,
+                            time: 1000
+                        });
+                        return false;
                     }
                 }
             })

+ 1 - 1
view/sys/sys_role/index.html

@@ -16,7 +16,7 @@
                 </tr>
                 <tr class="text-c">
                     <th width="25">
-                        <input type="checkbox" value="" name="">
+                        <input type="checkbox" value="" name="allcheck">
                     </th>
                     <th width="40px">ID</th>
                     <th width="120px">角色名称</th>

+ 112 - 112
view/sys/sys_role/save.html

@@ -1,120 +1,120 @@
 <article class="cl pd-20">
-	<form action="" method="post" class="form form-horizontal" id="form-save">
-		<input type="hidden" id="roleid" name="roleid" value="{$data.roleid}">
-		<div class="row cl">
-			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>角色名称:</label>
-			<div class="formControls col-xs-8 col-sm-9">
-				<input type="text" class="input-text" value="{$data.name}" placeholder="" id="name" name="name"
-					datatype="*4-16" nullmsg="角色名称">
-			</div>
-		</div>
-		<div class="row cl">
-			<label class="form-label col-xs-4 col-sm-2">备注:</label>
-			<div class="formControls col-xs-8 col-sm-9">
-				<input type="text" class="input-text" value="{$data.remark}" placeholder="备注" id="remark" name="remark">
-			</div>
-		</div>
-		<div class="row cl">
-			<label class="form-label col-xs-4 col-sm-2">权限选择:</label>
-			<div class="formControls col-xs-8 col-sm-9">
-				{foreach $dataPermission as $value}
-				<dl class="permission-list">
-					<dt>
-						<label>
-							<input type="checkbox" value="{$value.id}" id="check_{$value.id}" name="perm_check[]" {if
-								condition="in_array($value.id, $rolePowers)" }checked{/if}>
-							{$value.name}</label>
-					</dt>
-					{notempty name='value.child'}
-					{foreach $value.child as $val}
-					<dd>
-						<dl class="cl permission-list2">
-							<dt>
-								<label class="">
-									<input type="checkbox" value="{$val.id}" name="perm_check[]" id="check_{$val.id}"
-										{if condition="in_array($val.id, $rolePowers)" }checked{/if}>
-									{$val.name}</label>
-							</dt>
-							{notempty name='val.child'}
-							<dd>
-								{foreach $val.child as $vo}
-								<label class="">
-									<input type="checkbox" value="{$vo.id}" name="perm_check[]" id="check_{$val.id}" {if
-										condition="in_array($vo.id, $rolePowers)" }checked{/if}>
-									{$vo.name}</label>
-								{/foreach}
-							</dd>
-							{/notempty}
-						</dl>
-					</dd>
-					{/foreach}
-					{/notempty}
-				</dl>
-				{/foreach}
-			</div>
-		</div>
-		<div class="row cl">
-			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
-				<button type="button" class="btn btn-success radius" id="form-save-button"><i class="icon-ok"></i>
-					确定</button>
-				<button type="button" class="btn btn-default radius" onClick="layer_close();"><i
-						class="Hui-iconfont">&#xe66b;</i>取消</button>
-			</div>
-		</div>
-	</form>
+    <form action="" method="post" class="form form-horizontal" id="form-save">
+        <input type="hidden" id="roleid" name="roleid" value="{$data.roleid}">
+        <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>角色名称:</label>
+            <div class="formControls col-xs-8 col-sm-9">
+                <input type="text" class="input-text" value="{$data.name}" placeholder="" id="name" name="name"
+                    datatype="*4-16" nullmsg="角色名称">
+            </div>
+        </div>
+        <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-2">备注:</label>
+            <div class="formControls col-xs-8 col-sm-9">
+                <input type="text" class="input-text" value="{$data.remark}" placeholder="备注" id="remark" name="remark">
+            </div>
+        </div>
+        <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-2">权限选择:</label>
+            <div class="formControls col-xs-8 col-sm-9">
+                {foreach $dataPermission as $value}
+                <dl class="permission-list">
+                    <dt>
+                        <label>
+                            <input type="checkbox" value="{$value.id}" id="check_{$value.id}" name="perm_check[]" {if
+                                condition="in_array($value.id, $rolePowers)" }checked{/if}>
+                            {$value.name}</label>
+                    </dt>
+                    {notempty name='value.child'}
+                    {foreach $value.child as $val}
+                    <dd>
+                        <dl class="cl permission-list2">
+                            <dt>
+                                <label class="">
+                                    <input type="checkbox" value="{$val.id}" name="perm_check[]" id="check_{$val.id}"
+                                        {if condition="in_array($val.id, $rolePowers)" }checked{/if}>
+                                    {$val.name}</label>
+                            </dt>
+                            {notempty name='val.child'}
+                            <dd>
+                                {foreach $val.child as $vo}
+                                <label class="">
+                                    <input type="checkbox" value="{$vo.id}" name="perm_check[]" id="check_{$val.id}" {if
+                                        condition="in_array($vo.id, $rolePowers)" }checked{/if}>
+                                    {$vo.name}</label>
+                                {/foreach}
+                            </dd>
+                            {/notempty}
+                        </dl>
+                    </dd>
+                    {/foreach}
+                    {/notempty}
+                </dl>
+                {/foreach}
+            </div>
+        </div>
+        <div class="row cl">
+            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
+                <button type="button" class="btn btn-success radius" id="form-save-button"><i class="icon-ok"></i>
+                    确定</button>
+                <button type="button" class="btn btn-default radius" onClick="layer_close();"><i
+                        class="Hui-iconfont">&#xe66b;</i>取消</button>
+            </div>
+        </div>
+    </form>
 </article>
 
 <!--请在下方写此页面业务相关的脚本-->
 <script type="text/javascript">
-	$(function () {
-		$(".permission-list dt input:checkbox").click(function () {
-			$(this).closest("dl").find("dd input:checkbox").prop("checked", $(this).prop("checked"));
-		});
-		$(".permission-list2 dd input:checkbox").click(function () {
-			var l = $(this).parent().parent().find("input:checked").length;
-			var l2 = $(this).parents(".permission-list").find(".permission-list2 dd").find("input:checked").length;
-			if ($(this).prop("checked")) {
-				$(this).closest("dl").find("dt input:checkbox").prop("checked", true);
-				$(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked", true);
-			}
-			else {
-				if (l == 0) {
-					$(this).closest("dl").find("dt input:checkbox").prop("checked", false);
-				}
-				if (l2 == 0) {
-					$(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked", false);
-				}
-			}
-		});
+    $(function () {
+        $(".permission-list dt input:checkbox").click(function () {
+            $(this).closest("dl").find("dd input:checkbox").prop("checked", $(this).prop("checked"));
+        });
+        $(".permission-list2 dd input:checkbox").click(function () {
+            var l = $(this).parent().parent().find("input:checked").length;
+            var l2 = $(this).parents(".permission-list").find(".permission-list2 dd").find("input:checked").length;
+            if ($(this).prop("checked")) {
+                $(this).closest("dl").find("dt input:checkbox").prop("checked", true);
+                $(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked", true);
+            }
+            else {
+                if (l == 0) {
+                    $(this).closest("dl").find("dt input:checkbox").prop("checked", false);
+                }
+                if (l2 == 0) {
+                    $(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked", false);
+                }
+            }
+        });
 
-		$("#form-save-button").click(function () {
-			var data = $("#form-save").serializeArray();
-			$.ajax({
-				type: 'POST',
-				url: '{:url("save")}',
-				data: data,
-				dataType: 'json',
-				success: function (res) {
-					console.log(res);
-					if (res.code = 0) {
-						layer.msg(data.msg, {
-							icon: 5,
-							time: 1000
-						});
-						return false;
-					} else {
-						layer.msg(res.msg, {
-							icon: 1,
-							time: 1000
-						}, function () {
-							parent.location.reload(); // 父页面刷新
-							var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
-							parent.layer.close(index);
-						});
-					}
-				}
-			})
-		});
-	})
+        $("#form-save-button").click(function () {
+            var data = $("#form-save").serializeArray();
+            $.ajax({
+                type: 'POST',
+                url: '{:url("save")}',
+                data: data,
+                dataType: 'json',
+                success: function (res) {
+                    console.log(res);
+                    if (res.code == 0) {
+                        layer.msg(res.msg, {
+                            icon: 1,
+                            time: 1000
+                        }, function () {
+                            parent.location.reload(); // 父页面刷新
+                            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
+                            parent.layer.close(index);
+                        });
+                    } else {
+                        layer.msg(data.msg, {
+                            icon: 5,
+                            time: 1000
+                        });
+                        return false;
+                    }
+                }
+            })
+        });
+    })
 </script>
 <!--请在上方写此页面业务相关的脚本-->

+ 11 - 63
view/sys/sys_user/index.html

@@ -24,6 +24,7 @@
                     <th width="140px">最后登录时间</th>
                     <th width="120px">最后登录ip</th>
                     <th width="140px">创建时间</th>
+                    <th>状态</th>
                     <th>操作</th>
                 </tr>
             </thead>
@@ -43,14 +44,17 @@
                     <td>{$val.per_time}</td>
                     <td>{$val.per_ip}</td>
                     <td>{$val.create_time}</td>
+                    <td class="td-status">
+                        <a href="javascript:;" onclick="status(this,'{$val.userid}')" style="text-decoration: none;"
+                            title="{$val.status==1? '禁用' : '正常'}">
+                            <span class="f-20 c-primary"><i class="Hui-iconfont">{$val.status==1?'&#xe601;' :
+                                    '&#xe677;'}</i></span></a>
+                    </td>
                     <td class="td-manage">
-                        <a title="编辑" href="javascript:save({$val.userid});" style="text-decoration:none">
-                            <i class="Hui-iconfont">&#xe6df;</i>
-                        </a>
-                        <a title="删除" href="javascript:;" onclick="del(this,'{$val.userid}')" class="ml-5"
-                            style="text-decoration:none">
-                            <i class="Hui-iconfont">&#xe6e2;</i>
-                        </a>
+                        <a title="编辑" href="javascript:save({$val.userid});" class="btn btn-primary radius">
+                            <i class="Hui-iconfont">&#xe6df;</i></a>
+                        <a title="删除" href="javascript:;" onclick="del(this,'{$val.userid}')" class="ml-5 btn btn-danger radius">
+                            <i class="Hui-iconfont">&#xe6e2;</i></a>
                     </td>
                 </tr>
                 {/foreach}
@@ -65,61 +69,5 @@
         var url = "{:url('save')}" + "?_layer=true&id=" + id
         layer_show(title, url, 800, 600);
     }
-
-    // 列表删除条目
-    function del(obj, id) {
-        layer.confirm('确认要删除吗?', function (index) {
-            $.post('delete', {
-                'id': id
-            }, function (data) {
-                if (data.code == 1) {
-                    $(obj).parents("tr").remove();
-                    layer.msg(data.msg, {
-                        icon: 1,
-                        time: 1000
-                    });
-                } else {
-                    layer.msg(data.msg, {
-                        icon: 5,
-                        time: 2000
-                    });
-                    return false;
-                }
-            }, 'json');
-        });
-    }
-
-    // 批量删除条目
-    function del_all() {
-        var checkbox = $('.text-c input[name="checkbox[]"]');
-        var ids = new Array();
-        checkbox.each(function (x) {
-            if (this.checked)
-                ids.push(this.value);
-        })
-        // console.log(ids);
-
-        layer.confirm('确认要删除吗?', function (index) {
-            $.post('delete', {
-                'id': ids
-            }, function (data) {
-                if (data.code == 1) {
-                    layer.msg(data.msg, {
-                        icon: 1,
-                        time: 1000
-                    });
-                    checkbox.each(function (x) {
-                        if (this.checked)
-                            $(this).parents("tr").remove();
-                    })
-                } else {
-                    layer.msg(data.msg, {
-                        icon: 5,
-                        time: 1000
-                    });
-                }
-            }, 'json')
-        });
-    }
 </script>
 <!--/请在上方写此页面业务相关的脚本-->

+ 7 - 7
view/sys/sys_user/password.html

@@ -75,18 +75,18 @@
                 },
                 dataType: 'json',
                 success: function (res) {
-                    if (res.code = 0) {
-                        layer.msg(res.msg, {
-                            icon: 5,
-                            time: 1000
-                        });
-                        return false;
-                    } else {
+                    if (res.code == 0) {
                         layer.msg(res.msg, { icon: 1 }, function () {
                             parent.location.reload(); // 父页面刷新
                             var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                             parent.layer.close(index);
                         });
+                    } else {
+                        layer.msg(res.msg, {
+                            icon: 5,
+                            time: 1000
+                        });
+                        return false;
                     }
                 }
             })

+ 11 - 11
view/sys/sys_user/save.html

@@ -79,12 +79,12 @@
             <label class="form-label col-xs-4 col-sm-2">
                 头像:</label>
                 <div class="formControls col-xs-6 col-sm-4">
-                    <div style="width: 200px;height: 200px;">
+                    <input type="text" class="input-text" value="{$data.avatar}" name="avatar" id="picture">
+                    <div style="width: 160px;height: 160px;">
                      <a href="javascript:void(0);" onclick="uploadPicture()" >
-                        <img id="view-img" src="{$data.avatar ? $data.avatar : '/static/images/upload_picture.png'}" alt="头像" title="{$data.title_pic ? '更换' : '添加'}头像" style="max-width: 200px;max-height: 200px;">
+                        <img id="view-img" src="{$data.avatar ? $data.avatar : '/static/images/upload_picture.png'}" alt="头像" title="{$data.title_pic ? '更换' : '添加'}头像" style="max-width: 160px;max-height: 160px;">
                      </a>
                     </div>
-                    <input type="text" class="input-text" value="{$data.avatar}" name="avatar" id="picture" style="display: none;">
                 </div>
                 <label class="form-label col-xs-2 col-sm-2">
                     <a class="btn btn-success radius" href="javascript:uploadPicture();">{$data.avatar ? '更换' : '添加'}头像</a></label>
@@ -95,7 +95,7 @@
                 <span class="c-red"></span>状态:</label>
             <div class="formControls col-xs-8 col-sm-6">
                 <div class="radio-box">
-                    <input type="radio" name="status" id="status-1" value="1" {$data==null || $data.status==1 ? 'checked' : ""}>
+                    <input type="radio" name="status" id="status-1" value="1" {$data.status ==null || $data.status==1 ? 'checked' : ""}>
                     <label for="typeId-1">启用</label>
                 </div>
                 <div class="radio-box">
@@ -220,18 +220,18 @@
                 dataType: 'json',
                 success: function (res) {
                     // console.log(res);
-                    if (res.code = 0) {
-                        layer.msg(data.msg, {
-                            icon: 5,
-                            time: 1000
-                        });
-                        return false;
-                    } else {
+                    if (res.code == 0) {
                         layer.msg(res.msg, { icon: 1 }, function () {
                             parent.location.reload(); // 父页面刷新
                             var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                             parent.layer.close(index);
                         });
+                    } else {
+                        layer.msg(data.msg, {
+                            icon: 5,
+                            time: 1000
+                        });
+                        return false;
                     }
                 }
             })

+ 270 - 0
view/sys/system/index.html

@@ -0,0 +1,270 @@
+<article class="cl pd-20">
+    <form action="{:url('save')}" method="post" class="form form-horizontal" id="form-article-add">
+        <div id="tab-system" class="HuiTab">
+            <div class="tabBar cl"><span>基本设置</span><span>SEO设置</span><span>留言邮箱设置</span></div>
+            <div class="tabCon">
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>网站名称:</label>
+                    <div class="formControls col-xs-8 col-sm-9">
+                        <input type="text" id="name" placeholder="控制在25个字、50个字节以内" value="{$data.name}" name="name"
+                            class="input-text">
+                    </div>
+                </div>
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>logo:</label>
+                    <div class="formControls col-xs-8 col-sm-9">
+                        <input type="text" id="picture" placeholder="logo 路径" value="{$data.logo}" name="logo"
+                            class="input-text">
+                    </div>
+                    <div class="formControls col-xs-8 col-sm-4 col-xs-offset-4 col-sm-offset-2">
+                        <div style="max-width: 200px;">
+                            <a href="javascript:void(0);" onclick="uploadLogo()">
+                                <img id="view-picture"
+                                    src="{$data.logo ? $data.logo : '/static/images/upload_picture.png'}"
+                                    alt="logo" title="{$data.title_pic ? '更换' : '添加'}logo"
+                                    style="max-width: 200px;max-height: 200px;">
+                            </a>
+                        </div>
+                    </div>
+                    <label class="form-label col-xs-2 col-sm-2">
+                        <a class="btn btn-success radius" href="javascript:uploadLogo();">{$data.logo ? '更换' :
+                            '添加'}logo</a></label>
+                </div>
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-2">备案号:</label>
+                    <div class="formControls col-xs-8 col-sm-9">
+                        <input type="text" id="website-icp" placeholder="京ICP备00000000号" value="{$data.icp}" name="icp"
+                            class="input-text">
+                    </div>
+                </div>
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>底部版权信息:</label>
+                    <div class="formControls col-xs-8 col-sm-9">
+                        <input type="text" id="website-copyright" placeholder="&copy; 2021 suryee.com"
+                            value="{$data.copyright}" name="copyright" class="input-text">
+                    </div>
+                </div>
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>网站地址:</label>
+                    <div class="formControls col-xs-8 col-sm-9">
+                        <input type="text" id="website-static" placeholder="www.suryee.com" value="{$data.url}"
+                            name="url" class="input-text">
+                    </div>
+                </div>
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>公司地址:</label>
+                    <div class="formControls col-xs-8 col-sm-9">
+                        <input type="text" id="website-static" placeholder="公司地址" value="{$data.address}" name="address"
+                            class="input-text">
+                    </div>
+                </div>
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>联系人:</label>
+                    <div class="formControls col-xs-8 col-sm-9">
+                        <input type="text" id="contacts" placeholder="联系人" value="{$data.contacts}" name="contacts"
+                            class="input-text">
+                    </div>
+                </div>
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>联系电话:</label>
+                    <div class="formControls col-xs-8 col-sm-9">
+                        <input type="text" id="tel" placeholder="联系电话" value="{$data.tel}" name="tel"
+                            class="input-text">
+                    </div>
+                </div>
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>手机号码:</label>
+                    <div class="formControls col-xs-8 col-sm-9">
+                        <input type="text" id="mobile_phone" placeholder="手机号码" value="{$data.mobile_phone}"
+                            name="mobile_phone" class="input-text">
+                    </div>
+                </div>
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>传真号码:</label>
+                    <div class="formControls col-xs-8 col-sm-9">
+                        <input type="text" id="fax" placeholder="传真号码" value="{$data.fax}" name="fax"
+                            class="input-text">
+                    </div>
+                </div>
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>邮箱账号:</label>
+                    <div class="formControls col-xs-8 col-sm-9">
+                        <input type="text" id="email" placeholder="邮箱账号" value="{$data.email}" name="email"
+                            class="input-text">
+                    </div>
+                </div>
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>QQ:</label>
+                    <div class="formControls col-xs-8 col-sm-9">
+                        <input type="text" id="qq" placeholder="QQ" value="{$data.qq}" name="qq" class="input-text">
+                    </div>
+                </div>
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>二维码:</label>
+                    <div class="formControls col-xs-8 col-sm-9">
+                        <input type="text" id="qrcode" placeholder="二维码" value="{$data.qrcode}" name="qrcode"
+                            class="input-text">
+                    </div>
+                    <div class="formControls col-xs-8 col-sm-4 col-xs-offset-4 col-sm-offset-2">
+                        <div style="max-width: 200px;">
+                            <a href="javascript:void(0);" onclick="addTitlePic()">
+                                <img id="view-qrcode"
+                                    src="{$data.qrcode ? $data.qrcode : '/static/images/upload_picture.png'}"
+                                    alt="logo" title="{$data.qrcode ? '更换' : '添加'}二维码"
+                                    style="max-width: 200px;max-height: 200px;">
+                            </a>
+                        </div>
+                    </div>
+                    <label class="form-label col-xs-2 col-sm-2">
+                        <a class="btn btn-success radius" href="javascript:uploadQrcode();">{$data.qrcode ? '更换' :
+                            '添加'}二维码</a></label>
+                </div>
+            </div>
+            <div class="tabCon">
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>SEO标题:</label>
+                    <div class="formControls col-xs-8 col-sm-9">
+                        <input type="text" id="title" placeholder="请输入SEO标题" value="{$data.title}" name="title"
+                            class="input-text">
+                    </div>
+                </div>
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>关键词:</label>
+                    <div class="formControls col-xs-8 col-sm-9">
+                        <input type="text" id="key" placeholder="5个左右,8汉字以内,用英文,隔开" value="{$data.key}" name="key"
+                            class="input-text">
+                    </div>
+                </div>
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>描述:</label>
+                    <div class="formControls col-xs-8 col-sm-9">
+                        <input type="text" id="description" placeholder="空制在80个汉字,160个字符以内" value="{$data.des}"
+                            name="des" class="input-text">
+                    </div>
+                </div>
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-2">统计代码:</label>
+                    <div class="formControls col-xs-8 col-sm-9">
+                        <textarea class="textarea" id="tongji" name="tongji">{$data.tongji}</textarea>
+                    </div>
+                </div>
+            </div>
+            <div class="tabCon">
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>SMTP服务器:</label>
+                    <div class="formControls col-xs-8 col-sm-9">
+                        <input type="text" id="email_host" placeholder="请输入SMTP服务器" value="{$data.email_host}"
+                            name="email_host" class="input-text">
+                    </div>
+                </div>
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>开启加密:</label>
+                    <div class="formControls col-xs-8 col-sm-9">
+                        <input type="text" id="email_secure" placeholder="secure, 一般为ssl协议" value="{$data.email_secure}"
+                            name="email_secure" class="input-text">
+                    </div>
+                </div>
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>服务器端口:</label>
+                    <div class="formControls col-xs-8 col-sm-9">
+                        <input type="text" id="email_port" placeholder="服务器端口 25 或者465 具体要看邮箱服务器支持"
+                            value="{$data.email_port}" name="email_port" class="input-text">
+                    </div>
+                </div>
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>账号:</label>
+                    <div class="formControls col-xs-8 col-sm-9">
+                        <input type="text" id="email_username" placeholder="即邮箱的用户名" value="{$data.email_username}"
+                            name="email_username" class="input-text">
+                    </div>
+                </div>
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>密码:</label>
+                    <div class="formControls col-xs-8 col-sm-9">
+                        <input type="text" id="email_password" placeholder="密码部分邮箱是授权码(例如163邮箱)"
+                            value="{$data.email_password}" name="email_password" class="input-text">
+                    </div>
+                </div>
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>发件人:</label>
+                    <div class="formControls col-xs-8 col-sm-9">
+                        <input type="text" id="email_from" placeholder="发件人, 一般和邮箱的用户名一致" value="{$data.email_from}"
+                            name="email_from" class="input-text">
+                    </div>
+                </div>
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>收件人:</label>
+                    <div class="formControls col-xs-8 col-sm-9">
+                        <input type="text" id="email_to" placeholder="收件人" value="{$data.email_to}" name="email_to"
+                            class="input-text">
+                    </div>
+                    <div class="formControls col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
+                        <span class="c-red">多个收件人用英文','隔开</span>
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div class="row cl">
+            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
+                <button class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
+                <button onClick="layer_close();" class="btn btn-default radius"
+                    type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
+            </div>
+        </div>
+    </form>
+</article>
+
+<script type="text/javascript">
+    jQuery.Huitab = function (tabBar, tabCon, class_name, tabEvent, i) {
+        var $tab_menu = $(tabBar);
+        // 初始化操作
+        $tab_menu.removeClass(class_name);
+        $(tabBar).eq(i).addClass(class_name);
+        $(tabCon).hide();
+        $(tabCon).eq(i).show();
+
+        $tab_menu.bind(tabEvent, function () {
+            $tab_menu.removeClass(class_name);
+            $(this).addClass(class_name);
+            var index = $tab_menu.index(this);
+            $(tabCon).hide();
+            $(tabCon).eq(index).show()
+        })
+    }
+
+    $(function () {
+        $('.skin-minimal input').iCheck({
+            checkboxClass: 'icheckbox-blue',
+            radioClass: 'iradio-blue',
+            increaseArea: '20%'
+        });
+        $.Huitab("#tab-system .tabBar span", "#tab-system .tabCon", "current", "click", "0");
+    });
+
+    //添加标题图
+    function uploadLogo() {
+        layer.open({
+            type: 2,
+            area: ['700px', '500px'],
+            fix: false, //不固定
+            maxmin: true,
+            shade: 0.4,
+            title: 'Logo上传',
+            content: '{:url("uploadlogo")}'
+        });
+    }
+
+    //添加标题图
+    function uploadQrcode() {
+        layer.open({
+            type: 2,
+            area: ['700px', '500px'],
+            fix: false, //不固定
+            maxmin: true,
+            shade: 0.4,
+            title: 'Logo上传',
+            content: '{:url("uploadqrcode")}'
+        });
+    }
+
+</script>