收藏
回答

提示非法的文件无法上传?

Error: 非法的文件,错误信息:invalid file: libs/sciencen_wx.js, undefined:18: SyntaxError: Unexpected token =,  count = { 3: "K", 6: "M", 9: "B", 12: "T", 15: "aa", 18: "ab", 21: "ac", 24: "ad", 27: "ae", 30: "af" };        ^SyntaxError: Unexpected token = [20190828 16:43:53][wxeba4190239e21346]

上传代码的时候提示非法的文件,上面是提示的错误 错误指向的是下面这个JS文件


 
class sciencen {
// 计数法
  count = { 3: "K", 6: "M", 9: "B", 12: "T", 15: "aa", 18: "ab", 21: "ac", 24: "ad", 27: "ae", 30: "af" };
// 超大数值加法运算
 addition (a, b) {
    var res = '', temp = 0;
    a = a.split('');
    b = b.split('');
    while (a.length || b.length || temp) {
        temp += ~~a.pop() + ~~b.pop();
        res = (temp % 10) + res;
        temp = temp > 9;
    }
    return res.replace(/^0+/, '');
};
// 超大数值减法运算
 subtraction(a, b) {
    a = a.split('');
    b = b.split('');
    var aMaxb = a.length > b.length;
    if (a.length == b.length) {
        for (var i = 0, len = a.length; i < len; i++) {
            if (a[i] == b[i])
                continue;
            aMaxb = a[i] > b[i];
            break;
        }
    }
    if (!aMaxb)
        a = [b, b = a][0];
    var result = '';
    while (a.length) {
        var temp = parseInt(a.pop()) - parseInt(b.pop() || 0);
        if (temp >= 0)
            result = temp + result;
        else {
            result = temp + 10 + result;
            a[a.length - 1]--;
        }
    }
    return (aMaxb ? '' : '-') + result.replace(/^0*/g, '');
};
// 数值格式化
 format (value) {
    let a = value;
    let b;
    let c;
    let is_j;
    //起掉小数点
    let inx = value.lastIndexOf(".");
    if(inx!=-1)
    {
        a = value.slice(0,inx);
    }
    for (let i in this.count) {
        let ii = Number(i);
        if (a.length - 1 >= ii) {
            is_j = true
            b = a.slice(0, a.length - ii) + "." + a.slice(a.length - ii, a.length - ii + 2) + this.count[ii];
        }
    };
    if (!b)
    {
        return value;
    }
    return b;
};
// 超大数值高位对比
 ContrastNumber(a, b) {
    a = a.split('');
    b = b.split('');
    var aMaxb = a.length > b.length;
    if (a.length == b.length) {
        for (var i = 0, len = a.length; i < len; i++) {
            if (a[i] == b[i])
                continue;
            aMaxb = a[i] > b[i];
            break;
        }
    }
    if (!aMaxb)
        a = [b, b = a][0];
    var result = '';
    while (a.length) {
        var temp = parseInt(a.pop()) - parseInt(b.pop() || 0);
        if (temp >= 0)
            result = temp + result;
        else {
            result = temp + 10 + result;
            a[a.length - 1]--;
        }
    }
    if (a === b)
        return true;
    return Boolean(aMaxb);
};
 
// 乘法: accMul("1000000000000","0.8")   除法: accDiv("100000000000","0.8")
 
 
// 数值乘法
 accMuls(a, b) {
    var arra = a.split('').reverse(), arrb = b.split('').reverse(), lena = arra.length, lenb = arrb.length, result = Array(lena + lenb + 1).join('0').split('');
    arra.map(function (itema, indexa) {
        arrb.map(function (itemb, indexb) {
            result[indexa + indexb] = +result[indexa + indexb] + itema * itemb;
        });
    });
    result.map(function (item, index) {
        if (item >= 10) {
            result[index + 1] = ~~result[index + 1] + ~~(result[index] / 10);
            result[index] %= 10;
        }
    });
    return result.reverse().join('').replace(/^0+/, '');
};
// 超大数值乘法
 accMul (arg1, arg2) {
    var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
    try {
        m += s1.split(".")[1].length;
    }
    catch (e) { }
    try {
        m += s2.split(".")[1].length;
    }
    catch (e) { }
    var targe = this.accMuls(Number(s1.replace(".", "")).toString(), Number(s2.replace(".", "")).toString());
    return this.accDiv(targe, Math.pow(10, m)).toString();
};
// 超大数值除法+运算
 accDiv (arg1, arg2) {
    var t1 = 0, t2 = 0, t3 = 0, r1, r2;
    try {
        t1 = arg1.toString().split(".")[1].length;
    }
    catch (e) { }
    try {
        t2 = arg2.toString().split(".")[1].length;
    }
    catch (e) { }
    r1 = Number(arg1.toString().replace(".", ""));
    r2 = Number(arg2.toString().replace(".", ""));
    if (r2 == 0)
        return 0;
    var result = String(r1 / r2);
    try {
        t3 = result.toString().split(".")[1].length;
    }
    catch (e) { }
    var index = t2 - t1 - t3;
    if (index < 0) {
        result = result.replace(".", "");
        while (result.length <= Math.abs(index)) {
            result = '0' + result;
        }
        var start = result.substring(0, result.length + index);
        var end = result.substring(result.length + index, result.length);
        result = start + '.' + end;
        return Number(result);
    }
    else if (index > 0) {
        result = result.replace(".", "");
        while (result.length <= Math.abs(index)) {
            result += '0';
        }
        return Number(result);
    }
    else
        return Number(result.replace(".", ""));
}
}
module.exports = new sciencen();


回答关注问题邀请回答
收藏

2 个回答

登录 后发表内容
问题标签