system.js 1.57 KB
// 字符上标
function convertToSuperscript(str) {
    var regex = /[\\\\|\?]+/; // 定义特殊符号的正则表达式

    if (regex.test(str)) {
        return str.replace(/([\\\\|\?])/g, '<sup>$1</sup>'); // 使用正则表达式全局替换特殊符号并添加上标样式
    } else {
        return str;
    }
}
let urlStr = window.location.href
let apilang = ''
if(urlStr.includes('English')){
    // url = url.replace('English',change)
    // window.location.href = url
    apilang = 'English'
}else if(urlStr.includes('Chinese')){
    apilang = 'Chinese'
}else if(urlStr.includes('Russian')){
    apilang = 'Russian'
}else if(urlStr.includes('Spain')){
    apilang = 'Spain'
}
// 获取体系列表
$.get(`http://www.ccdcdf.com:6080/api/index/getSystemList?apilang=${apilang}`, function (res) {
    console.log('返回的数据', res)
    let str = ''
    res.data.forEach(item => {
        let title = convertToSuperscript(item.title)
        let description = convertToSuperscript(item.description)
        
        // let objEncoded = encodeURIComponent(it);
        str += `
        <div>
        
                <a href="../system/system_detail.html?data=${item.id}">
                    <span>${title}</span>
                    <p style="width:85%;display: -webkit-box;
                    -webkit-box-orient: vertical;
                    -webkit-line-clamp: 3; 
                    overflow: hidden;
                    text-overflow: ellipsis;">${description}</p>
                    <div></div>
                </a>
            </div>
        `
    })
    $('.info').append(str)
})