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/picture.js
/**
 *  author      : liaoyaping
 *  createTime  : 2017/5/25 9:04
 *  description :
 */
var pictureobj = {
    list : function(tag_id){
        //删除
        $('.item-remove-btn').click(function(){
            var id = $(this).attr('data-id'),
                that = $(this);
            layer.confirm('确定删除此文件?', {
                skin:'layui-layer-molv',
                icon: 3,
                'title':'<strong class="">提示</strong>',
                btn: ['删除','关闭'] //按钮
            }, function(){
                jQuery.ajax({
                    method:'post',
                    url:'/admin/pictures/file_del/',
                    data:{'id':id},
                    dataType:'json',
                    timeout:5000,
                    beforeSend:function(){
                        layer.msg('数据处理中',{icon:16,time:0,shade:[0.8,'#000']});
                    },
                    success:function($d){
                        layer.msg($d.response_content, {icon: 1,time:300});
                        that.parents('.file-box').fadeOut();
                    },
                    error:function(xhrData){
                        layer.msg(errorMessage(xhrData.responseText),{time:2000,icon:7});
                    }
                });
            },function(){
                layer.msg('操作取消',{time:500});
            });
        });

        //文件信息编辑
        $('.item-edit-btn').click(function(){
            var query_strint = $(this).attr('data-id');
            layer.open({
                type: 2,
                title: ['编辑文件信息'],
                scrollbar:false,
                shadeClose: true,
                offset:[0,'20%'],
                queryParames:{},
                shade: [true,'rgba(0,0,0,.5)'],
                maxmin: true,
                shift:2,
                area: ['80%', '100%'],
                content: '/admin/pictures/edit/?id='+query_strint
            })
        });



        //标签删除
        $('.tag-item-remove-btn').click(function(){
            var id = $(this).attr('data-id');
            //询问框
            layer.confirm('确定删除此标签?', {
                skin:'layui-layer-molv',
                icon: 3,
                'title':'<strong class="">警告</strong>',
                btn: ['删除','关闭'] //按钮
            }, function(){
                jQuery.ajax({
                    method:'post',
                    url:'/admin/pictures/tag_del/',
                    data:{'id':id},
                    dataType:'json',
                    timeout:5000,
                    beforeSend:function(){
                        layer.msg('数据处理中',{icon:16,time:0,shade:[0.8,'#000']});
                    },
                    success:function($d){
                        layer.msg($d.response_content, {icon: 1,time:500},function(){
                            window.location.reload();
                        });
                    },
                    error:function(xhrData){
                        layer.msg(errorMessage(xhrData.responseText),{time:2000,icon:7});
                    }
                });
            },function(){
                layer.msg('操作取消',{time:500});
            });
        });

        //标签编辑
        $('.tag-item-edit-btn').click(function(){
            var query_strint = $(this).attr('data-id');
            layer.open({
                type: 2,
                title: ['编辑标签'],
                scrollbar:false,
                shadeClose: true,
                queryParames:{},
                shade: [true,'rgba(0,0,0,.5)'],
                maxmin: true,
                shift:2,
                area: ['300px', '200px'],
                content: '/admin/pictures/tag_edit/?id='+query_strint
            })
        });

        //标签添加
        $('.tag-add-btn').click(function(){
            layer.prompt({'title':"添加文件标签",skin:' text-blod '},function(val, index){
                $.ajax({
                    type: "post",
                    url: "/admin/pictures/tag_add_post/",
                    dataType: 'json',
                    timeout: 10000,
                    data: "tag_name="+val,//表单数据
                    beforeSend:function(){layer.msg('数据处理中',{icon:16,time:0,shade:[0.8,'#000']});},
                    success: function (d) {
                        layer.msg('保存成功!',{time:1000,icon:1},function(){
                            window.location.reload();
                        });
                        layer.close(index);
                    },
                    error:function(xhrData){
                        layer.msg(errorMessage(xhrData.responseText),{time:1000,icon:7});
                    }
                });
            });
        });

        $("#upload-btn").uploadify({
                'formData'     : {
                    'timestamp' : '',
                    'token'     : '',
                    'type'		:	'image_upload',
                    'tag_id'    :  tag_id
            },
            'fileTypeExts':'*.jpg;*.png;*.gif;*.jpeg;*.pdf;*.PDF;*.pdf;*.xls;*.xlsx',
                'removeTimeout':'0.2',
                'queueSizeLimit'	: 150,
                'uploadLimit'		:	150,//uploadLimit?uploadLimit:1,
                'swf'      : '/static/js/plugins/uploadify/uploadify.swf',
                'uploader' : '/admin/pictures/bat_upload',
                'onUploadSuccess':function(file, data, response){
                //判断文件是否上传成功
                if(data.indexOf('文件上传失败')>=0){
                    alert(data);
                }else{}
            }
        });
        $("img.lazy").lazyload({effect: "fadeIn"});
    },

    tag_edit : function(){
        $('#defaultForm').bootstrapValidator({
            message: '这是个无效值',
            feedbackIcons: {/*input状态样式图片*/
                //valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {/*验证:规则*/
                tag_name: {//验证input项:验证规则
                    validators: {
                        notEmpty: { message: '标签名称不能为空'},
                        stringLength: { min: 2, max: 20, message: '标签名称长度必须在2到20之间'}
                    }
                }
            }
        })
        .on('success.form.bv', function(e) {//点击提交之后
            e.preventDefault();
            var $form = $(e.target);
            var bv = $form.data('bootstrapValidator');
            $.ajax({
                type: "post",
                url: "/admin/pictures/tag_edit_post/",
                dataType: 'json',
                data: $('body').find('form').serialize(),//表单数据
                timeout: 5000,
                beforeSend:function(){
                    parent.layer.msg('数据处理中',{icon:16,time:0,shade:[0.8,'#000']});
                    $('#validateBtn').button('loading');
                },
                success: function (d) {
                    parent.location.reload();
                    parent.layer.closeAll('iframe');//关闭弹窗
                },
                error:function(xhrData){
                    parent.layer.msg(errorMessage(xhrData.responseText),{time:1000,icon:2});
                    $('#validateBtn').button('reset');
                }
            });
        });
        $('#validateBtn').click(function(){
            $('#defaultForm').bootstrapValidator('validate');
        });
    },

    edit : function(){
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green'
        });

        $('#defaultForm').bootstrapValidator({
            message: '这是个无效值',
            feedbackIcons: {/*input状态样式图片*/
                //valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {/*验证:规则*/
                file_name: {//验证input项:验证规则
                    validators: {
                        notEmpty: { message: '文件名称不能为空'},
                        stringLength: { min: 2, max: 30, message: '文件名称长度必须在2到30之间'}
                    }
                }
            }
        })
        .on('success.form.bv', function(e) {//点击提交之后
            e.preventDefault();
            var $form = $(e.target);
            var bv = $form.data('bootstrapValidator');
            $.ajax({
                type: "post",
                url: $form.attr('action'),
                dataType: 'json',
                timeout: 5000,
                data: $('body').find('form').serialize(),//表单数据
                beforeSend:function(){
                    layer.msg('数据处理中',{icon:16,time:0,shade:[0.8,'#000']});
                    $('#validateBtn').button('loading');
                },
                success: function (d) {
                    parent.location.reload();
                    parent.layer.closeAll('iframe');//关闭弹窗
                },
                error:function(xhrData){
                    layer.msg(errorMessage(xhrData.responseText),{icon:7,time:1000,shade:[0.8,'#000']});
                    $('#validateBtn').button('reset');
                }
            });
        });

        $('#validateBtn').click(function(){
            $('#defaultForm').bootstrapValidator('validate');
        });
    }
}