You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

398 lines
19 KiB

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>我的书单 - 用户中心 - {$kx.config.sitename}</title>
  6. <link rel="stylesheet" href="{$kx.config.resurl}/template/kxwebno1/css/global.css"/>
  7. <link rel="stylesheet" href="{$kx.config.resurl}/template/kxwebno1/css/style.css"/>
  8. <link rel="stylesheet" href="{$kx.config.resurl}/template/kxwebno1/js/select2/css/select2.min.css"/>
  9. <style>
  10. .pt-booklist-novel-list .pt-booklist-info{
  11. width:780px;
  12. }
  13. .pt-booklist-create .input {
  14. margin: 10px;
  15. min-height: 35px;
  16. line-height: 35px;
  17. }
  18. .pt-booklist-create .input > label{
  19. width: 130px;
  20. height: 35px;
  21. text-align: right;
  22. float: left;
  23. }
  24. .pt-booklist-create .input > div{
  25. width: 600px;
  26. float: left;
  27. margin-left: 20px;
  28. }
  29. .pt-booklist-create .input .field-textarea,
  30. .pt-booklist-create .input .field-input{
  31. border:1px solid #C9C9C9;
  32. width: 580px;
  33. padding: 10px;
  34. }
  35. .pt-booklist-create .input .field-select{
  36. width: 600px;
  37. }
  38. .pt-booklist-create .input .field-textarea{
  39. height: auto;
  40. line-height: normal;
  41. }
  42. .select2-selection--multiple{
  43. line-height: normal;
  44. }
  45. .select2-selection{
  46. border-radius:0 !important;
  47. border:1px solid #C9C9C9 !important;
  48. }
  49. .select2-results__options li{
  50. display: inline-block;
  51. }
  52. .select2-container--default .select2-results__option--highlighted[aria-selected],
  53. .select2-container--default .select2-results__option[aria-selected=true]{
  54. background-color: #f55;
  55. color:#fff
  56. }
  57. .pt-booklist-create .input.addnovel{
  58. position: relative;
  59. }
  60. .pt-booklist-create .input.addnovel input{
  61. width: 500px;
  62. }
  63. .pt-booklist-create .input.addnovel button{
  64. width: 80px;
  65. position: absolute;
  66. right: 178px;
  67. height: 43px;
  68. border: 1px solid #C9C9C9;
  69. background-color: #F5F5F5;
  70. }
  71. </style>
  72. </head>
  73. <body>
  74. <!-- 头部 -->
  75. {include file="/system/header"}
  76. <!-- 内容 -->
  77. <div class="pt-content">
  78. <!-- 面包屑 -->
  79. <div class="pt-crumb">
  80. <img src="{$kx.config.resurl}/template/kxwebno1/images/crumb_icon.png" class="pt-crumb-icon">
  81. <span class="color5">
  82. <a href="{$kx.config.siteurl}">{$kx.config.sitename}</a> > <a href="{link=user.index.index}" class="color5">用户中心</a> > <a href="{link=user.booklist.index}">我的书架</a>
  83. </span>
  84. </div>
  85. <!-- 一楼 -->
  86. <div class="pt-floor1">
  87. {include file="/system/userleft"}
  88. <div class="relative pt-rank">
  89. {block method=booklist.info booklistid=$kx.get.id name=info}
  90. <div class="pt-booklist-head">
  91. <span class="size16 color3 pl10" style="border-left:5px solid #f55;">{=empty($info)?'创建书单':'修改书单'}</span>
  92. </div>
  93. <form method="post">
  94. <div class="pt-booklist-create">
  95. {if !empty($info)}
  96. <input type="hidden" name="id" value="{$info.id}">
  97. {/if}
  98. <div class="mb20 input clearfix">
  99. <label for="title">书单名称</label>
  100. <div>
  101. <input class="field-input" type="text" name="title" value="{$info.title}" placeholder="请输入书单名称">
  102. </div>
  103. </div>
  104. <div class="mb20 input clearfix">
  105. <label for="tags">标签</label>
  106. <div>
  107. <select class="field-select select-tags none" name="tags[]" multiple>
  108. {~$tags=array_column($info.tags,'id')}
  109. {block method="tag" name=list}
  110. {loop}
  111. <option value="{$loop.id}" {=in_array($loop.id,$tags)?'selected':''}>{$loop.name}</option>
  112. {/loop}
  113. </select>
  114. </div>
  115. </div>
  116. <div class="mb20 input clearfix">
  117. <label for="intro">书单简介</label>
  118. <div>
  119. <textarea class="field-textarea" name="intro" id="intro" rows="5" placeholder="请输入书单简介">{$info.intro
  120. }</textarea>
  121. </div>
  122. </div>
  123. <div class="mb20 input clearfix addnovel">
  124. <label>添加小说</label>
  125. <div>
  126. <input type="text" class="field-input" placeholder="请输入小说名称"><button type="button">搜索</button>
  127. </div>
  128. </div>
  129. <div class="mb20 input clearfix">
  130. <label></label>
  131. <div>
  132. <button type="submit" class="plr35 ptb10 bg-red color1">确认</button>
  133. <a href="{link=index}" class="plr35 ptb10 border-c9 bg-white color2 ml25">取消</a>
  134. </div>
  135. </div>
  136. </div>
  137. <ul class="pt-booklist-novel-list">
  138. {loop=$info.novels}
  139. <li>
  140. <img class="fl pt-booklist-cover" src="{$loop.novel.cover}" alt="">
  141. <div class="fl pt-booklist-info">
  142. <input type="hidden" name="novels[id][]" value="{$loop.novel.id}">
  143. <span class="mr60 size24 color3">{$loop.novel.name}</span>
  144. <div class="star">
  145. <input type="hidden" name="novels[star][]" value="{$loop.star}">
  146. <span class="color5 mr10 size16">推荐指数:</span>
  147. <span class="pt-photo" data-star="{$loop.star}">
  148. <span title="不知所云">
  149. <img src="{$kx.config.resurl}/template/kxwebno1/images/star1.png" class="high">
  150. <img src="{$kx.config.resurl}/template/kxwebno1/images/star.png" class="nohigh">
  151. </span>
  152. <span title="随便看看">
  153. <img src="{$kx.config.resurl}/template/kxwebno1/images/star1.png" class="high">
  154. <img src="{$kx.config.resurl}/template/kxwebno1/images/star.png" class="nohigh">
  155. </span>
  156. <span title="值得一读">
  157. <img src="{$kx.config.resurl}/template/kxwebno1/images/star1.png" class="high">
  158. <img src="{$kx.config.resurl}/template/kxwebno1/images/star.png" class="nohigh">
  159. </span>
  160. <span title="不容错过">
  161. <img src="{$kx.config.resurl}/template/kxwebno1/images/star1.png" class="high">
  162. <img src="{$kx.config.resurl}/template/kxwebno1/images/star.png" class="nohigh">
  163. </span>
  164. <span title="经典必读">
  165. <img src="{$kx.config.resurl}/template/kxwebno1/images/star1.png" class="high">
  166. <img src="{$kx.config.resurl}/template/kxwebno1/images/star.png" class="nohigh">
  167. </span>
  168. </span>
  169. </div>
  170. <textarea rows="2" placeholder="请填写书评" name="novels[comment][]">{$loop.comment}</textarea>
  171. </div>
  172. <a class="remove">移除</a>
  173. </li>
  174. {/loop}
  175. </ul>
  176. </form>
  177. </div>
  178. </div>
  179. </div>
  180. <!--搜索书籍-->
  181. <div style="display: none;" id="tpl_novel_search">
  182. <div>
  183. <div class="mlr35 mtb35">
  184. <h1 class="pl10" style="border-left: 5px solid #FF5555">搜索结果</h1>
  185. <table class="size14 mt40 w100" style="padding: 0">
  186. <thead class="color92 bg" style="line-height: 35px;background-color: #F5F5F5;">
  187. <tr class="border-e9">
  188. <th style="width: 35%;padding: 0">书名</th>
  189. <th style="width: 35%;padding: 0">作者</th>
  190. <th style="width: 10%;padding: 0">分类</th>
  191. <th style="width: 10%;padding: 0">点击</th>
  192. <th style="width: 10%;padding: 0">操作</th>
  193. </tr>
  194. </thead>
  195. <tbody class="color62" style="line-height: 45px;text-align: center;">
  196. </tbody>
  197. </table>
  198. </div>
  199. </div>
  200. </div>
  201. <!--书籍模板-->
  202. <div style="display: none" id="tpl_novel">
  203. <li>
  204. <img class="fl pt-booklist-cover" src="" alt="">
  205. <div class="fl pt-booklist-info">
  206. <input class="id" type="hidden" name="novels[id][]">
  207. <span class="mr60 size24 color3 name"></span>
  208. <div class="star">
  209. <input class="star" type="hidden" name="novels[star][]" value="0">
  210. <span class="color5 mr10 size16">推荐指数:</span>
  211. <span class="pt-photo" data-star="0">
  212. <span title="不知所云">
  213. <img src="{$kx.config.resurl}/template/kxwebno1/images/star1.png" class="high">
  214. <img src="{$kx.config.resurl}/template/kxwebno1/images/star.png" class="nohigh">
  215. </span>
  216. <span title="随便看看">
  217. <img src="{$kx.config.resurl}/template/kxwebno1/images/star1.png" class="high">
  218. <img src="{$kx.config.resurl}/template/kxwebno1/images/star.png" class="nohigh">
  219. </span>
  220. <span title="值得一读">
  221. <img src="{$kx.config.resurl}/template/kxwebno1/images/star1.png" class="high">
  222. <img src="{$kx.config.resurl}/template/kxwebno1/images/star.png" class="nohigh">
  223. </span>
  224. <span title="不容错过">
  225. <img src="{$kx.config.resurl}/template/kxwebno1/images/star1.png" class="high">
  226. <img src="{$kx.config.resurl}/template/kxwebno1/images/star.png" class="nohigh">
  227. </span>
  228. <span title="经典必读">
  229. <img src="{$kx.config.resurl}/template/kxwebno1/images/star1.png" class="high">
  230. <img src="{$kx.config.resurl}/template/kxwebno1/images/star.png" class="nohigh">
  231. </span>
  232. </span>
  233. </div>
  234. <textarea class="comment" rows="3" placeholder="请填写书评" name="novels[comment][]"></textarea>
  235. </div>
  236. <a class="remove">移除</a>
  237. </li>
  238. </div>
  239. <!-- 底部版权-->
  240. {include file="/system/footer"}
  241. <script src="{$kx.config.resurl}/template/kxwebno1/js/jquery-3.3.1.js"></script>
  242. <script src="{$kx.config.resurl}/template/kxwebno1/js/select2/js/select2.min.js"></script>
  243. <script src="https://cdn.bootcss.com/select2/4.0.6-rc.1/js/i18n/zh-CN.js"></script>
  244. <!-- js-->
  245. <script>
  246. var loading = null;
  247. $('.select-tags').select2({
  248. placeholder: '请选择标签分类',
  249. maximumSelectionLength:3,
  250. language: "zh-CN",
  251. });
  252. $('.addnovel').on('click', 'button', function (e) {
  253. $.ajax('{link=novel.search.result}', {
  254. type: 'post',
  255. dataType: 'json',
  256. data: {'searchkey': $('.addnovel input').val()},
  257. beforeSend: function () {
  258. if (loading == null) {
  259. loading = layer.load(1, {shade: [0.1, '#000']});
  260. }
  261. },
  262. complete: function () {
  263. if (loading != null) {
  264. layer.close(loading);
  265. loading = null;
  266. }
  267. },
  268. success: function (res) {
  269. layer.open({
  270. type: 1,
  271. skin: 'layui-layer-rim',
  272. area: '720px',
  273. btn: false,
  274. title: false,
  275. content: '',
  276. success: function (layero, index) {
  277. var html = $(tpl_novel_search.innerHTML);
  278. tbody = html.find('tbody');
  279. $.each(res.data, function (k, v) {
  280. tbody.append('<tr data-id="' + v.id + '" data-name="' + v.name + '" data-cover="' + v.cover + '">' +
  281. '<td>' + v.name + '</td>' +
  282. '<td>' + v.author + '</td>' +
  283. '<td>' + v.category + '</td>' +
  284. '<td>' + v.allvisit + '</td>' +
  285. '<td><a style="color: #FF5555;">添加</a></td>' +
  286. '</tr>'
  287. );
  288. });
  289. layero.find('.layui-layer-content').append(html.html());
  290. layero.resize();
  291. layero.find('.layui-layer-content tbody').on('click', 'a', function () {
  292. var tr = $(this).parents('tr');
  293. if ($('.pt-booklist-novel-list input[name="novels[id][]"][value=' + tr.data('id') + ']').length) {
  294. return layer.msg('本书已存在',function(){});
  295. }
  296. var html = $(tpl_novel.innerHTML);
  297. html.find('.id').val(tr.data('id'));
  298. html.find('.name').text(tr.data('name'));
  299. html.find('.pt-booklist-cover').attr('src', tr.data('cover'));
  300. html.prependTo('.pt-booklist-novel-list');
  301. })
  302. }
  303. })
  304. },
  305. error: function () {
  306. layer.alert('加载失败,请重试!', {icon: 2,});
  307. }
  308. });
  309. }).on('keyup','input',function(e){
  310. if (e.keyCode === 13){
  311. $('.addnovel button').click();
  312. }
  313. });
  314. $('.pt-booklist-novel-list').on('mouseleave','.pt-photo',function(){
  315. $(this).find('.high').css('z-index', 0);
  316. var count = parseInt($(this).data('star'));
  317. if (count === 5) {
  318. $(this).children('span').children('.high').css('z-index', 1);
  319. } else {
  320. $(this).find('span').eq(count).prevAll().find('.high').css('z-index', 1);
  321. }
  322. }).on('mouseenter','.pt-photo span',function(){
  323. $(this).prevAll().find('.high').css('z-index', 1);
  324. $(this).find('.high').css('z-index', 1);
  325. $(this).nextAll().find('.high').css('z-index', 0);
  326. }).on('click','.pt-photo span',function(){
  327. var index = $(this).index() + 1;
  328. $(this).parents('.pt-photo')
  329. .data('star',index)
  330. .siblings('input[name="novels[star][]"]')
  331. .val(index);
  332. }).on('click','.remove',function(){
  333. $(this).parents('li').remove();
  334. }).on('keyup','textarea.comment',function () {
  335. var str = $(this).val();
  336. var len = str.length;
  337. var reLen = 0;
  338. for (var i = 0; i < len; i++) {
  339. if (str.charCodeAt(i) < 33) {
  340. continue;
  341. }
  342. if (str.charCodeAt(i) >= 0 || str.charCodeAt(i) <= 128) {
  343. reLen += 1;
  344. } else {
  345. reLen += 2;
  346. }
  347. }
  348. if(reLen > 200){
  349. $(this).addClass('color2').addClass('border-red');
  350. }else{
  351. $(this).removeClass('color2').removeClass('border-red');
  352. }
  353. });
  354. $('.pt-photo').mouseleave();
  355. $('.pt-rank form').submit(function(){
  356. if (!($(this).find('input[name=title]').val())) {
  357. layer.msg('标题不能为空', function () {
  358. });
  359. return false;
  360. }
  361. if ($(this).find('select[name="tags[]"]').val().length > 3) {
  362. layer.msg('标签不能多于3个', function () {
  363. });
  364. return false;
  365. }
  366. if (!$(this).find('textarea[name=intro]').val()) {
  367. layer.msg('简介不能为空', function () {
  368. });
  369. return false;
  370. }
  371. if ($(this).find('input[name="novels[id][]"]').length < 3) {
  372. layer.msg('书籍不能少于三本', function () {
  373. });
  374. return false;
  375. }
  376. for (var i = 0; i < $(this).find('input[name="novels[id][]"]').length; i++) {
  377. if (!$(this).find('textarea[name="novels[comment][]"]:eq(' + i + ')').val()) {
  378. layer.msg('书评不能为空', function () {
  379. });
  380. return false;
  381. }
  382. star = parseInt($(this).find('input[name="novels[star][]"]:eq(' + i + ')').val());
  383. if (!star || star < 1 || star > 5) {
  384. layer.msg('评分必须介于1 - 5之间', function () {
  385. });
  386. return false;
  387. }
  388. }
  389. });
  390. </script>
  391. </body>
  392. </html>