replace-to-home.vue
1.33 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
<template>
<a v-if="isShow"
class="back-btn hover-opacity"
:class="{'scroll-opacity': scrolling}"
:href="toHomeHref || 'javascript:;'">
</a>
</template>
<script>
import _ from 'lodash';
import qs from 'querystring';
export default {
name: 'replace-to-home',
props: {
scrolling: {
type: Boolean,
default: false
},
},
data() {
return {
toHomeHref: '//m.yohobuy.com?openby:yohobuy= {"action":"go.guangchannel","params":{"index":"1"}}',
hasBackToHome: 0,
isShow: false
};
},
mounted() {
// 地址栏携带参数过来,并且当前页面不在app中
const hasBackToHome = _.chain(window.location.href)
.thru(n => n.split('?'))
.get('[1]', '')
.thru(qs.parse)
.get('hasBackToHome', 0)
.thru(JSON.parse)
.thru(n => n === 1 ? 1 : 0)
.value();
// && this.$yoho.isApp;
this.isShow = hasBackToHome === 1 && this.$yoho.isApp;
}
};
</script>
<style scoped>
.back-btn {
width: 260px;
height: 80px;
position: absolute;
left: calc(50% - 130px);
z-index: 99;
display: flex;
align-items: center;
transition: all 600ms ease-in-out;
background-image: url("~statics/image/article/back_zc@3x.png");
background-size: contain;
background-repeat: no-repeat;
&.scroll-opacity {
opacity: 0.3;
}
}
</style>