...
|
...
|
@@ -4,6 +4,7 @@ const helpers = global.yoho.helpers; |
|
|
const utils = '../../../utils';
|
|
|
const productProcess = require(`${utils}/product-process`);
|
|
|
const service = global.yoho.ServiceAPI;
|
|
|
const co = require('bluebird').coroutine;
|
|
|
|
|
|
module.exports = class extends global.yoho.BaseModel {
|
|
|
constructor(ctx) {
|
...
|
...
|
@@ -171,14 +172,80 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
});
|
|
|
}
|
|
|
|
|
|
_getProductList(skns) {
|
|
|
return api.get('', {
|
|
|
method: 'app.search.li',
|
|
|
query: skns
|
|
|
}).then((result) => {
|
|
|
if (result && result.code === 200) {
|
|
|
return result.data;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 将商品转化成以 product_skn 为键名的对象
|
|
|
* @param {*} goodsArray
|
|
|
*/
|
|
|
_goodsArrayToObj(goodsArray) {
|
|
|
return _.keyBy(goodsArray, value => {
|
|
|
return value.product_skc;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
_getOrderGoods(token) {
|
|
|
if (!token) {
|
|
|
return;
|
|
|
}
|
|
|
return api.get('', {
|
|
|
method: 'app.SpaceOrders.getProductList',
|
|
|
order_token: token
|
|
|
}).then((result) => {
|
|
|
let self = this;
|
|
|
|
|
|
if (result && result.code === 200) {
|
|
|
let sknList = '';
|
|
|
let sknData = _.get(result, 'data.arrays', []);
|
|
|
|
|
|
_.forEach(sknData, function(val) {
|
|
|
sknList += val.product_skn + ',';
|
|
|
});
|
|
|
|
|
|
return co(function* () {
|
|
|
let orderInfo;
|
|
|
let friendsGoods = [];
|
|
|
let skcGoods;
|
|
|
|
|
|
orderInfo = yield self._getProductList(sknList);
|
|
|
|
|
|
_.forEach(_.get(orderInfo, 'product_list', []), function(data) {
|
|
|
if (data.goods_list) {
|
|
|
skcGoods = _.assign(skcGoods, self._goodsArrayToObj(data.goods_list));
|
|
|
}
|
|
|
});
|
|
|
|
|
|
_.forEach(sknData, function(val) {
|
|
|
friendsGoods.push({
|
|
|
imgSrc: _.get(skcGoods[val.product_skc], 'images_url', ''),
|
|
|
goodUrl: helpers.urlFormat(`/product/${val.product_skn}.html`, '', null),
|
|
|
});
|
|
|
});
|
|
|
|
|
|
return friendsGoods;
|
|
|
})();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 好友邀请页
|
|
|
*/
|
|
|
friendInvite(inciteCode, yhChannel, limit, page, contentCode) {
|
|
|
friendInvite(inciteCode, yhChannel, limit, page, contentCode, token) {
|
|
|
return api.all([
|
|
|
this.inviteUserInfo(inciteCode),
|
|
|
this._hotGoods(yhChannel, limit, page),
|
|
|
this._getTrendPop(contentCode)
|
|
|
this._getTrendPop(contentCode),
|
|
|
this._getOrderGoods(token)
|
|
|
]).then(result => {
|
|
|
let friendInviteData = {};
|
|
|
|
...
|
...
|
@@ -189,6 +256,11 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
inviteCode: _.get(result[0], 'data.inviteCode', '')
|
|
|
}) : '//m.yohobuy.com/reg.html';
|
|
|
|
|
|
if (token) {
|
|
|
friendInviteData.payText = true;
|
|
|
friendInviteData.friendsGoods = _.get(result, '[3]', []);
|
|
|
}
|
|
|
|
|
|
return friendInviteData;
|
|
|
});
|
|
|
}
|
...
|
...
|
|