lrf402788946 4 年之前
父節點
當前提交
0d29ac5f59
共有 1 個文件被更改,包括 15 次插入7 次删除
  1. 15 7
      src/layout/common/share.vue

+ 15 - 7
src/layout/common/share.vue

@@ -10,7 +10,13 @@ import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: weixin } = createNamespacedHelpers('weixin');
 export default {
   name: 'share',
-  props: {},
+  props: {
+    title: { type: String, default: '分享' },
+    desc: { type: String, default: '内容' },
+    img: { type: String, default: '' },
+    route: { type: String, default: '/' },
+    type: { type: String, default: 'py' },
+  },
   components: {},
   data: function() {
     return {
@@ -60,14 +66,16 @@ export default {
       }
     },
     toShare() {
-      this.wx.updateAppMessageShareData({
-        title: '测试分享',
-        desc: '测试',
-        // imgUrl:''
-        link: `${this.host}/articlemobile/login`,
+      const url = 'http://broadcast.waityou24.cn/api/article/auth?redirect_uri=http://broadcast.waityou24.cn/articlemobile' + this.route;
+      let method = 'updateAppMessageShareData';
+      if (type !== 'py') method = 'updateTimelineShareData';
+      this.wx[method]({
+        title: this.title,
+        desc: this.desc,
+        imgUrl: this.img,
+        link: url,
         success: res => {
           console.log('in function:share success');
-          console.log(res);
         },
         error: err => {
           alert('share is fail');