lists.html 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. {extend name="base"/}
  2. {block name="resources"}
  3. <style>
  4. .layui-table-view td:last-child>div{overflow: inherit;}
  5. .operation-wrap{position: relative;}
  6. .layui-table-box{overflow: inherit;}
  7. .layui-table-body{overflow: inherit;}
  8. .popup-qrcode-wrap{text-align: center;background: #fff;border-radius: 2px;box-shadow: 0 2px 8px 0 rgba(200,201,204,.5);padding: 10px;position: absolute;z-index: 1;top: -73px;left: -180px;display: none;width: 170px;height: 230px;}
  9. .popup-qrcode-wrap:before, .popup-qrcode-wrap:after {left: 100%;top: 50%;border: solid transparent;content: " ";height: 0;width: 0;position: absolute;pointer-events: none;}
  10. .popup-qrcode-wrap:before {border-color: transparent;border-left-color: #e5e5e5;border-width: 8px;margin-top: -29px;}
  11. .popup-qrcode-wrap:after {border-color: transparent;border-left-color: #ffffff;border-width: 7px;margin-top: -31px;}
  12. .popup-qrcode-wrap img{width: 150px;height: 150px;max-width: initial;}
  13. .popup-qrcode-wrap p{font-size: 12px;margin: 5px 0;line-height: 1.8!important;}
  14. .popup-qrcode-wrap a{font-size: 12px;}
  15. .popup-qrcode-wrap input{opacity: 0;position: absolute;}
  16. .popup-qrcode-wrap .popup-qrcode-loadimg {width: 16px!important; height: 16px!important; margin-top: 107px;}
  17. </style>
  18. {/block}
  19. {block name="main"}
  20. <div class="layui-collapse ns-tips">
  21. <div class="layui-colla-item">
  22. <h2 class="layui-colla-title">操作提示</h2>
  23. <ul class="layui-colla-content layui-show">
  24. <li>微页面是用户打开的具体内容页面,您可以完全实现自定义页面,不同模块组合及样式的自由编辑。</li>
  25. <li>好的页面可以吸引客户浏览的兴趣,快速找到自己想要买的商品,给客户带来良好的购物体验,最终实现高的转化率。</li>
  26. <li>创建不同活动页面,实现线上推广转化,提升网店的传播量。</li>
  27. <li>满足不同商家各种场景下页面的样式及推广诉求。</li>
  28. </ul>
  29. </div>
  30. </div>
  31. <div class="ns-single-filter-box">
  32. <button class="layui-btn ns-bg-color" onclick="location.href = ns.url('admin/diy/edit')">新建页面</button>
  33. </div>
  34. <div class="nc-table-box">
  35. <table id="diy_list" lay-filter="diy_list"></table>
  36. </div>
  37. <script type="text/html" id="operation">
  38. <div class="operation-wrap" data-id="{{d.id}}">
  39. <div class="ns-table-btn">
  40. <div class="popup-qrcode-wrap"><img class="popup-qrcode-loadimg" src="__STATIC__/loading/loading.gif" /></div>
  41. <a class="layui-btn" lay-event="promote">推广</a>
  42. <a class="layui-btn" lay-event="edit">编辑</a>
  43. <a class="layui-btn" lay-event="delete">删除</a>
  44. </div>
  45. </div>
  46. </script>
  47. <script type="text/html" id="batchOperation">
  48. <button class="layui-btn layui-btn-primary" lay-event="delete">批量删除</button>
  49. </script>
  50. <!-- 推广 -->
  51. <script type="text/html" id="promote">
  52. {{# if(d.path.h5.status == 1){ }}
  53. <img src="{{ ns.img(d.path.h5.img) }}" alt="推广二维码">
  54. <p class="qrcode-item-description">扫码后直接访问页面</p>
  55. <a class="ns-text-color" href="javascript:ns.copy('h5_url_{{ d.id }}');">复制链接</a>
  56. <a class="ns-text-color" href="{{ ns.img(d.path.h5.img) }}" download>下载二维码</a>
  57. <input class="layui-input nc-len-mid" type="text" value="{{ d.path.h5.url }}" id="h5_url_{{ d.id }}" readonly>
  58. {{# } }}
  59. </script>
  60. {/block}
  61. {block name="script"}
  62. <script>
  63. var laytpl;
  64. layui.use([ 'laytpl'], function () {
  65. laytpl = layui.laytpl;
  66. });
  67. var table = new Table({
  68. elem: '#diy_list',
  69. filter: "diy_list",
  70. url: ns.url("admin/diy/lists"),
  71. cols: [[{
  72. width: '3%',
  73. type: 'checkbox',
  74. unresize: 'true'
  75. }, {
  76. field: 'title',
  77. width: '32%',
  78. title: '名称',
  79. unresize: 'true'
  80. }, {
  81. field: 'name',
  82. width: '30%',
  83. title: '标识',
  84. unresize: 'true'
  85. }, {
  86. width: '20%',
  87. title: '创建时间',
  88. unresize: 'true',
  89. templet: function (d) {
  90. return ns.time_to_date(d.create_time);
  91. }
  92. }, {
  93. title: '操作',
  94. toolbar: '#operation',
  95. unresize: 'true',
  96. width: '15%',
  97. }]],
  98. bottomToolbar: "#batchOperation"
  99. });
  100. //监听工具条
  101. table.tool(function(obj) {
  102. var data = obj.data;
  103. if (obj.event === 'promote') {
  104. promote(data.id);
  105. } else if (obj.event === 'edit') {
  106. location.href = ns.url("admin/diy/edit", {
  107. id: data.id,
  108. name: data.name
  109. });
  110. } else if (obj.event == "delete") {
  111. layer.confirm('确定要删除该微页面吗', function (index) {
  112. $.ajax({
  113. type: "post",
  114. url: ns.url("admin/diy/deleteSiteDiyView"),
  115. data: {'id': data.id},
  116. dataType: "JSON",
  117. success: function (res) {
  118. layer.msg(res.message);
  119. if (res.code == 0) {
  120. table.reload();
  121. }
  122. }
  123. });
  124. layer.close(index);
  125. });
  126. }
  127. });
  128. //批量操作
  129. table.bottomToolbar(function(obj) {
  130. if(obj.data.length < 1){
  131. layer.msg('请选择要操作的数据');
  132. return;
  133. }
  134. switch (obj.event) {
  135. case "delete":
  136. layer.confirm('确定要删除微页面吗', function (index) {
  137. var id_array = new Array();
  138. for (i in obj.data) id_array.push(obj.data[i].id);
  139. $.ajax({
  140. url: ns.url("admin/diy/deleteSiteDiyView"),
  141. data: {'id': id_array.toString()},
  142. dataType: "JSON",
  143. success: function (res) {
  144. layer.msg(res.message);
  145. if (res.code == 0) {
  146. table.reload();
  147. }
  148. }
  149. });
  150. layer.close(index);
  151. });
  152. break;
  153. }
  154. });
  155. function promote(id) {
  156. $(".operation-wrap[data-id='" + id + "'] .popup-qrcode-wrap").show();
  157. $.ajax({
  158. type: "POST",
  159. url: ns.url("admin/diy/promote"),
  160. data: {
  161. 'id': id,
  162. },
  163. dataType: 'JSON',
  164. success: function (res) {
  165. if(res.data.path.h5.status == 1) {
  166. res.data.id = id;
  167. laytpl($("#promote").html()).render(res.data, function (html) {
  168. $(".operation-wrap[data-id='" + id + "'] .popup-qrcode-wrap").html(html).show();
  169. $("body").click(function (e) {
  170. if (!$(e.target).closest(".popup-qrcode-wrap").length) {
  171. $(".operation-wrap[data-id='" + id + "'] .popup-qrcode-wrap").hide();
  172. }
  173. });
  174. });
  175. }else{
  176. layer.msg(res.data.path.h5.message);
  177. }
  178. }
  179. });
  180. }
  181. </script>
  182. {/block}