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

    if (regex.test(str)) {
        return str.replace(/([\\\\|\?])/g, '<sup>$1</sup>'); // 使用正则表达式全局替换特殊符号并添加上标样式
    } else {
        return str;
    }
}
let baseUrl = 'https://ccdcfile.oss-cn-chengdu.aliyuncs.com'
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/getTechnologyList?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 += `
        <a href="../technology/technology_detail.html?data=${item.id}">
                <div class="child" style="background: linear-gradient(180deg, rgba(30, 43, 95, 0) 0%, rgba(30, 43, 95, 0.8) 100%), url(${item.image}) center center no-repeat;
                background-size: 100% 100%;">
                    <div class="tec_sp">
                        <span>${title}</span>
                    <p>${description}</p>
                    </div>
                    <div class="tec_more">MORE</div>
                </div>
            </a>
        `
    })
    $('.technology').append(str)
})