Files
novel-plus/novel-front/src/main/resources/templates/author/index.html
T

347 lines
14 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<title>作家管理系统-小说精品屋</title>
<link rel="stylesheet" href="/css/base.css?v=1"/>
<link rel="stylesheet" href="/css/user.css"/>
<link rel="stylesheet" href="/css/author.css"/>
</head>
</head>
<body class="author_zone">
<div class="header">
<div class="mainNav" id="mainNav">
<div class="box_center cf"
style="text-align: center;height: 44px;line-height: 48px;color: #fff;font-size: 16px;">
小说精品屋作家管理
</div>
</div>
</div>
<div class="main box_center cf">
<div class="userBox cf">
<div class="my_l">
<ul class="log_list">
<li><a class="link_book on" href="/author/index.html">小说管理</a></li>
<li><a class="link_ai" href="/author/ai_assistant.html">AI创作助手</a></li>
<li><a class="link_income" href="/author/author_income_detail.html">稿费收入</a></li>
</ul>
</div>
<div class="my_r">
<div id="noContentDiv">
<div class="empty_box">
<svg width="72" height="72" viewBox="0 0 24 24" fill="none" stroke="#3eaf7c" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 7.5C10.5 6 8 5.4 4.5 5.7v12C8 17.5 10.5 18 12 19.5M12 7.5c1.5-1.5 4-2.1 7.5-1.8v12c-3.5-.2-6 .3-7.5 1.8"/>
</svg>
<p>还没有作品,快去创建一部吧~</p>
<a href="/author/book_add.html" class="btn_main">创建作品</a>
</div>
</div>
<div class="my_bookshelf" id="hasContentDiv" style="display: none">
<div class="title cf">
<h2 class="fl">小说列表</h2>
<div class="fr"><a href="/author/book_add.html" class="btn_main">+ 发布小说</a></div>
</div>
<div id="divData" class="updateTable">
<table cellpadding="0" cellspacing="0">
<thead>
<tr>
<th class="name">
作品
</th>
<th class="goread col_visit">
点击量
</th>
<th class="goread col_buy">
昨日订阅
</th>
<th class="goread col_time">
更新时间
</th>
<th class="goread col_word">
总字数
</th>
<th class="goread col_status">
状态
</th>
<th class="goread col_opt">
操作
</th>
</tr>
</thead>
<tbody id="bookList">
</tbody>
</table>
<div class="pageBox cf" id="shellPage">
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script src="/javascript/jquery-1.8.0.min.js" type="text/javascript"></script>
<script src="/javascript/ajaxfileupload.js" type="text/javascript"></script>
<script src="/layui/layui.all.js" type="text/javascript"></script>
<script src="/javascript/header.js" type="text/javascript"></script>
<script src="/javascript/user.js" type="text/javascript"></script>
<script src="/javascript/date.js" type="text/javascript"></script>
<script src="/javascript/common.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
var coverUpdateInterval;
search(1, 10);
//数字缩写:超过10万用“万”作单位,避免数字过长撑宽列
function fmtNum(n) {
var num = Number(n || 0);
if (isNaN(num)) {
num = 0;
}
return num >= 100000 ? (num / 10000).toFixed(1).replace(/\.0$/, '') + '万' : String(num);
}
//时间两行展示:日期 + 时刻
function fmtTime(t) {
var d = new Date(Date.parse(t));
return d.Format('yyyy-MM-dd') + '<br>' + d.Format('hh:mm');
}
//HTML转义,防止书名/章节名破坏表格结构
function escapeHtml(str) {
return String(str == null ? '' : str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}
function search(curr, limit) {
clearInterval(coverUpdateInterval);
$.ajax({
type: "get",
url: "/author/listBookByPage",
data: {'curr': curr, 'limit': limit},
dataType: "json",
success: function (data) {
if (data.code == 200) {
var bookList = data.data.list;
if (bookList.length > 0) {
if (curr == 1 && bookList[0].picUrl == '/images/default.gif') {
coverUpdateInterval = setInterval(function () {
$.ajax({
type: "get",
url: "/author/queryAiGenPic",
data: {'bookId': bookList[0].id},
dataType: "json",
success: function (data) {
if (data.code == 200 && data.data) {
$("#cover" + bookList[0].id).attr("src", data.data);
clearInterval(coverUpdateInterval);
}
}
});
}, 3000);
setTimeout(() => {
clearInterval(coverUpdateInterval);
}, 10000);
}
$("#hasContentDiv").css("display", "block");
$("#noContentDiv").css("display", "none");
var bookListHtml = "";
for (var i = 0; i < bookList.length; i++) {
var book = bookList[i];
var updTime = fmtTime(book.lastIndexUpdateTime ? book.lastIndexUpdateTime : book.updateTime);
bookListHtml += '<tr class="book_list">'
+ '<td class="name">'
+ ' <div class="book_cell">'
+ ' <div class="cover_wrap">'
+ ' <input type="file" id="file' + book.id + '" name="file" title="点击更换封面" onchange="picChange(\'' + book.id + '\')" />'
+ ' <img id="cover' + book.id + '" src="' + book.picUrl + '" alt="封面"/>'
+ ' <span class="cover_mask">更换封面</span>'
+ ' </div>'
+ ' <div class="book_info">'
+ ' <a class="book_name" target="_blank" href="/book/' + book.id + '.html" title="' + escapeHtml(book.bookName) + '">' + escapeHtml(book.bookName) + '</a>'
+ ' <p class="book_cat">' + escapeHtml(book.catName || '') + '</p>'
+ ' </div>'
+ ' </div>'
+ '</td>'
+ '<td class="goread"><span class="num">' + fmtNum(book.visitCount) + '</span></td>'
+ '<td class="goread"><span class="num">' + fmtNum(book.yesterdayBuy) + '</span></td>'
+ '<td class="goread time_cell">' + updTime + '</td>'
+ '<td class="goread"><span class="num">' + fmtNum(book.wordCount) + '</span></td>'
+ '<td class="goread">' + (book.bookStatus == 0 ? '<span class="tag tag_serial">连载中</span>' : '<span class="tag tag_done">已完结</span>') + '</td>'
+ '<td class="goread opt" id="opt' + book.id + '">'
+ '<a target="_blank" href="/author/index_list.html?bookId=' + book.id + '">章节管理</a>'
+ '<a href="/author/ai_assistant.html?bookId=' + book.id + '">AI创作</a>'
+ '<a target="_blank" href="/author/author_income_detail.html?bookId=' + book.id + '">薪酬查询</a>'
+ (book.bookStatus == 0 ? '<a class="opt_del" href="javascript:finishBook(\'' + book.id + '\')">设为完结</a>' : '')
+ '</td></tr>';
}
$("#bookList").html(bookListHtml);
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
, theme: '#3eaf7c'
, jump: function (obj, first) {
//首次不执行
if (!first) {
search(obj.curr, obj.limit);
}
}
});
});
}
} else if (data.code == 1001) {
//未登录
location.href = '/user/login.html?originUrl=' + encodeURIComponent(location.href);
} else {
layer.alert(data.msg);
}
},
error: function () {
layer.alert('网络异常');
}
})
}
function updateBookStatus(bookId, status) {
$.ajax({
type: "POST",
url: "/author/updateBookStatus",
data: {'bookId': bookId, 'status': status == 0 ? 1 : 0},
dataType: "json",
success: function (data) {
if (data.code == 200) {
location.reload();
} else if (data.code == 1001) {
//未登录
location.href = '/user/login.html?originUrl=' + encodeURIComponent(location.href);
} else {
layer.alert(data.msg);
}
},
error: function () {
layer.alert('网络异常');
}
})
}
function picChange(bookId) {
var file = $("#file" + bookId).val(); //文件名称
if (file != "") {
if (checkPicUpload($("#file" + bookId)[0])) {
$.ajaxFileUpload({
url: "/file/picUpload", //用于文件上传的服务器端请求地址
secureuri: false, //是否需要安全协议,一般设置为false
fileElementId: "file" + bookId, //文件上传域的ID
dataType: "json", //返回值类型 一般设置为json
type: "post",
success: function (data) { //服务器成功响应处理函数
if (data.code == 200) {
let picUrl = data.data;
$.ajax({
type: "POST",
url: "/author/updateBookPic",
data: {'bookId': bookId, 'bookPic': data.data},
dataType: "json",
success: function (data) {
if (data.code == 200) {
$("#cover" + bookId).attr("src", picUrl);
} else {
layer.alert(data.msg);
}
},
error: function () {
layer.alert('网络异常');
}
})
} else {
layer.alert(data.msg);
}
}
});
}
} else {
alert("请选择上传文件!");
}
}
function finishBook(bookId) {
layer.confirm('确认要完结作品吗?该操作不可逆!', {
btn: ['确定', '取消']//按钮
}, function (index) {
layer.close(index);
$.ajax({
type: "post",
url: "/author/finishBook",
data: {"bookId": bookId},
dataType: "json",
success: function (data) {
if (data.code == 200) {
location.reload();
} else if (data.code == 1001) {
//未登录
location.href = '/user/login.html?originUrl=' + encodeURIComponent(location.href);
} else {
layer.alert(data.msg);
}
},
error: function () {
layer.alert('网络异常');
}
})
});
}
</script>
</html>