// 首页banner
$.ajax({
url: base_url + "dfhcate/details",
data: {
id: 5
},
success: function (res) {
if (res.statusCode == 200) {
// console.log('首页-成功', res.data);
// res.data.albums = [
// {
// img: "http://www.edongfanghong.com/upload/bgs/category1/album/202406/17/202406171509477999.jpeg",
// link: "http://www.edongfanghong.com/abouts/2-1-1about.html?pageid=2",
// title: ""
// },
// {
// img: "http://www.edongfanghong.com/upload/bgs/category1/album/202405/31/202405311658527800.jpg",
// link: "http://www.edongfanghong.com/abouts/2-1-1about.html?pageid=2",
// title: ""
// }
// ]
// res.data.albumsH5 = [
// {
// img: "http://www.edongfanghong.com/upload/bgs/category1/album/202406/25/202406251015118052.jpg",
// link: "http://www.edongfanghong.com/abouts/2-1-1about.html?pageid=2",
// title: ""
// },
// {
// img: "http://www.edongfanghong.com/upload/bgs/category1/album/202405/31/202405311658527800.jpg",
// link: "http://www.edongfanghong.com/abouts/2-1-1about.html?pageid=2",
// title: ""
// }
// ]
res.data.albums.forEach((item,index) => {
// console.log('首页-成功-pc',item)
$('#ajaxbannerPc').append(`
`)
});
// 处理banner为1的指示器问题
if(res.data.albums.length<=1){
$(".banner_page").hide()
}
res.data.albumsH5.forEach((item,index) => {
// console.log('首页-成功-h5',item)
$('#ajaxbannerH5').append(`
`)
});
// 轮播图-初始化-pc
let bannerSwiper_PC = new Swiper('.banner-pc', {
slidesPerView: 1,
spaceBetween: 0,
speed: 1000,
allowSlideNext: res.data.albums.length<=1? false : true,
allowSlidePrev: res.data.albums.length<=1? false : true,
autoplay: false,
disableOnInteraction: false,
loop: true,
pagination: {
el: '.swiper-pagination',
clickable: true,
},
on: {
// init: function () {
// swiperAnimateCache(this); //隐藏动画元素
// swiperAnimate(this); //初始化完成开始动画
// },
// slideChangeTransitionEnd: function () {
// swiperAnimate(this); //每个slide切换结束时也运行当前slide动画
// },
}
});
// 轮播图-初始化-h5
let bannerSwiper_H5 = new Swiper('.banner-h5', {
slidesPerView: 1,
spaceBetween: 0,
speed: 1000,
allowSlideNext: res.data.albumsH5.length<=1? false : true,
allowSlidePrev: res.data.albumsH5.length<=1? false : true,
autoplay: false,
disableOnInteraction: false,
loop: true,
pagination: {
el: '.swiper-pagination',
clickable: true,
},
on: {
// init: function () {
// swiperAnimateCache(this); //隐藏动画元素
// swiperAnimate(this); //初始化完成开始动画
// },
// slideChangeTransitionEnd: function () {
// swiperAnimate(this); //每个slide切换结束时也运行当前slide动画
// },
}
});
// 轮播图-点击切换
$('#bannerponl').click(function () {
bannerSwiper_PC.slidePrev();
})
$('#bannerponr').click(function () {
bannerSwiper_PC.slideNext();
})
}
},
error: function (err) {
console.log('失败', err);
},
});
// console.log('homeSwiper', homeSwiper);
// 通知公告
$.ajax({
url: base_url + "dfharticle/list",
data: {
id: 18,
index: true,
pageIndex: 1,
pageSize: 4
},
success: function (res) {
if (res.statusCode == 200) {
res.data.items = sort(res.data.items,'sort')
// console.log('通知公告成功', res.data);
if (res.data.items.length < 1) {
$('#ajaxtzgg').append(`
暂无内容
`)
} else {
res.data.items.forEach(item => {
$('#ajaxtzgg').append(`
${item.title}
${item.addTime}
`)
});
}
}
},
error: function (err) {
console.log('失败', err);
},
});
// 公司新闻
$.ajax({
url: base_url + "dfharticle/list",
data: {
id: 17,
index: true,
pageIndex: 1,
pageSize:6
},
success: function (res) {
if (res.statusCode == 200) {
res.data.items = sort(res.data.items,'sort')
// console.log('公司新闻-成功', res.data);
if (res.data.items.length < 1) {
$('#ajaxbjsp').append(`
暂无内容
`)
} else {
// swiper-slide
res.data.items.forEach(item => {
$('#ajaxbjsp').append(`
${item.title}
${item.subTitle}
`)
});
// 公司新闻-tab点击切换
$('.project-tags-aaa .project-tag').click(function () {
var index = $(this).index();
// console.log(index);
// 改变图标
$(this).addClass('news_chose').siblings().removeClass('news_chose')
if(index){
$(this).children('img').attr('src', './img/jkzx_icon0.png')
$(this).siblings().children('img').attr('src', './img/gsxw_icon1.png')
// $('.project-total-aaa ul').eq(index).show()
// $('.project-total-aaa ul').eq(index-1).hide()
// second_swiper two_swiper
// console.log(second_swiper);
second_swiper.slideTo(6)
}else{
$(this).children('img').attr('src', './img/gsxw_icon0.png')
$(this).siblings().children('img').attr('src', './img/jkzx_icon1.png')
second_swiper.slideTo(6)
// console.log(second_swiper);
}
// $('.project-total-aaa ul').eq(index).show()
projectTypeSwiperaaa.slideTo(index);
})
// 公司新闻-滑动产品对应tab切换
var projectTypeSwiperaaa = new Swiper('.project-total-aaa', {
on: {
slideChangeTransitionStart: function(){
// console.log(this.activeIndex);
if (this.activeIndex == 0) {
$('.news_tit>div').eq(0).addClass('news_chose')
$('.news_tit>div').eq(1).removeClass('news_chose')
// console.log( $('.news_tit>div').eq(this.activeIndex).find('img'));
// console.log( $('.news_tit>div').eq(this.activeIndex+1).find('img'));
$('.news_tit>div').eq(this.activeIndex).find('img').attr('src', './img/gsxw_icon0.png')
$('.news_tit>div').eq(this.activeIndex+1).find('img').attr('src', './img/jkzx_icon1.png')
} else {
$('.news_tit>div').eq(1).addClass('news_chose')
$('.news_tit>div').eq(0).removeClass('news_chose')
// console.log( $('.news_tit>div').eq(this.activeIndex).find('img'));
// console.log( $('.news_tit>div').eq(this.activeIndex-1).find('img'));
$('.news_tit>div').eq(this.activeIndex).find('img').attr('src', './img/jkzx_icon0.png')
$('.news_tit>div').eq(this.activeIndex-1).find('img').attr('src', './img/gsxw_icon1.png')
}
},
}
});
// ====
var second_swiper=new Swiper('.second-one',{
nested: true,
slidesPerView: 'auto',
on: {
// 最后一个
reachEnd: function (e) {
// console.log('最后一个');
// $('.news_tit>div').eq(1).addClass('news_chose')
// $('.news_tit>div').eq(0).removeClass('news_chose')
// $('.news_tit>div').eq(this.activeIndex).find('img').attr('src', './img/jkzx_icon0.png')
// $('.news_tit>div').eq(this.activeIndex-1).find('img').attr('src', './img/gsxw_icon1.png')
}
}
});
// ====
}
}
},
error: function (err) {
console.log('失败', err);
},
});
// 健康资讯-营养补充类
$.ajax({
url: base_url + "dfharticle/list",
data: {
id: 19,
index: true,
pageIndex: 1,
pageSize: 6
},
success: function (res) {
if (res.statusCode == 200) {
res.data.items = sort(res.data.items,'sort')
// console.log('健康资讯-成功', res.data);
if (res.data.items.length < 1) {
$('#ajaxyybc').append(`
暂无内容
`)
} else {
res.data.items.forEach(item => {
$('#ajaxyybc').append(`
${item.title}
${item.zhaiYao}
`)
});
var two_swiper=new Swiper('.second-two',{
nested: true,
slidesPerView: 'auto',
on:{
reachBeginning: function () {
console.log('到了第一个slide');
},
},
});
}
}
},
error: function (err) {
console.log('失败', err);
},
});
// 走进太阳成tyc122cc入口+科研创新
$.ajax({
url: base_url + "dfharticle/list",
data: {
id: 5,
index: true,
},
success: function (res) {
if (res.statusCode == 200) {
res.data.items = sort(res.data.items,'sort')
// console.log('走进太阳成tyc122cc入口++科研创新-成功===', res.data.items);
// 走进太阳成tyc122cc入口
if (res.data.items[0].subTitle.length < 1) {
$('#ajaxabout1').text('暂无内容')
$('#ajaxabout2').text('暂无内容')
$('#ajaxabout3').text('暂无内容')
} else {
$('#ajaxabout1').text(res.data.items[0].title)
$('#ajaxabout2').text(res.data.items[0].subTitle)
$('#ajaxabout3').text(res.data.items[0].zhaiYao)
}
// 走进太阳成tyc122cc入口的数字 和 背景
$('.about_right').css('background-image',`url('${res.data.items[0].albums[0].img}')`)
let txtarry = res.data.items[0].albums[0].title
let txtarry2=[]
txtarry = txtarry.split(';')
txtarry.forEach(i => {
txtarry2.push(i.split('$'))
})
// console.log('走进太阳成tyc122cc入口++科研创新-成功===', txtarry2);
$('#ajaxabout4').append(`
${txtarry2[0][2]}
${txtarry2[0][0]}
${txtarry2[1][2]}
${txtarry2[1][0]}
${txtarry2[2][2]}
${txtarry2[2][0]}
`)
ajaxaboutnum1 = txtarry2[0][1]
ajaxaboutnum20 = txtarry2[1][1].split('.')[0]
ajaxaboutnum21 = txtarry2[1][1].split('.')[1]
ajaxaboutnum3 = txtarry2[2][1]
// 科研创新
if (res.data.items[1].title.length < 1) {
$('#ajaxkycx1').text('暂无内容')
} else {
$('#ajaxkycx1').append(res.data.items[1].zhaiYao)
res.data.items[1].albums.forEach((item, index) => {
// let title = item.title.split('\n')[0]
// let desc = item.title.split('\n')[1]
// console.log('hasNewline==',item.title.split('\n'));
$('#ajaxkycx2').append(`
${item.title.split('\n')[0]}
${item.title.split('\n')[1]}
`)
})
// console.log(pageWidth)
var mySwiper
setTimeout(()=>{
if(pageWidth<1080){
// h5
mySwiper = new Swiper('#swiper0', {
autoplay: true, //是否自动播放 true 是 false 否
centeredSlides: true,
loop: true,
slidesPerView:2,
spaceBetween: 10,
effect: 'slide',
})
}else{
// pc
mySwiper = new Swiper('#swiper0', {
autoplay: true, //是否自动播放 true 是 false 否
centeredSlides: true,
loop: true,
effect:'coverflow',
slidesPerView:3,
spaceBetween: 10,
coverflowEffect: {
rotate: 0,
depth: 180,
modifier: 1,
}
})
}
},1000)
// 科研创新-轮播图-pc
// var mySwiper = new Swiper('#swiper0', {
// autoplay: true, //是否自动播放 true 是 false 否
// centeredSlides: true,
// loop: true,
// effect: pageWidth<375? 'slide':'coverflow',
// coverflowEffect: {
// rotate: 0, //slide做3d旋转时Y轴的旋转角度
// depth: 180, //slide的位置深度。值越大z轴距离越远,看起来越小。
// modifier: 1, //值越大这三个参数的效果越明显。
// },
// breakpoints: {
// 375: { //当屏幕宽度大于等于375
// slidesPerView:2,
// spaceBetween: 10,
// effect: 'slide',
// },
// 1000: { //当屏幕宽度大于等于1000
// slidesPerView:3,
// }
// }
// })
// 科研创新-图标交互
$('#kycxLeft').click(function () {
mySwiper.slidePrev();
})
$('#kycxLeft').mouseenter(function () {
$(this).children('.shzr_tit_btnpic1').hide()
$(this).children('.shzr_tit_btnpic2').show()
})
$('#kycxLeft').mouseleave(function () {
$(this).children('.shzr_tit_btnpic2').hide()
$(this).children('.shzr_tit_btnpic1').show()
})
$('#kycxRight').click(function () {
mySwiper.slideNext();
})
$('#kycxRight').mouseenter(function () {
$(this).children('.shzr_tit_btnpic1').hide()
$(this).children('.shzr_tit_btnpic2').show()
})
$('#kycxRight').mouseleave(function () {
$(this).children('.shzr_tit_btnpic2').hide()
$(this).children('.shzr_tit_btnpic1').show()
})
}
}
},
error: function (err) {
console.log('失败', err);
},
});
// 研发团队-列表 ====
var pageWidth = $(window).width();
$.ajax({
url: base_url + "dfharticle/list",
data: {
id: 15,
index: true,
pageIndex: 1,
pageSize: 10
},
success: function (res) {
if (res.statusCode == 200) {
res.data.items = sort(res.data.items,'sort')
// console.log('研发团队-列表-成功', res.data);
//
//
//
// ,url("./img/science/zjbg1.png"),url("./img/science/zjbg2.png")
if (res.data.items.length < 1) {
$('#ajaxyftd').append(`
暂无内容
`)
} else {
//
res.data.items.forEach(item => {
$('#ajaxyftd').append(`
${item.title}
${item.subTitle}
${item.zhaiYao}
`)
});
var mySwiper1 =new Swiper('#swiper1', {
loop: true,
slidesPerView: pageWidth<=500?1:4,
// autoplay: true,
speed: 1000,
})
// 研发团队-点击icon切换
$('#yftdLeft').click(function () {
mySwiper1.slidePrev();
})
$('#yftdRight').click(function () {
mySwiper1.slideNext();
})
// 研发团队-icon hover效果
$('#yftdLeft').mouseenter(function () {
$(this).children('.shzr_tit_btnpic1').hide()
$(this).children('.shzr_tit_btnpic2').show()
})
$('#yftdLeft').mouseleave(function () {
$(this).children('.shzr_tit_btnpic2').hide()
$(this).children('.shzr_tit_btnpic1').show()
})
$('#yftdRight').mouseenter(function () {
$(this).children('.shzr_tit_btnpic1').hide()
$(this).children('.shzr_tit_btnpic2').show()
})
$('#yftdRight').mouseleave(function () {
$(this).children('.shzr_tit_btnpic2').hide()
$(this).children('.shzr_tit_btnpic1').show()
})
// 研发团队-item的hover效果 1 蓝 2灰
// 进入
$('.yftd_item').mouseenter(function () {
$(this).find('.cri1').css('height','100%')
$(this).find('.cri2').css('height','0%')
// $(this).find('.cri1').show()
// $(this).find('.cri2').hide()
})
$('.yftd_item').mouseleave(function () {
$(this).find('.cri1').css('height','0%')
$(this).find('.cri2').css('height','100%')
// $(this).find('.cri1').hide()
// $(this).find('.cri2').show()
})
}
}
},
error: function (err) {
console.log('失败', err);
},
});
// 产品体系-列表 tab
$.ajax({
url: base_url + "dfhcate/tree",
data: {
parentId: 4,
},
success: function (res) {
if (res.statusCode == 200) {
res.data = sort(res.data,'sort')
// console.log('产品体系-列表-成功', res.data);
res.data.forEach((item, index) => {
// console.log(index, item.id);
// 循环tab
$('#ajaxcptxnav').append(`
${item.title}
`)
// 循环tab对应的box
$('#ajaxcptxbox').append(`
`)
})
setTimeout(() => {
getgoods(20)
getgoods(21)
getgoods(22)
getgoods(23)
getgoods(24)
},1000)
}
},
error: function (err) {
console.log('失败', err);
},
});
// =================产品体系-详情=================
function getgoods(navid) {
// wrapnum产品的列数,也就是换行的index数
function getclass(wrapnum,length,index) {
if (length <= 6) {
return 'wrapnormal'
} else {
// console.log(wrapnum,length)
if(wrapnum%2==0){ //换行从偶数开始
if (index >= wrapnum) {
return 'wrapsecond'
} else {
return 'wrapfirst'
}
}else{ //换行从奇数开始
return 'wrapsecond'
}
}
}
$.ajax({
url: base_url + "dfharticle/list",
data: {
id: navid,
pageSize: 10,
pageIndex:1
},
success: function (res) {
if (res.statusCode == 200) {
res.data.items = sort(res.data.items, 'sort')
let wrapnum
if (res.data.items.length >= 6) {
// console.log(navid, res.data.items.length+'/2=',Math.ceil(res.data.items.length/2)) //除以2 向上取整
wrapnum = Math.ceil(res.data.items.length/2)
}
// console.log($('#navid' + navid).find('.zzzzzzzzzzuuuuu'));
$('#navid'+navid).find('.zzzzzzzzzzuuuuu').empty();
if (res.data.items.length < 1) {
$('#navid' + navid).find('.main-layout').empty()
$('#navid' + navid).find('.main-layout').append(`
暂无内容
`)
} else {
res.data.items.forEach((item, index, array) => {
// 老版本
// if (index % 2==0) {
// console.log('1111',array[index + 1]);
// console.log('1111',array[index + 1]==undefined);
// $('#navid'+navid).find('.zzzzzzzzzzuuuuu').append(`
//
// `)
// }
// 新版本
$('#navid'+navid).find('.zzzzzzzzzzuuuuu').append(`
`)
})
// 产品体系-轮播初始化
new Swiper('.project-swiper', {
parallax: true,
// spaceBetween: 0,
// slidesPerView: 3,
// 底部分页
pagination: {
el: '.project-pagination',
clickable: true,
},
// 左右翻页
navigation: {
nextEl: '.project-next',
prevEl: '.project-prev',
},
breakpoints: {
375: { //当屏幕宽度大于等于500
spaceBetween: 25,
slidesPerView: 1,
grid: {
fill: 'row',
rows: 1,
},
},
1280: { //当屏幕宽度大于等于1280
spaceBetween: 0,
slidesPerView: 3,
grid: {
fill: 'row',
rows: 2,
},
},
}
});
}
}
},
error: function (err) {
console.log('失败', err);
},
});
}
// =================产品体系-列表 详情=================
// 视频专区
$.ajax({
url: base_url + "dfharticle/list",
data: {
id: 29,
index: true,
pageIndex: 1,
pageSize: 2
},
success: function (res) {
if (res.statusCode == 200) {
// res.data.items = sort(res.data.items,'sort')
// console.log('视频专区-成功', res.data.items);
if (res.data.items.length < 2) {
$('#ajaxvideohiden').remove()
} else {
// $('#ajaxvideo1').data(res.data.items[0].video)
$('#ajaxvideo1 h5').text(res.data.items[0].title)
$('#ajaxvideo1 p').text(res.data.items[0].subTitle)
$('#video_pic1').attr('src', res.data.items[0].img)
$('#video_pic1').click(() => {
// console.log(000, res.data.items[0].video)
$("#video").attr('src',res.data.items[0].video)
})
// $('#ajaxvideo2').data(res.data.items[1].video)
$('#ajaxvideo2 h5').text(res.data.items[1].title)
$('#ajaxvideo2 p').text(res.data.items[1].subTitle)
$('#video_pic2').attr('src',res.data.items[1].img)
$('#video_pic2').click(() => {
// console.log(111, res.data.items[1].video)
$("#video").attr('src',res.data.items[1].video)
})
}
}
},
error: function (err) {
console.log('失败', err);
},
});
// 社会责任
$.ajax({
url: base_url + "dfharticle/list",
data: {
id: 7,
index: true,
pageIndex: 1,
pageSize: 10
},
success: function (res) {
if (res.statusCode == 200) {
res.data.items = sort(res.data.items,'sort')
// console.log('社会责任-成功', res.data.items);
if (res.data.items.length < 1) {
$('#ajaxshzrhiden').remove()
} else {
res.data.items.forEach((item, index) => {
$('#swiper-wrapper3').append(`
`)
})
// 社会责任-banner初始化
var mySwiper3 = new Swiper('#swiper3', {
loop: true,
slidesPerView: 3,
// autoplay: true,
speed: 1000,
spaceBetween: 20,
breakpoints: {
320: { //当屏幕宽度大于等于320
slidesPerView: 1,
spaceBetween: 0,
},
1280: { //当屏幕宽度大于等于1280
slidesPerView: 3,
spaceBetween: 20,
}
}
})
// 社会责任-icon交互
$('.shzr_tit_btn>.pubbtn').mouseenter(function () {
$(this).children('.shzr_tit_btnpic1').hide()
$(this).children('.shzr_tit_btnpic2').show()
});
$('.shzr_tit_btn>.pubbtn').mouseleave(function () {
$(this).children('.shzr_tit_btnpic2').hide()
$(this).children('.shzr_tit_btnpic1').show()
});
// 社会责任-icon点击事件
$('#shzr_tit_btnr').click(function () {
mySwiper3.slideNext();
})
$('#shzr_tit_btnl').click(function () {
mySwiper3.slidePrev();
})
// swiper-wrapper3
$('.shzr_item').mouseenter(function(){
$(this).children('.shzr_btn_box').show()
});
$('.shzr_item').mouseleave(function(){
$(this).children('.shzr_btn_box').hide()
});
$('#yftdLeft').click(function () {
mySwiper3.slidePrev();
})
}
}
},
error: function (err) {
console.log('失败', err);
},
});