index.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. {extend name='admin@main'}
  2. {block name="button"}
  3. <button data-open="{:url('add')}" class='layui-btn layui-btn-sm layui-btn-primary'>添加图文</button>
  4. {/block}
  5. {block name='content'}
  6. <div class="think-box-shadow">
  7. <div id="news-box" class="layui-clear">
  8. {foreach $list as $vo}
  9. <div class="news-item">
  10. <div class='news-tools layui-hide'>
  11. <a data-phone-view="{:url('@wechat/api.review/news/'.$vo.id)}" href='javascript:void(0)'>预览</a>
  12. <a data-open='{:url("edit")}?id={$vo.id}' href='javascript:void(0)'>编辑</a>
  13. <a data-news-del="{$vo.id}" href='javascript:void(0)'>删除</a>
  14. </div>
  15. {foreach $vo.articles as $k => $v}
  16. {if $k < 1}
  17. <div data-tips-image='{$v.local_url}' class='news-articel-item' style='background-image:url("{$v.local_url}")'>
  18. {if $v.title}<p>{$v.title}</p>{/if}
  19. </div>
  20. <div class="hr-line-dashed"></div>
  21. {else}
  22. <div class='news-articel-item other'>
  23. <span>{$v.title}</span>
  24. <div data-tips-image='{$v.local_url}' style='background-image:url("{$v.local_url}");'></div>
  25. </div>
  26. <div class="hr-line-dashed"></div>
  27. {/if}
  28. {/foreach}
  29. </div>
  30. {/foreach}
  31. </div>
  32. {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
  33. </div>
  34. {/block}
  35. {block name='script'}
  36. <script>
  37. $('body').on('mouseenter', '.news-item', function () {
  38. $(this).find('.news-tools').removeClass('layui-hide');
  39. }).on('mouseleave', '.news-item', function () {
  40. $(this).find('.news-tools').addClass('layui-hide');
  41. });
  42. require(['jquery.masonry'], function (Masonry) {
  43. var item = document.querySelector('#news-box');
  44. var msnry = new Masonry(item, {itemSelector: '.news-item', columnWidth: 0});
  45. msnry.layout();
  46. $('body').on('click', '[data-news-del]', function () {
  47. var that = this;
  48. var dialogIndex = $.msg.confirm('确定要删除图文吗?', function () {
  49. $.form.load('{:url("remove")}', {value: 0, field: 'delete', id: that.getAttribute('data-news-del')}, 'post', function (ret) {
  50. if (ret.code) {
  51. $(that).parents('.news-item').remove();
  52. return $.msg.success(ret.msg), msnry.layout(), false;
  53. }
  54. return $.msg.error(ret.msg), false;
  55. });
  56. $.msg.close(dialogIndex);
  57. });
  58. });
  59. });
  60. </script>
  61. {/block}
  62. {block name="style"}
  63. <style>
  64. #news-box {
  65. position: relative
  66. }
  67. #news-box .news-item {
  68. top: 0;
  69. left: 0;
  70. padding: 5px;
  71. margin: 10px;
  72. width: 300px;
  73. position: relative;
  74. border: 1px solid #ccc;
  75. box-sizing: content-box
  76. }
  77. #news-box .news-item .news-articel-item {
  78. width: 100%;
  79. height: 150px;
  80. overflow: hidden;
  81. position: relative;
  82. background-size: 100%;
  83. background-position: center center
  84. }
  85. #news-box .news-item .news-articel-item p {
  86. bottom: 0;
  87. width: 100%;
  88. color: #fff;
  89. padding: 5px;
  90. max-height: 5em;
  91. font-size: 12px;
  92. overflow: hidden;
  93. position: absolute;
  94. text-overflow: ellipsis;
  95. background: rgba(0, 0, 0, .7)
  96. }
  97. #news-box .news-item .news-articel-item.other {
  98. height: 50px;
  99. padding: 5px 0
  100. }
  101. #news-box .news-item .news-articel-item span {
  102. width: 245px;
  103. overflow: hidden;
  104. line-height: 50px;
  105. white-space: nowrap;
  106. display: inline-block;
  107. text-overflow: ellipsis
  108. }
  109. #news-box .news-item .news-articel-item div {
  110. width: 50px;
  111. height: 50px;
  112. float: right;
  113. overflow: hidden;
  114. position: relative;
  115. background-position: center center;
  116. background-size: cover;
  117. }
  118. #news-box .hr-line-dashed {
  119. margin: 6px 0 1px 0
  120. }
  121. #news-box .news-item .hr-line-dashed:last-child {
  122. display: none
  123. }
  124. #news-box .news-tools {
  125. top: 0;
  126. z-index: 80;
  127. color: #fff;
  128. width: 302px;
  129. padding: 0 5px;
  130. margin-left: -6px;
  131. line-height: 38px;
  132. text-align: right;
  133. position: absolute;
  134. background: rgba(0, 0, 0, .7)
  135. }
  136. #news-box .news-tools a {
  137. color: #fff;
  138. margin-left: 10px
  139. }
  140. </style>
  141. {/block}