12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- class utils{
- constructor(){
- console.log('utils初始化');
- }
- getVipLevel(vipexp){
- vipexp = vipexp || GameModel.player.VIPExp;
- let cfgs = ConfigModel.getType(ConfigType.VIP);
- let cfg = cfgs[0];
- while(cfgs[cfg.ID +1] && cfgs[cfg.ID +1].Invest <= vipexp){
- cfg = cfgs[cfg.ID + 1];
- }
- return cfg.ID;
- }
- getGoldString(val){
- let value = val || GameModel.getItemCountByModel(0);
- if(value < 100000){
- return value;
- }
- if(value < 1000000000){
- value = (value / 10000).toFixed(1); //转换为"万"单位,并保留一位小数
- // 去除末尾的".0"
- if (value.slice(-2) === '.0') {
- value = value.slice(0, -2);
- }
- return value + '万';
- }
- value = (value / 100000000).toFixed(1); //转换为"亿"单位,并保留一位小数
- // 去除末尾的".0"
- if (value.slice(-2) === '.0') {
- value = value.slice(0, -2);
- }
- return value + '亿';
- }
- }
- let instance = null;
- utils.getInstance = function(){
- if(!instance){
- instance = new utils();
- }
- return instance;
- }
- // export default utils.getInstance();
- window.utils = utils.getInstance();
|