You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

App.js 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. import Swiper from 'swiper/bundle'
  2. import gsap from 'gsap'
  3. import LocomotiveScroll from 'locomotive-scroll';
  4. import Common from '../common/js/Common';
  5. import {
  6. isMobile
  7. } from '../common/js/utils';
  8. import $ from '/dev/static/lib/jquery-2.1.1.min.js';
  9. export default class App {
  10. constructor() {
  11. let common = new Common(document.querySelector('.main'),0) //导航菜单高亮,0是首页,后面的按顺序添加
  12. this.isMobile = isMobile()
  13. this.scroll = new LocomotiveScroll();
  14. // 图片及视频资源懒加载。防止阻塞js执行
  15. let lazyDoms = document.querySelectorAll(".lazy");
  16. let isMob=this.isMobile;
  17. lazyDoms.forEach((item) => {
  18. if (item.nodeName == "PICTURE") {
  19. item.children[0].setAttribute("srcset", item.children[0].dataset.srcset);
  20. item.children[1].setAttribute("src", item.children[1].dataset.src);
  21. }
  22. if (item.nodeName == "IMG") {
  23. if(isMob){item.setAttribute("src", item.dataset.srcm);}
  24. else{
  25. item.setAttribute("src", item.dataset.src);
  26. }
  27. }
  28. if (item.nodeName == "VIDEO") {
  29. console.log(item, 'item---2')
  30. item.setAttribute("src", item.dataset.src);
  31. // item.load();
  32. }
  33. });
  34. this.four();
  35. }
  36. four() {
  37. let isMob = this.isMobile;
  38. let fourCon = document.querySelector(".fourCon");
  39. let fourSons = document.querySelectorAll(".fourSon");
  40. let fourR = document.querySelector(".fourR");
  41. let fourRsons = document.querySelectorAll(".fourRson");
  42. let sonArr = [];
  43. fourSons.forEach((item, index) => {
  44. let childHeight = item.offsetHeight;
  45. if (index == 3) childHeight = childHeight * 0.5;
  46. sonArr.push([childHeight, index]);
  47. });
  48. fourRsons.forEach((item, index) => {
  49. item.style.width = fourR.offsetWidth+1 + 'px';
  50. item.style.height = fourR.offsetWidth+1 + 'px';
  51. item.style.zIndex = fourRsons.length - index;
  52. });
  53. function changeDiv(num, val) {
  54. fourSons.forEach((item, index) => {
  55. if (index == num) {
  56. let nvl = val * 100;
  57. nvl = nvl > 97 ? 100 : nvl < 3 ? 0 : nvl;
  58. nvl = nvl.toFixed(2);
  59. if (index < fourSons.length - 1) {
  60. fourRsons[index].style.clipPath = 'inset(0px 0px ' + nvl + '%)';
  61. if (index > 0) {
  62. fourRsons[index - 1].style.clipPath = 'inset(0px 0px 100%)';
  63. }
  64. }
  65. if (index < fourSons.length) fourSons[index + 1].style.opacity = 0.3 + (val > 0.7 ? 0.7 : val);
  66. }
  67. })
  68. }
  69. // 获取元素的滚动条高度
  70. let scrollHeight = fourCon.scrollHeight;
  71. let conStart = 0;
  72. let conEnd = 0;
  73. function updateScrollChange1() {
  74. try {
  75. let hh = fourCon.getBoundingClientRect();
  76. let scrollTop = hh.top;
  77. let scrollBottom = hh.bottom;
  78. let scrollY = window.scrollY;
  79. if (scrollTop < 0 & conStart == 0) {
  80. conStart = scrollY;
  81. conEnd = scrollY + scrollHeight;
  82. let startH = 0;
  83. sonArr.forEach((item, index) => {
  84. let childH = scrollY + startH + item[0];
  85. let childHs = scrollY + startH;
  86. if(index==0){
  87. startH += item[0]-80;
  88. }else{
  89. startH += item[0];
  90. }
  91. item.push(childH)
  92. item.push(childHs)
  93. });
  94. } else if (scrollTop < 0 && scrollY > conStart && scrollY < conEnd) {
  95. sonArr.forEach((item, index) => {
  96. let chazhi = item[2] - scrollY;
  97. if (chazhi > 0 && scrollY < item[2] && scrollY > item[3]) {
  98. let bili = chazhi / item[0];
  99. bili = bili.toFixed(4);
  100. bili = parseFloat(bili);
  101. bili = 1 - bili;
  102. bili = bili.toFixed(4);
  103. bili = parseFloat(bili);
  104. changeDiv(index, bili)
  105. }
  106. });
  107. }
  108. } catch (error) { }
  109. }
  110. // 添加滚动事件监听器
  111. if(!isMob){
  112. window.addEventListener('scroll', updateScrollChange1);
  113. }
  114. //弹框资质荣誉
  115. let pop=document.querySelector(".pop");
  116. let guanbi=document.querySelector(".icon-guanbi");
  117. let allNum=document.querySelector(".allNum");
  118. let honorsRis=document.querySelectorAll(".honorsRi");
  119. let nowNum=document.querySelector(".nowNum");
  120. let nowName=document.querySelector(".nowName");
  121. let mySwiper = new Swiper('.productSwiper', {
  122. autoplay: false,//可选选项,自动滑动
  123. // loop: true,
  124. // loopedSlides: 4,
  125. navigation: {
  126. nextEl: isMob?'.btn-nextP2':'.btn-nextP1',
  127. prevEl: isMob?'.btn-prevP2':'.btn-prevP1',
  128. },
  129. on:{
  130. slideChange: function(){
  131. let index0=this.realIndex;
  132. nowNum.textContent=index0+1;
  133. // let name=honorsRis[index0].querySelector(".text").textContent;
  134. // nowName.textContent=name;
  135. },
  136. },
  137. });
  138. honorsRis.forEach((item, index) => {
  139. item.addEventListener("click", (e) => {
  140. let lists=item.querySelectorAll(".swiper-slide");
  141. lists.forEach((item2,index2)=>{
  142. let newSlide=item2.cloneNode(true);
  143. mySwiper.appendSlide(newSlide);
  144. });
  145. allNum.textContent=lists.length;
  146. let name=item.querySelector(".text").textContent;
  147. nowName.textContent=name;
  148. nowNum.textContent=1;
  149. pop.classList.add("popShow");
  150. });
  151. });
  152. guanbi.addEventListener("click", (e) => {
  153. pop.classList.remove("popShow");
  154. mySwiper.removeAllSlides(); //移除全部
  155. });
  156. //企业架构
  157. if(!isMob){
  158. let fourMores=document.querySelectorAll(".fourMore");
  159. let threeDivs=document.querySelectorAll(".threeDiv");
  160. let moresList=[];
  161. // fourMores.forEach((item, index) => {
  162. // let sonList=[];
  163. // let lists=item.querySelectorAll(".fours");
  164. // lists.forEach((item2,index2)=>{
  165. // let newSlide=item2.cloneNode(true);
  166. // sonList.push(newSlide);
  167. // });
  168. // moresList.push(sonList);
  169. // item.addEventListener("click", (e) => {
  170. // moresList[index].forEach((item2,index2)=>{
  171. // item.parentElement.appendChild(item2);
  172. // });
  173. // item.parentElement.parentElement.classList.add("fourMoreShow");
  174. // item.remove();
  175. // });
  176. // });
  177. function doFun() {
  178. let fourMoress=document.querySelectorAll(".fourMore");
  179. fourMoress.forEach((item, index) => {
  180. item.addEventListener("click", (e) => {
  181. moresList[index].forEach((item2,index2)=>{
  182. item.parentElement.appendChild(item2);
  183. });
  184. item.parentElement.parentElement.classList.add("fourMoreShow");
  185. item.remove();
  186. });
  187. });
  188. }
  189. // threeDivs.forEach((item, index) => {
  190. // item.addEventListener("click", (e) => {
  191. // if(item.parentElement.classList.contains("fourMoreShow")){
  192. // item.parentElement.classList.remove("fourMoreShow");
  193. // item.parentElement.querySelectorAll(".fours").forEach((item2,index2)=>{
  194. // if(index2>3){
  195. // item2.remove();
  196. // }
  197. // });
  198. // let newDiv = document.createElement('div');
  199. // newDiv.className = 'fours fourMore';
  200. // let innerDiv = document.createElement('div');
  201. // innerDiv.className = 'fourDiv';
  202. // innerDiv.textContent = '展开更多';
  203. // newDiv.appendChild(innerDiv);
  204. // item.parentElement.querySelector(".threeSon").appendChild(newDiv);
  205. // doFun();
  206. // }
  207. // });
  208. // });
  209. $(".twoDiv").click(function(){
  210. if($(this).parent().hasClass("closeDiv")){
  211. $(this).parent().removeClass("closeDiv");
  212. $(this).siblings().slideDown();
  213. }else{
  214. $(this).parent().addClass("closeDiv");
  215. $(this).siblings().slideUp();
  216. }
  217. });
  218. $(".hasFour").click(function(){
  219. if($(this).parent().hasClass("closeDiv")){
  220. $(this).parent().removeClass("closeDiv");
  221. $(this).siblings().slideDown();
  222. }else{
  223. $(this).parent().addClass("closeDiv");
  224. $(this).siblings().slideUp();
  225. }
  226. });
  227. $(".fourMore").click(function(){
  228. if($(this).hasClass("openSon")){
  229. $(this).children(".fourMoreList").slideUp();
  230. $(this).removeClass("openSon");
  231. $(this).children(".fourDivMore").text("展开更多")
  232. }else{
  233. $(this).children(".fourMoreList").slideDown()
  234. $(this).addClass("openSon");
  235. $(this).children(".fourDivMore").text("收起更多")
  236. }
  237. });
  238. }
  239. else{
  240. let fourMores=document.querySelectorAll(".fourMore");
  241. fourMores.forEach((item, index) => {
  242. let lists=item.querySelectorAll(".fours");
  243. lists.forEach((item2,index2)=>{
  244. let newSlide=item2.cloneNode(true);
  245. item.parentElement.appendChild(newSlide);
  246. });
  247. item.remove();
  248. });
  249. // let twoDivs=document.querySelectorAll(".twoDiv");
  250. // twoDivs.forEach((item, index) => {
  251. // item.addEventListener("click", (e) => {
  252. // if(item.parentElement.querySelectorAll('.three').length>0){
  253. // if(item.parentElement.classList.contains("openDiv")){
  254. // item.parentElement.classList.remove("openDiv");
  255. // }else{
  256. // item.parentElement.classList.add("openDiv");
  257. // }
  258. // }
  259. // });
  260. // });
  261. $(".twoDiv").click(function(){
  262. if($(this).parent().hasClass("openDiv")){
  263. $(this).parent().removeClass("openDiv");
  264. $(this).siblings().slideUp();
  265. }else{
  266. $(this).parent().addClass("openDiv");
  267. $(this).siblings().slideDown();
  268. }
  269. });
  270. $(".threeDiv").click(function(){
  271. if($(this).parent().hasClass("openDiv")){
  272. $(this).parent().removeClass("openDiv");
  273. $(this).siblings().slideUp();
  274. }else{
  275. $(this).parent().addClass("openDiv");
  276. $(this).siblings().slideDown();
  277. }
  278. });
  279. // let threeDivs=document.querySelectorAll(".threeDiv");
  280. // threeDivs.forEach((item, index) => {
  281. // item.addEventListener("click", (e) => {
  282. // if(item.parentElement.querySelectorAll('.fours').length>0){
  283. // if(item.parentElement.classList.contains("openDiv")){
  284. // item.parentElement.classList.remove("openDiv");
  285. // }else{
  286. // item.parentElement.classList.add("openDiv");
  287. // }
  288. // }
  289. // });
  290. // });
  291. }
  292. }
  293. }