Authored by 张孝茹

好友下单数据

@@ -100,8 +100,9 @@ exports.friendInvite = (req, res, next) => { @@ -100,8 +100,9 @@ exports.friendInvite = (req, res, next) => {
100 let isApp = req.yoho.isApp; 100 let isApp = req.yoho.isApp;
101 let inciteCode = req.query.inviteCode; 101 let inciteCode = req.query.inviteCode;
102 let contentCode = '319f92c4b072c3c40ea4cb4499b78bb4'; 102 let contentCode = '319f92c4b072c3c40ea4cb4499b78bb4';
  103 + let token = req.query.token;
103 104
104 - req.ctx(expandModel).friendInvite(inciteCode, yhChannel, limit, page, contentCode).then(result => { 105 + req.ctx(expandModel).friendInvite(inciteCode, yhChannel, limit, page, contentCode, token).then(result => {
105 res.render('expand-new/friend-invite', { 106 res.render('expand-new/friend-invite', {
106 pageHeader: headerModel.setNav({ 107 pageHeader: headerModel.setNav({
107 navTitle: '好友邀请' 108 navTitle: '好友邀请'
@@ -4,6 +4,7 @@ const helpers = global.yoho.helpers; @@ -4,6 +4,7 @@ const helpers = global.yoho.helpers;
4 const utils = '../../../utils'; 4 const utils = '../../../utils';
5 const productProcess = require(`${utils}/product-process`); 5 const productProcess = require(`${utils}/product-process`);
6 const service = global.yoho.ServiceAPI; 6 const service = global.yoho.ServiceAPI;
  7 +const co = require('bluebird').coroutine;
7 8
8 module.exports = class extends global.yoho.BaseModel { 9 module.exports = class extends global.yoho.BaseModel {
9 constructor(ctx) { 10 constructor(ctx) {
@@ -171,14 +172,71 @@ module.exports = class extends global.yoho.BaseModel { @@ -171,14 +172,71 @@ module.exports = class extends global.yoho.BaseModel {
171 }); 172 });
172 } 173 }
173 174
  175 + _getProductList(skns) {
  176 + return api.get('', {
  177 + method: 'app.search.li',
  178 + query: skns
  179 + }).then((result) => {
  180 + if (result && result.code === 200) {
  181 + return result.data;
  182 + }
  183 + });
  184 + }
  185 +
  186 + _getOrderGoods(token) {
  187 + if (!token) {
  188 + return;
  189 + }
  190 + return api.get('', {
  191 + method: 'app.SpaceOrders.getProductList',
  192 + order_token: token
  193 + }).then((result) => {
  194 + let self = this;
  195 +
  196 + if (result && result.code === 200) {
  197 + let sknList = '';
  198 + let sknData = _.get(result, 'data.arrays', []);
  199 +
  200 + // [{skn: 50015580, skc: 16641}, {skn: 51016919, skc: 106763}];
  201 +
  202 + _.forEach(sknData, function(val) {
  203 + sknList += val.skn + ',';
  204 + });
  205 +
  206 + return co(function* () {
  207 + let orderInfo;
  208 + let friendsGoods = [];
  209 +
  210 + orderInfo = yield self._getProductList(sknList);
  211 +
  212 + _.forEach(_.get(orderInfo, 'product_list', []), function(data) {
  213 + _.forEach(data.goods_list, function(val) {
  214 + _.forEach(sknData, function(list) {
  215 + if (list.skc === val.product_skc) {
  216 + friendsGoods.push({
  217 + imgSrc: val.images_url,
  218 + goodUrl: helpers.urlFormat(`/product/${list.skn}.html`, '', null),
  219 + });
  220 + }
  221 + });
  222 + });
  223 + });
  224 +
  225 + return friendsGoods;
  226 + })();
  227 + }
  228 + });
  229 + }
  230 +
174 /** 231 /**
175 * 好友邀请页 232 * 好友邀请页
176 */ 233 */
177 - friendInvite(inciteCode, yhChannel, limit, page, contentCode) { 234 + friendInvite(inciteCode, yhChannel, limit, page, contentCode, token) {
178 return api.all([ 235 return api.all([
179 this.inviteUserInfo(inciteCode), 236 this.inviteUserInfo(inciteCode),
180 this._hotGoods(yhChannel, limit, page), 237 this._hotGoods(yhChannel, limit, page),
181 - this._getTrendPop(contentCode) 238 + this._getTrendPop(contentCode),
  239 + this._getOrderGoods(token)
182 ]).then(result => { 240 ]).then(result => {
183 let friendInviteData = {}; 241 let friendInviteData = {};
184 242
@@ -189,6 +247,11 @@ module.exports = class extends global.yoho.BaseModel { @@ -189,6 +247,11 @@ module.exports = class extends global.yoho.BaseModel {
189 inviteCode: _.get(result[0], 'data.inviteCode', '') 247 inviteCode: _.get(result[0], 'data.inviteCode', '')
190 }) : '//m.yohobuy.com/reg.html'; 248 }) : '//m.yohobuy.com/reg.html';
191 249
  250 + if (token) {
  251 + friendInviteData.payText = true;
  252 + friendInviteData.friendsGoods = _.get(result, '[3]', []);
  253 + }
  254 +
192 return friendInviteData; 255 return friendInviteData;
193 }); 256 });
194 } 257 }
1 <div class="friend-invite-page yoho-page"> 1 <div class="friend-invite-page yoho-page">
2 {{# friendInviteData}} 2 {{# friendInviteData}}
3 <div class="banner"> 3 <div class="banner">
4 - <span class="title">您的好友{{nickname}}<br><b>邀请您来有货玩潮流</b></span> 4 + <span class="title">您的好友{{nickname}}<br><b>{{#if payText}}发现了好物并完成下单{{else}}邀请您来有货玩潮流{{/if}}</b></span>
5 <span class="ico-left"></span> 5 <span class="ico-left"></span>
6 <span class="ico-right"></span> 6 <span class="ico-right"></span>
  7 + {{#if friendsGoods}}
7 <div class="avatar-wrap"> 8 <div class="avatar-wrap">
8 <div class="avatar-swiper avatar"> 9 <div class="avatar-swiper avatar">
9 <ul class="clearfix swiper-wrapper"> 10 <ul class="clearfix swiper-wrapper">
  11 + {{# friendsGoods}}
10 <li class="order-good swiper-slide"> 12 <li class="order-good swiper-slide">
11 - <a href="">  
12 - <img class="" src="http://img11.static.yhbimg.com/articleTags/2016/06/21/16/012496ccd3dd8e1e11af82a3654ed8ebec.jpg?imageView2/2/w/180/h/180/q/90">  
13 - </a>  
14 - <li>  
15 - <li class="order-good swiper-slide">  
16 - <a href="">  
17 - <img class="" src="http://img11.static.yhbimg.com/articleTags/2016/06/21/16/012496ccd3dd8e1e11af82a3654ed8ebec.jpg?imageView2/2/w/180/h/180/q/90"> 13 + <a href="{{goodUrl}}">
  14 + <img class="" src="{{image imgSrc 240 320}}">
18 </a> 15 </a>
19 <li> 16 <li>
  17 + {{/ friendsGoods}}
20 </ul> 18 </ul>
21 </div> 19 </div>
22 </div> 20 </div>
  21 + {{/if}}
23 22
24 <div class="tip-text"> 23 <div class="tip-text">
25 <img src="{{image2 imgSrc w=951 h=522 q=100}}"> 24 <img src="{{image2 imgSrc w=951 h=522 q=100}}">
@@ -23,7 +23,7 @@ @@ -23,7 +23,7 @@
23 font-weight: 700; 23 font-weight: 700;
24 24
25 b { 25 b {
26 - font-size: 39px; 26 + font-size: 37px;
27 } 27 }
28 } 28 }
29 29
@@ -32,7 +32,7 @@ @@ -32,7 +32,7 @@
32 width: 99px; 32 width: 99px;
33 height: 44px; 33 height: 44px;
34 position: absolute; 34 position: absolute;
35 - left: 44px; 35 + left: 40px;
36 top: 102px; 36 top: 102px;
37 background-image: resolve("activity/expand-new/tip-left.png"); 37 background-image: resolve("activity/expand-new/tip-left.png");
38 background-size: 100%; 38 background-size: 100%;
@@ -43,7 +43,7 @@ @@ -43,7 +43,7 @@
43 width: 79px; 43 width: 79px;
44 height: 36px; 44 height: 36px;
45 position: absolute; 45 position: absolute;
46 - right: 62px; 46 + right: 60px;
47 top: 92px; 47 top: 92px;
48 background-image: resolve("activity/expand-new/tip-right.png"); 48 background-image: resolve("activity/expand-new/tip-right.png");
49 background-size: 100%; 49 background-size: 100%;
@@ -69,7 +69,6 @@ @@ -69,7 +69,6 @@
69 } 69 }
70 70
71 .avatar-wrap { 71 .avatar-wrap {
72 - height: 350px;  
73 margin: 15px 0; 72 margin: 15px 0;
74 73
75 .avatar-swiper { 74 .avatar-swiper {