{include file="public/header" /}
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto" id="LAY-user">
			<blockquote class="layui-elem-quote">
				<p style="color:red">原来的『和彩云网盘』，已经正式更名为『中国移动云盘』，支持移动/联通/电信用户注册，官方地址：<a href="https://yun.139.com/w/#/" target="_blank" style="color:blue;">https://yun.139.com/w/#/</a></p>
				<p >采用cookie登录，cookie有效期一个月，若失效后需手动更新账号cookie</p>
			</blockquote>		
            <div>
                <button class="layui-btn" data-type="add" onclick="wk.layer_show('添加账号','{:url('userAdd')}','600px','300px')">
                    <i class="fa fa-plus"></i> 添加账号
                </button>
            </div>
        </div>

        <div class="layui-card-body">
            <table id="LAY-table-manage" lay-filter="LAY-table-manage"></table>
			<!--账号模板-->
            <script type="text/html" id="userBar">
				<a lay-href="{:url('panList')}?id={{d.id}}&type=0&newCloud={{d.newCloud}}" class="layui-btn layui-btn-xs" title="点击进入管理个人云网盘文件" >【{{# if(d.newCloud == 1){ }}新{{# } }}个人云】{{d.username}}</a>
                {{# if(d.familyId != ''){ }}
				<a lay-href="{:url('panList')}?id={{d.id}}&type=1" class="layui-btn layui-btn-xs" title="点击进入管理家庭云网盘文件" >【家庭云】{{d.username}}</a>
                {{# } }}
            </script>
			<!--操作模板-->
            <script type="text/html" id="opeBar">
				<a class="layui-btn layui-btn-xs" title="编辑" onclick="wk.layer_show('编辑账号','{:url('userEdit')}?id={{d.id}}','600px','300px')"><i class="fa fa-pencil"></i></a>
                <a class="layui-btn layui-btn-danger layui-btn-xs" title="删除" onclick="wk.confirm('{{d.id}}','{:url('userDel')}','删除后该账号生成的外链、分享记录均会同步删除，<br>请谨慎确认是否删除？')"><i class="fa fa-trash-o"></i></a>
            </script>			
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    layui.use(['index', 'table'], function () {
        var $ = layui.$
            , form = layui.form
            , table = layui.table;
        table.render({
            elem: '#LAY-table-manage'
            , url: '{:url("userList")}'
            , page: true
            , size: 'lg' 
            , autoSort: false
            , cellMinWidth: 150
            , limits: [10, 20, 30, 40, 50]
            , limit: "15"
            , loading: true
            , id: 'LAY-table'
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'username', minWidth: 500, title: '网盘账号', align: 'center', toolbar: '#userBar'}
				, {field: 'beizhu', minWidth: 200, title: '备注', edit:'text', align: 'center'}
                , {field: 'time', width: 200, title: '更新时间', align: 'center'}	
				, {field: 'end_time', width: 200, title: '预计失效时间', align: 'center',templet: function (d) {
					let time = new Date(d.time);
					let end_time = time.setMonth(time.getMonth() + 1);
					let nowDate = new Date();
					let week_later = nowDate.setDate(nowDate.getDate() + 7);
					if(end_time<week_later){
						return '<font color="red">'+layui.util.toDateString(end_time)+'</font>';
					}else{
						return layui.util.toDateString(end_time);
					}
				}}	
                , {fixed: 'right', width: 120, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.layui-circle').viewer({
                    url: 'data-original',
                });
				if(count==0 && res.code==0){
					layer.alert('您还未添加过账号，请先点击添加账号',{icon:0});
				}
            }
        });

    });
</script>
</body>
</html>