lrf402788946 4 gadi atpakaļ
vecāks
revīzija
165b7edc8f
3 mainītis faili ar 12 papildinājumiem un 6 dzēšanām
  1. 5 6
      src/layout/common/share.vue
  2. 1 0
      src/main.js
  3. 6 0
      src/plugins/weixin.js

+ 5 - 6
src/layout/common/share.vue

@@ -5,7 +5,6 @@
 </template>
 
 <script>
-let wx = require('weixin-js-sdk');
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: weixin } = createNamespacedHelpers('weixin');
 export default {
@@ -39,7 +38,7 @@ export default {
       if (this.$checkRes(res)) {
         const { data } = res;
         const shareUrl = 'http://broadcast.waityou24.cn/api/article/auth?redirect_uri=http://broadcast.waityou24.cn/articlemobile' + this.route;
-        wx.config({
+        this.$wx.config({
           debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
           appId: data.appid, // 必填,公众号的唯一标识
           timestamp: data.timestamp, // 必填,生成签名的时间戳
@@ -50,11 +49,11 @@ export default {
             'updateTimelineShareData', // 朋友圈及QQ空间
           ],
         });
-        wx.ready(() => {
-          wx.updateTimelineShareData({
+        this.$wx.ready(() => {
+          this.$wx.updateAppMessageShareData({
             title: this.title,
-            // desc: this.desc,
-            // imgUrl: this.img,
+            desc: this.desc,
+            imgUrl: this.img,
             link: shareUrl,
             success: res => {
               console.log(res);

+ 1 - 0
src/main.js

@@ -12,6 +12,7 @@ import '@/plugins/loading';
 import '@/plugins/var';
 import '@/plugins/methods';
 import '@/plugins/setting';
+import '@/plugins/weixin';
 import InitStomp from '@/plugins/stomp';
 Vue.config.productionTip = false;
 

+ 6 - 0
src/plugins/weixin.js

@@ -0,0 +1,6 @@
+import Vue from 'vue';
+const wx = require('weixin-js-sdk');
+wx.config({
+  appid: `wxdf3ed83c095be97a`,
+});
+Vue.prototype.$wx = wx;