截流自动化的商城平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. {layout name="layout1" /}
  2. <style>
  3. .layui-form-label{
  4. width: 150px;
  5. }
  6. </style>
  7. <div class="wrapper">
  8. <div class="layui-card">
  9. <div class="layui-card-body">
  10. <div class="layui-collapse like-layui-collapse" lay-accordion="" style="border:1px dashed #c4c4c4">
  11. <div class="layui-colla-item">
  12. <h2 class="layui-colla-title like-layui-colla-title" style="background-color: #fff">操作提示</h2>
  13. <div class="layui-colla-content layui-show">
  14. <p>*设定充值方案后,会员可以选择推荐的充值方案充值。</p>
  15. <p>*充值设置允许关闭充值功能。</p>
  16. <p>*充值金额不能提现。</p>
  17. </div>
  18. </div>
  19. </div>
  20. </div>
  21. <div class="layui-tab layui-tab-card" lay-filter="tab-all">
  22. <ul class="layui-tab-title">
  23. <li data-type="1" class="layui-this">充值方案</li>
  24. <li data-type="2" >充值设置</li>
  25. </ul>
  26. <div class="layui-tab-content">
  27. <div class="layui-tab-item layui-show">
  28. <div class="layui-card">
  29. <div class="layui-card-body">
  30. <div style="padding-bottom: 10px;" class="add">
  31. <button class="layui-btn layui-btn-sm layuiadmin-btn-recharge {$view_theme_color}" data-type="add">新增充值方案</button>
  32. </div>
  33. <table id="recharge-lists" lay-filter="recharge-lists"></table>
  34. <script type="text/html" id="recharge-operation">
  35. <a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="edit">编辑</a>
  36. <a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a>
  37. </script>
  38. <script type="text/html" id="recommend">
  39. <input type="checkbox" lay-filter="switch-status" data-id={{d.id}} data-field='is_recommend' lay-skin="switch"
  40. lay-text="是|否" {{# if(d.is_recommend){ }} checked {{# } }} />
  41. </script>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="layui-tab-item">
  46. <div class="layui-form" lay-filter="">
  47. <div class="layui-form-item">
  48. <label class="layui-form-label">充值功能:</label>
  49. <div class="layui-input-inline">
  50. <input type="radio" name="open_racharge" value="1" title="开启">
  51. <input type="radio" name="open_racharge" value="0" title="关闭">
  52. </div>
  53. </div>
  54. <div class="layui-form-item">
  55. <label class="layui-form-label"></label>
  56. <span style="color: #a3a3a3;font-size: 9px">开启或关闭充值功能,关闭后商城会隐藏充值功能入口</span>
  57. </div>
  58. <div class="layui-form-item">
  59. <label class="layui-form-label">充值赠送成长值:</label>
  60. <div class="layui-input-inline">
  61. <input type="number" name="give_growth" autocomplete="off" class="layui-input give_growth">
  62. </div>
  63. </div>
  64. <div class="layui-form-item">
  65. <label class="layui-form-label"></label>
  66. <span style="color: #a3a3a3;font-size: 9px">填写每充值1元赠送成长值,填写正整数</span>
  67. </div>
  68. <div class="layui-form-item">
  69. <label class="layui-form-label">最低充值金额:</label>
  70. <div class="layui-input-inline">
  71. <input type="number" name="min_money" autocomplete="off" class="layui-input min_money">
  72. </div>
  73. </div>
  74. <div class="layui-form-item">
  75. <label class="layui-form-label"></label>
  76. <span style="color: #a3a3a3;font-size: 9px">自定义充值最低充值金额要求,不填或填0表示没有限制</span>
  77. </div>
  78. <div class="layui-form-item">
  79. <div class="layui-input-block">
  80. <button class="layui-btn layui-btn-sm {$view_theme_color}" lay-submit lay-filter="set">确定</button>
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. <style>
  90. .layui-table-cell {
  91. height: auto;
  92. }
  93. </style>
  94. <script>
  95. layui.config({
  96. version:"{$front_version}",
  97. base: '/static/lib/' //静态资源所在路径
  98. }).use(['table','form'], function(){
  99. var $ = layui.$
  100. ,form = layui.form
  101. ,table = layui.table
  102. ,element = layui.element;
  103. $('.layui-btn.layuiadmin-btn-recharge').on('click', function(){
  104. var type = $(this).data('type');
  105. active[type] ? active[type].call(this) : '';
  106. });
  107. //事件
  108. var active = {
  109. add: function(){
  110. var index = layer.open({
  111. type: 2
  112. ,title: '新增充值方案'
  113. ,content: '{:url("recharge/add")}'
  114. ,area: ['60%', '60%']
  115. ,btn: ['保存', '取消']
  116. ,maxmin: true
  117. ,yes: function(index, layero){
  118. var iframeWindow = window['layui-layer-iframe'+ index]
  119. ,submitID = 'add-recharge-submit'
  120. ,submit = layero.find('iframe').contents().find('#'+ submitID);
  121. //监听提交
  122. iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
  123. var field = data.field;
  124. like.ajax({
  125. url:'{:url("recharge/add")}',
  126. data:field,
  127. type:"post",
  128. success:function(res)
  129. {
  130. if(res.code == 1)
  131. {
  132. layui.layer.msg(res.msg, {
  133. offset: '15px'
  134. , icon: 1
  135. , time: 1000
  136. });
  137. layer.close(index); //关闭弹层
  138. table.reload('recharge-lists'); //数据刷新
  139. }
  140. }
  141. });
  142. });
  143. submit.trigger('click');
  144. }
  145. });
  146. }
  147. }
  148. //获取列表
  149. getList(1)
  150. //切换列表
  151. element.on('tab(tab-all)', function (data) {
  152. var type = $(this).attr('data-type');
  153. getList(type)
  154. });
  155. form.on('switch(switch-status)',function (obj) {
  156. var id = obj.elem.attributes['data-id'].nodeValue
  157. var fields = obj.elem.attributes['data-field'].nodeValue
  158. var status = 0;
  159. if(this.checked){
  160. status = 1;
  161. }
  162. changeFields(id,fields,status);
  163. })
  164. //监听工具条
  165. table.on('tool(recharge-lists)', function(obj){
  166. var id = obj.data.id;
  167. if(obj.event === 'edit'){
  168. var id = obj.data.id;
  169. layer.open({
  170. type: 2
  171. ,title: '修改充值方案'
  172. ,content: '{:url("recharge/edit")}?id='+id
  173. ,area: ['60%','60%']
  174. ,btn: ['确定', '取消']
  175. ,yes: function(index, layero){
  176. var iframeWindow = window['layui-layer-iframe'+ index]
  177. ,submitID = 'edit-recharge-submit'
  178. ,submit = layero.find('iframe').contents().find('#'+ submitID);
  179. //监听提交
  180. iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
  181. var field = data.field;
  182. like.ajax({
  183. url:'{:url("recharge/edit")}',
  184. data:field,
  185. type:"post",
  186. success:function(res)
  187. {
  188. if(res.code == 1)
  189. {
  190. layui.layer.msg(res.msg, {
  191. offset: '15px'
  192. , icon: 1
  193. , time: 1000
  194. });
  195. layer.close(index); //关闭弹层
  196. table.reload('recharge-lists'); //数据刷新
  197. }
  198. }
  199. });
  200. });
  201. submit.trigger('click');
  202. }
  203. })
  204. }
  205. if(obj.event === 'del'){
  206. var money = obj.data.money;
  207. layer.confirm('确定删除充值金额:'+'<span style="color: red">'+money+'</span>', function(index){
  208. like.ajax({
  209. url:'{:url("recharge/del")}',
  210. data:{id:id},
  211. type:"post",
  212. success:function(res)
  213. {
  214. if(res.code == 1)
  215. {
  216. layui.layer.msg(res.msg, {
  217. offset: '15px'
  218. , icon: 1
  219. , time: 1000
  220. });
  221. layer.close(index); //关闭弹层
  222. table.reload('recharge-lists'); //数据刷新
  223. }
  224. }
  225. });
  226. layer.close(index);
  227. })
  228. }
  229. if(obj.event === 'tips'){
  230. layer.tips('数字越大,越靠前', $(this), {tips: [1, '#FF5722'],time:1500});
  231. }
  232. });
  233. //商品排序
  234. table.on('edit(recharge-lists)', function (obj) {
  235. var id = obj.data.id;
  236. var fields = 'sort';
  237. var field_value = obj.value;
  238. if(isNaN(field_value)){
  239. var old_value=$(this).prev().text();
  240. layer.tips('请输入数字', $(this), {tips: [1, '#FF5722']});
  241. $(this).val(old_value);
  242. return false;
  243. }
  244. changeFields(id,fields,field_value);
  245. });
  246. form.on('submit(set)', function (data) {
  247. like.ajax({
  248. url: '{:url("recharge/setRecharge")}' //实际使用请改成服务端真实接口
  249. , data: data.field
  250. , type: 'post'
  251. , success: function (res) {
  252. if (res.code == 1) {
  253. layer.msg(res.msg, {
  254. offset: '15px'
  255. , icon: 1
  256. , time: 1000
  257. });
  258. }
  259. }
  260. });
  261. });
  262. function getList(type) {
  263. layui.define(['table', 'form'], function(exports){
  264. var $ = layui.$
  265. ,table = layui.table
  266. ,form = layui.form;
  267. var cols = [
  268. {field: 'money', title: '充值金额',width:320,}
  269. ,{field: 'give_money',width:160, title: '赠送金额'}
  270. ,{field: 'recommend',width:160, title: '推荐',toolbar: '#recommend'}
  271. ,{field: 'sort',width: 80, title:'排序',event: 'tips',edit:'text',sort: true}
  272. ,{fixed: 'right', title: '操作', align: 'center', width:300, toolbar: '#recharge-operation'}
  273. ];
  274. table.render({
  275. id:'recharge-lists'
  276. ,elem: '#recharge-lists'
  277. ,url: '{:url("recharge/lists")}?type='+type //模拟接口
  278. ,cols: [cols]
  279. ,text: {none: '暂无数据!'}
  280. ,parseData: function(res){ //将原始数据解析成 table 组件所规定的数据
  281. if(type == 2){
  282. console.log(res)
  283. $('.give_growth').val(res.data[0].give_growth);
  284. $('.min_money').val(res.data[0].min_money);
  285. $("input[name=open_racharge][value="+res.data[0].open_racharge+"]").prop("checked",true);
  286. form.render();
  287. }else{
  288. return {
  289. "code":res.code,
  290. "msg":res.msg,
  291. "data": res.data, //解析数据列表
  292. };
  293. }
  294. },
  295. response: {
  296. statusCode: 1
  297. }
  298. ,done: function(res, curr, count){
  299. // 解决操作栏因为内容过多换行问题
  300. $(".layui-table-main tr").each(function (index, val) {
  301. $($(".layui-table-fixed-l .layui-table-body tbody tr")[index]).height($(val).height());
  302. $($(".layui-table-fixed-r .layui-table-body tbody tr")[index]).height($(val).height());
  303. });
  304. }
  305. });
  306. });
  307. }
  308. function changeFields(id,fields,value){
  309. $.ajax({
  310. url:'{:url("recharge/changeFields")}',
  311. data:{id:id,field:fields,value:value},
  312. type:'get',
  313. dataType:'json',
  314. success:function (res) {
  315. if(res.code == 1) {
  316. layui.layer.msg(res.msg, {
  317. offset: '15px'
  318. , icon: 1
  319. , time: 1000
  320. });
  321. }else {
  322. layui.layer.msg(res.msg, {
  323. offset: '15px'
  324. , icon: 2
  325. , time: 1000
  326. }, function () {
  327. if (fields === 'is_recommend') {
  328. window.location.href = window.location.href;
  329. }
  330. });
  331. }
  332. }
  333. })
  334. }
  335. });
  336. </script>