1var CONSTOBJ = { 2 mapobj:{ 3 'en': 'en', 4 'jp': 'ja', 5 'kr': 'kr', 6 'ru': 'ru', 7 }, 8 i18nMessages: { 9 'zh-Hans': { 10 'localeChange': 'æ ¹æ®æ¨æå¨çåºåå设置åå¥½ï¼æ¨å¯è½è¦è®¿é®', 11 'switch':'ï¼æ¯å¦åæ¢ï¼', 12 'prompt': 'æç¤º', 13 'confirm': 'ç¡®å®', 14 'cancle': 'åæ¶', 15 }, 16 'en': { 17 'localeChange': 'Depending on your region and settings preferences, you may need to access ', 18 'switch':'. Do you want to switch?', 19 'prompt': 'Prompt', 20 'confirm': 'Confirm', 21 'cancle': 'Cancel', 22 }, 23 'ja': { 24 'localeChange': 'å ´æã¨è¨å®ã®å¥½ã¿ã«å¿ãã¦ãã¢ã¯ã»ã¹ãããã¨ãã§ãã¾ã', 25 'switch':'ãè¨èªã夿´ãã¾ããï¼', 26 'prompt': 'ãã³ã', 27 'confirm': '確èª', 28 'cancle': 'åãæ¶ã', 29 }, 30 'kr': { 31 'localeChange': 'íì¬ ìì¹ ë° ì¤ì ì í¸ëì ë°ë¼ ', 32 'switch':'ì¼ë¡ ì ííê² ìµëê¹?', 33 'prompt': 'í', 34 'confirm': 'íì¸', 35 'cancle': 'ì·¨ì', 36 }, 37 'ru': { 38 'localeChange': 'РзавиÑимоÑÑи Ð¾Ñ Ð·Ð¾Ð½Ñ Ð¸ наÑÑÑойки пÑедпоÑÑений, Ð²Ñ Ð¼Ð¾Ð¶ÐµÑе полÑÑиÑÑ Ð´Ð¾ÑÑÑп', 39 'switch':'ÐеÑеклÑÑаÑÑ Ð¸Ð»Ð¸ неÑ?', 40 'prompt': 'подÑказк', 41 'confirm': 'ÐодÑвеÑдиÑÑ', 42 'cancle': 'ÐÑмена', 43 } 44 } 45} 46Vue.use(VueI18n) 47var i18n = new VueI18n({ 48 locale: 'zh-Hans', 49 messages:CONSTOBJ.i18nMessages 50}) 51//æ¯å¦ç»å½ï¼ç»å½åè°ï¼æ¯å¦æ¾ç¤ºæç¤ºä¿¡æ¯ 52function gIsLogin(cb, isShowMsg) { 53 ms.http 54 .post(ms.base + "/api/checkLoginStatus.do") 55 .then((data) => { 56 if (!data.result && isShowMsg) { 57 // Vue.prototype.$message.error(`请å ç¹å»å³ä¸è§ç»å½`); 58 Vue.prototype.$notify({ 59 title: "æç¤º", 60 message: "请å ç¹å»å³ä¸è§ç»å½", 61 type: "warning", 62 }); 63 } 64 //true/false 65 cb(data.result); 66 }) 67 .catch((err) => { 68 console.log(err); 69 }); 70} 71 72//è·åç¨æ·ä¿¡æ¯ 73function getUserInfo(cb) { 74 ms.http 75 .get(ms.base + "/api/people/user/info.do") 76 .then((data) => { 77 data.result && cb(data.data); 78 /* let data = { 79 del: 0, 80 id: "653", 81 peopleAutoLogin: 0, 82 peopleIp: "127.0.0.1", 83 peopleDateTime: "2023-01-11 15:12:36", 84 peopleMailCheck: -1, 85 peopleName: "yaoyao", 86 peoplePhoneCheck: -1, 87 peopleState: 1, 88 newUser: true, 89 peopleLoginCount: "0", 90 peopleId: 653, 91 puRealName: "yaoyao", 92 puNickname: "yaoyao", 93 puLanguagePreference: 0, 94 puListStyle: 0, 95 }; */ 96 }) 97 .catch(function (err) {}); 98} 99 100//æ¯å¦å¼å¯è¯è®º 101function getCommentSwitch(cb) { 102 ms.http 103 .get(ms.base + "/api/mdiy/config/feedback.do") 104 .then(function (data) { 105 //true/false 106 cb(Boolean(data.data)); 107 }) 108 .catch(function (err) {}); 109} 110 111//ä¸ä¸æ»å¨æ¨è 112/* 113 * @description: ä¸ä¸æ»å¨æ¨èçæä»¶ï¼è·é©¬ç¯ææ 114 * @require jquery 115 * @param {opt.wrap} required ç¶å®¹å¨ 116 * @param {opt.stepTime} required æ»å¨æ¶é´é´é minseconds 117 * @return: å®ä¾ 118 */ 119 120function RecCarousel(opt) { 121 const $this = this 122 this.recTimer = null 123 this.step = 1 124 this.wrap = opt.wrap 125 this.stepTime = opt.stepTime 126 127 if(!this.wrap){ 128 console.error('wrap is required') 129 return 130 } 131 this.start = function(){ 132 clearInterval($this.recTimer) 133 $this.recTimer = null 134 if($this.wrap.attr('bind')){ 135 return 136 } 137 $this.recTimer = setInterval(()=>{ 138 $this.setRecCarousel() 139 }, $this.stepTime) 140 } 141 142 this.stop = function(){ 143 const timer = $this.recTimer 144 if(timer){ 145 clearInterval(timer) 146 $this.recTimer = null 147 } 148 } 149 150 this.setRecCarousel = function(){ 151 const listbox = this.wrap.find('.channel-recommend-h-list') 152 const listboxHeight = listbox.height() 153 const listAll = listbox.find('.channel-recommend-news') 154 const stepSpace = this.wrap.height() 155 const step = this.step
156 const row = Math.ceil(listboxHeight/stepSpace) 157 if(row >= 2){ 158 // const row = Math.ceil(listAll.length/2) 159 if(step >= row){ 160 this.step = 1 161 }else{ 162 this.step++ 163 } 164 this.wrap.find(".channel-recommend-h-list").animate({top: -(this.step-1)*stepSpace+'px'}); 165 this.wrap.attr('bind','true') 166 } 167 } 168 this.stop() 169 this.start() 170 171 this.wrap.hover(function(){ 172 $this.wrap.removeAttr('bind') 173 $this.stop() 174 },function(){ 175 $this.start() 176 }) 177 return this 178} 179//æ¯å¦å¼å¯ç¹èµ 180function getPrizeSwitch(cb) { 181 ms.http 182 .get(ms.base + "/api/mdiy/config/approve.do") 183 .then(function (data) { 184 //true/false 185 if (data.data === 'false'){ 186 cb(Boolean(false)); 187 }else { 188 cb(Boolean(true)); 189 } 190 }) 191 .catch(function (err) {}); 192 } 193 194 // æ¥è¯¢æ¯å¦æ¶è 195function collectStatus (dataId,cb) { 196 const params = { 197 dataId: dataId, 198 dataType: 2, 199 } 200 ms.http.post(ms.base + "/api/attention/collectionLog/isExists.do", params).then(function (res) { 201 let obj={ 202 collectStatue:res.result, // 第ä¸ä¸ªåæ°æ¯æ¶èç¶æ 203 isLogIn: true // 第äºä¸ªç»å½ç¶æ 204 } 205 cb(obj) 206 }).catch(function (err) { 207 console.log(err); 208 let obj={ 209 collectStatue:false, // 第ä¸ä¸ªåæ°æ¯æ¶èç¶æ 210 isLogIn: false// 第äºä¸ªç»å½ç¶æ 211 } 212 cb(obj) 213 }); 214} 215// æ¥è¯¢æ¯å¦ç¹èµ 216function prizeStatus (dataId,cb) { 217 const params = { 218 dataId: dataId, 219 dataType: 1, 220 } 221 ms.http.post(ms.base + "/api/attention/collectionLog/isExists.do", params).then(function (res) { 222 let obj={ 223 collectStatue:res.result, // 第ä¸ä¸ªåæ°æ¯ç¹èµç¶æ 224 isLogIn: true // 第äºä¸ªç»å½ç¶æ 225 } 226 cb(obj) 227 }).catch(function (err) { 228 console.log(err); 229 let obj={ 230 collectStatue:false, // 第ä¸ä¸ªåæ°æ¯ç¹èµç¶æ 231 isLogIn: false// 第äºä¸ªç»å½ç¶æ 232 } 233 cb(obj) 234 }); 235} 236// æ¶è 237function collect(params,cb){ 238 ms.http.post(ms.base + "/api/people/attention/collectionLog/save.do", params).then(function (res) { 239 if (res.result) { 240 let isCollect = true 241 cb(Boolean(isCollect)) 242 this.$message.success(`æ¶èæå`); 243 } else { 244 this.$message.error(data.data.msg); 245 } 246 247 }).catch(function (err) { 248 console.log(err); 249 }); 250} 251// åæ¶æ¶è 252function cancleCollect(params,cb){ 253 ms.http.post(ms.base + "/api/people/attention/collectionLog/delete.do", params).then(function (res) { 254 if (res.result) { 255 let isCollect = false 256 cb(Boolean(isCollect)) 257 this.$message.success(`åæ¶æ¶è`); 258 } else { 259 this.$message.error(data.data.msg); 260 } 261 }).catch(function (err) { 262 console.log(err); 263 }); 264} 265 266// ç¹èµ 267function prize(params,cb){ 268 ms.http.post(ms.base + "/api/people/attention/collectionLog/save.do", params).then(function (res) { 269 if (res.result) { 270 let isPrize = true 271 cb(Boolean(isPrize)) 272 this.$message.success(`ç¹èµæå`); 273 } else { 274 this.$message.error(data.data.msg); 275 } 276 277 }).catch(function (err) { 278 console.log(err); 279 }); 280} 281// åæ¶ç¹èµ 282function canclePrize(params,cb){ 283 ms.http.post(ms.base + "/api/people/attention/collectionLog/delete.do", params).then(function (res) { 284 if (res.result) { 285 let isPrize = false 286 cb(Boolean(isPrize)) 287 this.$message.success(`åæ¶ç¹èµ`); 288 } else { 289 this.$message.error(data.data.msg); 290 } 291 }).catch(function (err) { 292 console.log(err); 293 }); 294} 295function getDeviceId(){ 296 let options = { 297 excludes: { 298 language: true, 299 colorDepth: true, 300 deviceMemory: true, 301 pixelRatio: true, 302 availableScreenResolution: true, 303 timezoneOffset: true, 304 timezone: true, 305 sessionStorage: true, 306 localStorage: true, 307 indexedDb: true, 308 addBehavior: true, 309 openDatabase: true, 310 cpuClass: true, 311 doNotTrack: true, 312 plugins: true, 313 canvas: true, 314 webglVendorAndRenderer: true, 315 adBlock: true, 316 hasLiedLanguages: true, 317 hasLiedResolution: true, 318 hasLiedOs: true, 319 hasLiedBrowser: true, 320 touchSupport: true, 321 audio: false, 322 enumerateDevices: true, 323 hardwareConcurrency: true, 324 }, 325 } 326 const cb = function (components, resolve, reject) { 327 let time = new Date().getTime(); 328 components.push({ 329 key:'timeStr', 330 value: time 331 }); 332 const values = components.map((component) => { 333 return component.value; 334 }); 335 // æçº¹ 336 const finger = Fingerprint2.x64hash128(values.join(''), 31); 337 localStorage.setItem('localeDeviceId',finger) 338 resolve(finger) 339 } 340 const promise = new Promise(function (resolve, reject){ 341 const localeDeviceId = localStorage.getItem('localeDeviceId') 342 if(localeDeviceId){ 343 resolve(localeDeviceId) 344 }else{ 345 if (window.requestIdleCallback) { 346 requestIdleCallback(function () { 347 Fingerprint2.get(options,function (components) { 348 cb(components,resolve, reject) 349 }) 350 }) 351 } else { 352 setTimeout(function () { 353 Fingerprint2.get(options,function (components) { 354 cb(components,resolve, reject) 355 }) 356 }, 500) 357 } 358 } 359 360 }) 361 362 return promise 363} 364// 设置åè·åé»è®¤è¯è¨ 365function setAndGetLocale(params, locationStr, cb){ 366 // const mapobj = { 367 // 'zh-Hans': '0', 368 // 'en': '1', 369 // 'ja': '2', 370 // 'ru': '3', 371 // 'kr': '4' 372 // } 373 // const language = mapobj[params]||'0' 374 // const obj = params?{language:language}:{} 375 // const host = location.host 376 // console.log("setAndGetLocale----host:"+host) 377 // if(obj.language==null&&location.href.endsWith("index.html")){ 378 // console.log("setAndGetLocale----é¢è§") 379 // return 380 // } 381 // getDeviceId().then((res)=>{ 382 // obj.deviceId = res 383 siteid = params||'1' 384 ms.http.get((ms.base||'') + "/api/cms/content/appList").then(function (res) { 385 if (res.data&&Array.isArray(res.data)) { 386 res.data.forEach(item => { 387 if(item.id===params){ 388 location.href = item.appUrl 389 } 390 }); 391 } else { 392 // this.$message.error(res.data.msg); 393 } 394 }).catch(function (err) { 395 console.log(err); 396 }); 397 // }) 398 399 400} 401function $t(args) { 402 return i18n.t.call(i18n, args); 403 } 404function setLocaleLanguage(strurl){ 405 let realLang = null 406 if(strurl){ 407 const mapobj = CONSTOBJ.mapobj 408 const langKeys = Object.keys(mapobj) 409 const filterlang = langKeys.filter(function(item){ 410 return strurl.indexOf(item) >= 0 411 }) 412 realLang =filterlang.length? mapobj[filterlang[0]] : 'zh-Hans' 413 if(realLang){ 414 i18n.locale = realLang 415 } 416 417 } 418} 419// 设置åè·åé»è®¤è¯è¨ 420function checkSetLocale(strurl){ 421 422 423 const host = location.host 424 let realLang = null
425 let confirmLocale = localStorage.getItem('confirmLocalenew') 426 // if(location.href.endsWith("index.html")){ 427 // console.log("setAndGetLocale----é¢è§") 428 // return 429 // } 430 if(strurl){ 431 // const lastPathsplit = strurl.lastIndexOf('/') 432 // const len = strurl.length 433 // if(lastPathsplit !== len-1){ 434 // const lanStr = strurl.substr(lastPathsplit+1,len) 435 const mapobj = CONSTOBJ.mapobj 436 const langKeys = Object.keys(mapobj) 437 const filterlang = langKeys.filter(function(item){ 438 return strurl.indexOf(item) >= 0 439 }) 440 realLang =filterlang.length? mapobj[filterlang[0]] : 'zh-Hans' 441 if(realLang){ 442 i18n.locale = realLang 443 } 444 // } 445 446 } 447 if(confirmLocale === '1'){ 448 return 449 } 450 //æç §ipè·å 451 getDeviceId().then((res)=>{ 452 ms.http.get((ms.base||'') + "/api/cms/category/getIpLanguage").then(function (res) { 453 if (res.data) { 454 const appName = res.data.appName 455 const appId = res.data.id 456 const objSite={ 457 '1':'䏿ç«', 458 '36':'æ¥æ¬èª', 459 '37':'íêµì´', 460 '38':'English', 461 '42':'Ð ÑÑÑкий ÑзÑк' 462 } 463 if (typeof appId == 'string' && appId.length > 0){ 464 var appmapName = objSite[appId]||'English' 465 //å¼¹çªæç¤ºä¸æ¬¡éæ©çç«ç¹ï¼ç¡®è®¤è°è®¾ç½®è¯è¨ç«ç¹æ¥å£ï¼ 466 Vue.prototype.$confirm($t('localeChange') + '"' + appmapName + '"' + $t('switch') , $t('prompt'), { 467 confirmButtonText: $t('confirm'), 468 cancelButtonText: $t('cancle'), 469 type: 'warning' 470 }).then(() => { 471 localStorage.setItem('confirmLocalenew','1') 472 setAndGetLocale(res.data.id) 473 }).catch(() => { 474 // setAndGetLocale(realLang||'zh-Hans') 475 localStorage.setItem('confirmLocalenew','1') 476 }); 477 } 478 } 479 }).catch(function (err) { 480 console.log(err); 481 }); 482 }) 483 484 485} 486// å¹é hostè¯è¨ 487function checkHostSite(strurl){ 488 var promise = new Promise(function(res,rej){ 489 let realLang = null 490 if(strurl){ 491 const mapobj = CONSTOBJ.mapobj 492 const langKeys = Object.keys(mapobj) 493 const filterlang = langKeys.filter(function(item){ 494 return strurl.indexOf(item) >= 0 495 }) 496 realLang = filterlang.length? mapobj[filterlang[0]] : 'zh-Hans' 497 res({ 498 code:200, 499 lang:realLang 500 }) 501 502 }else{ 503 res({ 504 code: 200, 505 lang: 'zh-Hans' 506 }) 507 } 508 509 }) 510 511 return promise 512 513} 514function redictToh5(url, par){ 515 if(par && par.param && par.param.code === 200 && browserSys.versions.mobile){ 516 var param = deepCopy(par.param) 517 var suffixPath = par.suffixPath 518 519 var urlarr = [url,'#'] 520 delete param.code 521 var h5url = getUrlFromObj(suffixPath, param) 522 urlarr.push(h5url) 523 var fullUrl = urlarr.join('') 524 525 location.href = fullUrl 526 } 527} 528/** 529 * ä¼ å ¥å¯¹è±¡è¿åurlåæ° 530 * @param {Object} data {a:1} 531 * @returns {string} 532 */ 533function getParamFromObj(data){ 534 let url = ''; 535 for(var k in data){ 536 let value = data[k] !==undefined ? data[k] : ''; 537 url += `&${k}=${encodeURIComponent(value)}` 538 } 539 return url ? url.substring(1) : '' 540} 541 542/** 543 * å°urlååæ°æ¼æ¥æå®æ´å°å 544 * @param {string} url urlå°å 545 * @param {Json} data json对象 546 * @returns {string} 547 */ 548function getUrlFromObj(url, data){ 549 //çåå§urlå°åä¸å¼å¤´æ¯å¦å¸¦?ï¼ç¶åæ¼æ¥å¤ç好çåæ° 550 return url += (url.indexOf('?') < 0 ? '?' : '&') + getParamFromObj(data) 551} 552 553//è·åurlækeyå¼ 554const getParamByUrl = (key) => { 555 const url = new URL(location.href) 556 return url.searchParams.get(key) 557} 558function typeOf(obj) { 559 const toString = Object.prototype.toString 560 const map = { 561 '[object Boolean]': 'boolean', 562 '[object Number]': 'number', 563 '[object String]': 'string', 564 '[object Function]': 'function', 565 '[object Array]': 'array', 566 '[object Date]': 'date', 567 '[object RegExp]': 'regExp',
568 '[object Undefined]': 'undefined', 569 '[object Null]': 'null', 570 '[object Object]': 'object', 571 } 572 return map[toString.call(obj)] 573} 574 575function deepCopy(data) { 576 const t = typeOf(data) 577 let o 578 579 if (t === 'array') { 580 o = [] 581 } else if (t === 'object') { 582 o = {} 583 } else { 584 return data 585 } 586 587 if (t === 'array') { 588 for (let i = 0; i < data.length; i++) { 589 o.push(deepCopy(data[i])) 590 } 591 } else if (t === 'object') { 592 for (let i in data) { 593 o[i] = deepCopy(data[i]) 594 } 595 } 596 return o 597} 598 599function getImgUrl(data) { 600 return data && window.location.origin+JSON.parse(data)[0].url; 601} 602 603// setAndGetLocale() 604 605//å¤çåå°æ°æ®ï¼"[{\"url\":\"/upload/1/cms/content/1674007726555.png\",\"desc\":\"\"}]" 606//示ä¾ï¼getImgUrl(contentImg, 'img34') 607function getImgUrlBySize(data, size) { 608 try { 609 var key = size || "url"; 610 611 if (data) { 612 var img = JSON.parse(data)[0]; 613 // console.log(API_URL + (img[key] || img.url)) 614 //å ¼å®¹èæ°æ®æ²¡æimgxxè¿ç§å段 615 return window.location.origin + (img[key] || img.url); 616 } 617 } catch (e) { 618 return ""; 619 } 620} 621 622function throttle(fn, delay) { 623 let timer = null; 624 625 return function () { 626 if (timer) return;//妿宿¶å¨è¿å¨ï¼è¯´æä¸ä¸æ¬¡å»¶è¿æ§è¡è¿æ²¡æå®æï¼åä¸åæ§è¡ 627 timer = setTimeout(() => { 628 fn.apply(this, arguments); 629 timer = null; 630 }, delay); 631 }; 632} 633 634function debounce (fn, wait) { 635 let timer = null; 636 return function(){ 637 clearTimeout(timer); 638 timer = setTimeout(()=>{ 639 fn.apply(this, arguments); 640 }, wait); 641 }; 642 }; 643function isUrl(url) { 644 return /(http|https):\/\/([\w.]+\/?)\S*/.test(url); 645} 646/** 647 * 微信å享é»è®¤å¾æ ï¼åä¸å°å°é¢æ¶çå åºï¼ 648 * @description utils.js æ¯éææä»¶ï¼{ms:global.host/}ã{ms:global.style/} ä¸ä¼è¢«æ¿æ¢ï¼ 649 * æä»¥ç±å模æ¿é¡µé¢å¨å¼å ¥ head-file.htm ä¹åï¼æè§£æå¥½çå°åèµè¿æ¥ï¼image/180x180.pngï¼ 650 */ 651var WX_SHARE_DEFAULT_IMG = '' 652/** 653 * è§èååäº«å¾æ å°å 654 * @description {ms:global.host/} ç»å°¾å¸¦ /ï¼è litpic/imageUrl ç url å¼å¤´ä¹å¸¦ /ï¼æ¼æ¥åä¼åºç° host//path 655 * 微信侧å¶å°ä¼å æ¤åä¸å°å¾ï¼è¿éç»ä¸æ¶ææåææ ï¼åè®®åç // ä¿çï¼ 656 * @param {string} imgUrl 657 * @returns {string} 658 */ 659function normalizeWxImgUrl(imgUrl) { 660 if (!imgUrl) return '' 661 return imgUrl.replace(/^(https?:\/\/[^/]+)\/+/, '$1/') 662} 663 664/** 665 * ç´æè¯¦æ 页微信å享åå§åï¼å ¬å ±æ¹æ³ï¼ 666 * @description ç´æç±»é¡µé¢é½æ¯æ ç®é¡µï¼/list/{æ ç®id}.html?liveId=xxxï¼ï¼æå¡ç«¯æ²¡ææç« id/fieldï¼ 667 * wx-share.htm éç <#if id??> 夿䏿ç«ä¼è¾åºç©ºå å®¹ï¼ 668 * æä»¥åªè½å¨ getLiveDetail æå°è¯¦æ åï¼ç±å®¢æ·ç«¯åæ é¢å°é¢æ¥åå§å 669 * @param {Object} detail ç´æè¯¦æ 对象ï¼å模æ¿éç detailObjï¼ 670 */ 671function initLiveWxShare(detail) { 672 detail = detail || {} 673 let imgUrl = '' 674 try { 675 var arr = detail.imageUrl ? JSON.parse(detail.imageUrl) : [] 676 var rawImg = arr.length ? (arr[0].url || arr[0].img169 || '') : '' 677 //utils.js æ¯éææä»¶ï¼{ms:global.host/} ä¸ä¼è¢«æ¿æ¢ï¼ç»ä¸åå½åç«ç¹ååï¼ä¸ getImgUrl ä¸è´ï¼ 678 imgUrl = /^https?:\/\//.test(rawImg) ? rawImg : (rawImg ? window.location.origin + rawImg : '') 679 } catch (e) { 680 imgUrl = '' 681 } 682 initWxShare({ 683 title: detail.title || document.title, 684 imgUrl: imgUrl 685 }) 686} 687 688/** 689 * 微信å èªå®ä¹å享ï¼å ¬å ±æ¹æ³ï¼ä¾å详æ 页è°ç¨ï¼ 690 * @description é微信ç¯å¢ç´æ¥è¿åï¼jWeixin åªæéå è½½ä¸æ¬¡ï¼ç¾åå¤ç¨ ms.http èªå¸¦çç¾å头 691 * @param {Object} opt 692 * @param {string} opt.title å享æ é¢ 693 * @param {string} [opt.desc] å享æè¿°ï¼é»è®¤âæ¥èªæ°æç¥å®¢æ·ç«¯â 694 * @param {string} [opt.imgUrl] åäº«å¾æ ï¼å¿ é¡»æ¯ç»å¯¹å°å 695 * @param {string} [opt.link] åäº«é¾æ¥ï¼é»è®¤å½å页é¢å°åï¼å»æ hashï¼ 696 */ 697function initWxShare(opt) { 698 opt = opt || {} 699 // ä» å¾®ä¿¡å æ§è¡ï¼é微信ç¯å¢ï¼æµè§å¨/å ¶å® APPï¼ç´æ¥è¿å 700 if (!/micromessenger/i.test(navigator.userAgent.toLowerCase())) return 701 702 var shareData = { 703 title: opt.title || document.title, 704 desc: opt.desc || 'æ¥èªæ°æç¥å®¢æ·ç«¯', 705 link: opt.link || location.href.split('#')[0], 706 //åä¸å°å°é¢æ¶å åºæç«ç¹é»è®¤å¾æ ï¼ç± head-file.htm èµå¼ï¼ 707 imgUrl: normalizeWxImgUrl(opt.imgUrl || WX_SHARE_DEFAULT_IMG) 708 } 709 710 // åªå è½½ä¸æ¬¡å¾®ä¿¡ jssdk 711 if (typeof jWeixin === 'undefined' && !document.getElementById('wx-jweixin-script')) { 712 var script = document.createElement('script') 713 script.id = 'wx-jweixin-script' 714 script.async = true 715 script.src = 'https://res.wx.qq.com/open/js/jweixin-1.6.0.js' 716 document.head.appendChild(script) 717 } 718 // jWeixin ä¸ºå¼æ¥å è½½ï¼ä¸æ¬æ¹æ³å¯è½å¨é¡µé¢æ©æè°ç¨ï¼éåæ¶çå¾ jWeixin ä¸ ms 就绪 719 var checkCount = 0 720 var timer = setInterval(function () { 721 if (typeof jWeixin !== 'undefined' && typeof ms !== 'undefined') { 722 clearInterval(timer)
723 applyWxShare(shareData) 724 } else if (++checkCount > 100) { // æå¤ç 5 ç§ 725 clearInterval(timer) 726 } 727 }, 50) 728} 729 730/** 731 * æåç¾åå¹¶é 置微信å享ï¼ç± initWxShare å¨ç¯å¢å°±ç»ªåè°ç¨ 732 * @param {Object} shareData {title, desc, link, imgUrl} 733 */ 734function applyWxShare(shareData) { 735 // å¤ç¨ ms.http.postï¼èªå¸¦ SignFilter ç¾åå¤´ï¼æ éå端å ç½åå 736 ms.http 737 .post(ms.base + '/api/wechat/getWechatShareData', { url: shareData.link }) 738 .then(function (res) { 739 var cfg = res.data || {} 740 jWeixin.config({ 741 debug: false, 742 appId: cfg.appId, 743 timestamp: cfg.timestamp, 744 nonceStr: cfg.nonceStr, 745 signature: cfg.signature, 746 jsApiList: [ 747 'updateAppMessageShareData', // åäº«ç»æåï¼1.4+ï¼ 748 'updateTimelineShareData', // åäº«å°æååï¼1.4+ï¼ 749 'onMenuShareAppMessage' // æ§çå ¼å®¹ 750 ] 751 }); 752 jWeixin.ready(function () { 753 jWeixin.updateAppMessageShareData(shareData); 754 jWeixin.updateTimelineShareData(shareData); 755 jWeixin.onMenuShareAppMessage(shareData); 756 }); 757 }) 758 .catch(function () {}); 759}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.