Authored by xuqi

html path

... ... @@ -6,6 +6,7 @@
var express = require('express'),
path = require('path'),
hbs = require('hbs'),
bodyParser = require('body-parser');
var logger = require('morgan'),
... ... @@ -14,8 +15,9 @@ var logger = require('morgan'),
var app = express();
app.set('views', path.join(__dirname, 'views'));
app.set('views', path.join(__dirname, 'views/action'));
app.set('view engine', 'hbs');
hbs.registerPartials(__dirname + '/views/partials');
app.use(favicon(path.join(__dirname, '/public/favicon.ico')));
app.use(logger('dev'));
... ... @@ -25,7 +27,7 @@ app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use(function(req, res, next) {
res.locals.isDevelop = app.get('env') === 'development';
res.locals.devEnv = app.get('env') === 'development';
next();
});
... ...
... ... @@ -12,7 +12,8 @@
"cookie-parser": "~1.3.5",
"debug": "~2.2.0",
"express": "~4.13.1",
"hbs": "~3.1.0",
"gulp-util": "^3.0.7",
"hbs": "^3.1.1",
"lodash": "^4.6.1",
"morgan": "~1.6.1",
"request-promise": "^2.0.1",
... ... @@ -51,6 +52,7 @@
"stylelint": "^5.2.1",
"stylelint-config-yoho": "^1.1.0",
"vinyl-named": "^1.1.0",
"webpack-stream": "^3.1.0"
"webpack": "^1.12.14",
"webpack-dev-server": "^1.14.1"
}
}
... ...
... ... @@ -10,16 +10,18 @@ var errUtil = require('../../util/error');
exports.index = (req, res) => {
// 传入参数给lotteryModel发送到后端,获取返回的数据
lotteryModel({test: 1}).then((data) => {
// lotteryModel({test: 1}).then((data) => {
// 接收接口返回到的数据,处理后,渲染页面或者返回 JSON
res.send(data);
// // 接收接口返回到的数据,处理后,渲染页面或者返回 JSON
// res.send(data);
// res.render('wxLottery/index', {
// title: '微信抽奖',
// wxLottery: data
// });
}).catch((err) => {
errUtil.webError(err, res); // 抓取 Promise 链的错误
// }).catch((err) => {
// errUtil.webError(err, res); // 抓取 Promise 链的错误
// });
res.render('wxLottery/index', {
title: '微信抽奖',
module: 'wxLottery',
version: '0.0.1'
// wxLottery: data
});
};
... ...
{
"name": "wxLottery",
"version": "0.0.1"
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{{title}}</title>
<meta name="keywords" content="{{keywords}}">
<meta name="description" content="{{description}}">
<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" />
<link rel="dns-prefetch" href="//cdn.yoho.cn">
<link rel="dns-prefetch" href="//static.yohobuy.com">
<link rel="dns-prefetch" href="//img12.static.yhbimg.com">
<link rel="dns-prefetch" href="//img13.static.yhbimg.com">
{{#if devEnv}}
<link rel="stylesheet" href="//localhost:3000/{{module}}/css/index.css">
{{^}}
<link rel="stylesheet" href="//cdn.yoho.cn/{{module}}/{{version}}/index.css">
{{/if}}
</head>
<body>
{{{body}}}
{{#if devEnv}}
<script type="text/javascript" src="//localhost:8002/index.js"></script>
{{^}}
<script type="text/javascript" src="//cdn.yoho.cn/{{module}}/{{version}}/lib.js"></script>
<script type="text/javascript" src="//cdn.yoho.cn/{{module}}/{{version}}/index.js"></script>
{{/if}}
</body>
</html>
... ...
<!DOCTYPE html>
<html>
<head>
<title>{{title}}</title>
</head>
<body>
{{{body}}}
</body>
</html>