<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>{$tkd.title|parseTpl}</title>
    <meta name="keywords" content="{$tkd.keywords|parseTpl}">
    <meta name="description" content="{$tkd.description|parseTpl}">
    <link rel="canonical" href="{$kx.config.pcurl}__SELF__" />
    {if ($kx.config.ampurl)}<link rel="amphtml" href="{$kx.config.ampurl}__SELF__">{/if}
    {if ($kx.config.mipurl)}<link rel="miphtml" href="{$kx.config.mipurl}__SELF__">{/if}
    <meta property="og:type" content="novel"/>
    <meta property="og:title" content="{$novel.name}"/>
    <meta property="og:description" content="{$novel.intro|showIntroLine}"/>
    <meta property="og:image" content="{$novel.cover}"/>
    <meta property="og:novel:category" content="{$category.name}"/>
    <meta property="og:novel:author" content="{$author.name}"/>
    <meta property="og:novel:book_name" content="{$novel.name}"/>
    <meta property="og:novel:read_url" content="{$kx.config.pcurl}{link=novel.novel.index novelid=$novel.id pinyin=$novel.pinyin}"/>
    <meta property="og:url" content="{$kx.config.pcurl}{link=novel.novel.index novelid=$novel.id pinyin=$novel.pinyin}"/>
    <meta property="og:novel:author_link" content="{$kx.config.pcurl}{link=author.space.index authorid=$author.id pinyin=$author.pinyin name=$author.name}"/>
    <meta property="og:novel:status" content="{if $novel.is_over}完结{else}连载中{/if}"/>
    <meta property="og:novel:update_time" content="{$last.time|date='Y-m-d H:i:s'}"/>
    <meta property="og:novel:latest_chapter_name" content="{$last.name}"/>
    <meta property="og:novel:latest_chapter_url" content="{$kx.config.pcurl}{link=novel.chapter.read novelid=$novel.id pinyin=$novel.pinyin chapterid=$last.id}"/>
    {include file="/system/head"}
    <link rel="stylesheet" href="{$kx.config.resurl}/template/kxwebno2/css/font-awesome.min.css">
