index.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. {extend name="public/container"}
  2. {block name="content"}
  3. <div class="layui-fluid">
  4. <div class="layui-row layui-col-space15" id="app">
  5. <div class="layui-col-md12">
  6. <div class="layui-card">
  7. <div class="layui-card-header">通知列表</div>
  8. <div class="layui-card-body">
  9. <div class="layui-btn-container">
  10. <button class="layui-btn layui-btn-sm" onclick="$eb.createModalFrame(this.innerText,'{:Url('create')}')">添加通知</button>
  11. </div>
  12. <table class="layui-hide" id="List" lay-filter="List"></table>
  13. <!--消息状态-->
  14. <script type="text/html" id="type">
  15. {{# if(d.type==0){ }}
  16. <p>系统通知</p>
  17. {{# }else if(d.type==2){ }}
  18. <p>会员通知</p>
  19. {{# } else if(d.type == 1){ }}
  20. <p>分组通知</p>
  21. {{# } }}
  22. </script>
  23. <script type="text/html" id="add_time">
  24. <div>{{ layui.util.toDateString(d.add_time * 1000, 'yyyy-MM-dd HH:MM') }}</div>
  25. </script>
  26. <!--消息状态-->
  27. <script type="text/html" id="is_send">
  28. {{# if(d.del_time==0){ }}
  29. <span style="color:green;">否</span><br />
  30. {{# }else{ }}
  31. <span style="color:red;">是</span>
  32. <!-- <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event='send'>启用</a> -->
  33. {{# } }}
  34. </script>
  35. <script type="text/html" id="act">
  36. <button type="button" class="layui-btn layui-btn-xs" onclick="dropdown(this)">操作 <span class="caret"></span></button>
  37. <ul class="layui-nav-child layui-anim layui-anim-upbit">
  38. {{# if(d.type==2){ }}
  39. <li>
  40. <a href="javascript:;" onclick="window.location.href='{:Url('user')}?id={{d.id}}'"><i class="fa fa-user"></i> 用户信息</a>
  41. </li>
  42. {{# } }}
  43. <li>
  44. <a href="javascript:;" onclick="$eb.createModalFrame('编辑','{:Url('edit')}?id={{d.id}}')"><i class="fa fa-edit"></i> 编辑</a>
  45. </li>
  46. <li>
  47. <a href="javascript:;" lay-event='warning'><i class="fa fa-times"></i> 删除</a>
  48. </li>
  49. </ul>
  50. </script>
  51. </div>
  52. </div>
  53. </div>
  54. </div>
  55. </div>
  56. <script src="{__ADMIN_PATH}js/layuiList.js"></script>
  57. {/block}
  58. {block name="script"}
  59. <script>
  60. layList.tableList('List',"{:Url('index')}",function (){
  61. return [
  62. {field: 'id', title: '编号',width:'4%', sort: true,event:'id',align:"center"},
  63. {filed: 'icon', title: '图标',align:'center',templet:'<p><img class="avatar " style="cursor: pointer" data-image="{{d.icon}}" src="{{d.icon}}" alt="{{d.title}}"></p>', width:'6%'},
  64. {field: 'user', title: '发送人',align:"center",width:'10%'},
  65. {field: 'title', title: '通知标题',align:"center",width:'10%'},
  66. {field: 'add_time', title: '添加时间',templet:'#add_time',align:'center',width:'12%'},
  67. {field: 'content', title: '通知内容',align:"center"},
  68. {field: 'type', title: '消息类型',templet:'#type',align:"center",width:'10%'},
  69. //{field: 'is_send', title: '是否删除',templet:'#is_send',align:"center",width:'6%'},
  70. {field: 'right', title: '操作',align:'center',toolbar:'#act',width:'6%'},
  71. ];
  72. });
  73. //下拉框
  74. $(document).click(function (e) {
  75. $('.layui-nav-child').hide();
  76. })
  77. function dropdown(that){
  78. var oEvent = arguments.callee.caller.arguments[0] || event;
  79. oEvent.stopPropagation();
  80. var offset = $(that).offset();
  81. var top=offset.top-$(window).scrollTop();
  82. var index = $(that).parents('tr').data('index');
  83. $('.layui-nav-child').each(function (key) {
  84. if (key != index) {
  85. $(this).hide();
  86. }
  87. })
  88. if($(document).height() < top+$(that).next('ul').height()){
  89. $(that).next('ul').css({
  90. 'padding': 10,
  91. 'top': - ($(that).parents('td').height() / 2 + $(that).height() + $(that).next('ul').height()/2),
  92. 'min-width': 'inherit',
  93. 'position': 'absolute'
  94. }).toggle();
  95. }else{
  96. $(that).next('ul').css({
  97. 'padding': 10,
  98. 'top':$(that).parents('td').height() / 2 + $(that).height(),
  99. 'min-width': 'inherit',
  100. 'position': 'absolute'
  101. }).toggle();
  102. }
  103. }
  104. layList.tool(function (event,data,obj) {
  105. switch (event) {
  106. case 'send':
  107. var url =layList.U({c:'user.user_notice',a:'send',p:{id:data.id}});
  108. $eb.$swal('delete',function(){
  109. $eb.axios.get(url).then(function(res){
  110. if(res.status == 200 && res.data.code == 200) {
  111. $eb.$swal('success',res.data.msg);
  112. obj.update({is_send:1,send_time:'{:date("Y-m-d H:i:s",time())}'});
  113. }else
  114. return Promise.reject(res.data.msg || '发送失败')
  115. }).catch(function(err){
  116. $eb.$swal('error',err);
  117. });
  118. },{
  119. title:"您确定要发送这条信息吗",
  120. text:"发送后将无法修改通知信息,请谨慎操作!",
  121. confirm:"是的,我要发送!",
  122. cancel:"让我再考虑一下"
  123. })
  124. break;
  125. case 'warning':
  126. window.t = $(this);
  127. var _this = obj,url =layList.U({a:'delete',p:{id:data.id}});
  128. $eb.$swal('delete',function(){
  129. $eb.axios.get(url).then(function(res){
  130. if(res.status == 200 && res.data.code == 200) {
  131. $eb.$swal('success',res.data.msg);
  132. _this.del();
  133. }else
  134. return Promise.reject(res.data.msg || '删除失败')
  135. }).catch(function(err){
  136. $eb.$swal('error',err);
  137. });
  138. })
  139. break;
  140. }
  141. })
  142. $('.head_image').on('click',function (e) {
  143. var image = $(this).data('image');
  144. $eb.openImage(image);
  145. })
  146. </script>
  147. {/block}