Authored by 郭成尧

'个人中心重构'

... ... @@ -5,16 +5,18 @@
*/
'use strict';
const favoriteModel = require('../models/favorite');
// const indexModel = require('../models/index');
exports.index = (req, res, next) => {
let params = {
uid: req.user.uid || ''
};
favoriteModel.favorite(params).then(result => {
if (result) {
res.render('favorite', result);
}
}).catch(next);
// indexModel.index(params).then(result => {
// if (result) {
// res.render('index', result);
// }
// }).catch(next);
res.render('index', params);
};
... ...
... ... @@ -10,6 +10,11 @@
// const logger = global.yoho.logger;
const favApi = global.yoho.FavAPI;
/**
* 收藏数量接口
* @param params
* @returns {*|Promise.<TResult>}
*/
const favorite = (params) => {
return favApi.get('brower', {
method: 'app.favorite.getFavoriteCount',
... ... @@ -21,6 +26,15 @@ const favorite = (params) => {
});
};
/**
* 个人中心首页
* @param params
* @returns {function()}
*/
const index = (params) => {
return favorite;
};
module.exports = {
favorite
index
};
... ...
... ... @@ -10,12 +10,12 @@ const router = express.Router(); // eslint-disable-line
const cRoot = './controllers';
const personalController = require(`${cRoot}/qrcode`);
const favoriteController = require(`${cRoot}/favorite`);
const homeController = require(`${cRoot}/index`);
// 查看二维码
router.get('/QRcode/:id', personalController.QRcode);
// 收藏的商品或者品牌
router.get('/favorite', favoriteController.index);
router.get('/index', homeController.index);
module.exports = router;
... ...
... ... @@ -20,7 +20,7 @@ module.exports = {
api: 'http://testapi.yoho.cn:28078/',
service: 'http://testservice.yoho.cn:28077/',
favApi: 'http://192.168.102.206:8092/'
favApi: 'http://192.168.102.31:8092/'
},
subDomains: {
host: '.m.yohobuy.com',
... ...