export default {
    info: function (data) {
        this.hideLoading();
        return uni.showToast(this.handle(data, '/static/images/toast/warning.png'));
    },
    fail: function (data) {
        this.hideLoading();
        return uni.showToast(this.handle(data,'/static/images/toast/fail.png'));
    },
    success: function (data) {
        this.hideLoading();
        return uni.showToast(this.handle(data));
    },
    loading: function (data) {
        if (typeof data === 'string') {
            data = {
                title: data,
                duration: 30000
            };
        }
        data.duration = data.duration || 30000;
        return uni.showLoading(this.handle(data));
    },
    hideLoading: function () {
        return uni.hideLoading();
    },
    handle: function (data, image) {
        if (typeof data !== 'object' || data === null)
            data = { title: data || '' };
        if (image) {
            data['image'] = image;
        }
        data['duration'] = data['duration'] || 2000;
        return data;
    }
}