截流自动化的商城平台
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

lists.html 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. {layout name="layout1" /}
  2. <div class="wrapper">
  3. <div class="layui-card">
  4. <div class="layui-card-body">
  5. <div class="layui-collapse like-layui-collapse" lay-accordion="" style="border:1px dashed #c4c4c4">
  6. <div class="layui-colla-item">
  7. <h2 class="layui-colla-title like-layui-colla-title" style="background-color: #fff">操作提示</h2>
  8. <div class="layui-colla-content layui-show">
  9. <p>*会员根据设定好的等级成长值升级,等级成长值通过日常消费积累;</p>
  10. <p>*删除会员等级时会重新调整对应会员的等级,请谨慎操作。</p>
  11. </div>
  12. </div>
  13. </div>
  14. </div>
  15. <div class="layui-tab layui-tab-card" lay-filter="tab-all">
  16. <div class="layui-card">
  17. <div class="layui-card-body">
  18. <div style="padding-bottom: 10px;" class="add">
  19. <button class="layui-btn layui-btn-sm layuiadmin-btn-user_level {$view_theme_color}" data-type="add">新增会员等级</button>
  20. <button class="layui-btn layui-btn-sm layuiadmin-btn-user_level layui-btn-primary" data-type="set">设置等级说明</button>
  21. </div>
  22. <table id="user_level-lists" lay-filter="user_level-lists"></table>
  23. <script type="text/html" id="image">
  24. <img src="{{d.image}}" style="height:auto;width: auto" class="image-show">
  25. </script>
  26. <script type="text/html" id="background">
  27. <img src="{{d.background_image}}" style="height:auto;width: auto" class="image-show">
  28. </script>
  29. <script type="text/html" id="user_level-operation">
  30. <a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="edit">编辑</a>
  31. <a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a>
  32. </script>
  33. </div>
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. <script type="text/html" id="discount-info">
  39. {{d.discount}}折
  40. </script>
  41. <style>
  42. .layui-table-cell {
  43. height: auto;
  44. }
  45. </style>
  46. <script>
  47. layui.config({
  48. version:"{$front_version}",
  49. base: '/static/lib/' //静态资源所在路径
  50. }).use(['table','form'], function(){
  51. var $ = layui.$
  52. ,form = layui.form
  53. ,table = layui.table
  54. ,element = layui.element;
  55. //图片放大
  56. $(document).on('click', '.image-show', function () {
  57. var src = $(this).attr('src');
  58. like.showImg(src,600);
  59. });
  60. $('.layui-btn.layuiadmin-btn-user_level').on('click', function(){
  61. var type = $(this).data('type');
  62. active[type] ? active[type].call(this) : '';
  63. });
  64. layui.define(['table', 'form'], function(exports){
  65. var $ = layui.$
  66. ,table = layui.table
  67. ,form = layui.form;
  68. table.render({
  69. id:'user_level-lists'
  70. ,elem: '#user_level-lists'
  71. ,url: '{:url("user.level/lists")}' //模拟接口
  72. ,cols: [[
  73. {field: 'name', title: '等级名称',width:160}
  74. ,{field: 'growth_value',width:160, title: '成长值'}
  75. ,{field: 'icon',width:160, title: '等级图标',toolbar:'#image'}
  76. ,{field: 'background_image',width:160, title: '等级背景图片',toolbar:'#background'}
  77. ,{width:160, title:'等级折扣', templet: '#discount-info'}
  78. ,{field: 'remark',width:160, title:'等级说明'}
  79. ,{fixed: 'right', title: '操作', width:160,align: 'center', toolbar: '#user_level-operation'}
  80. ]]
  81. ,page:true
  82. ,text: {none: '暂无数据!'}
  83. ,parseData: function(res){ //将原始数据解析成 table 组件所规定的数据
  84. return {
  85. "code":res.code,
  86. "msg":res.msg,
  87. "count": res.data.count, //解析数据长度
  88. "data": res.data.lists, //解析数据列表
  89. };
  90. }
  91. ,response: {
  92. statusCode: 1
  93. }
  94. ,done: function(res, curr, count){
  95. // 解决操作栏因为内容过多换行问题
  96. $(".layui-table-main tr").each(function (index, val) {
  97. $($(".layui-table-fixed-l .layui-table-body tbody tr")[index]).height($(val).height());
  98. $($(".layui-table-fixed-r .layui-table-body tbody tr")[index]).height($(val).height());
  99. });
  100. }
  101. });
  102. });
  103. //事件
  104. var active = {
  105. add: function(){
  106. var index = layer.open({
  107. type: 2
  108. ,title: '新增等级'
  109. ,content: '{:url("user.level/add")}'
  110. ,area: ['90%', '90%']
  111. ,btn: ['保存', '取消']
  112. ,maxmin: true
  113. ,yes: function(index, layero){
  114. var iframeWindow = window['layui-layer-iframe'+ index]
  115. ,submitID = 'add-user_level-submit'
  116. ,submit = layero.find('iframe').contents().find('#'+ submitID);
  117. //监听提交
  118. iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
  119. var field = data.field;
  120. like.ajax({
  121. url:'{:url("user.level/add")}',
  122. data:field,
  123. type:"post",
  124. success:function(res)
  125. {
  126. if(res.code == 1)
  127. {
  128. layui.layer.msg(res.msg, {
  129. offset: '15px'
  130. , icon: 1
  131. , time: 1000
  132. });
  133. layer.close(index); //关闭弹层
  134. table.reload('user_level-lists'); //数据刷新
  135. }
  136. }
  137. });
  138. });
  139. submit.trigger('click');
  140. }
  141. });
  142. },
  143. set: function() {
  144. var index = layer.open({
  145. type: 2
  146. ,title: '设置等级说明'
  147. ,content: '{:url("user.level/set")}'
  148. ,area: ['60%', '60%']
  149. ,btn: ['保存', '取消']
  150. ,maxmin: true
  151. ,yes: function(index, layero){
  152. var iframeWindow = window['layui-layer-iframe'+ index]
  153. ,submitID = 'add-user_intro-submit'
  154. ,submit = layero.find('iframe').contents().find('#'+ submitID);
  155. //监听提交
  156. iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
  157. var field = data.field;
  158. like.ajax({
  159. url:'{:url("user.level/set")}',
  160. data:field,
  161. type:"post",
  162. success:function(res)
  163. {
  164. if(res.code == 1)
  165. {
  166. layui.layer.msg(res.msg, {
  167. offset: '15px'
  168. , icon: 1
  169. , time: 1000
  170. });
  171. layer.close(index); //关闭弹层
  172. table.reload('user_level-lists'); //数据刷新
  173. }
  174. }
  175. });
  176. });
  177. submit.trigger('click');
  178. }
  179. });
  180. }
  181. }
  182. table.on('tool(user_level-lists)', function(obj) {
  183. var id = obj.data.id;
  184. if (obj.event === 'edit') {
  185. var index = layer.open({
  186. type: 2
  187. , title: '编辑等级'
  188. , content: '{:url("user.level/edit")}?id=' + id
  189. , area: ['90%', '90%']
  190. , btn: ['保存', '取消']
  191. , maxmin: true
  192. , yes: function (index, layero) {
  193. var iframeWindow = window['layui-layer-iframe' + index]
  194. , submitID = 'edit-user_level-submit'
  195. , submit = layero.find('iframe').contents().find('#' + submitID);
  196. //监听提交
  197. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  198. var field = data.field;
  199. like.ajax({
  200. url: '{:url("user.level/edit")}',
  201. data: field,
  202. type: "post",
  203. success: function (res) {
  204. if (res.code == 1) {
  205. layui.layer.msg(res.msg, {
  206. offset: '15px'
  207. , icon: 1
  208. , time: 1000
  209. });
  210. layer.close(index); //关闭弹层
  211. table.reload('user_level-lists'); //数据刷新
  212. }
  213. }
  214. });
  215. });
  216. submit.trigger('click');
  217. }
  218. });
  219. }
  220. if (obj.event === 'del') {
  221. var name = obj.data.name;
  222. layer.confirm('确定删除会员等级:<span style="color: red">' + name + '</span>', function (index) {
  223. like.ajax({
  224. url: '{:url("user.level/del")}',
  225. data: {id: id},
  226. type: "post",
  227. success: function (res) {
  228. if (res.code == 1) {
  229. layui.layer.msg(res.msg, {
  230. offset: '15px'
  231. , icon: 1
  232. , time: 1000
  233. });
  234. layer.close(index); //关闭弹层
  235. table.reload('user_level-lists'); //数据刷新
  236. }
  237. }
  238. });
  239. layer.close(index);
  240. })
  241. }
  242. })
  243. });
  244. </script>