张延森 3 年 前
コミット
a2199e10e3
共有6 個のファイルを変更した44 個の追加18 個の削除を含む
  1. 1
    1
      public/index.html
  2. 39
    13
      src/utils/wx.js
  3. 1
    1
      src/views/apartment.vue
  4. 1
    1
      src/views/index.vue
  5. 1
    1
      src/views/office.vue
  6. 1
    1
      src/views/projectIndex.vue

+ 1
- 1
public/index.html ファイルの表示

11
       <link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="stylesheet" />
11
       <link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="stylesheet" />
12
 	  <% } %> -->
12
 	  <% } %> -->
13
     <title><%= webpackConfig.name %></title>
13
     <title><%= webpackConfig.name %></title>
14
-    <script type="text/javascript" src="http://res2.wx.qq.com/open/js/jweixin-1.6.0.js "></script>
14
+    <script type="text/javascript" src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js "></script>
15
   </head>
15
   </head>
16
   <body>
16
   <body>
17
     <noscript>
17
     <noscript>

+ 39
- 13
src/utils/wx.js ファイルの表示

9
     })
9
     })
10
 }
10
 }
11
 
11
 
12
+const jsApiList = [
13
+  'updateAppMessageShareData',
14
+  'updateTimelineShareData',
15
+  'onMenuShareTimeline',
16
+  'onMenuShareAppMessage',
17
+  'onMenuShareQQ',
18
+  'onMenuShareWeibo',
19
+  'onMenuShareQZone'
20
+]
21
+
12
 function init() {
22
 function init() {
13
   const url = location.origin + location.pathname
23
   const url = location.origin + location.pathname
14
   request(`https://api.h5.njyunzhi.com/mp/jssdk?url=${encodeURIComponent(url)}`).then((res) => {
24
   request(`https://api.h5.njyunzhi.com/mp/jssdk?url=${encodeURIComponent(url)}`).then((res) => {
15
     window.wx.config({
25
     window.wx.config({
16
-      debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
26
+      debug: true, // process.env.NODE_ENV === 'development', // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
17
       appId: res.appId, // 必填,公众号的唯一标识
27
       appId: res.appId, // 必填,公众号的唯一标识
18
       timestamp: res.timestamp, // 必填,生成签名的时间戳
28
       timestamp: res.timestamp, // 必填,生成签名的时间戳
19
       nonceStr: res.nonceStr, // 必填,生成签名的随机串
29
       nonceStr: res.nonceStr, // 必填,生成签名的随机串
20
       signature: res.signature, // 必填,签名
30
       signature: res.signature, // 必填,签名
21
-      jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData'] // 必填,需要使用的JS接口列表
31
+      jsApiList // 必填,需要使用的JS接口列表
22
     })
32
     })
23
   })
33
   })
24
 }
34
 }
30
  * @param {*} opt
40
  * @param {*} opt
31
  */
41
  */
32
 export function shareData(opt) {
42
 export function shareData(opt) {
33
-  window.wx.updateAppMessageShareData({
34
-    title: opt.title, // 分享标题
35
-    desc: opt.desc, // 分享描述
36
-    link: opt.link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
37
-    imgUrl: opt.imgUrl // 分享图标
43
+  window.wx.ready(function() {
44
+    window.wx.updateAppMessageShareData({
45
+      title: opt.title, // 分享标题
46
+      desc: opt.desc, // 分享描述
47
+      link: opt.link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
48
+      imgUrl: opt.imgUrl // 分享图标
49
+    })
38
   })
50
   })
39
 }
51
 }
40
 
52
 
41
 export function shareTimeline(opt) {
53
 export function shareTimeline(opt) {
42
-  window.wx.updateTimelineShareData({
43
-    title: opt.title, // 分享标题
44
-    link: opt.link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
45
-    imgUrl: opt.imgUrl // 分享图标
54
+  window.wx.ready(function() {
55
+    window.wx.updateTimelineShareData({
56
+      title: opt.title, // 分享标题
57
+      link: opt.link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
58
+      imgUrl: opt.imgUrl // 分享图标
59
+    })
46
   })
60
   })
47
 }
61
 }
48
 
62
 
63
+/**
64
+ * 分享全部
65
+ * @param {*} opt
66
+ */
49
 export function share(opt) {
67
 export function share(opt) {
50
-  shareData(opt)
51
-  shareTimeline(opt)
68
+  window.wx.ready(function() {
69
+    jsApiList.map((apiName) => {
70
+      const api = window.wx[apiName]
71
+      api({
72
+        title: opt.title, // 分享标题
73
+        link: opt.link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
74
+        imgUrl: opt.imgUrl // 分享图标
75
+      })
76
+    })
77
+  })
52
 }
78
 }

+ 1
- 1
src/views/apartment.vue ファイルの表示

121
     }
121
     }
122
   },
122
   },
123
   mounted() {
123
   mounted() {
124
-    share({ title: '华侨城欢乐滨江可售物业', imgUrl: shareImg })
124
+    share({ title: '华侨城欢乐滨江可售物业', link: window.location.href, imgUrl: shareImg })
125
   }
125
   }
126
 }
126
 }
127
 </script>
127
 </script>

+ 1
- 1
src/views/index.vue ファイルの表示

13
     IndexImage: () => import('./components/IndexImage.vue')
13
     IndexImage: () => import('./components/IndexImage.vue')
14
   },
14
   },
15
   mounted() {
15
   mounted() {
16
-    share({ title: '华侨城欢乐滨江可售物业', imgUrl: shareImg })
16
+    share({ title: '华侨城欢乐滨江可售物业', link: window.location.href, imgUrl: shareImg })
17
   }
17
   }
18
 }
18
 }
19
 </script>
19
 </script>

+ 1
- 1
src/views/office.vue ファイルの表示

118
   },
118
   },
119
 
119
 
120
   mounted() {
120
   mounted() {
121
-    share({ title: '华侨城欢乐滨江可售物业', imgUrl: shareImg })
121
+    share({ title: '华侨城欢乐滨江可售物业', link: window.location.href, imgUrl: shareImg })
122
   },
122
   },
123
 
123
 
124
   methods: {
124
   methods: {

+ 1
- 1
src/views/projectIndex.vue ファイルの表示

81
       this.swiperShow = true
81
       this.swiperShow = true
82
     })
82
     })
83
 
83
 
84
-    share({ title: '华侨城欢乐滨江项目介绍', imgUrl: shareImg })
84
+    share({ title: '华侨城欢乐滨江项目介绍', link: window.location.href, imgUrl: shareImg })
85
   },
85
   },
86
   methods: {
86
   methods: {
87
     handleImageLoad() {
87
     handleImageLoad() {