</head>
<body>
{include file="/system/header"}
<section class="w-all">
    <nav class="mt20">
        <ul class="clearfix">
            <li><a href="{$kx.config.siteurl}" title="{$kx.config.sitename}首页"><i class="pticon pticon-home pticon-lg"></i> {$kx.config.sitename}首页</a><i class="pticon pticon-angle-right icon"></i></li>
            <li><a href="{link=novel.category.list categoryid=$category.id key=$category.key}" title="{$category.name}小说">{$category.name}小说</a><i class="pticon pticon-angle-right icon"></i></li>
            <li><a href="#" title="{$novel.name}">{$novel.name}</a></li>
        </ul>
    </nav>
    <div class="container clearfix mt20">
        <div class="clearfix">
            <div class="w-left">
                <div class="card">
                    <div class="header line">
                        <h1>{$novel.name}</h1>
                    </div>
                    <div class="body novel">
                        <div class="novelinfo">
                            <div class="novelinfo-l">
                                <ul>
                                    <li>作者：<a href="{link=author.space.index authorid=$author.id pinyin=$author.pinyin name=$author.name}" title="{$author.name} 作品大全">{$author.name}</a></li>
                                    <li>评分：{$data.star}</li>
                                    <li>收藏：{$data.mark}</li>
                                    <li>推荐：{$data.vote}</li>
                                    <li>来源：{$source.name}({$source.host})</li>
                                    <li>最新：<a href="{link=novel.chapter.read novelid=$novel.id pinyin=$novel.pinyin chapterid=$last.id}" title="{$novel.name} {$last.name}" target="_blank">{$last.name}</a></li>
                                    <li>更新：{$last.time|date="Y-m-d H:i:s"}</li>
                                </ul>
                            </div>
                            <div class="novelinfo-r"><img src="{$novel.cover}" alt="{$novel.name}"></div>
                        </div>
                        <div class="operate">
                            {if $last.id}
                            <a href="{link=novel.chapter.read novelid=$novel.id pinyin=$novel.pinyin chapterid=1}" class="btn btn-primary" target="_blank"><i class="pticon pticon-leanpub "></i> 开始阅读</a>
                            {else}
                            <a href="javascript:void(0);" class="btn btn-primary" target="_blank"><i class="pticon pticon-leanpub "></i> 开始阅读</a>
                            {/if}
                            <a href="{link=user.mark.add novelid=$novel.id}" class="btn btn-success" target="_blank"><i class="pticon pticon-bookmark "></i> 收藏</a>
                            <a href="{link=user.vote.add novelid=$novel.id}" class="btn btn-danger"><i class="pticon pticon-heart"></i> 推荐</a>
                            <a href="javascript:$.pt.gopos('.commentarea');" class="btn btn-default"><i class="pticon pticon-comments "></i> 评论</a>
                            <a href="{link=novel.novel.down novelid=$novel.id pinyin=$novel.pinyin}" title="{$novel.name}TXT下载" class="btn btn-warning"> TXT下载</a>
                        </div>
                        <div class="clear"></div>
                    </div>
                </div>
                <div class="card mt20">
                    <div class="header line">
                        <h3>内容简介</h3>
                    </div>
                    <div class="body novelintro" style="height:171px;overflow-y:auto">
                        {$novel.intro|showintro}
                        <br/>
                        　　各位书友要是觉得《{$novel.name}》还不错的话请不要忘记向您QQ群和微博里的朋友推荐哦！{$novel.name}最新章节,{$novel.name}全文阅读.
                    </div>
                </div>
            </div>
            <div class="w-right">
                <div class="card pt-tab">
                    <div class="header line">
                        <h3>{$novel.name} 评分</h3>
                    </div>
                    <div class="body novel-star">
                        <b>我来评分：</b>
                        <div class="g-star"></div>
                        <br>
                        <b>综合评分：</b><span class="num-avg-star" data-star-score="{$data.star_score}" data-star-num="{$data.star_num}">{$data.star}</span><br>
                        <b>参与人数：</b><span class="num-star-people">{$data.star_num}</span><br>
                    </div>
                </div>
                <div class="card pt-tab mt20">
                    <div class="header tab pt-tab-nav">
                        <ul class="clearfix">
                            <li class="active">本月热门</li>
                            <li>本周热门</li>
                        </ul>
                    </div>
                    <div class="body pt-tab-con">
                        <ul class="rightlist">
                            {block method="novel.list" name="list" order="monthvisit" num=15}
                            {section loop=$list}
                            <li><i {if $i.order<4}class="first"{/if}>{$i.order}</i><span><a href="{link=author.space.index authorid=$loop.author.id pinyin=$loop.author.pinyin name=$loop.author.name}" title="{$loop.author.name} 作品大全">{$loop.author.name}</a></span><a href="{link=novel.novel.index novelid=$loop.novel.id pinyin=$loop.novel.pinyin}" title="{$loop.novel.name}">{$loop.novel.name}</a>
                            </li>
                            {/section}
                        </ul>
                        <ul class="rightlist none">
                            {block method="novel.list" name="list" order="weekvisit" num=15}
                            {section loop=$list}
                            <li><i {if $i.order<4}class="first"{/if}>{$i.order}</i><span><a href="{link=author.space.index authorid=$loop.author.id pinyin=$loop.author.pinyin name=$loop.author.name}" title="{$loop.author.name} 作品大全">{$loop.author.name}</a></span><a href="{link=novel.novel.index novelid=$loop.novel.id pinyin=$loop.novel.pinyin}" title="{$loop.novel.name}">{$loop.novel.name}</a>
                            </li>
                            {/section}
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <div class="card infotab mt20">
            <div class="header  line">
                <h2>作品集</h2>
            </div>
            <div class="body pt-tab-con">
                <ul class="coverlist clearfix">
                    {block method="novel.list" name="list" author=$author.id}
                    {section loop=$list}
                    <li>
                        <span class="cover"><a href="{link=novel.novel.index novelid=$loop.novel.id pinyin=$loop.novel.pinyin}" title="{$loop.novel.name}" target="_blank"><img src="{$loop.novel.cover}" alt="{$loop.novel.name}"></a></span>
                        <span class="name cut"><a href="{link=novel.novel.index novelid=$loop.novel.id pinyin=$loop.novel.pinyin}" title="{$loop.novel.name}" target="_blank">{$loop.novel.name}</a></span>
                    </li>
                    {/section}
                </ul>

            </div>
        </div>
        <div class="card mt20 ">
            <div class="header line">
                <h2>最新章节</h2>
            </div>
            <div class="body ">
                <ul class="dirlist three clearfix">
                    {block method=chapter.list novelid=$novel.id num=9 name=$list sort=desc}
                    {section loop="list"}
                    <li><a href="{link=novel.chapter.read novelid=$novel.id pinyin=$novel.pinyin chapterid=$loop.chapterid}" title="{$novel.name} {$loop.name} {$loop.time|date='Y-m-d H:i:s'}" target="_blank">{$loop.name}</a></li>
                    {/section}
                </ul>
            </div>
        </div>
        <div class="card mt20 fulldir">
            <div class="header line">
                <h2>章节目录</h2>
            </div>
            <div class="body ">
                <ul class="dirlist three clearfix">
                    {block method=chapter.list novelid=$novel.id name=$list sort=asc}
                    {section loop="list"}
                    <li class="hide"><a href="{link=novel.chapter.read novelid=$novel.id pinyin=$novel.pinyin chapterid=$loop.chapterid}" title="{$novel.name} {$loop.name}" target="_blank">{$loop.name}</a></li>
                    {/section}
                </ul>
            </div>
        </div>
        <div class="card mt20 commentarea">
            <div class="header line">
                <a href="{link=novel.comment.list novelid=$novel.id pinyin=$novel.pinyin}">
                    <h3>评论区</h3><span class="fr" style="margin-right: 10px;color: #999; font-size: 16px;">全部评论({$data.comment}条)</span>
                </a>
            </div>
            <div class="body">
                {block method="comment.list" name=commentlist type='novel' userid=$userinfo.id typeid=$novel.id}
                {if $commentlist}
                <ul class="commentlist full">
                    {loop=commentlist}
                    <li class="clearfix">
                        <div class="avatar">
                            <img src="{$loop.user.avatar}" alt="{$loop.user.name}">
                        </div>
                        <div class="item">
                            <div class="title">
                                <a href="{link=novel.comment.post novelid=$novel.id pinyin=$novel.pinyin commentid=$loop.id}">{$loop.user.name}</a>
                                <span class="time">{$loop.datetime|date="Y-m-d H:i:s"}</span>
                                <span class="fr {$loop.rating|boolval|default='','disable'}" data-id="{$loop.id}">
                                    <a class="comment" href="{link=novel.comment.post novelid=$novel.id pinyin=$novel.pinyin commentid=$loop.id}" title="回复 {$loop.post_num}"><i class="pticon pticon-comments"></i> <span>{$loop.post_num}</span></a>
									<a class="up" title="赞同 {$loop.good_num}"><i class="fa fa-thumbs-up"></i> <span>{$loop.good_num}</span></a>
									<a class="down" title="反对 {$loop.bad_num}"><i class="fa fa-thumbs-down"></i> <span>{$loop.bad_num}</span></a>
								</span>
                            </div>
                            <div class="content">
                                {$loop.content|nl2br}
                            </div>
                        </div>
                    </li>
                    {/loop}
                </ul>
                {else}
                <div class="addcomment full" style="border-top:none;padding-top:0">
                    <div class="tips">本书暂无评论,快来抢占第一条评论吧</div>
                </div>
                {/if}
                <div class="addcomment full clearfix">
                    {if $islogin}
                    <form action="{link=novel.comment.add}" method="post">
                        <input type="hidden" name="type" value="novel">
                        <input type="hidden" name="type_id" value="{$novel.id}">
                        <textarea name="content" class="text"></textarea>
                        <button class="btn btn-success fr">发布评论</button>
                    </form>
                    {else}
                    <div class="tips">请您 <a href="{link=user.auth.register}">注册</a> 或 <a href="{link=user.auth.login}">登陆</a> 之后再发布评论</div>
                    {/if}
                </div>
            </div>
        </div>
    </div>
    <div class="seofooter">
        <p>
            <a href="#" title="{$novel.name}">《{$novel.name}》</a>是由<a href="{link=author.space.index authorid=$author.id pinyin=$author.pinyin name=$author.name">{$author.name}</a>倾情撰写的小说！<a href="#" title="{$novel.name}">《{$novel.name}》</a>为热心网友免费发布在<a href="{$kx.config.siteurl}">{$kx.config.sitename}</a>供大家免费阅读。
        </p>
        <p>欢迎进入<a href="#}" title="{$novel.name}">《{$novel.name}》</a>txt下载和<a href="#" title="{$novel.name}">《{$novel.name}》</a>全文阅读。谢谢您一直对<a href="{$kx.config.siteurl}">{$kx.config.sitename}</a>
            <a href="{link=novel.category.list categoryid=$category.id key=$category.key}">{$category.name}小说</a>的关注和支持！
        </p>
    </div>
