index.js
7.67 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
// 首页体系
// 字符上标
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 = ''
let strIntroduce = ''
let moreStr = ''
if(urlStr.includes('English')){
// url = url.replace('English',change)
// window.location.href = url
apilang = 'English'
strIntroduce = 'INTRODUCE'
moreStr = 'MORE'
}else if(urlStr.includes('Chinese')){
apilang = 'Chinese'
strIntroduce = '介绍'
moreStr = '更多'
}else if(urlStr.includes('Russian')){
apilang = 'Russian'
strIntroduce = 'Презентация'
moreStr = 'больше'
}else if(urlStr.includes('Spain')){
apilang = 'Spain'
strIntroduce = 'Introducción'
moreStr = 'Más'
}
// 获取体系列表
$.get(`http://www.ccdcdf.com:6080/api/index/getSystemList?apilang=${apilang}`, function (res) {
console.log('返回的数据', res)
let str = ''
let arr = res.data.slice(0, 6)
arr.forEach(item => {
let title = convertToSuperscript(item.title)
let description = convertToSuperscript(item.description)
// let objEncoded = encodeURIComponent(it);
str += `
<a href="./system/system_detail.html?data=${item.id}">
<div>
<span>${title}</span>
<p>${description}</p>
<div></div>
</div>
</a>
`
})
$('.info').append(str)
})
let baseUrl = 'https://ccdcfile.oss-cn-chengdu.aliyuncs.com'
// 获取技术列表
$.get(`http://www.ccdcdf.com:6080/api/index/getTechnologyList?apilang=${apilang}`, function (res) {
console.log('返回的数据', res)
let arr = res.data.slice(0, 4)
let str = ''
arr.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">${moreStr}</div>
</div>
</a>
`
})
$('.tech').append(str)
})
// 获取实验室列表
$.get(`http://www.ccdcdf.com:6080/api/index/ObtainLaboratory?apilang=${apilang}`, function (res) {
console.log('返回的数据', res)
let arr = res.data.slice(0, 4)
let str = ''
arr.forEach(item => {
let title = convertToSuperscript(item.title)
title = title.toUpperCase()
let description = convertToSuperscript(item.description)
// let objEncoded = encodeURIComponent(it);
str += `
<a href="./team_lab/t_l_lab_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(${baseUrl + item.covos}) center center no-repeat;
background-size: 100% 100%;">
<span>${title}</span>
<p>${description}
</p>
<div>${moreStr}</div>
</div>
</a>
`
})
$('.team_Four').append(str)
})
// 获取产品列表
$.get(`http://www.ccdcdf.com:6080/api/index/getProductByCate?apilang=${apilang}`, function (res) {
console.log('产品', res)
let arr = res.data.sort(function(a,b){
return a.views - b.views
})
arr = arr.slice(0,8)
let str = ''
arr.forEach(item => {
let section = item.url.split('/')[2]
console.log(section)
let title = convertToSuperscript(item.title)
// title = title.toUpperCase()
let description = convertToSuperscript(item.description)
// let objEncoded = encodeURIComponent(it);
str += `
<div class="swiper-slide pro" style="border-radius: 13px 13px 13px 13px;">
<img src="${item.image}" style="border-radius: 13px 13px 13px 13px; height:100%;width:auto;"/>
<div class="bg_p">
<p class="p_one">${title}</p>
<p class="p_two" style="display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
text-overflow: ellipsis;">${description}</p>
<a href="./product/product_type.html?data=${item.channel_id}&title=${section}">
<p class="p_more">${moreStr}</p>
</a>
</div>
</div>
`
})
// let str1 = `
// <div class="swiper-wrapper">
// ${str}
// </div>
// <div class="swiper-button-next">
// <img src="../static/imgs/home/right.png" alt="" class="icon next" style="margin-right: 33px;">
// </div>
// <div class="swiper-button-prev">
// <img src="../static/imgs/home/left.png" alt="" class="icon prev" style="margin-left: 33px;">
// </div>
// <!-- <div class="swiper-scrollbar"></div> -->
// <div class="swiper-pagination"></div>
// <a href="./product/product.html" target="_self">
// <div class="more"><p style="width: 40px;color: #C70009;">更多</p> <img style="width: 19px;
// height: 10px;margin-right: 5px;" src="../static/imgs/home/red_more.png" alt=""></div>
// </a>
// `
$('.products').append(str)
// 产品区域轮播
var swiper = new Swiper('.proSwiper', {
slidesPerView: 4,
// spaceBetween: 20,
spaceBetween: 10,
slidesPerGroup: 4,
loop: true,
loopFillGroupWithBlank: true,
pagination: {
el: ".swiper-pagination",
clickable: false,
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
});
})
// 产品区域鼠标移入效果
$('.pro').removeClass('swiper-slide-active')
// $('.pro').mouseenter(function () {
// $(this).siblings().removeClass('swiper-slide-active')
// $(this).addClass('swiper-slide-active')
// })
$(document).on('mouseenter','.pro',function(){
$(this).siblings().removeClass('swiper-slide-active')
$(this).addClass('swiper-slide-active')
})
$(document).on('mouseleave','.pro',function(){
$(this).siblings().removeClass('swiper-slide-active')
$(this).removeClass('swiper-slide-active')
})
// $('.pro').mouseleave(function () {
// $(this).siblings().removeClass('swiper-slide-active')
// $(this).removeClass('swiper-slide-active')
// })
// 获取首页视频
$.get(`http://www.ccdcdf.com:6080/api/index/HomepageVideo?apilang=${apilang}`, function (res) {
console.log('返回的数据', res)
$('.foot').empty()
let str = ''
// let objEncoded = encodeURIComponent(it);
str += `
<video src="${baseUrl + res.data[0].HomepageVideo}" class="video" controls muted autoplay loop></video>
`
$('.foot').append(str)
})