index.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. {include file="public/header" /}
  2. <style>
  3. .layui-table-view .layui-table[lay-size=lg] .layui-table-cell {height: 58px;line-height: 58px;}
  4. .wx-audio-content{padding:0px;border:0px;}
  5. .wx-audio-content .wx-audio-left .wx-audio-state{margin-bottom:15px;}
  6. .wx-audio-content .wx-audio-right .wx-audio-time{padding-top:0px;position: relative;bottom:6px;}
  7. .wx-audio-content .wx-audio-right .wx-audio-progrees{top:6px;}
  8. </style>
  9. <body>
  10. <div class="layui-fluid">
  11. <div class="layui-card">
  12. <div class="layui-form layui-card-header layuiadmin-card-header-auto">
  13. <div class="layui-form-item">
  14. <div class="layui-inline">
  15. <div class="layui-input-inline">
  16. <input type="text" name="start" class="layui-input" onclick="wk.lay_date(this);" placeholder="创建开始日期">
  17. </div>
  18. <div class="layui-form-mid">
  19. -
  20. </div>
  21. <div class="layui-input-inline">
  22. <input type="text" name="end" class="layui-input" onclick="wk.lay_date(this);" placeholder="创建结束日期">
  23. </div>
  24. </div>
  25. <div class="layui-inline">
  26. <div class="layui-input-inline">
  27. <input type="text" id="key" class="layui-input" name="key" placeholder="文章名称"/>
  28. </div>
  29. </div>
  30. <div class="layui-inline">
  31. <div class="layui-input-inline">
  32. <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
  33. <button class="layui-btn layui-btn-normal" id="empty" lay-submit="" lay-filter="LAY-search">重置</button>
  34. </div>
  35. </div>
  36. </div>
  37. <blockquote class="layui-elem-quote" style="margin-top: 10px;">
  38. <button class="layui-btn" id="test3" onclick="setCountdown()">倒计时<span id="test2" >60</span>秒</button>
  39. <button class="layui-btn" onclick="wk.msg('速度框架萨达成卡萨打可承受的擦上档次萨达初三党测试导出砂垫层坚')">提示信息</button>
  40. <button class="layui-btn" onclick="wk.layer_show('打印订单','{:url('printOrder')}')">打印订单</button>
  41. <button class="layui-btn layui-btn-normal" onclick="toastr.success('你有新消息了!','消息提示');wk.voice_msg();">成功消息</button>
  42. <button class="layui-btn layui-btn-warm" onclick="toastr.warning('你有新消息了!','消息提示');">警告消息</button>
  43. <button class="layui-btn layui-btn-danger" onclick="toastr.error('你有新消息了!','消息提示');">失败消息</button>
  44. <button class="layui-btn layui-btn-info" onclick="toastr.info('你有新消息了!','消息提示');">信息消息</button>
  45. <button class="layui-btn " onclick="wk.voice_msg()">声音消息</button>
  46. </blockquote>
  47. <div>
  48. <button class="layui-btn" data-type="add" onclick="wk.href('{:url('add_article')}')">
  49. <i class="fa fa-plus"></i> 添加文章
  50. </button>
  51. <span class="layui-btn-dropdown" style="display:inline-block;">
  52. <button class="layui-btn layui-btn-danger" data-toggle="dropdown"><i class="fa fa-wrench"></i> 批量操作 <i class="fa fa-caret-down"></i></button>
  53. <ul class="layui-dropdown-menu layui-anim layui-anim-upbit">
  54. <li><a href="javascript:;" class="layuiBtn" data-type="getCheckData"><i class="fa fa-trash-o"></i> 批量删除 </a></li>
  55. <li><a href="javascript:;" class="layuiBtn" data-type="usingAll" id="onAll"><i class="fa fa-check-circle"></i> 批量启用</a></li>
  56. <li><a href="javascript:;" class="layuiBtn" data-type="forbiddenAll" id="offAll"><i class="fa fa-ban"></i> 批量禁用</a></li>
  57. </ul>
  58. </span>
  59. </div>
  60. </div>
  61. <div class="layui-card-body">
  62. <table id="LAY-table-manage" lay-filter="LAY-table-manage"></table>
  63. <!--图片模板-->
  64. <script type="text/html" id="imgTpl">
  65. <ul class="layui-cricle">
  66. <li><img src="{{d.photo[0]}}" class="layui-table-img layui-circle"onerror="this.src='/static/admin/images/timg.jpg'" /></li>
  67. {{# if(d.photo.length >= 1){ }}
  68. {{# for(var i=1;i<d.photo.length;i++){ }}
  69. <li style="display:none;"><img src="{{d.photo[i]}}" onerror="this.src='/static/admin/images/timg.jpg'" ></li>
  70. {{# } }}
  71. {{# } }}
  72. </ul>
  73. </script>
  74. <!--音频模板-->
  75. <script type="text/html" id="musicTpl">
  76. <div id="music_{{d.id}}" style=""></div>
  77. </script>
  78. <!--状态模板-->
  79. <script type="text/html" id="staBar">
  80. <input type="checkbox" value="{{d.id}}" lay-skin="switch" lay-text="ON|OFF" lay-filter="OnOff"{{d.status == 1 ? 'checked' : '' }} >
  81. </script>
  82. <!--操作模板-->
  83. <script type="text/html" id="opeBar">
  84. <a onclick="wk.layer_show('编辑文章','{:url('edit_article')}?id={{d.id}}')" class="layui-btn layui-btn-xs" title="编辑"><i class="fa fa-pencil"></i></a>
  85. <a href="javascript:;" onclick="wk.confirm('{{d.id}}','{:url('del_article')}')" class="layui-btn layui-btn-danger layui-btn-xs" title="删除"><i class="fa fa-trash-o"></i></a>
  86. </script>
  87. </div>
  88. </div>
  89. </div>
  90. {include file="public/footer" /}
  91. <script>
  92. var music = function(){
  93. if($('#music').length == 0){
  94. $('body').append('<div id="music"></div>');
  95. }
  96. var wxAudio = wk.lay_audio({elem:'#music',src:'/static/admin/images/default.mp3'});
  97. $('#music').hide();
  98. wxAudio.audioPlay();
  99. }
  100. layui.use(['index', 'table','util'], function () {
  101. var $ = layui.$
  102. , form = layui.form
  103. , table = layui.table
  104. table.render({
  105. elem: '#LAY-table-manage'
  106. , url: '{:url("Article/index")}'
  107. ,response: {
  108. statusCode: 220 //成功的状态码,默认:0
  109. }
  110. , page: true
  111. , even: false //开启隔行背景
  112. , size: 'lg' //sm小尺寸的表格 lg大尺寸
  113. // ,width:100
  114. , cellMinWidth: 150
  115. , height: "full-220"
  116. , limits: [10, 20, 30, 40, 50]
  117. , limit: "{:config('pages')}"
  118. , loading: true
  119. , toolbar:'#123'
  120. , id: 'LAY-table'
  121. , cols: [[
  122. {type: 'checkbox', fixed: 'left',}
  123. , {field: 'id', width: 60, title: 'ID', sort: true, align: 'center'}
  124. , {field: 'title', width: '', title: '标题', align: 'center'}
  125. , {field: 'name', width: '', title: '所属分类', align: 'center'}
  126. , {field: 'picture', width: 80, title: '封面', align: 'center',templet: '#imgTpl'}
  127. , {field: 'views', width: '', title: '浏览量',sort: true, align: 'center'}
  128. , {field: 'music', width: 290, title: '音频', align: 'center',templet:'#musicTpl'}
  129. , {field: 'is_tui', width: 100, title: '是否推荐', align: 'center',templet: "<div>{{ d.is_tui==1?'是':'否'}}</div>"}
  130. , {field: 'create_time', width: 180, title: '创建时间',sort: true, align: 'center',templet:"<div>{{layui.util.toDateString(d.create_time,'yyyy年MM月dd日')}}</div>"}
  131. , {field: 'update_time', width: 180, title: '更新时间',sort: true, align: 'center'}
  132. , {field: 'status',fixed: 'right', width: 100, title: '状态',sort: true, align: 'center', templet: '#staBar'}
  133. , {fixed: 'right', width: 120, title: '操作', align: 'center', toolbar: '#opeBar'}
  134. ]]
  135. ,done: function (res, curr, count) {
  136. $('.layui-cricle').viewer({
  137. url: 'data-original',
  138. });
  139. $.each(res.data,function(index,item) {
  140. wk.lay_audio({elem:'#music_'+item['id'],src:item['music'],width:'250px'});
  141. });
  142. }
  143. });
  144. //监听状态开关操作
  145. form.on('switch(OnOff)', function (obj) {
  146. var num = '';
  147. obj.elem.checked == true? num = 1: num = 2;
  148. //用户状态
  149. wk.status(this.value,num, '{:url("user_state")}',obj);
  150. });
  151. //事件
  152. var active = {
  153. getCheckData: function(){
  154. //批量删除
  155. wk.batchDel(getIds(),"{:url('batchDelUser')}");
  156. }
  157. ,forbiddenAll: function(){
  158. //批量禁用
  159. wk.batchForbidden(getIds(),2,"{:url('forbiddenAdmin')}");
  160. }
  161. ,usingAll: function(){
  162. //批量启用
  163. wk.usingAll(getIds(),1,"{:url('usingAdmin')}");
  164. }
  165. ,excelAll: function(){
  166. //导出Excel
  167. wk.excelAll(getIds(),$("form").serialize(),"{:url('excelAdmin')}");
  168. }
  169. };
  170. $('.layuiBtn').on('click', function () {
  171. var type = $(this).data('type');
  172. active[type] ? active[type].call(this) : '';
  173. });
  174. var getIds = function () {
  175. var ids = [];
  176. var checkStatus = table.checkStatus('LAY-table')
  177. ,data = checkStatus.data;
  178. $.each(data,function(index,item){
  179. ids.push(item['id'])
  180. });
  181. return ids;
  182. }
  183. //倒计时
  184. // var thisTimer, setCountdown = function(){
  185. // lay('#test3').addClass('layui-disabled').attr('disabled').text('完了');
  186. // var endTime = new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate(),new Date().getHours(),new Date().getMinutes(),new Date().getSeconds() + 60).getTime() //结束日期
  187. // ,serverTime = new Date().getTime(); //假设为当前服务器时间,这里采用的是本地时间,实际使用一般是取服务端的
  188. // clearTimeout(thisTimer);
  189. // util.countdown(endTime, serverTime, function(date, serverTime, timer){
  190. // var str = date[3] + '秒';
  191. // if(date[3] == 0){
  192. // lay('#test3').removeClass('layui-disabled').removeAttr('disabled').text('完了');
  193. // }else{
  194. // lay('#test2').html(str);
  195. // }
  196. // thisTimer = timer;
  197. // });
  198. // };
  199. // var date = new Date();
  200. // setCountdown(date.getFullYear(),date.getMonth(),date.getDate(),date.getHours(),date.getMinutes(),date.getSeconds() + 60);
  201. });
  202. var thisTimer, setCountdown = function(){
  203. $('#test3').addClass('layui-disabled').attr('disabled','disabled');
  204. var endTime = new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate(),new Date().getHours(),new Date().getMinutes(),new Date().getSeconds() + 60).getTime() //结束日期
  205. ,serverTime = new Date().getTime(); //假设为当前服务器时间,这里采用的是本地时间,实际使用一般是取服务端的
  206. clearTimeout(thisTimer);
  207. layui.util.countdown(endTime, serverTime, function(date, serverTime, timer){
  208. var str = date[3];
  209. if(date[3] == 0){
  210. $('#test3').removeClass('layui-disabled').removeAttr('disabled');
  211. $('#test2').html(60);
  212. }else{
  213. $('#test2').html(str);
  214. }
  215. thisTimer = timer;
  216. });
  217. };
  218. </script>
  219. </body>
  220. </html>