广告请求

feature/ad-0531-ch
ch 2 years ago
parent 8d5f2d6a2c
commit 295537b06c

@ -2,12 +2,12 @@
* @Author: ch * @Author: ch
* @Date: 2022-05-03 22:14:16 * @Date: 2022-05-03 22:14:16
* @LastEditors: ch * @LastEditors: ch
* @LastEditTime: 2022-05-04 22:21:04 * @LastEditTime: 2022-05-31 18:41:33
* @Description: file content * @Description: file content
--> -->
<template> <template>
<div class="home"> <div class="home">
<Banner /> <Banner :data="bannerList"/>
<div class="home-wrap"> <div class="home-wrap">
<Seckil <Seckil
v-if="seckillData.activityTimeVO" v-if="seckillData.activityTimeVO"
@ -50,9 +50,13 @@ import {
ApiGetRecommendedGoodsList, ApiGetRecommendedGoodsList,
ApiGetGoodsList, ApiGetGoodsList,
} from "@/plugins/api/goods"; } from "@/plugins/api/goods";
import {
ApiGetAdList
} from "@/plugins/api/ad";
import Banner from "./module/Banner.vue"; import Banner from "./module/Banner.vue";
import Seckil from "./module/Seckill.vue"; import Seckil from "./module/Seckill.vue";
import Pick from "./module/Pick.vue"; import Pick from "./module/Pick.vue";
import { AD_LOCATION } from '@/plugins/dicts/ad';
import TabbarFixed from "./module/TabbarFixed.vue"; import TabbarFixed from "./module/TabbarFixed.vue";
const SECKILL_COUNT = 20; // const SECKILL_COUNT = 20; //
const NEW_COUNT = 5; // const NEW_COUNT = 5; //
@ -95,9 +99,16 @@ export default {
if (newDataResult) { if (newDataResult) {
newData = newDataResult.records || []; newData = newDataResult.records || [];
} }
let {result:bannerList} = await ApiGetAdList({
location : AD_LOCATION.HOME_BANNER
});
bannerList = bannerList || [];
return { return {
currentTime, currentTime,
bannerList,
newData, newData,
sekillGoodsList, sekillGoodsList,
seckillData, seckillData,
@ -121,7 +132,7 @@ export default {
created() { created() {
this.getSelectProducts(); this.getSelectProducts();
}, },
mounted() { async mounted() {
// //
window.addEventListener("scroll", this.scrollEventMethod); window.addEventListener("scroll", this.scrollEventMethod);
}, },

@ -2,32 +2,17 @@
* @Author: ch * @Author: ch
* @Date: 2022-05-04 17:50:33 * @Date: 2022-05-04 17:50:33
* @LastEditors: ch * @LastEditors: ch
* @LastEditTime: 2022-05-04 22:15:26 * @LastEditTime: 2022-05-31 18:43:10
* @Description: file content * @Description: file content
--> -->
<template> <template>
<div class="home-banner"> <div class="home-banner">
<el-carousel height="360px" indicator-position="outside"> <el-carousel height="360px" indicator-position="outside">
<el-carousel-item> <el-carousel-item v-for="item in data" :key="item.id">
<el-image <el-image
@click="onAdvBannerClick(0)" @click="onBannerClick(item)"
:src="adv1" :src="item.pictureUrl"
fit="cover"
></el-image>
</el-carousel-item>
<el-carousel-item>
<el-image
@click="onAdvBannerClick(1)"
:src="adv2"
fit="cover"
></el-image>
</el-carousel-item>
<el-carousel-item v-for="item in bannerList" :key="item.id">
<el-image
@click="onBannerClick(item.id)"
:src="item.url"
fit="cover" fit="cover"
></el-image> ></el-image>
</el-carousel-item> </el-carousel-item>
@ -35,50 +20,32 @@
</div> </div>
</template> </template>
<script> <script>
import { AD_JUMP_TYPE } from '@/plugins/dicts/ad';
export default { export default {
name: "HomtBanner", name: "HomtBanner",
props : {
data : {
type : Array,
default : () => ([])
}
},
data() { data() {
return { return {
adv1: require("~/assets/img/banner/zbk.jpg"),
adv2: require("~/assets/img/banner/jlp.jpg"),
bannerList: [
{
url: require(`~/assets/img/banner/1.jpg`),
id: 13,
},
{
url: require(`~/assets/img/banner/2.jpg`),
id: 30,
},
{
url: require(`~/assets/img/banner/3.jpg`),
id: 15,
},
{
url: require(`~/assets/img/banner/4.jpg`),
id: 40,
},
],
}; };
}, },
methods: { methods: {
onAdvBannerClick(i) { onBannerClick(item) {
if (i === 1) { switch (item.jumpType) {
window.open(`https://www.mashibing.com/live/1530`); case AD_JUMP_TYPE.GOODS:
} else if (i === 2) { window.open(`${location.origin}/goods/detail/${item.jumpUrl}`);
window.open(`https://www.mashibing.com/free/1373`); break;
} case AD_JUMP_TYPE.LINK:
}, window.open(item.jumpUrl, '_blank');
onBannerClick(goodsId) { break;
window.open(`${location.origin}/goods/detail/${goodsId}`); default:
}, break
onAdvBannerClick(i) {
if (i === 0) {
window.open(`https://www.mashibing.com/live/1530`);
} else if (i === 1) {
window.open(`https://www.mashibing.com/free/1373`);
} }
}, }
}, },
}; };

@ -0,0 +1,19 @@
/*
* @Author: ch
* @Date: 2022-05-31 11:17:38
* @LastEditors: ch
* @LastEditTime: 2022-05-31 18:40:27
* @Description: file content
*/
import {ToAsyncAwait} from '@/plugins/utils';
import { AD_PLATFORM } from '../dicts/ad';
import {axios} from "../axios";
const BASE_URL = '/mall/marketing';
// 获取广告列表
export const ApiGetAdList = (params) => ToAsyncAwait(axios.get(`${BASE_URL}/app/advertisement`, {
platform : AD_PLATFORM.PC,
...params
}))

@ -0,0 +1,42 @@
/*
* @Author: ch
* @Date: 2022-05-31 11:05:08
* @LastEditors: ch
* @LastEditTime: 2022-05-31 17:23:02
* @Description: file content
*/
const AD_PLATFORM = {
PC: 2,
MOBILE : 1
}
const AD_LOCATION = {
// 首页轮播图
HOME_BANNER: 1,
// 首页精装区
HOME_HARDCOVER: 2,
// 分类banner
CATEGORY_BANNER : 3
}
const AD_JUMP_TYPE = {
// 商品详情
GOODS: 1,
// 分类
CATEGORY: 2,
// 链接
LINK: 3,
// 不跳转
NO_JUMP : 4
}
export {
// 广告所属平台
AD_PLATFORM,
// 广告位置
AD_LOCATION,
// 广告跳转类型
AD_JUMP_TYPE
}
Loading…
Cancel
Save