Authored by 周少峰

foramt

... ... @@ -193,7 +193,9 @@ module.exports = class extends global.yoho.BaseModel {
// 个人中心首页 异步获取新品上架数据
async newArrive() {
let arriveCaceKey = `${cachePreKey}arrive`;
let arrive = await cache.get(arriveCaceKey).catch(() => {return {}});
let arrive = await cache.get(arriveCaceKey).catch(() => {
return {};
});
if (_.isEmpty(arrive)) {
let arriveOrigin = await new IndexApi(this.ctx).newArrival();
... ... @@ -212,7 +214,9 @@ module.exports = class extends global.yoho.BaseModel {
// 推荐数据
async recommend(uid, udid, channelNum) {
let recommendCaceKey = `${cachePreKey}recommend`;
let recommend = await cache.get(recommendCaceKey).catch(() => {return {}});
let recommend = await cache.get(recommendCaceKey).catch(() => {
return {};
});
if (_.isEmpty(recommend)) {
let recommendOrigin = await new IndexApi(this.ctx).recommend(channelNum, uid, udid, '100004', 30);
... ... @@ -231,7 +235,9 @@ module.exports = class extends global.yoho.BaseModel {
// 个人中心首页 异步获取品牌数据
async brands() {
let brandsCaceKey = `${cachePreKey}brands`;
let brand = await cache.get(brandsCaceKey).catch(() => {return {}});
let brand = await cache.get(brandsCaceKey).catch(() => {
return {};
});
if (_.isEmpty(brand)) {
let brandOrigin = await new IndexApi(this.ctx).guessBrand();
... ... @@ -254,7 +260,9 @@ module.exports = class extends global.yoho.BaseModel {
profile: new UserApi(this.ctx).getUserInfo(uid),
msg: new MsgApi(this.ctx).unreadTotal(uid)
}
).catch(() => {return {}});
).catch(() => {
return {};
});
let avatar = helpers.image(_.get(result, 'profile.data.head_ico', ''), 100, 100) || defaultAvatar;
let msgCount = _.get(result, 'msg.data.total', 0);
... ... @@ -268,7 +276,9 @@ module.exports = class extends global.yoho.BaseModel {
pending: new IndexApi(this.ctx).pendingOrderCount(uid), // 待处理订单
unread: new IndexApi(this.ctx).unreadMessageCount(uid, udid), // 未读消息
needComment: new IndexApi(this.ctx).needCommentCount(uid) // 待评论商品
}).catch(() => {return {}});
}).catch(() => {
return {};
});
result[numbersKey.pending] = _.get(numbers, 'pending.data.count', 0);
result[numbersKey.unread] = _.get(numbers, 'unread.data.inbox_total', 0);
... ... @@ -285,7 +295,9 @@ module.exports = class extends global.yoho.BaseModel {
recentOrder: this._recentOrder(uid),
footerBanner: this._footerBanner(),
reason: this._cancelReason()
}).catch(() => {return {}});
}).catch(() => {
return {};
});
return Object.assign(
{
... ...