| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- define(["jquery", "easy-admin"], function ($, ea) {
- var element = layui.element;
- var table = layui.table;
- var init = {
- table_elem: '#currentTable',
- table_render_id: 'currentTableRenderId',
- index_url: 'box.OpenBoxAction/index',
- add_url: 'coupon.couponarea/add',
- edit_url: 'coupon.couponarea/edit',
- delete_url: 'box.OpenBoxAction/delete',
- opentime_url:'coupon.couponarea/addtime',
- export_url: 'mall.cate/export',
- modify_url: 'coupon.couponarea/modify',
- setting_url:'box.OpenBoxAction/setting',
- openbox_url:'box.OpenBoxAction/openBox',
- openboxaction_url: 'box.OpenBoxAction/',
- beforeopen_url:'box.OpenBoxAction/beforeopen',
- beforehandle_url:'box.HandleBoxAction/index',
- };
- var Controller = {
- index: function () {
- ea.table.render({
- init: init,
- toolbar:['refresh','setting',
- [
- {
- text: '一键开福袋',
- url: 'none',
- method: 'none',
- auth: 'openBox',
- extend: 'data-full="false"',
- class: 'layui-btn layui-btn-warm layui-btn-sm layui-open-box',
- icon: 'fa fa-cube '
- },
- ]
- ],
- limits: [10, 15, 20, 25, 50,100],
- cols: [[
- {type: "checkbox"},
- {field: 'id', width: 80, title: 'id'},
- {field: 'box_id', minWidth: 80, title: '盒子id'},
- {field: 'qi_count', minWidth: 80, title: '第几期'},
- {field: 'lun_count', minWidth: 80, title: '第几轮'},
- {field: 'num', minWidth: 80, title: '数量',templet: function (d) {
- return '<span class="layui-badge layui-bg-green">' + d.num+'</span>';
- }},
- {field: 'pay_type', minWidth: 100, title: '支付类型', search: 'select', selectList: {'1': '积分', '2': '余额'}},
- {field: 'uid', minWidth: 120, title: '用户uid'},
- {field: 'mobile', minWidth: 150, title: '用户手机号'},
- {field: 'yesterday_money', minWidth: 120, title: '昨日盈利',templet: function (d) {
- return '<span class="layui-badge layui-bg-red">' + d.yesterday_money+'</span>';
- }},
- {field: 'last_team_profit', minWidth: 150, title: '昨日团队盈利',templet: function (d) {
- return '<span>' + d.last_team_profit+(d.last_team_profit>=2000?'<br><span style="color: red;">(应放'+parseInt(d.last_team_profit/2000)+'个普通)</span>':'')+'</span>';
- }},
- {field: 'total_free', minWidth: 120, title: '总共消费金额'},
- {field: 'total_income', minWidth: 120, title: '总盈利'},
- {field: 'total_appoint_count', minWidth: 120, title: '总共预约次数'},
- {field: 'total_null_box', minWidth: 180, title: '总共空盒个数'},
- {field: 'ubox10', minWidth: 100, title: '中过普通'},
- {field: 'ubox20', minWidth: 100, title: '中过稀有'},
- {field: 'ubox30', minWidth: 100, title: '中过史诗'},
- {field: 'ubox40', minWidth: 100, title: '中过传说'},
- {field: 'create_time', minWidth: 200, title: '创建时间'},
- {field: 'box10', minWidth: 120, title: '匹配普通'},
- {field: 'box20', minWidth: 120, title: '匹配稀有'},
- {field: 'box30', minWidth: 120, title: '匹配史诗'},
- {field: 'box40', minWidth: 120, title: '匹配传说'},
- {field: 'hs_xy', minWidth: 120, title: '指定稀有',templet: function (d) {
- if(d.hs_xy){
- return '<span style="color: red;">是</span>';
- }else{
- return '<span>否</span>';
- }
- }},
- {
- width: 120,
- title: '操作',
- fixed: 'right',
- templet: function (d) {
- console.log(d);
- var button = '';
- 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>';
- return button;
- },
- }
- ]],
- });
- let _this = this;
- element.on('tab(box)', function(e){
- var type = e.index
- if(type == 1){
- init.table_elem = '#currentTable1'
- init.table_render_id = 'currentTableRenderId1'
- init.index_url = 'box.OpenBoxAction/index?match=1'
- }else{
- init.table_elem = '#currentTable'
- init.table_render_id = 'currentTableRenderId'
- init.index_url = 'box.OpenBoxAction/index'
- }
- _this.index();
- });
- $('body').on('click', '.layui-open-box', function () {
- var checkStatus = table.checkStatus(init.table_render_id),
- data = checkStatus.data;
- if (data.length <= 0) {
- ea.msg.error('请勾选需要操作的数据');
- return false;
- }
- var ids = [];
- var boxCount = 0;
- $.each(data, function (i, v) {
- ids.push(v.id);
- boxCount += parseInt(v.num);
- });
- ea.msg.confirm('确定开出选中的'+(ids.length)+'个用户的'+boxCount+'个福袋?开奖过程中请不要刷新页面', function () {
- ea.request.post({
- url: ea.url(init.openbox_url),
- data: {
- id: ids
- },
- }, function (res) {
- layer.confirm(msg, {title: '开奖结果', btn: ['确认'], time: 20000}, function () {
- document.reload();
- })
- // ea.msg.confirm(res.msg, function () {
- // document.reload();
- // },20000);
- });
- });
- return false;
- });
- ea.listen();
- },
- add: function () {
- ea.listen();
- },
- edit: function () {
- ea.listen();
- },
- addtime: function () {
- ea.listen();
- },
- beforeopen: function (){
- ea.listen();
- },
- setting: function () {
- ea.listen();
- },
- openBox: function () {
- console.log(44)
- ea.listen();
- }
- };
- return Controller;
- });
|