﻿let bus = new Vue();
Vue.prototype.bus = bus;
Vue.prototype.$system = "";
Vue.prototype.$userId = "";
Vue.prototype.$userName = "";
Vue.prototype.$unitVersion = null;
Vue.prototype.$getUrl = function(url) {
    return "/" + this.$system + url;
};
Vue.prototype.$getIndexUrl= function(url) {
    return "/readercenter" + url;
}
Vue.prototype.subString = function (str, len, needAdd) {
    var strLen = 0;
    var s = "";
    for (var i = 0; i < str.length; i++) {
        if (str.charCodeAt(i) > 128) {
            strLen += 2;
        } else {
            strLen++;
        }
        s += str.charAt(i);
        if (strLen >= len) {
            if (needAdd)
                return s + "...";
            else
                return s;
        }
    }
    return s;
}
Vue.prototype.$utils = {
    
}

Vue.prototype.getLoadingHtml=function (style) {
    let margin = 80;
    let height = 32;
    if (style) {
        if (style.margin) {
            margin = style.margin;
        }
        if (style.height) {
            height = style.height;
        }
    }
    let loadingHtml = '<div style="margin: ' + margin + 'px auto; width: 32px;height:' + height + 'px;"><span class="loading_circle"></span></div>';
    //console.log(loadingHtml);
    return loadingHtml;
}

