Helius
2021-06-16 5728be2af515b2200e782aa201ca5d4d67d9ea47
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
layui.define([ 'form', 'laydate', 'table' ], function(exports) {
    var form = layui.form;
    var laydate = layui.laydate;
    var table = layui.table;
    var pstatisTable = null;
    var data = {};
    laydate.render({
        elem: '#date',
        type: 'datetime',
        format: 'yyyy-MM-dd HH:mm:ss'
    });
    laydate.render({
        elem: '#date1',
        type: 'datetime',
        format: 'yyyy-MM-dd HH:mm:ss'
    });
 
 
    var view ={
 
        init:function(e){
            data = e;
            this.initTable();
        },
        initTable:function(){
            pstatisTable = table.render({
                elem : '#pstatisTable',
                method : 'post',
                url : Common.ctxPath+ '/admin/cuser/qromoter/queryQromoterList.json' //数据接口
                ,page : true //开启分页
                ,limit : 10,
                where: data,
                parseData :function(res){ //res 即为原始返回的数据
                    if(res.data.length == 0){
                        Common.info('并没有数据');
                    }
                    return res;
                },
                cols : [ [ //表头
                    {
                        field: '',
                        title : '角色',
                        width : 120,
                        templet: function () {
                            return '推广员';
                        }
                    },{
                        title : '昵称',
                        width : 150,
                        templet: function (d) {
                            if(d.nickName == null){
                                return '--';
                            }else{
                                return $.base64.atob(d.nickName, true) + '(姓名: '+ (d.name != null ? d.name : '无')+')';
                            }
                        }
                    },{
                        field : 'mobilePhone',
                        title : '手机号',
                        width : 120
                    }, {
                        field : 'unregistCount',
                        title : '未注册用户',
                        width : 150,
                        templet:function (d) {
                            return d.unregistCount == null ? '--' : d.unregistCount;
                        }
                    },
                    {
                        field : 'registCount',
                        title : '已注册用户',
                        width : 120,
                        templet:function (d) {
                            return d.registCount == null ? '--' : d.registCount;
                        }
                    },{
                        field : 'orderCount',
                        title : '已下单用户',
                        width : 120,
                        templet:function (d) {
                            return d.orderCount == null ? '--' : d.orderCount;
                        }
                    },{
                        field : 'orderWeightCount',
                        title : '订单总重量',
                        templet : function (d) {
                            if(d.orderWeightCount == null || d.orderWeightCount.length === 0){
                                return '--';
                            }
                            return toDecimal2(d.orderWeightCount,3) +"kg";
                        }
                    },{
                        field : 'orderMoneyCount',
                        title : '订单总金额',
                        templet : function (d) {
                            if(d.orderMoneyCount == null || d.orderMoneyCount.length === 0){
                                return '--';
                            }
                            return toDecimal2(d.orderMoneyCount,2) + '元';
                        }
                    },
                    {
                        field: '',
                        title: '操作',
                        templet: function (data) {
                            var st = $("#date").val();
                            var et = $("#date1").val();
                            return '<a class="layui-btn layui-btn-xs" ' +
                                'href="'+Common.ctxPath+'/admin/statis/promoter/order.do?userId='+data.userId+'&startTime='+st+'&endTime='+et+'"'+
                                //'onclick="queryCuserDetail('+data.userID+', '+data.mobilePhone+', '+data.userTypex+')" ' +
                                'lay-event="detail">查看订单</a>';
                        }
                    }
                ] ]
 
            });
        },
 
    }
 
 
    // 搜索
    $("#search").click(function () {
        data = {'name':$("#name").val(),'nickName':$("#nickName").val(), 'mobilePhone':$("#mobilePhone").val(),'userType':6};
        view.init(data);
    });
 
 
    exports('index',view);
 
});
 
function toDecimal2(x,num) {
    var f = parseFloat(x);
    if (isNaN(f)) {
        return false;
    }
    var f;
    if(num>2){
         f = Math.round(x*1000)/1000;
    }else{
         f = Math.round(x*100)/100;
    }
    //var f = Math.round(x*100)/100;
    var s = f.toString();
    var rs = s.indexOf('.');
    if (rs < 0) {
        rs = s.length;
        s += '.';
    }
    while (s.length <= rs + num) {
        s += '0';
    }
    return s;
}