lihao 2 anos atrás
pai
commit
0520cebf6d
1 arquivos alterados com 52 adições e 59 exclusões
  1. 52 59
      pages/activity/invite-user/fission.vue

+ 52 - 59
pages/activity/invite-user/fission.vue

@@ -200,9 +200,9 @@
 </template>
 
 <script>
-import { Toast, Dialog } from 'vant';
-import NativeShare from 'nativeshare';
-import { fileKeyToUrl } from '@/plugins/file-center.js';
+import { Toast } from 'vant';
+// import NativeShare from 'nativeshare';
+// import { fileKeyToUrl } from '@/plugins/file-center.js';
 
 export default {
   auth: false,
@@ -271,12 +271,12 @@ export default {
       preRanking: 0,
       userType: 1,
       received: 0,
-      shareInfo: {
-        title: '双子星云手机',
-        content: `免费领取一台全能云手机!`,
-        shareUrl: '',
-        shareImage: ''
-      },
+      // shareInfo: {
+      //   title: '双子星云手机',
+      //   content: `免费领取一台全能云手机!`,
+      //   shareUrl: '',
+      //   shareImage: ''
+      // },
       showShare: false,
       returnContent: [{
         img: require('@/assets/image/activity/invite-user/card-1.png'),
@@ -301,6 +301,7 @@ export default {
     try {
       this.token = this.$route.query.token;
       await this.getActiveInfo();
+      this.$native.setShareInfo(this.shareInfo);
       await this.shareCanReceiveCloudPhone();
       await Promise.all([
         this.getActivityRules(),
@@ -373,6 +374,21 @@ export default {
           },
         }).href
       );
+    },
+    shareInfo() {
+      if (this.$userAgent.isMiniProgram) {
+        return {
+          title: '双子星APP',
+          path: '/pages/home/home',
+          imgUrl: location.origin + require('~/assets/image/logo.png'),
+        };
+      }
+      return {
+        title: '双子星云手机',
+        desc: `畅玩“原神”“幻塔”,24小时在线,不限下载流量的手机`,
+        link: this.shareUrl,
+        imgUrl: location.origin + require('~/assets/image/logo.png'),
+      };
     }
   },
   mounted() {
@@ -385,27 +401,11 @@ export default {
       try {
         const res = await this.$axios.$get('/resources/register/send/cloud/phone/shareCanReceiveCloudPhone', {}, { headers: { Authorization: this.token } });
         this.received = res.data.received
-        this.shareInfo.title = res.data.title
-        this.shareInfo.content = res.data.content
-        this.shareInfo.shareUrl = res.data.url
-        this.shareInfo.shareImage = fileKeyToUrl(res.data.imgUrl)
-        this.$native.setShareInfo(this.shareInfo);
-      } catch (err) {
-        Toast({
-          message: err.message,
-          position: 'top'
-        });
-      }
-    },
-    async shareReceiveCloudPhone() {
-      try {
-        const res = await this.$axios.$post('/resources/register/send/cloud/phone/shareReceiveCloudPhone', {}, { headers: { Authorization: this.token } });
-        Dialog.alert({
-          message: res.msg,
-        }).then(() => {
-          this.showShare = false
-        });
-        this.addUserVisit(7);
+        // this.shareInfo.title = res.data.title
+        // this.shareInfo.content = res.data.content
+        // this.shareInfo.shareUrl = res.data.url
+        // this.shareInfo.shareImage = fileKeyToUrl(res.data.imgUrl)
+        // this.$native.setShareInfo(this.shareInfo);
       } catch (err) {
         Toast({
           message: err.message,
@@ -413,6 +413,22 @@ export default {
         });
       }
     },
+    // async shareReceiveCloudPhone() {
+    //   try {
+    //     const res = await this.$axios.$post('/resources/register/send/cloud/phone/shareReceiveCloudPhone', {}, { headers: { Authorization: this.token } });
+    //     Dialog.alert({
+    //       message: res.msg,
+    //     }).then(() => {
+    //       this.showShare = false
+    //     });
+    //     this.addUserVisit(7);
+    //   } catch (err) {
+    //     Toast({
+    //       message: err.message,
+    //       position: 'top'
+    //     });
+    //   }
+    // },
     async receiveLevelAward(goodsId) {
       try {
         const res = await this.$axios.$post('/activity/v1/level/award/receiveLevelAward', { activityId: this.myCodeFrom.activityId, goodsId }, { headers: { Authorization: this.token } });
@@ -490,7 +506,7 @@ export default {
         this.codeIsLoading = false;
       }
     },
-    share() {
+    async share() {
       if (this.data.status !== 1) {
         if (this.data.status === 0) {
           Toast({
@@ -526,36 +542,13 @@ export default {
       if (this.$userAgent.isSzx || this.$userAgent.isSzxBrowser) {
         // app环境
         this.$native.share(this.shareInfo);
+        this.makePoint('activity_Share_分享好友按钮');
       } else {
         // 浏览器环境
-        const nativeShare = new NativeShare()
-        nativeShare.setShareData({
-          icon: this.shareInfo.shareImage,
-          link: this.shareInfo.shareUrl,
-          title: this.shareInfo.content,
-          desc: this.shareInfo.title,
-          success: () => {
-            this.shareReceiveCloudPhone()
-          },
-          fail: () => {
-            Toast({
-              message: '分享失败',
-              position: 'center'
-            })
-          }
-        })
-        try {
-          nativeShare.call('wechatTimeline')
-        } catch (err) {
-          Toast({
-            message: '您的浏览器不支持分享功能,请下载app使用!',
-            position: 'center',
-            duration: 3000
-          })
-          setTimeout(() => {
-            window.open('https://www.androidscloud.com/', '_self');
-          }, 3000)
-        }
+        await this.$native.clipboard.writeText(`${this.shareUrl} 双子星云手机`);
+        // throw new Error('1231');
+        this.$toast.success('链接复制成功');
+        this.makePoint('activity_Share_复制链接');
       }
     },
     makePoint(positionButton) {