lihao 2 年之前
父节点
当前提交
274575a64d
共有 1 个文件被更改,包括 83 次插入22 次删除
  1. 83 22
      pages/activity/invite-user/fission.vue

+ 83 - 22
pages/activity/invite-user/fission.vue

@@ -200,9 +200,15 @@
 </template>
 
 <script>
+<<<<<<< HEAD
 import { Toast } from 'vant';
 // import NativeShare from 'nativeshare';
 // import { fileKeyToUrl } from '@/plugins/file-center.js';
+=======
+import { Toast, Dialog } from 'vant';
+import NativeShare from 'nativeshare';
+import { fileKeyToUrl } from '@/plugins/file-center.js';
+>>>>>>> 6996e6c966cfa7e49b1fdde30f339cb400f99a8e
 
 export default {
   auth: false,
@@ -271,12 +277,21 @@ export default {
       preRanking: 0,
       userType: 1,
       received: 0,
+<<<<<<< HEAD
       // shareInfo: {
       //   title: '双子星云手机',
       //   content: `免费领取一台全能云手机!`,
       //   shareUrl: '',
       //   shareImage: ''
       // },
+=======
+      shareInfo: {
+        title: '双子星云手机',
+        content: `免费领取一台全能云手机!`,
+        shareUrl: '',
+        shareImage: ''
+      },
+>>>>>>> 6996e6c966cfa7e49b1fdde30f339cb400f99a8e
       showShare: false,
       returnContent: [{
         img: require('@/assets/image/activity/invite-user/card-1.png'),
@@ -301,8 +316,12 @@ export default {
     try {
       this.token = this.$route.query.token;
       await this.getActiveInfo();
+<<<<<<< HEAD
       this.$native.setShareInfo(this.shareInfo);
       // await this.shareCanReceiveCloudPhone();
+=======
+      await this.shareCanReceiveCloudPhone();
+>>>>>>> 6996e6c966cfa7e49b1fdde30f339cb400f99a8e
       await Promise.all([
         this.getActivityRules(),
         this.type === 2 && this.getMyActivationCode(this.myCodeFrom),
@@ -374,21 +393,6 @@ 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() {
@@ -397,6 +401,7 @@ export default {
     this.addUserVisit(12);
   },
   methods: {
+<<<<<<< HEAD
     // async shareCanReceiveCloudPhone() {
     //   try {
     //     const res = await this.$axios.$get('/resources/register/send/cloud/phone/shareCanReceiveCloudPhone', {}, { headers: { Authorization: this.token } });
@@ -429,6 +434,40 @@ export default {
     //     });
     //   }
     // },
+=======
+    async shareCanReceiveCloudPhone() {
+      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);
+      } catch (err) {
+        Toast({
+          message: err.message,
+          position: 'top'
+        });
+      }
+    },
+>>>>>>> 6996e6c966cfa7e49b1fdde30f339cb400f99a8e
     async receiveLevelAward(goodsId) {
       try {
         const res = await this.$axios.$post('/activity/v1/level/award/receiveLevelAward', { activityId: this.myCodeFrom.activityId, goodsId }, { headers: { Authorization: this.token } });
@@ -506,7 +545,7 @@ export default {
         this.codeIsLoading = false;
       }
     },
-    async share() {
+    share() {
       if (this.data.status !== 1) {
         if (this.data.status === 0) {
           Toast({
@@ -535,7 +574,6 @@ export default {
         });
         return
       }
-
       this.$tongji.trackEvent('活动', '分享', '', 0);
       if (this.received) {
         this.addUserVisit(13);
@@ -543,13 +581,36 @@ export default {
       if (this.$userAgent.isSzx || this.$userAgent.isSzxBrowser) {
         // app环境
         this.$native.share(this.shareInfo);
-        this.makePoint('activity_Share_分享好友按钮');
       } else {
         // 浏览器环境
-        await this.$native.clipboard.writeText(`${this.shareUrl} 双子星云手机`);
-        // throw new Error('1231');
-        this.$toast.success('链接复制成功');
-        this.makePoint('activity_Share_复制链接');
+        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)
+        }
       }
     },
     makePoint(positionButton) {