Authored by Tao

add channel

<template>
<LayoutApp :show-back="true">
<div class="scroll-app">
<div class="scroll-flex">
<div class="scroll-list-wrap">
<Scroll
ref="scroll"
... ... @@ -7,28 +8,18 @@
@pulling-up="onPullingUp">
<div class="body" ref="body">
<div v-for="(item, index) in channelList.list" :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>
<Slider :list="item.data" v-if="item.template_name == 'focus'" />
<Hot :list="item.data" v-if="item.template_name == 'hotSeries'" />
<Banner :list="item.data" v-if="item.template_name == 'single_image'" />
<TwoBanner :list="item.data" v-if="item.template_name == 'twoPicture'" />
</div>
<ScrollNav></ScrollNav>
<ProductList :list="channelList.productlist"></ProductList>
</div>
</Scroll>
</div>
</LayoutApp>
</div>
</div>
</template>
<script>
... ... @@ -52,178 +43,18 @@ export default {
},
pullUpLoad: true
},
items: [1,2,3,4,5,6,7,8,9],
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"
},
],
}
},
computed: {
...mapState(['channelList']),
},
created() {
},
mounted() {
this.fetchChannelList();
this.fetchProductList();
},
created() {
},
methods: {
...mapActions(['fetchChannelList','fetchProductList']),
... ... @@ -231,7 +62,6 @@ export default {
await this.fetchProductList();
setTimeout(() => { this.$refs.scroll.forceUpdate() }, 1000)
}
},
components: {
Slider,
... ... @@ -247,6 +77,29 @@ export default {
</script>
<style lang="scss" scoped>
.scroll-app {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
overflow: hidden;
font-size: 0.6rem;
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
flex-direction: column;
}
.scroll-flex {
-webkit-box-flex: 1;
-webkit-flex: 1;
flex: 1;
overflow: hidden;
position: relative;
}
.scroll-list-wrap {
height: 100%;
width: 100%;
... ...
<template>
<div class="banner">
<a :href="linkUrl">
<img class="banner-image" :src="imgUrl" alt="" />
</a>
<div class="banner" v-if="list.length > 0">
<ul>
<li v-for="(item, index) in list" :key="index" @click="jump(item)">
<ImageFormat :lazy="false" :src="item.src" :alt="item.alt" :width="item.width" :height="item.height" />
</li>
</ul>
</div>
</template>
... ... @@ -10,16 +12,18 @@
export default {
name: 'banner',
props: {
linkUrl: {
type: String,
default: true,
},
imgUrl: {
type: String,
list: {
type: Array,
default: true,
},
},
methods: {
jump(item) {
const { src, url } = item;
console.log(src);
console.log(url);
}
// 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"}}'
... ... @@ -32,12 +36,15 @@ export default {
<style lang="scss" scoped>
.banner {
width: 100%;
margin: 20px 0;
margin-bottom: 20px;
overflow: hidden;
.banner-image {
width: 100%;
height: 200px;
ul {
li {
img {
max-width: 100%;
display: block;
}
}
}
}
</style>
... ...
<template>
<div class="ScrollNav">
<ScrollNavBar :current="current" :labels="labels">
<ScrollNavBar :current="current" :labels="labels" @change="changeHandler">
<span slot-scope="props" @click="changeHandler(props.index)">
{{props.txt}}
</span>
... ...
<template>
<div class="slider" v-if="list.length > 0">
<Slide :data="list"></Slide>
</div>
<cube-slide ref="slide" :data="list">
<cube-slide-item v-for="(item, index) in list" :key="index" @click.native="clickHandler(item, index)">
<a :href="item.url">
<ImageFormat :lazy="false" class="item-imge" :src="item.src" :width="750" :height="200"></ImageFormat>
</a>
</cube-slide-item>
</cube-slide>
</template>
<script>
import Vue from 'vue'
import { Style, Slide } from 'cube-ui';
import ImgSize from '../../../../components/img-size';
// import { createNamespacedHelpers } from 'vuex';
// const {mapState} = createNamespacedHelpers('channel');
... ... @@ -18,9 +23,30 @@ export default {
default: true
},
},
data() {
return {
items: [
{
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-slide02.png'
},
{
url: 'http://www.didichuxing.com/',
image: '//webapp.didistatic.com/static/webapp/shield/cube-ui-examples-slide03.png'
}
]
}
},
components: {
Style,
Slide
Slide,
cubeSlide: Slide,
cubeSlideItem: Slide.Item,
ImgSize,
},
computed: {
// ...mapState(['resource'])
... ... @@ -32,7 +58,8 @@ export default {
</script>
<style lang="scss" scoped>
.slider {
.cube-slide {
width: 100%;
margin-bottom: 20px;
}
</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 class="banner" v-if="list.length > 0">
<ul>
<li v-for="(item, index) in list" :key="index" @click="jump(item)">
<ImageFormat :lazy="false" :src="item.src" :alt="item.alt" :width="200" :height="200" />
</li>
</ul>
</div>
</template>
... ... @@ -19,6 +19,11 @@ export default {
},
methods: {
jump(item) {
const { src, url } = item;
console.log(src);
console.log(url);
}
// 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"}}'
... ... @@ -29,20 +34,19 @@ export default {
</script>
<style lang="scss" scoped>
.twoBanner {
.banner {
width: 100%;
margin: 20px 0;
overflow: hidden;
ul {
display: flex;
// align-items: center;
justify-content: space-between;
.list {
width: 48%;
li {
width: 50%;
img {
width: 100%;
height: 200px;
max-width: 100%;
display: block;
}
}
}
}
</style>
... ...
... ... @@ -51,7 +51,8 @@ export default function() {
async fetchChannelList({ commit }) {
const result = await this.$api.get('/api/ufo/channel/channelList', {
content_code: '9cb6138be8e60c96f48107da481816c3',
uid: '64668089',
// uid: '64668089',
uid: '500031170',
});
if (result.code === 200) {
commit(Types.FETCH_CHANNEL, { list: result.data });
... ...