import { number } from 'echarts';
import { ElMessageBox, MessageBoxState } from 'element-plus'
import type { Action } from 'element-plus'
/**
 * 清除用户的一些缓存数据
 */
export const clearUserIocalStorage = () =>{
    localStorage.removeItem('vipInfo');
    localStorage.removeItem('scoreInfo');
    localStorage.removeItem('userInfo');
    localStorage.removeItem('volunteer');
    localStorage.removeItem('fillVolunteer');
    localStorage.removeItem('X-Access-Token');
}
//判断vip等级
export const checkLevel = (level:number) =>{
    if(level===0){
        return true;
    }
    let vipInfo = localStorage.getItem('vipInfo') as any
    if(vipInfo){
        vipInfo = JSON.parse(vipInfo);
        return vipInfo.vipLevel >= number
    }
    return false
}

/**
 * 判断 Array 对象参数不为null且其size不等于0
 * @param array
 */
export function collectionUtilsIsNotEmpty(array:Array<object>){
    if (array == undefined || array == null || array.length == 0) {
        return false;
    }
    return true;
}

/**
 * 判断 Array 对象参数为null 或其size等于0
 * @param array
 */
export function collectionUtilsIsEmpty(array:Array<object>){
    if (array == undefined || array == null || array.length == 0) {
        return true;
    }
    return false;
}


export function isNull(str:string){
    if (str == undefined || str == null || str=='') {
        return true;
    }else{
        return false;
    }
}

export function isNotNull(str:string){
    if (str == undefined || str == null || str=='') {
        return false;
    }else{
        return true;
    }
}

/**
 * 数字转汉字
 * @param num
 */
export function convertToChinaNum(num: number) {
    var arr1 = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
    var arr2 = ['', '十', '百', '千', '万', '十', '百', '千', '亿', '十', '百', '千','万', '十', '百', '千','亿'];//可继续追加更高位转换值
    if(!num || isNaN(num)){
        return "零";
    }
    var english = num.toString().split("")
    var result = "";
    for (var i = 0; i < english.length; i++) {
        var des_i = english.length - 1 - i;//倒序排列设值
        result = arr2[i] + result;
        var arr1_index = english[des_i];
        result = arr1[Number(arr1_index)] + result;
    }
    //将【零千、零百】换成【零】 【十零】换成【十】
    result = result.replace(/零(千|百|十)/g, '零').replace(/十零/g, '十');
    //合并中间多个零为一个零
    result = result.replace(/零+/g, '零');
    //将【零亿】换成【亿】【零万】换成【万】
    result = result.replace(/零亿/g, '亿').replace(/零万/g, '万');
    //将【亿万】换成【亿】
    result = result.replace(/亿万/g, '亿');
    //移除末尾的零
    result = result.replace(/零+$/, '')
    //将【零一十】换成【零十】
    //result = result.replace(/零一十/g, '零十');//貌似正规读法是零一十
    //将【一十】换成【十】
    result = result.replace(/^一十/g, '十');
    return result;
}

/**
 * 获取系统名称
 */
export function getSystemName(){
    let systemName = '艺体志愿宝'
    return systemName;
}
