Authored by xuqi

product detail

... ... @@ -6,7 +6,6 @@
var express = require('express'),
path = require('path'),
hbs = require('express-handlebars'),
bodyParser = require('body-parser'),
favicon = require('serve-favicon'),
cookieParser = require('cookie-parser');
... ...
/**
* 商品详情controller
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2016/5/6
*/
'use strict';
const mRoot = '../models';
// 商品详情model
const detail = require(`${mRoot}/detail`);
exports.index = (req, res) => {
var id = req.params.id;
detail({
id: id
}, (data) => {
res.render('detail');
});
};
\ No newline at end of file
... ...
/**
* sub app product
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2016/05/06
*/
var express = require('express'),
path = require('path'),
hbs = require('express-handlebars');
var app = express();
// set view engin
var doraemon = path.join(__dirname, '../../doraemon/views'); //parent view root
app.set('views', path.join(__dirname, 'views/action'));
app.engine('.hbs', hbs({
extname: '.hbs',
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: ['./views/partial', `${doraemon}/partial`],
helpers: 'helpers'
}));
// router
app.use(require('./router'));
module.exports = app;
\ No newline at end of file
... ...
/**
* 商品详情models
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2016/5/6
*/
'use strict';
const library = '../../../library';
const API = require(`${library}/api`);
const sign = require(`${library}/sign`);
var api = new API;
/**
* 详情页数据格式化
* @param origin Object 原始数据
* @return dest Object 格式化数据
*/
const introDataPkg = (origin) => {
var dest = {};
var descBo = origin.productDescBo;
var sizeBo = origin.sizeInfoBo;
// 商品信息
if (descBo) {
// 编号、颜色、性别
let sex;
switch (descBo.gender) {
case 1:
sex = '男款';
break;
case 2:
sex = '女款';
break;
default:
sex = '通用';
}
dest.description.table = [
`编号:${descBo.erpProductId}`,
`颜色:${descBo.colorName}`,
`性别:${sex}`
];
// 其余参数
for (let standard of descBo.standardBos) {
dest.description.table.push(`${standard.standardName}${standard.standardVal}`);
}
// 商品详情描述
dest.description.desc = descBo.phrase;
}
// 尺码信息
if (sizeBo) {
let gender = descBo.gender;
let boyReference = origin.productExtra.boyReference;
let girlReference = origin.productExtra.girlReference;
let reference = '参考尺码';
let showReference = false;
if (gender === 3) {
if (boyReference) {
reference = '参考尺码(男)';
} else if (girlReference) {
reference = '参考尺码(女)';
}
}
// 是否显示参考尺码
showReference = (boyReference && sizeBo.sizeBoList[0].boyReferSize) ||
(girlReference && sizeBo.sizeBoList[0].girlReferSize);
}
}
module.exports = (data, cb) => {
api.get('', sign.apiSign({
productskn: data.id,
udid: 'f528764d624db129b32c21fbca0cb8d6',
uid: '11993475',
method: 'h5.product.intro'
})).then(data => {
var dJson = JSON.parse(data);
cb(data);
});
};
\ No newline at end of file
... ...
/**
* router of sub app product
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2016/05/06
*/
'use strict';
const router = require('express').Router();
const cRoot = './controllers';
// 商品详情controller
const detail = require(`${cRoot}/detail`);
// routers
router.get('/detail/:id', detail.index);
module.exports = router;
\ No newline at end of file
... ...
hello, I am product hbs
\ No newline at end of file
... ...
... ... @@ -8,5 +8,5 @@ module.exports = app => {
// 公共服务
// 业务模块
app.use('/guang', require('./apps/guang'));
app.use('/product', require('./apps/product'));
};
... ...
... ... @@ -15,7 +15,7 @@ const sourcemaps = require('gulp-sourcemaps');
const cssnano = require('gulp-cssnano');
const webpack = require('webpack');
const webpackDevServer = require('webpack-dev-server');
const WebpackDevServer = require('webpack-dev-server');
const webpackConfig = require('./webpack.config.js');
const env = {
... ... @@ -165,7 +165,7 @@ gulp.task('webpack-dev-server', () => {
debug: true
});
new webpackDevServer(webpack(devConfig), {
new WebpackDevServer(webpack(devConfig), {
contentBase: '.',
publicPath: '//localhost:8000/',
hot: true,
... ... @@ -189,5 +189,6 @@ gulp.task('webpack', () => {
if (err) {
throw new gutil.PluginError('webpack', err);
}
gutil.log('[webpack compile]:', stats.endTime - stats.startTime, 'ms');
});
});
... ...
... ... @@ -6,17 +6,16 @@
'use strict';
const webpack = require('webpack');
const fs = require('fs');
// const webpack = require('webpack');
const path = require('path');
const _ = require('lodash');
require('shelljs/global');
const shelljs = require('shelljs');
var entries = {};
// 构建各模块子页面JS。生成规则module.page.js
ls(__dirname + '/js/**/*.page.js').forEach((f) => {
shelljs.ls(path.join(__dirname, 'js/**/*.page.js')).forEach((f) => {
var dir = _.slice(f.split('/'), -2); // [modulename, xx.page.js]
// Important
... ...