Authored by 姜枫

change module

@@ -25,7 +25,7 @@ exports.newBrandList = (req, res, next) => { @@ -25,7 +25,7 @@ exports.newBrandList = (req, res, next) => {
25 }).catch(next); 25 }).catch(next);
26 }; 26 };
27 exports.getCategory = (req, res, next) => { 27 exports.getCategory = (req, res, next) => {
28 - Model.getHeaderNavAsync().then(data => { 28 + Model.getCategory().then(data => {
29 res.send(data); 29 res.send(data);
30 }).catch(next); 30 }).catch(next);
31 }; 31 };
1 'use strict'; 1 'use strict';
2 2
  3 +const platformApi = new global.yoho.ApiBase(config.domains.platformApi, {
  4 + name: 'imCs',
  5 + cache: global.yoho.cache,
  6 + useCache: false
  7 +});
3 const api = global.yoho.API; 8 const api = global.yoho.API;
4 -const serviceApi = global.yoho.ServiceAPI;  
5 9
6 const index = (req) => { 10 const index = (req) => {
7 return api.get('/platform/product/material/canlogin', { uid: req.user.uid }).then(data => { 11 return api.get('/platform/product/material/canlogin', { uid: req.user.uid }).then(data => {
@@ -21,16 +25,16 @@ const index = (req) => { @@ -21,16 +25,16 @@ const index = (req) => {
21 const newBrandList = (req) => { 25 const newBrandList = (req) => {
22 let channel = req.query.yh_channel || 1; 26 let channel = req.query.yh_channel || 1;
23 27
24 - return serviceApi.get('', { method: 'app.brand.newBrandList', yh_channel: channel });  
25 -};  
26 -const getHeaderNavAsync = () => {  
27 - return serviceApi.get('operations/api/v6/category/getCategory', {}); 28 + return api.get('', { method: 'app.brand.newBrandList', yh_channel: channel });
28 }; 29 };
29 30
  31 +const getCategory = () => {
  32 + return api.get('', {method: 'web.regular.groupsort'});
  33 +};
30 34
31 35
32 module.exports = { 36 module.exports = {
33 index, 37 index,
34 newBrandList, 38 newBrandList,
35 - getHeaderNavAsync 39 + getCategory
36 }; 40 };
1 -'use strict';  
2 -  
3 -const Model = require('../models/index');  
4 -  
5 -exports.index = (req, res, next) => {  
6 - if (req.user.uid) {  
7 - Model.index(req).then(data => {  
8 - let result = {};  
9 -  
10 - if (data.code == 200) {  
11 - result.product_list = data.data.product_list;  
12 - } else {  
13 - result.product_list = '';  
14 - }  
15 - res.render('index', Object.assign({ page: 'index', layout: false }, result));  
16 - }).catch(next);  
17 - } else {  
18 - res.send(500);  
19 - }  
20 -  
21 -};  
22 -exports.newBrandList = (req, res, next) => {  
23 - Model.newBrandList(req).then(data => {  
24 - res.send(data);  
25 - }).catch(next);  
26 -};  
27 -exports.getCategory = (req, res, next) => {  
28 - Model.getHeaderNavAsync().then(data => {  
29 - res.send(data);  
30 - }).catch(next);  
31 -};  
32 -  
33 -// exports.getIndexGuide = (req, res, next) => {  
34 -// channelModel.getIndexGuideData().then(data => {  
35 -// if (data.code !== 200) {  
36 -// const err = new Error('异常');  
37 -  
38 -// throw err;  
39 -// }  
40 -// return channelModel.formatIndexGuideData(data.data);  
41 -// }).then(data => {  
42 -// return channelModel.getResourceData(data);  
43 -// }).then(data => {  
44 -// let result = {list: data, layout: false};  
45 -  
46 -// res.render('guide', result);  
47 -// }).catch(next);  
48 -// };  
49 -  
50 -// exports.hasNewUserFloor = (req, res, next) => {  
51 -  
52 -// channelModel.hasNewUserFloor(req.yoho.channel, req.user.uid).then(data => {  
53 -// res.send(data);  
54 -// }).catch(next);  
55 -// };  
1 -var express = require('express'),  
2 - path = require('path');  
3 -  
4 -var app = express();  
5 -  
6 -// set view engin  
7 -var doraemon = path.join(__dirname, '../../doraemon/views'); // parent view root  
8 -  
9 -  
10 -app.on('mount', function(parent) {  
11 - delete parent.locals.settings; // 不继承父 App 的设置  
12 - Object.assign(app.locals, parent.locals);  
13 -});  
14 -  
15 -app.use(global.yoho.hbs({  
16 - extname: '.hbs',  
17 - defaultLayout: 'layout',  
18 - layoutsDir: doraemon,  
19 - partialsDir: [path.join(__dirname, 'views/partial')],  
20 - views: path.join(__dirname, 'views/action'),  
21 - helpers: global.yoho.helpers  
22 -}));  
23 -  
24 -// router  
25 -app.use(require('./router'));  
26 -  
27 -module.exports = app;  
1 -'use strict';  
2 -  
3 -const api = global.yoho.API;  
4 -const serviceApi = global.yoho.ServiceAPI;  
5 -  
6 -const index = (req) => {  
7 - return api.get('/platform/product/material/canlogin', { uid: req.user.uid }).then(data => {  
8 - console.log(data);  
9 - let params = {  
10 - brandId: 1,  
11 - shelveTimeBegin: '2012-02-1 09:53:10',  
12 - shelveTimeEnd: '2017-03-10 09:53:10',  
13 - page: 1  
14 - };  
15 -  
16 - return api.get('/platform/product/material/getList', Object.assign({  
17 - method: ''  
18 - }, params), { cache: true });  
19 - });  
20 -};  
21 -const newBrandList = (req) => {  
22 - let channel = req.query.yh_channel || 1;  
23 -  
24 - return serviceApi.get('', { method: 'app.brand.newBrandList', yh_channel: channel });  
25 -};  
26 -const getHeaderNavAsync = () => {  
27 - return serviceApi.get('operations/api/v6/category/getCategory', {});  
28 -};  
29 -  
30 -  
31 -  
32 -module.exports = {  
33 - index,  
34 - newBrandList,  
35 - getHeaderNavAsync  
36 -};  
1 -'use strict';  
2 -  
3 -const router = require('express').Router({ strict: true }); // eslint-disable-line  
4 -const cRoot = './controllers';  
5 -const materialController = require(`${cRoot}/index`);  
6 -  
7 -router.get('/', materialController.index);  
8 -router.get('/newBrandList', materialController.newBrandList);  
9 -router.get('/getCategory', materialController.getCategory);  
10 -  
11 -// ajax  
12 -// router.post('/common/getNewArrival', channelController.getNewArrival);  
13 -// router.get('/guide', channelController.getIndexGuide);  
14 -  
15 -module.exports = router;  
1 -<!DOCTYPE html>  
2 -<html lang="en">  
3 -  
4 -<head>  
5 - <meta charset="UTF-8">  
6 - <title>{{title}}</title>  
7 - <meta name="keywords" content="{{keywords}}">  
8 - <meta name="description" content="{{description}}"> {{#if cononicalURL}}  
9 - <link rel="cononical" href="{{cononicalURL}}" /> {{/if}}  
10 - <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">  
11 - <meta http-equiv="cleartype" content="on">  
12 - <meta name="apple-mobile-web-app-status-bar-style" content="black" />  
13 - <meta content="telephone=no" name="format-detection" />  
14 - <meta content="email=no" name="format-detection" /> {{#dnsPrefetch.hosts}}  
15 - <link rel="dns-prefetch" href="{{this}}"> {{/dnsPrefetch.hosts}}  
16 - {{#if devEnv}}  
17 - <link rel="stylesheet" href="//{{devHost}}:5002/css/index.css">  
18 - {{^}}  
19 - <link rel="stylesheet" href="//{{#isEqual cdn 'qcloud'}}qcdn.yoho.cn{{^}}cdn.yoho.cn{{/isEqual}}/yohobuy-node/{{version}}/index.css">  
20 - {{/if}}  
21 -</head>  
22 -  
23 -<body>  
24 - {{#if pageErr}} {{> 404}} {{^}}  
25 - <div class="product_material">  
26 - <h1>商品素材列表页</h1>  
27 - <div class="line">  
28 - <a id="brand"><label>品牌>>></label><span id="brand_container"></span></a>  
29 - <label for="" style="margin-left: 10px;">首次上架时间</label>  
30 - <input type="date" class="sel">  
31 - </div>  
32 - <div class="line">  
33 - <label for="">品类</label>  
34 - <select name="" id="category" class="sel">  
35 - <option value="1">品牌</option>  
36 - <option value="2">品类</option>  
37 - <option value="3">首次上架时间</option>  
38 - </select>  
39 - </div>  
40 - {{>tbl}}  
41 - </div>  
42 - {{/if}}  
43 - {{#if devEnv}}  
44 - <script src="//{{devHost}}:5002/libs.js"></script>  
45 - <script src="//{{devHost}}:5002/{{module}}.{{page}}.js"></script>  
46 - {{^}}  
47 - <script src="//{{#isEqual cdn 'qcloud'}}qcdn.yoho.cn{{^}}cdn.yoho.cn{{/isEqual}}/yohobuy-node/{{version}}/libs.js"></script>  
48 - <script src="//{{#isEqual cdn 'qcloud'}}qcdn.yoho.cn{{^}}cdn.yoho.cn{{/isEqual}}/yohobuy-node/{{version}}/{{module}}.{{page}}.js"></script>  
49 - {{> analysis}}  
50 - {{/if}}  
51 -</body>  
52 -  
53 -</html>  
1 -<table border="1" class="table">  
2 - <tr><th>skn</th><th>商品前台名称</th><th>默认图片</th><th>经典款型</th><th>风格</th><th>图案纹理</th><th>工艺元素</th></tr>  
3 - {{#each product_list}}  
4 - <tr>  
5 - <td>{{productSkn}}</td>  
6 - <td>{{productName}}</td>  
7 - <td><img src="{{picImgUrl}}" alt=""></td>  
8 - <td>{{standardVal}}</td>  
9 - <td>{{style}}</td>  
10 - <td>{{pattern}}</td>  
11 - <td>{{makeCrafts}}</td>  
12 - </tr>  
13 -  
14 - {{/each}}  
15 -</table>