system_detail.js
1.74 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// 字符上标
function convertToSuperscript(str) {
var regex = /[\\\\|\?]+/; // 定义特殊符号的正则表达式
if (regex.test(str)) {
return str.replace(/([\\\\|\?])/g, '<sup>$1</sup>'); // 使用正则表达式全局替换特殊符号并添加上标样式
} else {
return str;
}
}
//获取url传来的值
let arr = window.location.href.split('?')[1]
let id = arr.split('=')[1]
let baseUrl = 'https://ccdcfile.oss-cn-chengdu.aliyuncs.com'
console.log(arr)
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'
}
// 根据ID获取详情
$.get(`http://www.ccdcdf.com:6080/api/index/getProductById?id=${id}&apilang=${apilang}`, function (res) {
console.log('返回的数据', res)
let data = res.data
let title = convertToSuperscript(data.title)
let description = convertToSuperscript(data.description)
let introduce = convertToSuperscript(data.introduce)
let str1 = ''
str1 = `<p class="title">${title}</p>
<p class="two">
${description}
</p>`
let str2 = ''
str2 = `<div class="p_pic">
<img src="${baseUrl + data.introduce_image}" alt="">
<div class="p_text">
<div class="lef">
<p class="top">INTRODUCE</p>
<p class="center">
${introduce}
</p>
</div>
</div>
</div>
<img src="${baseUrl + data.content_image}" class="sys_pic" alt="">
`
$('.fen').append(str1)
$('.content').append(str2)
})