Authored by ccbikai

channel 自定义

... ... @@ -19,6 +19,11 @@ module.exports = {
channel: channel
});
},
channel(req, res, next) {
channelModel.getChannelData().then(result => {
return res.json(result);
}).catch(next);
},
resources(req, res, next) {
channelModel.getResourcesData(req.query).then(result => {
return res.json(result);
... ...
... ... @@ -40,6 +40,14 @@ let channel = {
return result.data ? processProductList(result.data.product_list) : [];
});
},
getChannelData() {
return api.get('', {
method: 'app.blk.getAllChannels'
}, {
cache: true,
code: 200
}).then(global.yoho.camelCase);
}
};
module.exports = channel;
... ...
... ... @@ -14,6 +14,7 @@ const brand = require(cRoot + '/brand');
const router = expressRouter();
router.get('/', channel.index); // 首页
router.get('/channel/channel.json', channel.channel); // 查询所有频道
router.get('/channel/resources.json', channel.resources); // 资源位接口
router.get('/channel/goods.json', channel.goods); // 首页查询商品列表
router.get('/brand', brand.index); // 店铺首页
... ...
<template>
<div class="channel-tab">
<div v-if="channel.length" class="channel-tab">
<a v-for="(index, item) in channel" v-bind:class="{focus: index === current}" v-on:click.prevent="changeChannel(index)" href="/{{item.channel}}">
<span class="name">{{item.name | uppercase}}</span>
</a>
... ... @@ -22,18 +22,29 @@
},
data() {
return {
channel: [{
name: 'MEN男士',
channel: 'men'
}, {
name: 'WOMEN女士',
channel: 'women'
}, {
name: 'LIFESTYLE生活',
channel: 'lifestyle'
}]
channel: []
};
},
created() {
$.ajax({
url: '/channel/channel.json'
}).then(res => {
const channelMap = {};
if (res.code === 200) {
const channel = [];
res.data.forEach(c => {
channel.push[{
name: c.channelName,
channel: channelMap[c.channeId] || ''
}];
});
this.channel = channel;
}
});
},
methods: {
changeChannel(index) {
this.current = index;
... ...