layout-link.vue
1.06 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
<template>
<a href="javascript:;" class="layout-link" @click="jumpTo">
<slot></slot>
</a>
</template>
<script>
import { mapGetters } from 'vuex';
import queryString from 'querystring'
export default {
name: 'LayoutLink',
props: {
href: String,
report: {
type: Object,
},
reportEvent: String,
},
computed: {
...mapGetters(['getLogin'])
},
watch: {
report: function(newVal) {
},
},
methods: {
jumpTo() {
if (!this.href) {
return;
}
// 资源位跳转 领券等需判断是否登录
// 判断条件为查询参数 isNeedLogin
const qsParams = queryString.parse(this.href.split('?')[1]);
if(!this.getLogin && +qsParams.isNeedLogin === 1) {
this.$yoho.auth();
return;
}
this.$xianyu.goXianyuNewPage({
url: this.href
});
if (this.reportEvent) {
this.$store.dispatch('reportYas', {
params: {
appop: this.reportEvent,
param: this.report
}
});
}
}
}
};
</script>