<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <head th:replace="common/header :: common_head(~{::title},~{::meta},~{::link},~{})">
        <title th:text="'我的书架_'+${application.website.name}"></title>
        <meta name="keywords" th:content="'我的书架,个人中心,'+${application.website.name}+'小说,'+${application.website.name}" />
        <meta name="description" th:content="${application.website.name}+'小说每日更新小说连载,小说排行榜,提供言情小说,都市小说,玄幻小说,穿越小说,青春小说,总裁豪门小说,网络小说,免费小说,全本小说,首发小说,最新章节免费小说阅读,精彩尽在'+${application.website.name}+'小说!'" />
        <link rel="stylesheet" href="/css/user.css" />
    </head>
</head>
<body class="">

<div th:replace="common/top :: top('')">
</div>

<div class="main box_center cf">
    <div class="userBox cf">
        <div class="my_l">

            <ul class="log_list">
                <li><a class="link_1 " href="/user/userinfo.html">个人中心</a></li>
                <li><a class="link_4 on" href="/user/favorites.html">我的书架</a></li>
                <li><a class="link_6 " href="/user/comment.html">我的书评</a></li>
                <li><a class="link_7 " href="/user/feedback_list.html">我的反馈</a></li>
                <li><a class="link_8 " href="/user/setup.html">账号设置</a></li>
            </ul>

        </div>
        <div class="my_r">
            <div class="my_bookshelf">
                <div class="title cf">
                    <h2 class="fl"><a href="javascript:void(0);" class="red">我的书架</a></h2><i class="fl ml20 mr20 font16">|</i><h2 class="fl"><a href="/user/read_history.html" >最近阅读</a></h2>
                </div>

                <div id="divData" class="updateTable">
                    <table cellpadding="0" cellspacing="0">
                        <thead>
                        <tr>
                            <th class="style">
                                类别
                            </th>
                            <th class="name">
                                书名
                            </th>
                            <th class="chapter">
                                最新章节
                            </th>
                            <th class="time">
                                更新时间
                            </th>
                            <th class="goread">
                                书签
                            </th>
                        </tr>
                        </thead>
                        <tbody id="bookShelfList">



                        </tbody>
                    </table>
                    <div class="pageBox cf" id="shellPage">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div th:replace="common/footer :: footer">
</div>


</body>
<div th:replace="common/js :: js"></div>
<script src="/javascript/user.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
    search(1, 10);

    function search(curr, limit) {

        $.ajax({
            type: "get",
            url: "/user/listBookShelfByPage",
            data: {'curr':curr,'limit':limit},
            dataType: "json",
            success: function (data) {
                if (data.code == 200) {
                    var bookShelfList = data.data.list;
                    if (bookShelfList.length > 0) {
                        var bookShelfListHtml = "";
                        for(var i=0;i<bookShelfList.length;i++){
                            var book = bookShelfList[i];
                            bookShelfListHtml+=(" <tr class=\"book_list\" vals=\"291\">\n" +
                                "                            <td class=\"style bookclass\">\n" +
                                "                                <a href=\"/book/bookclass.html?c="+book.catId+"\" >["+book.catName+"]</a>\n" +
                                "                            </td>\n" +
                                "                            <td class=\"name\">\n" +
                                "                                <a href=\"/book/"+book.bookId+".html\">\n" +
                                "                                    "+book.bookName+"</a>\n" +
                                "                            </td>\n" +
                                "                            <td class=\"chapter\" valsc=\"291|2037554|1\">\n" +
                                "<a href='/book/"+book.bookId+"/"+book.lastIndexId+".html'>"+book.lastIndexName+"</a>"+
                                "                            </td>\n" +
                                "                            <td class=\"time\">\n" +
                                "                                "+book.lastIndexUpdateTime+"\n" +
                                "                            </td>\n" +
                                "                            <td class=\"goread\">\n" +
                                "<a href='/book/"+book.bookId+"/"+book.preContentId+".html'>继续阅读</a>"+
                                "                            </td>\n" +
                                "                        </tr>");
                        }
                        $("#bookShelfList").html(bookShelfListHtml);

                        layui.use('laypage', function () {
                            var laypage = layui.laypage;

                            //执行一个laypage实例
                            laypage.render({
                                elem: 'shellPage' //注意,这里的 test1 是 ID,不用加 # 号
                                , count: data.data.total //数据总数,从服务端得到,
                                , curr: data.data.pageNum
                                , limit: data.data.pageSize
                                , jump: function (obj, first) {


                                    //obj包含了当前分页的所有参数,比如:
                                    console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。
                                    console.log(obj.limit); //得到每页显示的条数


                                    //首次不执行
                                    if (!first) {
                                        search(obj.curr, obj.limit);
                                    } else {

                                    }
                                }
                            });
                        });

                    }


                } else if (data.code == 1001) {
                    //未登录
                    location.href = '/user/login.html?originUrl=' + decodeURIComponent(location.href);

                }else {
                    layer.alert(data.msg);
                }

            },
            error: function () {
                layer.alert('网络异常');
            }
        })

    }
</script>
</html>