technology.js
1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// 字符上标
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)
})