news.index.html 4.8 KB

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