Authored by shijian

save

'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
... ...
... ... @@ -16,11 +16,14 @@ module.exports = app => {
app.use(require('./apps/passport')); // 登录注册
app.use('/home', require('./apps/home')); // 会员中心
app.use(require('./apps/brands')); // 品牌一览
app.use('/guang', require('./apps/guang')); // 逛
app.use('/cart', require('./apps/cart'));// 购物车
app.use('/help', require('./apps/help'));// 帮助中心
app.use('/guang', require('./apps/guang')); // 逛
app.use('/cart', require('./apps/cart')); // 购物车
app.use('/help', require('./apps/help')); // 帮助中心
// 第三方,如广告联盟
app.use('/3party', require('./apps/3party'));
app.use('/service', require('./apps/service'));// 客服
app.use('/service', require('./apps/service')); // 客服
// 商品素材
app.use('/material', require('./apps/material'));
};
... ...
<div class="nav">
<span {{#if list.focus1}}class="focus"{{/if}} yh_channel="1" _index="1">男生</span>
<span {{#if list.focus2}}class="focus"{{/if}} yh_channel="2" _index="2">女生</span>
<span {{#if list.focus3}}class="focus"{{/if}} yh_channel="3" _index="3">潮童</span>
<span {{#if list.focus4}}class="focus"{{/if}} yh_channel="4" _index="4">创意生活</span>
</div>
{{#each list}}
<div class="title">{{name}}</div>
<div class="content">{{#each content}}{{#if brand_name_cn}}<span class="item">{{brand_name_cn}}</span>{{/if}}{{/each}}</div>
{{/each}}
\ No newline at end of file
... ...
var $ = require('yoho-jquery');
const brand_tmp = require('hbs/material/brand.hbs');
$('#filter').on('change', () => {
if ($('#filter').find('option:selected').attr('value') == 3) {
$('.date').show();
}
});
/* 品牌点击*/
$('#brand label').on('click', () => {
if ($('#brand_container').css('display') == 'none') {
$('#brand_container').css('display', 'block');
} else {
$('#brand_container').hide();
}
});
$(document).on('click', '#brand_container .nav span', function() {
$('#brand_container .nav span').removeClass('focus');
$(this).addClass('focus');
let yh_channel = $(this).attr('yh_channel');
getBrandList($(this).attr('_index'), yh_channel);
});
/* 获取品牌数据*/
function getBrandList(_index, yh_channel) {
$.get('/material/newBrandList?yh_channel=' + yh_channel, data => {
let list = [];
list = Object.keys(data.data.all_list).map(item => {
return { name: item, content: data.data.all_list[item] };
});
list['focus' + _index] = true;
$('#brand_container').html(brand_tmp({ list }));
});
}
getBrandList(1, 1);
/* 获取品类数据*/
$.get('/material/getCategory', data => {
console.log(data);
});
\ No newline at end of file
... ...
@charset "utf-8";
/* 公共 */
@import "common/index";
@import "plugin/index";
@import "common/dialog";
... ... @@ -8,6 +9,7 @@
@import "path-nav";
/* 模块 */
@import 'help/index';
@import "channel/index";
@import "product/index";
... ... @@ -15,6 +17,9 @@
@import "share";
@import 'home/index';
@import 'guang/index';
/*@import 'cart/index';*/
@import 'service/index';
@import '3party/index';
@import 'material/index';
\ No newline at end of file
... ...
.product_material {
width: 1200px;
margin: auto;
h1 {
font-size: 30px;
margin: 15px 0 50px;
text-align: center;
}
/*过滤*/
.line {
width: 1200px;
margin: 10px auto;
}
.sel {
width: 150px;
vertical-align: middle;
}
label,
a {
vertical-align: middle;
}
/*品牌*/
#brand {
position: relative;
label {
cursor: pointer
}
#brand_container {
position: absolute;
width: 1200px;
background: #ccc;
z-index: 1;
display: none;
.nav {
overflow: hidden;
span {
display: inline-block;
width: 25%;
text-align: center;
height: 30px;
line-height: 30px;
cursor: pointer;
float: left;
}
.focus {
background: #eee;
}
}
.title {
padding: 5px 0;
background: #555;
color: #fff;
text-align: center;
}
.content {
background: #fff;
}
.item {
display: inline-block;
width: 10%;
padding: 5px 0;
text-align: center;
height: 20px;
line-height: 20px;
font-size: 12px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
&:hover {
background: #eee;
cursor: pointer;
}
}
}
}
/*表格*/
table {
width: 1200px;
margin: 20px auto;
}
table {
table-layout: fixed;
empty-cells: show;
border-collapse: collapse;
img {
width: 80px;
}
}
td {
height: 30px;
}
.table {
border: 1px solid #cad9ea;
color: #666;
}
.table th {
background-repeat: repeat-x;
height: 30px;
}
.table td,
.table th {
border: 1px solid #cad9ea;
padding: 0 1em 0;
}
.table tr.alter {
background-color: #f5fafe;
}
}
\ No newline at end of file
... ...