Authored by 姜枫

change module

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