Authored by ccbikai

add focus

@@ -4,16 +4,22 @@ @@ -4,16 +4,22 @@
4 * @date: 2016/05/09 4 * @date: 2016/05/09
5 */ 5 */
6 'use strict'; 6 'use strict';
  7 +const channelModel = require('../models/channel');
7 8
8 /** 9 /**
9 * 频道选择页 10 * 频道选择页
10 */ 11 */
11 const channel = { 12 const channel = {
12 - index: (req, res) => { 13 + index(req, res) {
13 res.render('index', { 14 res.render('index', {
14 module: 'channel', 15 module: 'channel',
15 page: 'home' 16 page: 'home'
16 }); 17 });
  18 + },
  19 + resources(req, res, next) {
  20 + channelModel.getResourcesData(req.yoho.channel).then(result => {
  21 + return res.json(result);
  22 + }).catch(next);
17 } 23 }
18 }; 24 };
19 25
  1 +'use strict';
  2 +const api = global.yoho.ServiceAPI;
  3 +const contentCode = require('../../../config/content-code');
  4 +const resourcesProcess = require('../../../utils/resources-process');
  5 +
  6 +let channel = {
  7 + getResourcesData(c) {
  8 + return api.get('operations/api/v5/resource/get', {
  9 + content_code: contentCode.channel[c]
  10 + }, {
  11 + cache: true,
  12 + code: 200
  13 + }).then(result => {
  14 + return resourcesProcess(result.data);
  15 + });
  16 + }
  17 +};
  18 +
  19 +module.exports = channel;
@@ -8,10 +8,11 @@ @@ -8,10 +8,11 @@
8 8
9 const expressRouter = require('express').Router; 9 const expressRouter = require('express').Router;
10 const cRoot = './controllers'; 10 const cRoot = './controllers';
11 -const channel = require(cRoot); 11 +const channel = require(cRoot + '/channel');
12 12
13 const router = expressRouter(); 13 const router = expressRouter();
14 14
15 router.get('/', channel.index); // 首页 15 router.get('/', channel.index); // 首页
  16 +router.get('/resources', channel.resources); // 资源位接口
