github.com/jincm/wesharechain@v0.0.0-20210122032815-1537409ce26a/web/r/cms/www/default/js/b.core.js (about) 1 var B = { 2 _set : { 3 loginUrl : "", //session timeout 4 debug : true 5 }, 6 debug : function(msg) { 7 if (this._set.debug) { 8 if (typeof (console) != "undefined") 9 console.log(msg); 10 else 11 alert(msg); 12 } 13 } 14 } 15 16 ; 17 $(function() { 18 19 caseCanvasAnimation(); 20 21 usedefaultAssetLogo(); 22 23 particles(); 24 25 $(window).scroll(function() { 26 var scrollTop = $(window).scrollTop(); 27 var height = $(window).height(); 28 if($(".header").hasClass('header-index')){ 29 var scrollTop = $(window).scrollTop(); 30 if(scrollTop >= 30){ 31 $(".header").addClass("fixed"); 32 $('.logo').attr('src', resUrl + 'images/logo_bubi.png'); 33 }else{ 34 $(".header").removeClass("fixed"); 35 $('.logo').attr('src', resUrl + 'images/logo.png'); 36 } 37 } 38 if(scrollTop >= (height+1200)){ 39 $(".to-top").show(); 40 }else{ 41 $(".to-top").hide(); 42 } 43 }); 44 45 46 /***** 首页 *****/ 47 //应用场景 48 $('.scene-group .scene-item').mouseover(function(){ 49 $(this).addClass('active'); 50 }); 51 $('.scene-group .scene-item').mouseleave(function(){ 52 $('.scene-group .scene-item').removeClass('active'); 53 }); 54 55 // 技术优势 56 $('.avt-item').mouseover(function(){ 57 $('.avt-item').removeClass('active'); 58 $(this).addClass('active'); 59 $(this).children('img').attr('src', resUrl + 'images/adv'+($(this).index()+1)+'.png'); 60 }); 61 $('.avt-item').mouseleave(function(){ 62 $('.avt-item').removeClass('active'); 63 $(this).children('img').attr('src', resUrl + 'images/adv'+($(this).index()+1)+'-active.png'); 64 }); 65 66 // 合作伙伴 67 $('.partner-item').mouseover(function(){ 68 $(this).addClass('active');//children('img').attr('src', resUrl + 'images/partner_' + $(this).attr('data-img') + '.png'); 69 }); 70 $('.partner-item').mouseout(function(){ 71 $(this).removeClass('active'); 72 }); 73 74 // 更多应用场景 75 var count = 0; 76 $('.circle .box').eq(count++).addClass('active'); 77 setInterval(function () { 78 if (count == 5) { 79 for(var i=0; i<4; i++){ 80 $('.circle .box').eq(i).removeClass('active'); 81 } 82 setTimeout(function () { 83 $('.circle .box').eq(4).removeClass('active'); 84 $('.circle .box').eq(5).removeClass('active'); 85 }, 3000); 86 } else if (count == 6) { 87 count = 0; 88 } 89 90 $('.circle .box').eq(count++).addClass('active'); 91 }, 2000); 92 93 // 加入我们 94 $('.J-viewJob').click(function(){ 95 $this = $(this); 96 $this.addClass('active'); 97 if ($this.parent('.job-item').hasClass('active')) { 98 $this.removeClass('active'); 99 $this.parent('.job-item').removeClass('active'); 100 } else { 101 $this.addClass('active'); 102 $this.parent('.job-item').addClass('active'); 103 } 104 }); 105 106 // 联系我们 107 $('.address-item').click(function(){ 108 var index = $('.address-item').index(this); 109 $('.iframe').removeClass('active'); 110 $('.address-item').removeClass('active'); 111 $(this).addClass('active'); 112 $('.iframe').eq(index).addClass('active'); 113 }); 114 }); 115 116 function canvasSupport() { 117 return !!document.createElement('canvas').getContext; 118 } 119 120 function particles() { 121 var particlesObtion = { 122 particles: { 123 color: "#69a591", 124 shape: 'circle', // "circle", "edge" or "triangle" 125 opacity: 1, 126 size: 5, 127 size_random: false, 128 nb: 30, 129 line_linked: { 130 enable_auto: true, 131 distance: 180, 132 color: '#69a591', 133 opacity: 1, 134 width: 1, 135 condensed_mode: { 136 enable: false, 137 rotateX: 100, 138 rotateY: 600 139 } 140 }, 141 anim: { 142 enable: true, 143 speed: 0.5 144 } 145 }, 146 interactivity: { 147 enable: true, 148 mouse: { 149 distance: 300 150 }, 151 detect_on: 'window', // "canvas" or "window" 152 mode: 'grab', 153 line_linked: { 154 opacity: .5 155 }, 156 events: { 157 onclick: { 158 enable: false, 159 mode: 'push', // "push" or "remove" 160 nb: 4 161 } 162 } 163 }, 164 retina_detect: true 165 }; 166 167 if($('.particles-js').length && canvasSupport()) particlesJS('particles-js', particlesObtion); 168 } 169 170 function usedefaultAssetLogo(){ 171 var browser={ 172 versions:function(){ 173 var u = navigator.userAgent, app = navigator.appVersion; 174 return { 175 trident: u.indexOf('Trident') > -1, //IE内核 176 presto: u.indexOf('Presto') > -1, //opera内核 177 webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核 178 gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,//火狐内核 179 mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端 180 ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端 181 android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器 182 iPhone: u.indexOf('iPhone') > -1 , //是否为iPhone或者QQHD浏览器 183 iPad: u.indexOf('iPad') > -1, //是否iPad 184 webApp: u.indexOf('Safari') == -1 //是否web应该程序,没有头部与底部 185 }; 186 }(), 187 language:(navigator.language || navigator.browserLanguage || navigator.userLanguage).toLowerCase() 188 }; 189 if(browser.versions.mobile || browser.versions.ios || browser.versions.android || browser.versions.iPhone || browser.versions.iPad){ 190 $('body').addClass('wap'); 191 $('.wap .swiper-banner').height($(window).height()); 192 $('.wap .swiper-banner .swiper-container').height($(window).height()); 193 }else if(browser.versions.trident){ 194 // console.log("IE内核"); 195 } 196 } 197 198 function caseCanvasAnimation () { 199 var mapId = $("map").attr("id"); 200 var imgId = 'img1'; 201 var dataId = 'mature'; 202 var obj = []; 203 var canvasOpt = { 204 fillStyle: "#fbddc5", 205 strokeStyle: "#f4a58c",//"rgba(255,184,0,1)", 206 lineWidth: 2 207 }; 208 var canvasCss = { 209 left: '', 210 top: '', 211 zIndex: '', 212 position: "absolute", 213 zIndex: 11, 214 width: '', 215 height: '' 216 }; 217 218 function initCanvas(t) { 219 var i = $("#" + imgId), 220 e = i.parent(), 221 s = "canvas" + Math.ceil(1e3 * Math.random()); 222 e.append($('<canvas id="' + s + '"></canvas>')); 223 var n = $("#" + s); 224 canvasCss.left = i.position().left + "px", 225 canvasCss.top = i.position().top + "px", 226 canvasCss.width = i.width() + "px", 227 canvasCss.height = i.height() + "px", 228 canvasCss.zIndex && (canvasCss.zIndex += 1), 229 n.css(canvasCss).attr({ 230 width: i.width()*2 + "px", 231 height: i.height()*2 + "px" 232 }); 233 var a = n[0]; 234 obj[t + "Canvas"] = a, 235 obj[t + "RenderArea"] = a.getContext("2d"); 236 var o = canvasOpt; 237 for (var r in o) obj[t + "RenderArea"][r] = o[r] 238 } 239 240 function bindEvent() { 241 i = $("#" + mapId).find("area"); 242 i.bind("mouseover", function() { 243 var mouseoutCanvas = $(obj["hoverCanvas"]); 244 obj["hoverRenderArea"].clearRect(0, 0, 3000, 3000) 245 $('.case-solution span').removeClass('active'); 246 var coords = $(this).attr("coords"); 247 var point = coords.split(","); 248 var t = obj["hoverRenderArea"]; 249 t.beginPath(), 250 t.moveTo(point[0]*2, point[1]*2); 251 for (var n = 2; n < point.length; n += 2){ 252 t.lineTo(point[n]*2, point[n + 1]*2); 253 } 254 t.lineTo(point[0]*2, point[1]*2); 255 t.fill(); 256 t.stroke(); 257 258 t.closePath(); 259 $('.case-solution span').eq($(this).attr('data-index')).addClass('active'); 260 }), 261 i.bind("mouseout", function() { 262 // var mouseoutCanvas = $(obj["hoverCanvas"]); 263 // obj["hoverRenderArea"].clearRect(0, 0, mouseoutCanvas.width(), mouseoutCanvas.height()) 264 // var i = $(obj["hoverCanvas"]); 265 // obj["hoverRenderArea"].clearRect(0, 0, i.width(), i.height()) 266 }); 267 // i.bind("click", function() { 268 // var coords = $(this).attr("coords"); 269 // var point = coords.split(","); 270 // var t = obj["clickRenderArea"]; 271 // t.beginPath(), 272 // t.moveTo(point[0], point[1]); 273 // for (var n = 2; n < point.length; n += 2){ 274 // t.lineTo(point[n], point[n + 1]); 275 // } 276 // t.lineTo(point[0], point[1]); 277 // t.stroke(); 278 // t.fill(); 279 // t.closePath(); 280 // }); 281 } 282 function hoverEvent() { 283 i = $("#" + mapId).find("area"); 284 i.bind("mouseover", function() { 285 $('.case-solution span').removeClass('active'); 286 $('.case-solution span').eq($(this).attr('data-index')).addClass('active'); 287 }) 288 } 289 290 $('#img1').load(function() { 291 flag = 1; 292 if (canvasSupport()) { 293 initCanvas("hover"); 294 bindEvent(); 295 } else { 296 hoverEvent(); 297 } 298 }); 299 300 $("#img1").one('load', function() { 301 if (canvasSupport()) { 302 initCanvas("hover"); 303 bindEvent(); 304 } else { 305 hoverEvent(); 306 } 307 }).each(function() { 308 if (canvasSupport()) { 309 initCanvas("hover"); 310 bindEvent(); 311 } else { 312 hoverEvent(); 313 } 314 }); 315 }