1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import Swiper from 'swiper/bundle'
  2. import gsap from 'gsap'
  3. import Common from '../common/js/Common'
  4. import {
  5. isMobile
  6. } from '../common/js/utils'
  7. export default class App {
  8. constructor() {
  9. let common = new Common(document.querySelector('.main'),4) //导航菜单高亮,0是首页,后面的按顺序添加
  10. this.isMobile = isMobile()
  11. // this.tabChange()
  12. // 图片及视频资源懒加载。防止阻塞js执行
  13. let lazyDoms = document.querySelectorAll(".lazy");
  14. lazyDoms.forEach((item) => {
  15. console.log(item, 'item---1')
  16. if (item.nodeName == "PICTURE") {
  17. item.children[0].setAttribute("srcset", item.children[0].dataset.srcset);
  18. item.children[1].setAttribute("src", item.children[1].dataset.src);
  19. }
  20. if (item.nodeName == "IMG") {
  21. item.setAttribute("src", item.dataset.src);
  22. }
  23. if (item.nodeName == "VIDEO") {
  24. console.log(item, 'item---2')
  25. item.setAttribute("src", item.dataset.src);
  26. // item.load();
  27. }
  28. });
  29. vx()
  30. function vx(){
  31. console.log('vx',wx)
  32. wx.config({
  33. debug: false, // 开启调试模式
  34. appId: 'YOUR_APP_ID', // 公众号的唯一标识
  35. timestamp: 176565448486313, // 生成签名的时间戳
  36. nonceStr: 'NONCESTR', // 生成签名的随机串
  37. signature: 'SIGNATURE', // 签名,见附录1
  38. jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage'] // 需要使用的 JS 接口列表
  39. });
  40. wx.ready(function () {
  41. // 分享到朋友圈
  42. wx.onMenuShareTimeline({
  43. title: '分享标题', // 分享标题
  44. link: 'https://example.com', // 分享链接
  45. imgUrl: 'https://example.com/image.jpg', // 分享图标
  46. success: function () {
  47. // 用户确认分享后执行的回调函数
  48. },
  49. cancel: function () {
  50. // 用户取消分享后执行的回调函数
  51. }
  52. });
  53. const shareWx = document.querySelector('.shareWx');
  54. console.log(shareWx)
  55. shareWx.addEventListener('click',function(){
  56. // 分享给朋友
  57. wx.onMenuShareAppMessage({
  58. title: '分享标题', // 分享标题
  59. desc: '分享描述', // 分享描述
  60. type: 'link', // 分享类型,music、video或link,不填默认为link
  61. success: function () {
  62. // 用户确认分享后执行的回调函数
  63. },
  64. cancel: function () {
  65. // 用户取消分享后执行的回调函数
  66. }
  67. });
  68. })
  69. });
  70. }
  71. }
  72. }