footer.vue
1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<template>
<div>
<div ref="copy" class="btn" @click="onClick">
立即邀请
</div>
</div>
</template>
<script>
import { createNamespacedHelpers } from "vuex";
import { get } from "lodash";
import Clipboard from "clipboard";
const { mapActions } = createNamespacedHelpers("gain");
export default {
name: "GainFooter",
data() {
return {
isUnionType: false,
shareUrl:
"https://activity.yoho.cn/feature/5475.html?share_id=8169&title=新人礼遇"
};
},
mounted() {
let vm = this;
this.copyBtn = new Clipboard(this.$refs.copy, {
text() {
return vm.shareUrl + `&union_type=${vm.isUnionType}`;
}
});
this.copyBtn.on("success", function() {
if (vm.isUnionType) {
vm.$createToast({
txt: "邀请链接已复制,快去粘贴吧~",
type: "txt"
}).show();
}
});
this.copyBtn.on("error", function() {});
this.fetchUnionStatus().then(result => {
this.isUnionType = get(result, "data.unionType", false);
});
},
methods: {
...mapActions(["fetchUnionStatus"]),
async onClick() {
let vm = this;
const user = await this.$sdk.getUser();
if (!user.uid) {
this.$sdk.goLogin();
return;
}
if (!vm.isUnionType) {
this.$yoho.goNewPage({
url:
'http://m.yohobuy.com/activity/have-gain/apply?title=有货有赚介绍&openby:yohobuy={"action":"go.h5","params":{"title":"有货有赚介绍","url":"http://m.yohobuy.com/activity/have-gain/apply"}}'
});
return;
}
}
}
};
</script>
<style lang="scss" scoped>
.btn {
font-size: 32px;
width: 100%;
height: 98px;
line-height: 98px;
color: white;
text-align: center;
background: #444;
}
</style>