添加侧边广告悬浮

This commit is contained in:
熊丽君
2022-01-24 17:37:02 +08:00
parent 6881e2b57c
commit 174653551f
4 changed files with 78 additions and 9 deletions

View File

@ -1,5 +1,11 @@
import request from '@/utils/request'; import request from '@/utils/request';
export function getDataInfo(params) {
return request({
url: '/mobile/getJcPropagandaAd',
params
});
}
// 获取用户详细信息 // 获取用户详细信息
export function getList(params) { export function getList(params) {
return request({ return request({

BIN
src/assets/image/close.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -589,9 +589,9 @@ export default {
const middleIndex = Math.ceil(data.length / 2); const middleIndex = Math.ceil(data.length / 2);
this.listData = data.slice().splice(0, middleIndex); this.listData = data.slice().splice(0, middleIndex);
this.listData2 = data.slice().splice(-middleIndex); this.listData2 = data.slice().splice(-middleIndex);
console.log(this.listData); // console.log(this.listData);
console.log(this.listData2); // console.log(this.listData2);
console.log(data); // console.log(data);
}); });
} }
}; };

View File

@ -1,5 +1,19 @@
<template> <template>
<div class="index_page"> <div class="index_page">
<div
class="couplet"
:class="item.type == '1' ? 'c_left' : 'c_right'"
v-for="item in dataList"
:key="item.id"
v-show="item.status == 1"
>
<div class="couplet-close pointer" @click="item.status = 0">
<img src="../assets/image/close.gif" alt="" />
</div>
<div class="c_content">
<img :src="item.pic" alt="" />
</div>
</div>
<!-- 右侧悬浮 --> <!-- 右侧悬浮 -->
<div class="slid" v-if="path == '/home'"> <div class="slid" v-if="path == '/home'">
<div class="item-box"> <div class="item-box">
@ -64,12 +78,12 @@ import headerPage from './components/header';
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import footerPage from './components/footer'; import footerPage from './components/footer';
// import user from '@/store/modules/user'; // import user from '@/store/modules/user';
// import { getMsgCount } from '@/api/home/news'; import { getDataInfo } from '@/api/index';
export default { export default {
name: 'home', name: 'home',
components: { components: {
headerPage, headerPage,
footerPage footerPage,
}, },
data() { data() {
return { return {
@ -104,11 +118,12 @@ export default {
// name: '智能评估' // name: '智能评估'
// } // }
// ], // ],
path: this.$route.path == '/' ? '/home' : this.$route.path path: this.$route.path == '/' ? '/home' : this.$route.path,
dataList: [],
}; };
}, },
computed: { computed: {
...mapGetters(['avatar', 'badge']) ...mapGetters(['avatar', 'badge']),
}, },
// watch: { // watch: {
// badge(newVal, oldVal) { // badge(newVal, oldVal) {
@ -130,9 +145,14 @@ export default {
handlePath(path) { handlePath(path) {
this.path = path; this.path = path;
this.$router.push({ path }); this.$router.push({ path });
} },
}, },
created() { created() {
getDataInfo({ type: 1 }).then((res) => {
getDataInfo({ type: 2 }).then(({ data }) => {
this.dataList = [...res.data, ...data];
});
});
// console.log(this.badge); // console.log(this.badge);
// console.log(user.state.badge); // console.log(user.state.badge);
// getMsgCount().then(({ data }) => { // getMsgCount().then(({ data }) => {
@ -144,7 +164,7 @@ export default {
// if (this.badge == 0) { // if (this.badge == 0) {
// document.querySelector('.el-badge sup').style = 'display:none'; // document.querySelector('.el-badge sup').style = 'display:none';
// } // }
} },
}; };
</script> </script>
@ -165,6 +185,49 @@ export default {
// display: none; // display: none;
// } // }
// } // }
.couplet {
position: fixed;
top: 30%;
width: 100px;
height: 300px;
.couplet-close {
width: 43px;
height: 11px;
position: relative;
img {
width: 100%;
height: 100%;
vertical-align: top;
}
}
.c_content {
width: 100%;
margin-top: 5px;
background-color: #f00;
img {
width: 100%;
vertical-align: middle;
}
}
}
.c_left {
left: 5px;
.couplet-close {
text-align: left;
margin-left: 5px;
}
}
.c_right {
right: 5px;
.couplet-close {
margin-left: calc(100% - 48px);
}
}
@media screen and (max-width: 1365px) {
.couplet {
display: none;
}
}
.slid { .slid {
width: 70px; width: 70px;
height: 246px; height: 246px;