imageUtils.js 1.47 KB
var __image_utils = {
    setImage : function(_param) {
        var el = _param.el ,
        loadcb = _param.loadcb,
        closecb = _param.closecb;

        el.imageUpload({
            width: _param.width,
            height: _param.height,
            uploadInputName : _param.uploadInputName,
            realInputName: _param.realInputName,
            url: _param.uploadImageUrl,
            queryParams: {
                uploadFileName : _param.uploadInputName,
                bucket: _param.bucket
            },
            onBeforeSubmit: function () {
                $.messager.progress({
                    title: "正在执行",
                    msg: "正在执行,请稍后...",
                    interval: 500,
                    text: ""
                });
            },
            filterFileName: function (data) {
                if (!data || data.code != 200) {
                    $.messager.progress("close");
                    $.messager.alert("错误",data.message);
                    return "";
                }
                return data.data;
            },
            onLoadSuccess: function (data) {
                $.messager.progress("close");
                //loadcb && loadcb(data.data);
                return false;
            },
            onClose: function(){
                closecb && closecb();
            }
        });

        var val = el.attr('value');
        if (val) {
            el.imageUpload("setValue", val);
        }
}


}