|
@@ -201,9 +201,9 @@
|
|
|
|
|
|
<script>
|
|
|
|
|
|
-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';
|
|
|
|
|
|
|
|
|
export default {
|
|
@@ -273,12 +273,12 @@ export default {
|
|
|
preRanking: 0,
|
|
|
userType: 1,
|
|
|
received: 0,
|
|
|
- // shareInfo: {
|
|
|
- // title: '双子星云手机',
|
|
|
- // content: `免费领取一台全能云手机!`,
|
|
|
- // shareUrl: '',
|
|
|
- // shareImage: ''
|
|
|
- // },
|
|
|
+ shareInfo: {
|
|
|
+ title: '双子星云手机',
|
|
|
+ desc: `免费领取一台全能云手机!`,
|
|
|
+ link: '',
|
|
|
+ imgUrl: ''
|
|
|
+ },
|
|
|
showShare: false,
|
|
|
returnContent: [{
|
|
|
img: require('@/assets/image/activity/invite-user/card-1.png'),
|
|
@@ -303,7 +303,6 @@ 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(),
|
|
@@ -364,34 +363,34 @@ export default {
|
|
|
type() {
|
|
|
return 2;
|
|
|
},
|
|
|
- shareUrl() {
|
|
|
- return (
|
|
|
- location.origin +
|
|
|
- this.$router.resolve({
|
|
|
- path: '/activity/invite-user/register-fission/',
|
|
|
- query: {
|
|
|
- invitationUserName: this.data.inviteUserName,
|
|
|
- activityId: this.data.activityId,
|
|
|
- type: this.type,
|
|
|
- },
|
|
|
- }).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'),
|
|
|
- };
|
|
|
- }
|
|
|
+ // shareUrl() {
|
|
|
+ // return (
|
|
|
+ // location.origin +
|
|
|
+ // this.$router.resolve({
|
|
|
+ // path: '/activity/invite-user/register-fission/',
|
|
|
+ // query: {
|
|
|
+ // invitationUserName: this.data.inviteUserName,
|
|
|
+ // activityId: this.data.activityId,
|
|
|
+ // type: this.type,
|
|
|
+ // },
|
|
|
+ // }).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() {
|
|
|
this.makePoint('activity_Share_PV')
|
|
@@ -403,11 +402,27 @@ 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);
|
|
|
+ this.shareInfo.title = res.data.title
|
|
|
+ this.shareInfo.desc = res.data.content
|
|
|
+ this.shareInfo.link = res.data.url
|
|
|
+ this.shareInfo.imgUrl = 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,
|
|
@@ -492,7 +507,7 @@ export default {
|
|
|
this.codeIsLoading = false;
|
|
|
}
|
|
|
},
|
|
|
- async share() {
|
|
|
+ share() {
|
|
|
if (this.data.status !== 1) {
|
|
|
if (this.data.status === 0) {
|
|
|
Toast({
|
|
@@ -530,13 +545,37 @@ export default {
|
|
|
// app环境
|
|
|
this.$native.share(this.shareInfo);
|
|
|
console.log(this.shareInfo,'xxxx');
|
|
|
- this.makePoint('activity_Share_分享好友按钮');
|
|
|
+ // 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.imgUrl,
|
|
|
+ link: this.shareInfo.link,
|
|
|
+ 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) {
|