|
|
<template>
|
|
|
<a v-if="hasBackToHome" class="publish hover-opacity" :class="{'scroll-hide': scrolling}" :href="toHomeHref">
|
|
|
<img class="publish-icon" :src="toHomeImgSrc" />
|
|
|
<a v-if="isShow" class="publish-btn hover-opacity" :class="{'scroll-opacity': scrolling}" :href="toHomeHref || 'javascript:;'">
|
|
|
</a>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import _ from 'lodash';
|
|
|
import qs from 'querystring';
|
|
|
import {processImage} from 'utils/image-handler';
|
|
|
import config from 'config';
|
|
|
|
|
|
export default {
|
|
|
name: 'replace-to-home',
|
...
|
...
|
@@ -20,71 +17,46 @@ export default { |
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
toHomeHref: '',
|
|
|
toHomeImgSrc: '',
|
|
|
hasBackToHome: 0,
|
|
|
imgW: 0,
|
|
|
imgH: 0
|
|
|
toHomeHref: '//m.yohobuy.com?openby:yohobuy= {"action":"go.guangchannel","params":{"index":"1"}}',
|
|
|
hasBackToHome: 1
|
|
|
};
|
|
|
},
|
|
|
async created() {
|
|
|
|
|
|
const res = await this.$api.get('/api/resource/get', {content_code: config.toHomeResourceCode});
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
// 地址栏携带参数过来,并且当前页面不在app中
|
|
|
this.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;
|
|
|
|
|
|
const item = _.chain(res)
|
|
|
.get('data[0].data.list[0]', '')
|
|
|
.value();
|
|
|
|
|
|
const imgW = _.chain(res).get('data[0].data.imageWidth', 140).value();
|
|
|
const imgH = _.chain(res).get('data[0].data.imageHeight', 140).value();
|
|
|
|
|
|
this.toHomeImgSrc = _.chain(item)
|
|
|
.get('src', '')
|
|
|
.thru(n => processImage(`${n}/format/png`, 2, imgW, imgH))
|
|
|
.value();
|
|
|
|
|
|
this.toHomeHref = _.chain(item)
|
|
|
.get('url', '')
|
|
|
.value();
|
|
|
computed: {
|
|
|
isShow() {
|
|
|
return this.hasBackToHome === 1 && this.$yoho.isApp;
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
// 地址栏携带参数过来,并且当前页面不在app中
|
|
|
this.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();
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
.publish {
|
|
|
width: 140px;
|
|
|
height: 140px;
|
|
|
font-size: 24px;
|
|
|
.publish-btn {
|
|
|
width: 280px;
|
|
|
height: 80px;
|
|
|
position: absolute;
|
|
|
bottom: 140px;
|
|
|
right: 0;
|
|
|
z-index: 10;
|
|
|
left: calc(50% - 130px);
|
|
|
z-index: 1;
|
|
|
display: flex;
|
|
|
justify-content: center;
|
|
|
align-items: center;
|
|
|
transition: transform 300ms ease-in-out;
|
|
|
|
|
|
.publish-icon {
|
|
|
max-width: 140px;
|
|
|
max-height: 140px;
|
|
|
position: absolute;
|
|
|
bottom: 0;
|
|
|
}
|
|
|
transition: all 600ms ease-in-out;
|
|
|
background-image: url("~statics/image/article/back_zc@3x.png");
|
|
|
background-size: contain;
|
|
|
background-repeat: no-repeat;
|
|
|
|
|
|
&.scroll-hide {
|
|
|
transform: translate3d(86px, 0, 0);
|
|
|
&.scroll-opacity {
|
|
|
opacity: 0.3;
|
|
|
}
|
|
|
}
|
|
|
</style> |
...
|
...
|
|