open_box_action.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. define(["jquery", "easy-admin"], function ($, ea) {
  2. var element = layui.element;
  3. var table = layui.table;
  4. var init = {
  5. table_elem: '#currentTable',
  6. table_render_id: 'currentTableRenderId',
  7. index_url: 'box.OpenBoxAction/index',
  8. add_url: 'coupon.couponarea/add',
  9. edit_url: 'coupon.couponarea/edit',
  10. delete_url: 'box.OpenBoxAction/delete',
  11. opentime_url:'coupon.couponarea/addtime',
  12. export_url: 'mall.cate/export',
  13. modify_url: 'coupon.couponarea/modify',
  14. setting_url:'box.OpenBoxAction/setting',
  15. openbox_url:'box.OpenBoxAction/openBox',
  16. openboxaction_url: 'box.OpenBoxAction/',
  17. beforeopen_url:'box.OpenBoxAction/beforeopen',
  18. beforehandle_url:'box.HandleBoxAction/index',
  19. };
  20. var Controller = {
  21. index: function () {
  22. ea.table.render({
  23. init: init,
  24. toolbar:['refresh','setting',
  25. [
  26. {
  27. text: '一键开福袋',
  28. url: 'none',
  29. method: 'none',
  30. auth: 'openBox',
  31. extend: 'data-full="false"',
  32. class: 'layui-btn layui-btn-warm layui-btn-sm layui-open-box',
  33. icon: 'fa fa-cube '
  34. },
  35. ]
  36. ],
  37. limits: [10, 15, 20, 25, 50,100],
  38. cols: [[
  39. {type: "checkbox"},
  40. {field: 'id', width: 80, title: 'id'},
  41. {field: 'box_id', minWidth: 80, title: '盒子id'},
  42. {field: 'qi_count', minWidth: 80, title: '第几期'},
  43. {field: 'lun_count', minWidth: 80, title: '第几轮'},
  44. {field: 'num', minWidth: 80, title: '数量',templet: function (d) {
  45. return '<span class="layui-badge layui-bg-green">' + d.num+'</span>';
  46. }},
  47. {field: 'pay_type', minWidth: 100, title: '支付类型', search: 'select', selectList: {'1': '积分', '2': '余额'}},
  48. {field: 'uid', minWidth: 120, title: '用户uid'},
  49. {field: 'mobile', minWidth: 150, title: '用户手机号'},
  50. {field: 'yesterday_money', minWidth: 120, title: '昨日盈利',templet: function (d) {
  51. return '<span class="layui-badge layui-bg-red">' + d.yesterday_money+'</span>';
  52. }},
  53. {field: 'last_team_profit', minWidth: 150, title: '昨日团队盈利',templet: function (d) {
  54. return '<span>' + d.last_team_profit+(d.last_team_profit>=2000?'<br><span style="color: red;">(应放'+parseInt(d.last_team_profit/2000)+'个普通)</span>':'')+'</span>';
  55. }},
  56. {field: 'total_free', minWidth: 120, title: '总共消费金额'},
  57. {field: 'total_income', minWidth: 120, title: '总盈利'},
  58. {field: 'total_appoint_count', minWidth: 120, title: '总共预约次数'},
  59. {field: 'total_null_box', minWidth: 180, title: '总共空盒个数'},
  60. {field: 'ubox10', minWidth: 100, title: '中过普通'},
  61. {field: 'ubox20', minWidth: 100, title: '中过稀有'},
  62. {field: 'ubox30', minWidth: 100, title: '中过史诗'},
  63. {field: 'ubox40', minWidth: 100, title: '中过传说'},
  64. {field: 'create_time', minWidth: 200, title: '创建时间'},
  65. {field: 'box10', minWidth: 120, title: '匹配普通'},
  66. {field: 'box20', minWidth: 120, title: '匹配稀有'},
  67. {field: 'box30', minWidth: 120, title: '匹配史诗'},
  68. {field: 'box40', minWidth: 120, title: '匹配传说'},
  69. {field: 'hs_xy', minWidth: 120, title: '指定稀有',templet: function (d) {
  70. if(d.hs_xy){
  71. return '<span style="color: red;">是</span>';
  72. }else{
  73. return '<span>否</span>';
  74. }
  75. }},
  76. {
  77. width: 120,
  78. title: '操作',
  79. fixed: 'right',
  80. templet: function (d) {
  81. console.log(d);
  82. var button = '';
  83. button += '<button class="layui-btn layui-btn-xs layui-btn-normal" data-full="false" data-open="box.OpenBoxAction/beforeopen?id=' + d.id + '" data-title="提前匹配">提前匹配</button>';
  84. return button;
  85. },
  86. }
  87. ]],
  88. });
  89. let _this = this;
  90. element.on('tab(box)', function(e){
  91. var type = e.index
  92. if(type == 1){
  93. init.table_elem = '#currentTable1'
  94. init.table_render_id = 'currentTableRenderId1'
  95. init.index_url = 'box.OpenBoxAction/index?match=1'
  96. }else{
  97. init.table_elem = '#currentTable'
  98. init.table_render_id = 'currentTableRenderId'
  99. init.index_url = 'box.OpenBoxAction/index'
  100. }
  101. _this.index();
  102. });
  103. $('body').on('click', '.layui-open-box', function () {
  104. var checkStatus = table.checkStatus(init.table_render_id),
  105. data = checkStatus.data;
  106. if (data.length <= 0) {
  107. ea.msg.error('请勾选需要操作的数据');
  108. return false;
  109. }
  110. var ids = [];
  111. var boxCount = 0;
  112. $.each(data, function (i, v) {
  113. ids.push(v.id);
  114. boxCount += parseInt(v.num);
  115. });
  116. ea.msg.confirm('确定开出选中的'+(ids.length)+'个用户的'+boxCount+'个福袋?开奖过程中请不要刷新页面', function () {
  117. ea.request.post({
  118. url: ea.url(init.openbox_url),
  119. data: {
  120. id: ids
  121. },
  122. }, function (res) {
  123. layer.confirm(msg, {title: '开奖结果', btn: ['确认'], time: 20000}, function () {
  124. document.reload();
  125. })
  126. // ea.msg.confirm(res.msg, function () {
  127. // document.reload();
  128. // },20000);
  129. });
  130. });
  131. return false;
  132. });
  133. ea.listen();
  134. },
  135. add: function () {
  136. ea.listen();
  137. },
  138. edit: function () {
  139. ea.listen();
  140. },
  141. addtime: function () {
  142. ea.listen();
  143. },
  144. beforeopen: function (){
  145. ea.listen();
  146. },
  147. setting: function () {
  148. ea.listen();
  149. },
  150. openBox: function () {
  151. console.log(44)
  152. ea.listen();
  153. }
  154. };
  155. return Controller;
  156. });