Authored by ccbikai

Merge branch 'feature/channel' into develop

'use strict';
const api = global.yoho.ServiceAPI;
const contentCode = require('../../../config/content-code');
const resourcesProcess = require('../../../utils/resources-process');
let channel = {
getResourcesData(params) {
let code;
if (params.channel) {
code = contentCode.channel[params.channel];
} else if (params.contentCode) {
code = params.contentCode;
} else {
code = contentCode.channel.men;
if (!params.contentCode) {
return Promise.resolve([]);
}
return api.get('operations/api/v5/resource/get', {
content_code: code
content_code: params.contentCode
}, {
cache: true,
code: 200
... ...
... ... @@ -13,9 +13,6 @@ const channel = require(cRoot + '/channel');
const router = expressRouter();
router.get('/', channel.index); // 首页
router.get('/men', channel.index); // 首页
router.get('/women', channel.index); // 首页
router.get('/lifestyle', channel.index); // 首页
router.get('/resources', channel.resources); // 资源位接口
module.exports = router;
... ...
<div id="app">
<tab></tab>
<resources v-bind:channel="'{{channel}}' || 'men'"></resources>
<div id="channel">
<tab v-bind:page="page"></tab>
<resources v-bind:content-code.sync="contentCode"></resources>
</div>
... ...
const Vue = require('yoho-vue');
const lazyload = require('yoho-vue-lazyload');
const qs = require('yoho-qs');
const contentCode = require('content-code');
const tab = require('channel/tab.vue');
const resources = require('channel/resources.vue');
require('common/vue-filter');
Vue.use(lazyload);
new Vue({
el: '#app',
el: '#channel',
data() {
return {
page: 'channel',
contentCode: contentCode.channel[qs.channel || 'men']
};
},
components: {
tab: tab,
resources: resources
... ...
/**
* 前端资源位配置文件
*/
'use strict';
const channel = {
men: '9ee58aadd9559d07207fe4a98843eaac',
women: 'aa8d34c85934c2ccc16e2babd3eb5e47',
lifestyle: '3ad8826fc89fb0d023a4cd06a6991219'
};
module.exports = {
channel
};
... ...
... ... @@ -27,6 +27,7 @@
const $ = require('yoho-jquery');
const tip = require('common/tip');
const bus = require('common/vue-bus');
const contentCode = require('content-code');
const focus = require('component/resources/focus.vue');
const focusLeftRight = require('component/resources/focus-left-right.vue');
... ... @@ -38,7 +39,12 @@
const dataCache = {};
module.exports = {
props: ['channel', 'contentCode'],
props: {
contentCode: {
type: String,
default: contentCode.channel.men
}
},
data() {
return {
resources: []
... ... @@ -53,9 +59,6 @@
goods
},
watch: {
channel() {
this.getResourcesData();
},
contentCode() {
this.getResourcesData();
}
... ... @@ -66,8 +69,6 @@
if (this.contentCode) {
data.contentCode = this.contentCode;
} else {
data.channel = this.channel;
}
let param = $.param(data);
... ... @@ -77,7 +78,7 @@
return;
}
$.ajax({
return $.ajax({
url: '/resources',
data: data
}).then(result => {
... ... @@ -93,8 +94,8 @@
},
created() {
this.getResourcesData();
bus.$on('changeChannel', channel => {
this.channel = channel;
bus.$on('changeChannel', (page, channel) => {
this.contentCode = contentCode[page][channel];
});
}
};
... ...
... ... @@ -10,9 +10,18 @@
const bus = require('common/vue-bus');
module.exports = {
props: {
current: {
type: Number,
default: 0
},
page: {
type: String,
default: 'channel'
},
},
data() {
return {
current: 0,
channel: [{
name: 'MEN男士',
channel: 'men'
... ... @@ -28,7 +37,7 @@
methods: {
changeChannel(index) {
this.current = index;
bus.$emit('changeChannel', this.channel[index].channel);
bus.$emit('changeChannel', this.page, this.channel[index].channel);
}
}
};
... ...
<template>
<div class="focus-left-right">
<a v-for="item in floor" href="{{item.url}}" title="{{item.title}}">
<img v-bind:src="item.src | resize 250 250">
<img v-lazy="item.src | resize 250 250">
</a>
</div>
</template>
... ...
... ... @@ -3,7 +3,7 @@
<swipe class="swipe swipe-{{floor.length}}">
<swipe-item v-for="item in floor" v-bind:style="{backgroundColor: item.bgColor}">
<a href="{{item.url}}" title="{{item.title}}">
<img v-bind:src="item.src | resize 750 365">
<img v-lazy="item.src | resize 750 365">
</a>
</swipe-item>
</swipe>
... ...
<template>
<div class="recommend-content-five">
<a v-for="item in floor" href="{{item.url}}" title="{{item.title}}">
<img v-bind:src="item.src | resize 375 375">
<img v-lazy="item.src | resize 375 375">
</a>
</div>
</template>
... ...
... ... @@ -2,7 +2,7 @@
<div class="title-image">
<title-floor v-bind:title="{name: floor.title, moreName: floor.moreName, moreUrl: floor.moreUrl}"></title-floor>
<a class="image" v-bind:href="floor.image.url">
<img v-bind:src="floor.image.src | resize 750 364">
<img v-lazy="floor.image.src | resize 750 364">
</a>
</div>
</template>
... ...