|
@@ -104,10 +104,12 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
scrollTop: 0,
|
|
|
+ banner: {},
|
|
|
+ screenWidth: ""
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
- ...mapGetters(['screenWidth', 'isPc']),
|
|
|
+ ...mapGetters(['screenWidth', 'isPc', 'authUserId']),
|
|
|
offsetTop() {
|
|
|
if (this.scrollTop <= window.innerHeight / 2) return '10px'
|
|
|
return 10 + this.scrollTop - window.innerHeight / 2 + 'px'
|
|
@@ -117,17 +119,44 @@ export default {
|
|
|
window.addEventListener('scroll', () => {
|
|
|
this.scrollTop = document.documentElement.scrollTop
|
|
|
})
|
|
|
+ this.getBanner() // 获取轮播图
|
|
|
+ // 监听页面尺寸变化
|
|
|
+ this.screenWidth = document.body.clientWidth
|
|
|
+ window.onresize = () => {
|
|
|
+ return (() => {
|
|
|
+ this.screenWidth = document.body.clientWidth
|
|
|
+ })()
|
|
|
+ }
|
|
|
},
|
|
|
beforeDestroy() {
|
|
|
window.removeEventListener('scroll', () => {
|
|
|
this.scrollTop = document.documentElement.scrollTop
|
|
|
})
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ screenWidth: {
|
|
|
+ handler(val) {
|
|
|
+ const changeBanner = document.getElementsByClassName('page-top')[0]
|
|
|
+ if (changeBanner) {
|
|
|
+ if (val > 768) {
|
|
|
+ if(this.banner.headPcBanner) {
|
|
|
+ changeBanner.style.backgroundImage = 'url('+ this.banner.headPcBanner+ ')'
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if(this.banner.headAppBanner) {
|
|
|
+ changeBanner.style.backgroundImage = 'url('+ this.banner.headAppBanner+ ')'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ immediate: true,
|
|
|
+ deep: true
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
// 抖音挑战赛
|
|
|
toActivity() {
|
|
|
- return
|
|
|
- this.$router.push(`${this.routePrefix}/activity/challenge`)
|
|
|
+ this.banner.jumpLink && this.$router.push(this.banner.jumpLink)
|
|
|
},
|
|
|
// 从缓存中获取数据
|
|
|
initFromCache(cacheData) {
|
|
@@ -142,6 +171,18 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
|
|
|
+ // banner
|
|
|
+ async getBanner() {
|
|
|
+ const { data } = await this.$http.api.bannerImg(this.authUserId)
|
|
|
+ this.banner = data
|
|
|
+ const changeBanner = document.getElementsByClassName('page-top')[0]
|
|
|
+ if (this.screenWidth > 768) {
|
|
|
+ this.banner.headPcBanner && (changeBanner.style.backgroundImage = 'url('+ this.banner.headPcBanner+ ')')
|
|
|
+ }else {
|
|
|
+ this.banner.headAppBanner && (changeBanner.style.backgroundImage = 'url('+ this.banner.headAppBanner+ ')')
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
// 城市变化
|
|
|
onCityChange(valueMap) {
|
|
|
const { provinceId, cityId, townId } = valueMap
|
|
@@ -178,7 +219,7 @@ export default {
|
|
|
.page-top {
|
|
|
height: 530px;
|
|
|
background-image: fetch('pc-banner-club');
|
|
|
- // background-image: url(~assets/theme-images/ross/pc-banner-club.png);
|
|
|
+ // background-image: url(~/assets/theme-images/app/pc-banner-club.png);
|
|
|
background-size: cover;
|
|
|
background-position: center;
|
|
|
cursor: pointer;
|