Authored by ccbikai

Merge branch 'feature/channel' into develop

1 'use strict'; 1 'use strict';
2 const api = global.yoho.ServiceAPI; 2 const api = global.yoho.ServiceAPI;
3 -const contentCode = require('../../../config/content-code');  
4 const resourcesProcess = require('../../../utils/resources-process'); 3 const resourcesProcess = require('../../../utils/resources-process');
5 4
6 let channel = { 5 let channel = {
7 getResourcesData(params) { 6 getResourcesData(params) {
8 - let code;  
9 -  
10 - if (params.channel) {  
11 - code = contentCode.channel[params.channel];  
12 - } else if (params.contentCode) {  
13 - code = params.contentCode;  
14 - } else {  
15 - code = contentCode.channel.men; 7 + if (!params.contentCode) {
  8 + return Promise.resolve([]);
16 } 9 }
17 return api.get('operations/api/v5/resource/get', { 10 return api.get('operations/api/v5/resource/get', {
18 - content_code: code 11 + content_code: params.contentCode
19 }, { 12 }, {
20 cache: true, 13 cache: true,
21 code: 200 14 code: 200
@@ -13,9 +13,6 @@ const channel = require(cRoot + '/channel'); @@ -13,9 +13,6 @@ const channel = require(cRoot + '/channel');
13 const router = expressRouter(); 13 const router = expressRouter();
14 14
15 router.get('/', channel.index); // 首页 15 router.get('/', channel.index); // 首页
16 -router.get('/men', channel.index); // 首页  
17 -router.get('/women', channel.index); // 首页  
18 -router.get('/lifestyle', channel.index); // 首页  
19 router.get('/resources', channel.resources); // 资源位接口 16 router.get('/resources', channel.resources); // 资源位接口
20 17
21 module.exports = router; 18 module.exports = router;
1 -<div id="app">  
2 - <tab></tab>  
3 - <resources v-bind:channel="'{{channel}}' || 'men'"></resources> 1 +<div id="channel">
  2 + <tab v-bind:page="page"></tab>
  3 + <resources v-bind:content-code.sync="contentCode"></resources>
4 </div> 4 </div>
1 const Vue = require('yoho-vue'); 1 const Vue = require('yoho-vue');
  2 +const lazyload = require('yoho-vue-lazyload');
  3 +const qs = require('yoho-qs');
  4 +const contentCode = require('content-code');
  5 +
2 const tab = require('channel/tab.vue'); 6 const tab = require('channel/tab.vue');
3 const resources = require('channel/resources.vue'); 7 const resources = require('channel/resources.vue');
4 8
5 require('common/vue-filter'); 9 require('common/vue-filter');
6 10
  11 +Vue.use(lazyload);
  12 +
7 new Vue({ 13 new Vue({
8 - el: '#app', 14 + el: '#channel',
  15 + data() {
  16 + return {
  17 + page: 'channel',
  18 + contentCode: contentCode.channel[qs.channel || 'men']
  19 + };
  20 + },
9 components: { 21 components: {
10 tab: tab, 22 tab: tab,
11 resources: resources 23 resources: resources
  1 +/**
  2 + * 前端资源位配置文件
  3 + */
  4 +
  5 +'use strict';
  6 +
  7 +const channel = {
  8 + men: '9ee58aadd9559d07207fe4a98843eaac',
  9 + women: 'aa8d34c85934c2ccc16e2babd3eb5e47',
  10 + lifestyle: '3ad8826fc89fb0d023a4cd06a6991219'
  11 +};
  12 +
  13 +module.exports = {
  14 + channel
  15 +};
@@ -27,6 +27,7 @@ @@ -27,6 +27,7 @@
27 const $ = require('yoho-jquery'); 27 const $ = require('yoho-jquery');
28 const tip = require('common/tip'); 28 const tip = require('common/tip');
29 const bus = require('common/vue-bus'); 29 const bus = require('common/vue-bus');
  30 + const contentCode = require('content-code');
30 31
31 const focus = require('component/resources/focus.vue'); 32 const focus = require('component/resources/focus.vue');
32 const focusLeftRight = require('component/resources/focus-left-right.vue'); 33 const focusLeftRight = require('component/resources/focus-left-right.vue');
@@ -38,7 +39,12 @@ @@ -38,7 +39,12 @@
38 const dataCache = {}; 39 const dataCache = {};
39 40
40 module.exports = { 41 module.exports = {
41 - props: ['channel', 'contentCode'], 42 + props: {
  43 + contentCode: {
  44 + type: String,
  45 + default: contentCode.channel.men
  46 + }
  47 + },
42 data() { 48 data() {
43 return { 49 return {
44 resources: [] 50 resources: []
@@ -53,9 +59,6 @@ @@ -53,9 +59,6 @@
53 goods 59 goods
54 }, 60 },
55 watch: { 61 watch: {
56 - channel() {  
57 - this.getResourcesData();  
58 - },  
59 contentCode() { 62 contentCode() {
60 this.getResourcesData(); 63 this.getResourcesData();
61 } 64 }
@@ -66,8 +69,6 @@ @@ -66,8 +69,6 @@
66 69
67 if (this.contentCode) { 70 if (this.contentCode) {
68 data.contentCode = this.contentCode; 71 data.contentCode = this.contentCode;
69 - } else {  
70 - data.channel = this.channel;  
71 } 72 }
72 73
73 let param = $.param(data); 74 let param = $.param(data);
@@ -77,7 +78,7 @@ @@ -77,7 +78,7 @@
77 return; 78 return;
78 } 79 }
79 80
80 - $.ajax({ 81 + return $.ajax({
81 url: '/resources', 82 url: '/resources',
82 data: data 83 data: data
83 }).then(result => { 84 }).then(result => {
@@ -93,8 +94,8 @@ @@ -93,8 +94,8 @@
93 }, 94 },
94 created() { 95 created() {
95 this.getResourcesData(); 96 this.getResourcesData();
96 - bus.$on('changeChannel', channel => {  
97 - this.channel = channel; 97 + bus.$on('changeChannel', (page, channel) => {
  98 + this.contentCode = contentCode[page][channel];
98 }); 99 });
99 } 100 }
100 }; 101 };
@@ -10,9 +10,18 @@ @@ -10,9 +10,18 @@
10 const bus = require('common/vue-bus'); 10 const bus = require('common/vue-bus');
11 11
12 module.exports = { 12 module.exports = {
  13 + props: {
  14 + current: {
  15 + type: Number,
  16 + default: 0
  17 + },
  18 + page: {
  19 + type: String,
  20 + default: 'channel'
  21 + },
  22 + },
13 data() { 23 data() {
14 return { 24 return {
15 - current: 0,  
16 channel: [{ 25 channel: [{
17 name: 'MEN男士', 26 name: 'MEN男士',
18 channel: 'men' 27 channel: 'men'
@@ -28,7 +37,7 @@ @@ -28,7 +37,7 @@
28 methods: { 37 methods: {
29 changeChannel(index) { 38 changeChannel(index) {
30 this.current = index; 39 this.current = index;
31 - bus.$emit('changeChannel', this.channel[index].channel); 40 + bus.$emit('changeChannel', this.page, this.channel[index].channel);
32 } 41 }
33 } 42 }
34 }; 43 };
1 <template> 1 <template>
2 <div class="focus-left-right"> 2 <div class="focus-left-right">
3 <a v-for="item in floor" href="{{item.url}}" title="{{item.title}}"> 3 <a v-for="item in floor" href="{{item.url}}" title="{{item.title}}">
4 - <img v-bind:src="item.src | resize 250 250"> 4 + <img v-lazy="item.src | resize 250 250">
5 </a> 5 </a>
6 </div> 6 </div>
7 </template> 7 </template>
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 <swipe class="swipe swipe-{{floor.length}}"> 3 <swipe class="swipe swipe-{{floor.length}}">
4 <swipe-item v-for="item in floor" v-bind:style="{backgroundColor: item.bgColor}"> 4 <swipe-item v-for="item in floor" v-bind:style="{backgroundColor: item.bgColor}">
5 <a href="{{item.url}}" title="{{item.title}}"> 5 <a href="{{item.url}}" title="{{item.title}}">
6 - <img v-bind:src="item.src | resize 750 365"> 6 + <img v-lazy="item.src | resize 750 365">
7 </a> 7 </a>
8 </swipe-item> 8 </swipe-item>
9 </swipe> 9 </swipe>
1 <template> 1 <template>
2 <div class="recommend-content-five"> 2 <div class="recommend-content-five">
3 <a v-for="item in floor" href="{{item.url}}" title="{{item.title}}"> 3 <a v-for="item in floor" href="{{item.url}}" title="{{item.title}}">
4 - <img v-bind:src="item.src | resize 375 375"> 4 + <img v-lazy="item.src | resize 375 375">
5 </a> 5 </a>
6 </div> 6 </div>
7 </template> 7 </template>
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 <div class="title-image"> 2 <div class="title-image">
3 <title-floor v-bind:title="{name: floor.title, moreName: floor.moreName, moreUrl: floor.moreUrl}"></title-floor> 3 <title-floor v-bind:title="{name: floor.title, moreName: floor.moreName, moreUrl: floor.moreUrl}"></title-floor>
4 <a class="image" v-bind:href="floor.image.url"> 4 <a class="image" v-bind:href="floor.image.url">
5 - <img v-bind:src="floor.image.src | resize 750 364"> 5 + <img v-lazy="floor.image.src | resize 750 364">
6 </a> 6 </a>
7 </div> 7 </div>
8 </template> 8 </template>