product.js
1.16 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
// 字符上标
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/getProductCate?apilang=${apilang}`, function (res) {
console.log('返回的数据', res)
let str = ''
res.data.forEach(item => {
str += `
<div>
<a href="./product_type.html?data=${item.id}&title=${item.name}">
<p>${item.name}</p>
<p>${item.description}</p>
</a>
</div>
`
})
$('.type').append(str)
})