
<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="referrer" content="no-referrer">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="author" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <link href="/css/common/common.css" rel="stylesheet" type="text/css" />
    <link href="/css/admin/console.css" rel="stylesheet" type="text/css"/>
    <link href="/ref/layui-v2.6.8/layui/css/layui.css" rel="stylesheet" type="text/css" />
    <script src="/ref/layui-v2.6.8/layui/layui.js" type="text/javascript"></script>
    <script src="/ref/jquery/jquery-3.4.1.js" type="text/javascript"></script>

    <style>
        .search-condition-elem {
            width: 170px;
        }
    </style>
</head>
<body style="overflow-x: hidden">
<center>
    <div class="search-condition-module" style="background-color: transparent">
        <a href="/client/writer" target="_blank"><button class="btn" style="right: 100px" id="grant-btn">写文章</button></a>
    </div>

    <table class="account-apply-tab layui-table" id="search-result-tab">
        <thead>
        <tr>
            <th style="width: 90px">文章ID</th>
            <th style="width: 100px">关联公众号</th>
            <th style="width: 200px">文章标题</th>
            <th style="width: 200px">文章概述</th>
            <th style="width: 150px;" class="line1ppp">提交时间</th>
            <th style="width: 150px;" class="line1ppp">计划推文时间</th>
            <th style="width: 200px;" class="line1ppp">状态</th>
        </tr>
        </thead>
        <tbody>

        </tbody>
    </table>
    <div id="page"></div>
</center>
</body>
<script>

    function formatTimestamp(timestamp) {
        // 创建一个新的Date对象
        var date = new Date(timestamp);

        // 获取年、月、日、时、分、秒
        var year = date.getFullYear();
        var month = date.getMonth() + 1; // 月份是从0开始的
        var day = date.getDate();
        var hours = date.getHours();
        var minutes = date.getMinutes();
        var seconds = date.getSeconds();

        // 将单个数字格式化为两位数（例如，1变为01）
        month = month < 10 ? '0' + month : month;
        day = day < 10 ? '0' + day : day;
        hours = hours < 10 ? '0' + hours : hours;
        minutes = minutes < 10 ? '0' + minutes : minutes;
        seconds = seconds < 10 ? '0' + seconds : seconds;

        // 组合成年月日 时分秒格式
        return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
    }

    var firstSearch = true;
    var curr = 0, size = 10, total = 0;
    loadUserWalletInFlow();
    function loadUserWalletInFlow() {
        $.ajax({
            url:"/api/article/page?pageNo="+(curr == 0 ? 1 : curr)+"&pageSize="+size,
            type:"get",
            success:function (data) {
                data = eval(data);
                $("#search-result-tab").children("tbody").empty();
                if (data.success){
                    $.each(data.data, function (index, value) {
                        var tr = "<tr>"+
                            "<td>"+value.id+"</td>"+
                            "<td class='line1ppp'>"+value.publicAccountInfo.userName+"</td>"+
                            "<td class='line1ppp' style='max-width: 200px;'><a target='_blank' href='/article/"+value.id+"' style='color: #2626da'>"+value.title+"</a></td>"+
                            "<td class='line1ppp' style='max-width: 200px;'>"+value.description+"</td>"+
                            "<td>"+formatTimestamp(value.publishTime)+"</td>"+
                            "<td>"+formatTimestamp(value.planPushTime)+"</td>"+
                            "<td>"+(value.status == 2 ? "<span style='color: green'>已推文</span>" : "排队等待中...")+"</td>"+
                            "</tr>";
                        if (!firstSearch) {
                            $("#search-result-tab").children("tbody").append(tr);
                        }
                    })
                    if (curr == 0 || data.total != total) {
                        curr = 1;
                        firstSearch = false;
                        total = data.total;
                        initPage();
                    }
                } else {
                    layer.msg(data.msg);
                }
            },error:function () {}
        })
    }

    function initPage() {
        layui.use('laypage', function(){
            var laypage = layui.laypage;
            laypage.render({
                elem: 'page',
                count: total,
                limit: size,
                curr: curr,
                jump: function(obj){
                    curr = obj.curr;
                    loadUserWalletInFlow();
                }
            });
        })
    }
</script>
<style>
    .layui-laypage a, .layui-laypage span {
        display: inline-block;
        *display: inline;
        *zoom: 1;
        vertical-align: middle;
        padding: 3px 13px;
        height: 28px;
        line-height: 28px;
        margin: 0px 5px;
        border-radius: 4px;
        background-color: #fff;
        color: #4e6ef2;
        font-size: 14px;
        border: none;
    }
    .layui-laypage a:hover, .layui-laypage span:hover {
        background: #4e6ef2;
        color: #fff;
    }
    .layui-laypage .layui-laypage-curr .layui-laypage-em {
        position: absolute;
        left: -1px;
        top: -1px;
        padding: 1px;
        width: 100%;
        height: 100%;
        border-radius: 4px;
        background: #4e6ef2;
        color: #fff;
        font-weight: normal;
    }
    .layui-laypage-next, .layui-laypage-prev {
        border-radius: 4px;
    }
    .layui-laypage-default {
        float: right;
    }
</style>
</html>