张延森 3 年前
父节点
当前提交
de90b9d0bc
共有 2 个文件被更改,包括 7 次插入4 次删除
  1. 1
    1
      public/index.html
  2. 6
    3
      src/utils/wx.js

+ 1
- 1
public/index.html 查看文件

5
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
5
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
     <meta name="viewport" content="width=device-width,initial-scale=1.0">
6
     <meta name="viewport" content="width=device-width,initial-scale=1.0">
7
     <link rel="icon" href="<%= BASE_URL %>favicon.ico">
7
     <link rel="icon" href="<%= BASE_URL %>favicon.ico">
8
-    <script src="http://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
8
+    <script src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
9
     <title>华侨城</title>
9
     <title>华侨城</title>
10
     <style>
10
     <style>
11
       .page-loading-wrapper {
11
       .page-loading-wrapper {

+ 6
- 3
src/utils/wx.js 查看文件

33
   const defaultLink = origin + pathname
33
   const defaultLink = origin + pathname
34
   const defaultImg = `${origin}${pathname}images/share.jpg`
34
   const defaultImg = `${origin}${pathname}images/share.jpg`
35
 
35
 
36
-  initSDK(opt.link)
36
+  const link = opt.link || defaultLink
37
+  const imgUrl = opt.imgUrl || defaultImg
38
+
39
+  initSDK(link)
37
   window.wx.ready(function () {
40
   window.wx.ready(function () {
38
     jsApiList.map((apiName) => {
41
     jsApiList.map((apiName) => {
39
       const api = window.wx[apiName]
42
       const api = window.wx[apiName]
40
       api({
43
       api({
41
         title: opt.title || '', // 分享标题
44
         title: opt.title || '', // 分享标题
42
-        link: opt.link || defaultLink, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
43
-        imgUrl: opt.imgUrl || defaultImg, // 分享图标
45
+        link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
46
+        imgUrl, // 分享图标
44
         desc: opt.desc || ''
47
         desc: opt.desc || ''
45
       })
48
       })
46
     })
49
     })