</section>

{include file="/system/footer"}
<script type="text/javascript" src="{$kx.config.resurl}/template/kxwebno2/script/jquery.raty.js"></script>
<script type="text/javascript">
    $(function () {
        var loading = null;

        $(".g-star").raty({
            scoreName: "star", score: "{$data.star}", click: function (v) {
                layer.confirm("您对《{$novel.name}》评分" + v + "分,请确认操作!", {btn: ["确定", "放弃"]}, function (index) {
                    $.ajax('{link=user.star.add}', {
                        type: 'post',
                        dataType: 'json',
                        data: {
                            'novelid': '{$novel.id}',
                            'star': v,
                        },
                        beforeSend: function () {
                            if (loading == null) {
                                loading = layer.load(1, {shade: [0.1, '#000']});
                            }
                        },
                        complete: function () {
                            if (loading != null) {
                                layer.close(loading);
                                loading = null;
                            }
                        },
                        success: function (res) {
                            if (res.code) {
                                layer.alert(res.msg, {icon: 2,}, function (index) {
                                    if (res.data.redirect) {
                                        window.location.href = res.data.redirect;
                                    } else {
                                        layer.close(index);
                                    }
                                });
                            } else {
                                layer.msg('操作成功!');
                                var starPeopleNum = $('.num-star-people');
                                starPeopleNum.text(parseInt(starPeopleNum.text()) + 1);
                                var avgStar = $('.num-avg-star');
                                console.log(avgStar.data('star-score'));
                                console.log(avgStar.data('star-num'));
                                avgStar.text((parseInt(avgStar.data('star-score')) + v) / (parseInt(avgStar.data('star-num')) + 1));
                            }
                        },
                        error: function () {
                            layer.alert('评分失败，请刷新页面后重试！', {icon: 2,});
                        }
                    });
                    layer.close(index)
                })
            }
        });
        var length = $(".fulldir .dirlist li").length;
        if (length > 30) {
            var len = Math.ceil(length / 3);
            $(".fulldir .dirlist li:lt(15)").removeClass("hide");
            $(".fulldir .dirlist li:gt(" + (3 * (len - 5) - 1) + ")").removeClass("hide");
            $(".fulldir .dirlist li").eq(14).after('<li class="fulltip">···················· 查看全部' + length + "章节 ····················</li>")
        } else {
            $(".fulldir .dirlist li").removeClass("hide")
        }
        $(".loading").remove();
        $(".fulltip").on("click", function () {
            $(this).remove();
            $(".fulldir .dirlist li").removeClass("hide")
        });

        $(".commentlist a").on("click", function () {
            var action, self = $(this);
            if (self.hasClass("up")) {
                action = 'good';
            } else if (self.hasClass("down")) {
                action = 'bad';
            } else {
                return true
            }
            if (self.hasClass('active') || self.parent().hasClass('disable')) {
                layer.msg('操作失败，您已经评价过了！');
                return false;
            }
            var $num = self.find("span");
            $.ajax("{link=novel.comment.rating}", {
                type: 'post',
                dataType: 'json',
                data: {
                    comment_id: self.parent().data("id"),
                    type:'novel',
                    type_id:'{$novel.id}',
                    action: action,
                },
                beforeSend: function () {
                    if (loading == null) {
                        loading = layer.load(1, {shade: [0.1, '#000']});
                    }
                },
                complete: function () {
                    if (loading != null) {
                        layer.close(loading);
                        loading = null;
                    }
                },
                success: function (res) {
                    if (res.code) {
                        layer.alert(res.msg, {icon: 2,}, function (index) {
                            if (res.data.redirect) {
                                window.location.href = res.data.redirect;
                            } else {
                                layer.close(index);
                            }
                        });
                    } else {
                        self.addClass('active');
                        self.parent().addClass('disable');
                        $num.text(parseInt($num.text()) + 1);
                        layer.msg('操作成功');
                    }
                },
                error: function () {
                    layer.alert('操作失败，请刷新页面后重试！', {icon: 2,});
                }
            });
        })
    });
</script>
</body>
</html>