16 17
17 module.exports = router; 18 module.exports = router;
@@ -16,7 +16,7 @@ module.exports = { @@ -16,7 +16,7 @@ module.exports = {
16 siteUrl: '//m.yohobuy.com', 16 siteUrl: '//m.yohobuy.com',
17 domains: { 17 domains: {
18 api: 'http://devapi.yoho.cn:58078/', 18 api: 'http://devapi.yoho.cn:58078/',
19 - service: 'http://devservice.yoho.cn:58077/' 19 + service: 'http://123.206.1.104:28077/'
20 }, 20 },
21 subDomains: { 21 subDomains: {
22 host: '.m.yohobuy.com', 22 host: '.m.yohobuy.com',
@@ -6,52 +6,10 @@ @@ -6,52 +6,10 @@
6 6
7 'use strict'; 7 'use strict';
8 8
9 -const saleContentCode = {  
10 - boys: {  
11 - sale: '153180b9a88c0b565848850c523bb637',  
12 - breakCode: 'd763e3f8d208cbed8f100253ea4f8946',  
13 - vip: '6b9810a442efe1e6252b134154d36769'  
14 - },  
15 - girls: {  
16 - sale: '0b2d133419a0f7c381306fd3522365e1',  
17 - breakCode: '77258d0b526c7b6e243c1419877ead4a',  
18 - vip: 'e83f3582df32b6753eed49fda236a755'  
19 - },  
20 - kids: {  
21 - sale: 'de23648d28ee1e8a3f087a9dbac506f8',  
22 - breakCode: '3f0898f1089b7bef5f3e071725c7a608',  
23 - vip: '664935745012db6e2a96a7d57f75512f'  
24 - },  
25 - lifestyle: {  
26 - sale: '01269e498ff5b07756e0733ec0e88c75',  
27 - breakCode: '0020a5762771aa16902a666c9491394e',  
28 - vip: '647f1154d30b323ff46c787fc78aef65'  
29 - } 9 +const channel = {
  10 + men: '9ee58aadd9559d07207fe4a98843eaac'
30 }; 11 };
31 12
32 -const guangContentCode = {  
33 - special: '89cc20483ee2cbc8a716dcfe2b6c7603'  
34 -};  
35 -  
36 -const channelContentCode = {  
37 - boys: '8512bf0755cc549ac323f852c9fd945d',  
38 - girls: '189b6686065dbd6755dd6906cf03c002',  
39 - kids: 'b8c1bff53d4ea60f978926d538620636',  
40 - lifestyle: '61cd852c6afcf60660196154f66a3a62',  
41 - index: '7ba9118028f9b22090b57341487567eb'  
42 -};  
43 -  
44 -const bottomBannerContentCode = {  
45 - boys: 'a2ec977c027d0cd9cdccb356ddf16b08',  
46 - girls: '8c8bd1b89a22e5895f05882e0825b493'  
47 -};  
48 -  
49 -const outletContentCode = 'c19ffa03f053f4cac3690b22c8da26b7';  
50 -  
51 module.exports = { 13 module.exports = {
52 - sale: saleContentCode,  
53 - outlet: outletContentCode,  
54 - channel: channelContentCode,  
55 - bottom: bottomBannerContentCode,  
56 - guang: guangContentCode 14 + channel
57 }; 15 };
@@ -12,7 +12,7 @@ module.exports = () => { @@ -12,7 +12,7 @@ module.exports = () => {
12 pageChannel: {}, 12 pageChannel: {},
13 yohoTitle: 'Yoho!BLK' 13 yohoTitle: 'Yoho!BLK'
14 }; 14 };
15 - const channel = req.query.channel || req.cookies._Channel || 'boys'; 15 + const channel = req.query.channel || req.cookies._Channel || 'men';
16 16
17 // 用于头部颜色控制 17 // 用于头部颜色控制
18 yoho.pageChannel[channel] = true; 18 yoho.pageChannel[channel] = true;
@@ -75,6 +75,7 @@ @@ -75,6 +75,7 @@
75 "stylelint": "^6.9.0", 75 "stylelint": "^6.9.0",
76 "stylelint-config-yoho": "1.2.5", 76 "stylelint-config-yoho": "1.2.5",
77 "vue-loader": "^8.5.3", 77 "vue-loader": "^8.5.3",
  78 + "vue-swipe": "^0.2.6",
78 "webpack": "^1.13.1", 79 "webpack": "^1.13.1",
79 "webpack-dev-server": "^1.14.1", 80 "webpack-dev-server": "^1.14.1",
80 "webpack-stream": "^3.1.0", 81 "webpack-stream": "^3.1.0",
1 <template> 1 <template>
2 <div class="resources"> 2 <div class="resources">
3 - {{message}} 3 + <template v-for="floor in resources">
  4 + <div class="focus" v-if="floor.focus">
  5 + <focus :list="floor.data"></focus>
  6 + </div>
  7 + <div class="title-image" v-if="floor.titleImage">
  8 + <title-image></title-image>
  9 + </div>
  10 + </template>
4 </div> 11 </div>
5 </template> 12 </template>
6 13
7 <script> 14 <script>
  15 + const $ = require('yoho-jquery');
  16 + const tip = require('common/tip');
  17 + const focus = require('component/resources/focus.vue');
  18 + const titleImage = require('component/resources/title-image.vue');
  19 +
8 module.exports = { 20 module.exports = {
9 data() { 21 data() {
10 return { 22 return {
11 - message: 'resources' 23 + resources: []
12 }; 24 };
  25 + },
  26 + components: {
  27 + focus: focus,
  28 + titleImage: titleImage
  29 + },
  30 + init() {
  31 + $.ajax({
  32 + url: '/resources'
  33 + }).then(result => {
  34 + this.resources = result;
  35 + }).fail(() => {
  36 + tip('网络错误');
  37 + });
13 } 38 }
14 }; 39 };
15 </script> 40 </script>
  1 +<template>
  2 + <swipe class="my-swipe">
  3 + <swipe-item v-for="item in list" class="aaaa">
  4 + <a href="{{item.url}}" title="{{item.title}}">
  5 + <img src="{{item.src}}">
  6 + </a>
  7 + </swipe-item>
  8 + </swipe>
  9 +</template>
  10 +
  11 +<script>
  12 + require('vue-swipe/dist/vue-swipe.css');
  13 + const swipe = require('vue-swipe');
  14 +
  15 + module.exports = {
  16 + props: ['list'],
  17 + components: {
  18 + swipe: swipe.Swipe,
  19 + swipeItem: swipe.SwipeItem
  20 + }
  21 + };
  22 +</script>
  23 +
  24 +<style>
  25 +
  26 +</style>
  1 +<template>
  2 + <div class="focus">
  3 + title-image
  4 + </div>
  5 +</template>
  6 +
  7 +<script>
  8 + module.exports = {
  9 + data() {
  10 + return {
  11 + message: 'resources'
  12 + };
  13 + }
  14 + };
  15 +</script>
  16 +
  17 +<style>
  18 +
  19 +</style>
@@ -58,7 +58,7 @@ module.exports = { @@ -58,7 +58,7 @@ module.exports = {
58 }] 58 }]
59 }, 59 },
60 resolve: { 60 resolve: {
61 - modulesDirectories: ['node_modules', './vue', './hbs'] 61 + modulesDirectories: ['node_modules', './vue', './hbs', './js']
62 }, 62 },
63 plugins: [ 63 plugins: [
64 new webpack.optimize.OccurenceOrderPlugin(), 64 new webpack.optimize.OccurenceOrderPlugin(),