Authored by 张丽霞

帮助中心

... ... @@ -4,6 +4,9 @@
* @date: 2016/07/18
*/
'use strict';
const homeModel = require('../models/index');
const _ = require('lodash');
const helpers = global.yoho.helpers;
const model = require('../models/index');
... ... @@ -13,7 +16,8 @@ const model = require('../models/index');
*/
const component = {
index: (req, res, next) => {
var uid = req.user.uid
var uid = req.user.uid;
if (!uid && req.xhr) {
return res.json({
code: 400,
... ... @@ -25,15 +29,41 @@ const component = {
var result = {
module: 'home',
page: 'index',
head_ico: uid ? "" : "",
profile_name: uid ? "James Sen" : "登录/注册",
userinfourl: uid ? "/home/mydetails" : helpers.urlFormat('/signin.html', {
head_ico: uid ? '' : '',
profile_name: uid ? 'James Sen' : '登录/注册',
userinfourl: uid ? '/home/mydetails' : helpers.urlFormat('/signin.html', {
refer: req.originalUrl
}),
}
};
res.render('index', _.merge(result, data[1]));
}).catch(next);
},
help: (req, res, next) => {
homeModel.getHelpInfo().then(helpList => {
res.render('help', {
module: 'home',
page: 'help',
helpList: helpList
});
}).catch(next);
},
helpDetail: (req, res, next) => {
var helpDetailPara = {
code: req.query.code,
caption: req.query.caption
};
homeModel.getHelpDetail(helpDetailPara).then(helpDetail => {
res.render('help-detail', {
module: 'home',
page: 'help',
helpDetail: helpDetail
});
}).catch(next);
}
};
module.exports = component;
\ No newline at end of file
module.exports = component;
... ...
'use strict';
const api = global.yoho.ServiceAPI;
const api = global.yoho.API;
const Promise = require('bluebird');
const co = Promise.coroutine;
const _ = require('lodash');
const helpers = global.yoho.helpers;
/**
* 处理用户个人详情数据
... ... @@ -12,7 +14,7 @@ const co = Promise.coroutine;
const _getUserProfileData = (uid) => {
return co(function*() {
// 调用接口获取个人详情
const data = {}
const data = {};
return data;
// return api.get('operations/api/v5/resource/get', {
... ... @@ -40,12 +42,68 @@ const _getInfoNumData = (uid) => {
product_favorite_total: 5,
brand_favorite_total: 6,
yoho_coin_num: 7
}
};
return data;
})();
}
};
exports.getUserHomeData = (uid) => {
return Promise.all([_getUserProfileData(uid), _getInfoNumData(uid)]);
}
\ No newline at end of file
};
const helpListDataProc = (helpData) => {
const formatData = [];
helpData = helpData || [];
_.forEach(helpData, (item) => {
formatData.push({
name: item.caption,
code: item.code,
url: helpers.urlFormat('/home/helpDetail', {
code: item.code,
caption: item.caption,
})
});
});
return formatData;
};
/**
* 帮助中心
*
* @param req
* @param res
* @param next
*/
let home = {
getHelpInfo(data) {
var defaultParam = {
method: 'app.help.li'
},
infoData = Object.assign(defaultParam, data);
return api.get('', infoData).then(result => {
return helpListDataProc(result.data);
});
},
getHelpDetail(data) {
var defaultParam = {
method: 'app.help.detail',
return_type: 'html'
},
detailData = Object.assign(defaultParam, data);
return api.get('', detailData).then(result => {
console.log(result);
return result;
});
}
};
module.exports = home;
... ...
... ... @@ -12,5 +12,7 @@ const home = require(cRoot);
// Your controller here
router.get('/', home.index); // 个人中心主页
router.get('/help', home.help); // 帮助中心列表页
router.get('/helpDetail', home.helpDetail); // 帮助中心详情页
module.exports = router;
\ No newline at end of file
module.exports = router;
... ...
<div class="help">
<ul>
{{# helpList}}
<li><a href="{{url}}"><span>{{ name}}</span><i class="icon num">&#xe607;</i></a></li>
{{/ helpList}}
</ul>
</div>
... ...
.help {
width: 100%;
height: auto;
overflow: hidden;
ul {
width: 100%;
height: auto;
overflow: hidden;
display: block;
border-top: 1px solid #e0e0e0;
padding-left: 0;
margin: 0;
li {
width: 100%;
height: 80px;
line-height: 84px;
overflow: hidden;
font-size: 28px;
border-bottom: 1px solid #e0e0e0;
float: right;
color: #444;
list-style: none;
&:last-of-type {
border-bottom: none;
}
a:visited {
color: #444;
}
span {
width: 90%;
height: 100%;
overflow: hidden;
float: left;
padding-left: 5%;
}
i {
color: #e0e0e0;
}
}
}
.iconfont {
color: #fff;
}
}
... ...
@import "help";
.my-page {
color: #444;
background: #f0f0f0;
a {
color: #000000;
color: #000;
}
.user-info {
display: block;
position: relative;
padding: 0 30px;
color: #000000;
color: #000;
font-size: 34px;
line-height: 138px;
height: 469px;
... ... @@ -74,7 +76,7 @@
background: #eee;
}
.read-order{
.read-order {
font-size: 30px;
}
}
... ... @@ -133,7 +135,7 @@
}
&:after {
content: '';
content: "";
position: absolute;
right: 0;
bottom: 0;
... ...