HEX
Server: Apache/2.4.6 (CentOS) PHP/5.6.39
System: Linux izj6c6ukj0hyugxsgmuxz3z 3.10.0-514.6.2.el7.x86_64 #1 SMP Thu Feb 23 03:04:39 UTC 2017 x86_64
User: root (0)
PHP: 5.6.39
Disabled: NONE
Upload Files
File: /web/data/www.tbbprovision.com/static/manage/js/user.js
/**
 *  author      : liaoyaping
 *  createTime  : 2017/4/28 13:52
 *  description :
 */

var userobj = {
    list:function(){
        var $bootstrapTable = $('#table2').bootstrapTable({
            url:'/admin/user/list_json/',
            formatSearch:function(){return "用户名 / 邮箱 / 电话";},
            method:'post',
            striped:true,
            search:true,
            height:'450',
            toolbar:'#toolbar',
            showColumns:true,
            showRefresh:true,
            idField:'user_id',
            showToggle:true,
            sidePagination:'server',
            selectItemName:'id',
            totalRows:5,
            columns: [{
                field: 'user_id',
                title: 'ID',
                checkbox:true,
                formatter:function(value,row){
                    row['post_id'] = value;
                }
            },{
                field: 'first_name',
                title: '用户名',
                formatter:function(value,row,index){
                    return value+' '+ row['last_name'];
                },
                sortable:true
            },{
                field: 'email',
                title: '邮箱'
            },{
                field: 'telephone',
                title: '手机号码'
            },{
                field: 'reg_time',
                title: '注册时间',
                sortable:true,
                formatter:function(value,row,index){
                    return value;
                }
            },{
                field: 'login_times',
                title: '登录次数',
                sortable:true
            },{
                field: 'consumption_amount',
                title: '消费金额',
                sortable:true,
                formatter:function(value){return value;}
            },{
                field: 'is_lock',
                title: '操作',
                class:'text-center',
                formatter:function(value,row,index){
                    return 1==1?"<a data-id='"+row.post_id+"' class='item-lock-btn btn btn-info btn-list' title='锁定帐户'><i class='fa fa-lock fa-"+(value==1?"lock":"unlock")+"'></i></a>&nbsp;<a href='/admin/user/user_detail/?user_id="+row.post_id+"'class='item-edit-btn  btn btn-info btn-list' title='编辑用户'><i class='fa fa-pencil'></i></a>":"";
                }
            }],
            onLoadSuccess: function(data){
                $('.item-lock-btn').click(function(){
                    var query_strint = $(this).attr('data-id');
                    var $this = $(this).children('i');
                    $.ajax({
                        url: '/admin/user/user_lock/',
                        method: 'get',
                        timeout:10000,
                        data:"id="+query_strint,
                        dataType: 'json',
                        success:function(xhrData){
                            layer.msg(xhrData.response_content,{time:1000,icon:1});
                            $this.toggleClass('fa-unlock');
                        },
                        error:function(xhrData){layer.msg(errorMessage(xhrData.responseText),{time:1000,icon:7})}
                    });
                });
            }
        });

        //删除
        $('#remove').click(function(){
            //询问框
            layer.confirm('确定删除此记录?', {
                skin:'layui-layer-molv',
                'title':'<strong class="">提示</strong>',
                btn: ['删除','关闭'] //按钮
            }, function(){
                jQuery.ajax({
                    method:'post',
                    url:'/admin/user/user_del/',
                    data:global.get_selected_str('input[name="id"]:checked','id'),
                    dataType:'json',
                    success:function($d){
                        $bootstrapTable.bootstrapTable('refresh');
                        layer.msg($d.response_content, {icon: 1,time:1000});
                    },
                    error:function(xhrData){
                        layer.msg(xhrData.responseText,{time:2000,icon:7});
                    }
                });
            });
        });
    },

    detail: function(){
        //日志
        if($('#logs_table').length>0){
            var user_id = $('input[name=user_id]').val();
            $('#logs_table').bootstrapTable({
                url:'/admin/user/logs_list_json/',
                formatSearch:function(){return "标题";},
                method:'post',
                striped:true,
                search:true,
                sortOrder:'desc',
                height:'550',
                toolbar:'#toolbar',
                showColumns:true,
                showRefresh:true,
                idField:'user_id',
                showToggle:true,
                queryParams:function(data){
                    data.user_id = user_id;
                    return data;
                },
                sidePagination:'server',
                selectItemName:'id',
                totalRows:5,
                columns: [{
                    title: '序号',
                    formatter:function(value,row,index){
                        return index++;
                    }
                },{
                    field: 'title',
                    title: '标题'
                },{
                    field: 'form_url',
                    title: '来源网址'
                },{
                    field: 'ip',
                    title: '操作IP',
                    formatter:function(value,row){
                        return value+' ['+row['ip_addr']+']';
                    }
                },{
                    field: 'acc_time',
                    title: '操作时间',
                    sortable:true,
                    formatter:function(value,row,index){
                        return value;
                    }
                }]
            });
        }

        //收藏夹
        if($('#favorite_table').length>0){
            var user_id = $('input[name=user_id]').val();
            var offset = 0;
            $('#favorite_table').bootstrapTable({
                url:'/admin/user/favorite_list_json/',
                formatSearch:function(){return "标题";},
                method:'post',
                striped:true,
                search:true,
                sortOrder:'desc',
                height:'550',
                toolbar:'#toolbar',
                showColumns:true,
                showRefresh:true,
                idField:'user_id',
                showToggle:true,
                queryParams:function(data){
                    offset = data.offset;
                    data.user_id = user_id;
                    return data;
                },
                sidePagination:'server',
                selectItemName:'id',
                totalRows:5,
                columns: [{
                    title: '序号',
                    formatter:function(value,row,index){
                        return offset + (++index);
                    }
                },{
                    field: 'picture',
                    title: '产品图片',
                    width: '7%',
                    formatter:function(value,row){
                        if(value){
                            return "<a target='_blank' href='"+row['url']+"'><img class='lazy' width='50' height='50' src='"+value+"'></a>";
                        }else{
                            return "<a target='_blank' href='"+row['url']+"'><img width='50' height='50' src='/static/manage/img/webuploader.png'></a>";
                        }
                    }
                },{
                    field: 'name',
                    title: '产品名称',
                    width: '55%',
                    formatter:function(value,row){
                        return "<a target='_blank' href='"+row['url']+"'>"+value+"</a>";
                    }
                },{
                    field: 'model',
                    title: '型号',
                    width: '15%'
                },{
                    field: 'add_time',
                    title: '收藏时间',
                    width: '20%',
                    formatter:function(value,row){
                        return "<a target='_blank' href='"+row['url']+"'>"+value+"</a>";
                    }
                }]
            });
        }

        //地址薄管理
        if($('.address-list').length>0){
            var that = $('.address-list');
            var user_id = $('input[name=user_id]').val();
            $.ajax({
                timeout:10000,
                type: "post",
                url: '/admin/user/address_list_json/',
                dataType: 'json',
                data: 'user_id='+user_id,//表单数据
                beforeSend:function(){
                    layer.msg('数据加载中',{icon:16,time:0});
                },
                success: function (d) {
                    layer.closeAll();
                    var html = "";
                    for(var item = 0;item<d.response_content.length;item++){
                        var row = d.response_content[item];
                        html+= '<div class="col-sm-6"><div class="panel panel-default"><div class="panel-heading "><h3 class="panel-title">'+row.name_of_shipping_info+'</h3></div><div class="panel-body no-borders">';

                        html+= '<div class="clearfix form-group m-t-n m-b-n"><label class="control-label col-sm-4">Name of Shipping Info<br />( 装运信息名称 )</label><span class="col-sm-8 form-control-static">'+row.name_of_shipping_info+'</span></div><div class="hr-line-dashed"></div>';

                        html+= '<div class="clearfix form-group m-t-n m-b-n"><label class="control-label col-sm-4">Destination Port<br />( 目的港 )</label><span class="col-sm-8 form-control-static">'+row.destination_port+'</span></div><div class="hr-line-dashed"></div>';

                        html+= '<div class="clearfix form-group m-t-n m-b-n"><label class="control-label col-sm-4">Destination Country<br />( 目的地国家 )</label><span class="col-sm-8 form-control-static">'+row.destination_country+'</span></div><div class="hr-line-dashed"></div>';

                        html+= '<div class="clearfix form-group m-t-n m-b-n"><label class="control-label col-sm-4">Departure Port<br />( 出发港 )</label><span class="col-sm-8 form-control-static">'+row.departure_port+'</span></div><div class="hr-line-dashed"></div>';

                        html+= '<div class="clearfix form-group m-t-n m-b-n"><label class="control-label col-sm-4">Shipping Mode<br />( 运输方式 )</label><span class="col-sm-8 form-control-static">'+row.shipping_mode+'</span></div><div class="hr-line-dashed"></div>';

                        html+= '<div class="clearfix form-group m-t-n m-b-n"><label class="control-label col-sm-4">Consignee Notify Party<br />( 收货人通知人 )</label><span class="col-sm-8 form-control-static">'+row.consignee_notify_party+'</span></div><div class="hr-line-dashed"></div>';

                        html+= '<div class="clearfix form-group m-t-n m-b-n"><label class="control-label col-sm-4">Shipper<br />( 托运人 )</label><span class="col-sm-8 form-control-static">'+row.shipper+'</span></div><div class="hr-line-dashed"></div>';

                        html+= '<div class="clearfix form-group m-t-n m-b-n"><label class="control-label col-sm-4">Forwarder Info<br />( 代理信息 )</label><span class="col-sm-8 form-control-static">'+row.forwarder_info+'</span></div><div class="hr-line-dashed"></div>';

                        html+= '<div class="clearfix form-group m-t-n m-b-n"><label class="control-label col-sm-4">Goods<br />( 商品信息 )</label><span class="col-sm-8 form-control-static">'+row.goods+'</span></div><div class="hr-line-dashed"></div>';

                        html+= '<div class="clearfix form-group m-t-n m-b-n"><label class="control-label col-sm-4">Shipping Marks<br />( 运输标志 )</label><span class="col-sm-8 form-control-static">'+row.shipping_marks+'</span></div><div class="hr-line-dashed"></div>';

                        html+= '<div class="clearfix form-group m-t-n m-b-n"><label class="control-label col-sm-4">Notes<br />( 提示 )</label><span class="col-sm-8 form-control-static">'+row.notes+'</span></div><div class="hr-line-dashed"></div>';

                        html+='</div></div></div>';
                    }
                    that.html(html);
                },
                error:function(xhrData){
                    layer.msg(errorMessage(xhrData.responseText),{time:1000,icon:2});
                }
            });
        }
    },

    //会员添加
    add:function(){
        $('#defaultForm').bootstrapValidator({
            message: '这是个无效值',
            feedbackIcons: {/*input状态样式图片*/
                //valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {/*验证:规则*/
                gender: {//验证input项:验证规则
                    validators: {
                        notEmpty: { message: '性别不能为空'}
                    }
                },
                first_name: {//验证input项:验证规则
                    validators: {
                        notEmpty: { message: '姓别不能为空'}
                    }
                },
                last_name: {//验证input项:验证规则
                    validators: {
                        notEmpty: { message: '名不能为空'}
                    }
                }
            }
        })
        .on('success.form.bv', function(e) {//点击提交之后
            e.preventDefault();
            var $form = $(e.target);
            var bv = $form.data('bootstrapValidator');
            $.ajax({
                timeout:10000,
                type: "post",
                url: "/admin/user/user_add_post/",
                dataType: 'json',
                data: $('body').find('form').serialize(),//表单数据
                beforeSend:function(){
                    $("#validateBtn").button('loading');
                },
                success: function (d) {
                    window.location = '/admin/user/list/';
                },
                error:function(xhrData){
                    layer.msg(errorMessage(xhrData.responseText),{time:1000,icon:2});
                    $("#validateBtn").button('reset');
                }
            });
        });
        $('#validateBtn').click(function() {
            $('#defaultForm').bootstrapValidator('validate');
        });
    },

    export:function(){
        $('#table3').bootstrapTable({
            url:'/admin/user/export_json/',
            formatSearch:function(){return "用户名 / 邮箱 / 电话";},
            method:'post',
            search:false,
            height:'600',
            clickToSelect:true,
            pageSize: 500 ,
            pageList: [100,200,300,400,500],
            showColumns:false,
            showRefresh:false,
            idField:'user_id',
            showToggle:false,
            sidePagination:'server',
            selectItemName:'id[]',
            totalRows:5,
            columns: [{
                field: 'user_id',
                title: 'ID',
                checkbox:true
            },{
                field: 'first_name',
                title: '用户名',
                formatter:function(value,row,index){
                    return value+' '+ row['last_name'];
                },
                sortable:true
            },{
                field: 'email',
                title: '邮箱'
            }]
        });
    }
};