Newer
Older
stockTray / EastLineServer / src / main / resources / static / js / url.js
bello on 4 Nov 2020 1 KB 新增板块
// jQuery url get parameters function [获取URL的GET参数值]
// <code>
//     var GET = $.urlGet(); //获取URL的Get参数
//     var id = GET['id']; //取得id的值
// </code>
//  url get parameters
//  public
//  return array()
(function($) {
    $.extend({
        urlGet:function()
        {
            var aQuery = window.location.href.split("?");  //取得Get参数
            var aGET = new Array();
            if(aQuery.length > 1)
            {
                var aBuf = aQuery[1].split("&");
                for(var i=0, iLoop = aBuf.length; i<iLoop; i++)
                {
                    var aTmp = aBuf[i].split("=");  //分离key与Value
                    aGET[aTmp[0]] = aTmp[1];
                }
            }
            return aGET;
        }
    })
})(jQuery);



function formatWan(str) {
    // var str = '9134256781234';
    if (!str){
        return '';
    }
    var value = '';
    if (str.indexOf('.')!=-1){
        value = str.split('.')[0];
    } else {
        value = str;
    }
    // console.log(value);
    var result = '';
    if (value.length < 5){
        result = value;
    } else if (value.length >=5 && value.length < 9){
        result = value.substring(0, value.length + 1 - 5) + '万';
    } else if (value.length >=9 && value.length < 13){
        result = value.substring(0, value.length + 1 -9) + '亿';
    } else if (value.length >=13 ){
        result = value.substring(0, value.length + 1 - 13) + '.' + value.substring(value.length + 1 - 13, value.length + 1 - 9) + '万亿';
    }

    // console.log('r==> ' + result);
    return result;
}