Authored by Tao

channel template

<template>
<!-- <LayoutApp :show-back="true">
<LayoutApp :show-back="true">
<div class="body" ref="body">
<List></List>
<div v-for="(item, index) in list2" :key="index">
<template v-if="item.template_name == 'focus'">
<Slider :list="list"></Slider>
</template>
<template v-if="item.template_name == 'hotSeries'">
<Hot :list="item.data"></Hot>
</template>
<template v-if="item.template_name == 'single_image'">
<Banner :linkUrl="linkUrl" :imgUrl="imgUrl"></Banner>
</template>
<template v-if="item.template_name == 'twoPicture'">
<TwoBanner :list="item.data"></TwoBanner>
</template>
</div>
</div>
<Footer class="footer"></Footer>
</LayoutApp> -->
<div>wdwqdwqdwq </div>
</LayoutApp>
</template>
<script>
import Footer from './components/footer';
import List from './components/list';
import Slider from './components/slider'; // 轮播图
import Banner from './components/banner'; // 一张图广告位
import TwoBanner from './components/twoBanner'; // 两张图广告位
import Hot from './components/hot'; // 热门系列
export default {
data() {
return {
list: [
{
url: 'http://www.didichuxing.com/',
image: '//webapp.didistatic.com/static/webapp/shield/cube-ui-examples-slide01.png'
},
{
url: 'http://www.didichuxing.com/',
image: '//webapp.didistatic.com/static/webapp/shield/cube-ui-examples-slide01.png'
}
],
linkUrl: 'https://www.baidu.com',
imgUrl: 'https://ss0.baidu.com/94o3dSag_xI4khGko9WTAnF6hhy/baike/pic/item/cb8065380cd79123d7648113a7345982b3b780d4.jpg',
list2: [
{
"data": [
{
"bgColor": "",
"src": "http://img10.static.yhbimg.com/yhb-img01/2017/07/26/16/01d47fc95f71a19469f38a19c7c843fe43.jpg?imageView2/{mode}/w/{width}/h/{height}",
"title": "",
"url": "https://m.yohobuy.com/?title=标题&openby:yohobuy={\"action\":\"go.collagehome\",\"params\":{\"title\":\"标题\"}}"
},
{
"bgColor": "",
"src": "http://img10.static.yhbimg.com/yhb-img01/2017/07/26/16/01e90704cc16d5a32a1680ae1d415426c6.jpg?imageView2/{mode}/w/{width}/h/{height}",
"title": "",
"url": "https://m.yohobuy.com/groupPurchase?activityId=56&type=2&title=模式2测试&openby:yohobuy={\"action\":\"go.activitytemplate\",\"params\":{\"activityId\":\"56\",\"type\":\"2\",\"title\":\"模式2测试\"}}"
},
{
"bgColor": "",
"src": "http://img10.static.yhbimg.com/yhb-img01/2017/07/27/09/01cc06fea3c1d22375abcd90836759f85f.png?imageView2/{mode}/w/{width}/h/{height}",
"title": "",
"url": "http://m.yohobuy.com/groupPurchase?activityId=58&type=2&title=团购状态验证&openby:yohobuy={\"action\":\"go.activitytemplate\",\"params\":{\"activityId\":\"58\",\"type\":\"2\",\"title\":\"团购状态验证\"}}"
},
{
"bgColor": "",
"src": "http://img11.static.yhbimg.com/yhb-img01/2017/09/20/09/01cf74dac1b0a354b82dc894dc66634352.jpg?imageView2/{mode}/w/{width}/h/{height}",
"title": "",
"url": "https://list.m.yohobuy.com/?specialsale_id=2&gender=1,3&actiontype=2&cover_url=http://img10.static.yhbimg.com/couponImg/2018/08/27/10/01021a4ec4029934bcffca8ee912f61654.jpg&openby:yohobuy={\"action\":\"go.list\",\"params\":{\"actiontype\":\"2\",\"cover_url\":\"http://img10.static.yhbimg.com/couponImg/2018/08/27/10/01021a4ec4029934bcffca8ee912f61654.jpg\",\"gender\":\"1,3\",\"specialsale_id\":\"2\"}}"
},
{
"bgColor": "",
"src": "http://img11.static.yhbimg.com/yhb-img01/2017/10/13/18/018044cceeb5a2afe6223a1412ccda89b9.jpg?imageView2/{mode}/w/{width}/h/{height}",
"title": "",
"url": "https://search.m.yohobuy.com/?productPool=680&title=618抢先购-6.1折封顶&openby:yohobuy={\"action\":\"go.poollist\",\"params\":{\"title\":\"618抢先购-6.1折封顶\",\"productPool\":\"680\"}}"
},
{
"bgColor": "",
"src": "http://img11.static.yhbimg.com/yhb-img01/2018/03/06/11/019dea67754e6c4c08711b118c3d050891.JPG?imageView2/{mode}/w/{width}/h/{height}",
"title": "秒杀",
"url": "http://m.yohobuy.com/product/seckill?type=2&openby:yohobuy={\"action\":\"go.h5\",\"params\":{\"param\":{\"type\":\"2\"},\"type\":\"2\",\"url\":\"http://m.yohobuy.com/product/seckill\"}}"
},
{
"bgColor": "",
"src": "http://img11.static.yhbimg.com/yhb-img01/2018/03/06/11/016a0402a7ff364326046b215f4d088cb8.JPG?imageView2/{mode}/w/{width}/h/{height}",
"title": "",
"url": "https://m.yohobuy.com/home/family?openby:yohobuy={\"action\":\"go.family\"}"
}
],
"focus_type": "2",
"original_template_id": 1,
"template_id": "1",
"template_intro": "焦点图",
"template_name": "focus"
},
{
"template_name": "hotSeries",
"data": [
{
"image_url": "http://img11.static.yhbimg.com/yhb-img01/2017/07/26/16/0186f834d5a21f26717254407c28fc3c53.jpg",
"series_name": "哈哈",
"series_id": "1"
},
{
"image_url": "http://img11.static.yhbimg.com/yhb-img01/2017/07/26/16/0186f834d5a21f26717254407c28fc3c53.jpg",
"series_name": "耐克",
"series_id": "2"
},
{
"image_url": "http://img11.static.yhbimg.com/yhb-img01/2017/07/26/16/0186f834d5a21f26717254407c28fc3c53.jpg",
"series_name": "哈哈",
"series_id": "1"
},
{
"image_url": "http://img11.static.yhbimg.com/yhb-img01/2017/07/26/16/0186f834d5a21f26717254407c28fc3c53.jpg",
"series_name": "耐克",
"series_id": "2"
},
{
"image_url": "http://img11.static.yhbimg.com/yhb-img01/2017/07/26/16/0186f834d5a21f26717254407c28fc3c53.jpg",
"series_name": "哈哈",
"series_id": "1"
},
{
"image_url": "http://img11.static.yhbimg.com/yhb-img01/2017/07/26/16/0186f834d5a21f26717254407c28fc3c53.jpg",
"series_name": "耐克",
"series_id": "2"
},
{
"image_url": "http://img11.static.yhbimg.com/yhb-img01/2017/07/26/16/0186f834d5a21f26717254407c28fc3c53.jpg",
"series_name": "耐克",
"series_id": "2"
},
],
"template_intro": "热门系列",
"template_id": "1"
},
{
"template_name": "single_image",
"data": [
{
"image_url": "http://img11.static.yhbimg.com/yhb-img01/2017/07/26/16/0186f834d5a21f26717254407c28fc3c53.jpg",
"series_name": "",
"series_id": "1"
},
{
"image_url": "http://img11.static.yhbimg.com/yhb-img01/2017/07/26/16/0186f834d5a21f26717254407c28fc3c53.jpg",
"series_name": "",
"series_id": "2"
}
],
"template_intro": "热门系列",
"template_id": "1"
},
{
"template_name": "twoPicture",
"data": [
{
"src": "http://img11.static.yhbimg.com/yhb-img01/2019/09/24/14/01bdf0e379025b33c9690861b843dbd966.jpg",
"id": "",
"url": "https://m.yohobuy.com/?openby:yohobuy={'action':'go.bargainlist'}"
},
{
"src": "http://img11.static.yhbimg.com/yhb-img01/2019/09/24/14/01bdf0e379025b33c9690861b843dbd966.jpg",
"id": "",
"url": "https://m.yohobuy.com/?openby:yohobuy={'action':'go.bargainlist'}"
},
],
"template_intro": "热门系列",
"template_id": "1"
},
{
"template_name": "single_image",
"data": [
{
"image_url": "http://img11.static.yhbimg.com/yhb-img01/2017/07/26/16/0186f834d5a21f26717254407c28fc3c53.jpg",
"series_name": "",
"series_id": "1"
},
{
"image_url": "http://img11.static.yhbimg.com/yhb-img01/2017/07/26/16/0186f834d5a21f26717254407c28fc3c53.jpg",
"series_name": "",
"series_id": "2"
}
],
"template_intro": "热门系列",
"template_id": "1"
},
],
}
},
components: {
Footer,
List
Slider,
Banner,
TwoBanner,
Hot
}
};
</script>
... ... @@ -27,9 +208,10 @@ export default {
width: 100%;
z-index: 100;
}
.body {
height: 100%;
overflow-y: auto;
padding: 0 40px;
}
</style>
... ...
<template>
<div class="banner">
<img :src="resource" alt="">
<div class="link" @click="onClick"></div>
<a :href="linkUrl">
<img class="banner-image" :src="imgUrl" alt="" />
</a>
</div>
</template>
<script>
import {createNamespacedHelpers} from 'vuex';
const {mapState} = createNamespacedHelpers('gain');
export default {
computed: {
...mapState(['resource'])
name: 'banner',
props: {
linkUrl: {
type: String,
default: true,
},
imgUrl: {
type: String,
default: true,
},
},
methods: {
onClick() {
this.$yoho.goNewPage({
url: 'https://activity.yoho.cn/feature/5729.html?title=活动规则&openby:yohobuy={"action":"go.h5","params":{"title":"活动规则","url":"https://activity.yoho.cn/feature/5729.html"}}'
});
}
// onClick() {
// this.$yoho.goNewPage({
// url: 'https://activity.yoho.cn/feature/5729.html?title=活动规则&openby:yohobuy={"action":"go.h5","params":{"title":"活动规则","url":"https://activity.yoho.cn/feature/5729.html"}}'
// });
// }
}
};
</script>
<style lang="scss" scoped>
.banner {
font-size: 0;
padding-bottom: 20px;
background-color: #f0f0f0;
img {
position: relative;
width: 100%;
margin: 20px 0;
overflow: hidden;
.banner-image {
width: 100%;
}
.link {
position: absolute;
width: 200px;
height: 200px;
top: 0;
right: 0;
display: block;
}
}
</style>
... ...
<template>
<div class="hot" v-if="list.length > 0">
<ul>
<li v-for="(item, index) in list" :key="index" @click="goProduct">
<div class="hot-image">
<img :src="item.image_url" alt="" />
</div>
<div class="hot-name">{{item.series_name}}</div>
</li>
<li @click="goMore">
<div class="hot-image hot-more">更多</div>
<div class="hot-name">More</div>
</li>
</ul>
</div>
</template>
<script>
export default {
name: 'hot',
props: {
list: {
type: Array,
default: true,
},
},
methods: {
goProduct() {
alert('跳转列表!');
},
goMore() {
alert('跳转更多!');
}
// onClick() {
// this.$yoho.goNewPage({
// url: 'https://activity.yoho.cn/feature/5729.html?title=活动规则&openby:yohobuy={"action":"go.h5","params":{"title":"活动规则","url":"https://activity.yoho.cn/feature/5729.html"}}'
// });
// }
}
};
</script>
<style lang="scss" scoped>
.hot {
ul {
overflow: hidden;
li {
width: 25%;
float: left;
text-align: center;
margin-top: 20px;
.hot-image {
width: 150px;
height: 100px;
overflow: hidden;
margin: 0 auto;
img {
width: 100%;
height: 100%;
display: block;
}
}
.hot-name {
margin-top: 20px;
}
.hot-more {
line-height: 100px;
border: 1px solid #999;
}
}
}
}
</style>
... ...
<template>
<div class="slider" v-if="list.length > 0">
<Slide :data="list"></Slide>
</div>
</template>
<script>
import Vue from 'vue'
import { Style, Slide } from 'cube-ui';
// import { createNamespacedHelpers } from 'vuex';
// const {mapState} = createNamespacedHelpers('channel');
export default {
name: 'slide',
props: {
list: {
type: Array,
default: true
},
},
components: {
Style,
Slide
},
computed: {
// ...mapState(['resource'])
},
methods: {
}
};
</script>
<style lang="scss" scoped>
.slider {
}
</style>
... ...
<template>
<div class="twoBanner" v-if="list.length > 0">
<div class="list" v-for="(item, index) in list" :key="index">
<a :href="item.url">
<img class="banner-image" :src="item.src" :alt="item.alt" />
</a>
</div>
</div>
</template>
<script>
export default {
name: 'twoBanner',
props: {
list: {
type: Array,
default: [1,2],
},
},
methods: {
// onClick() {
// this.$yoho.goNewPage({
// url: 'https://activity.yoho.cn/feature/5729.html?title=活动规则&openby:yohobuy={"action":"go.h5","params":{"title":"活动规则","url":"https://activity.yoho.cn/feature/5729.html"}}'
// });
// }
}
};
</script>
<style lang="scss" scoped>
.twoBanner {
width: 100%;
margin: 20px 0;
overflow: hidden;
display: flex;
// align-items: center;
justify-content: space-between;
.list {
width: 48%;
img {
width: 100%;
height: 200px;
display: block;
}
}
}
</style>
... ...
... ... @@ -2,6 +2,6 @@ export default [
{
name: 'channel',
path: '/xianyu/channel',
component: () => import('./channel/channel')
component: () => import(/* webpackChunkName: "channel" */ './channel/channel')
},
];
... ...