Showing
12 changed files
with
473 additions
and
294 deletions
@@ -13,14 +13,7 @@ const _ = require('lodash'); | @@ -13,14 +13,7 @@ const _ = require('lodash'); | ||
13 | const myCurrency = (req, res, next) => { | 13 | const myCurrency = (req, res, next) => { |
14 | let uid = req.user.uid || 8039759; | 14 | let uid = req.user.uid || 8039759; |
15 | let contentCode = '05afedf76886d732573f10f7451a1703'; | 15 | let contentCode = '05afedf76886d732573f10f7451a1703'; |
16 | - let gender = req.query.gender || '1,3'; | ||
17 | - let lifestyleHomePage = ''; | ||
18 | - | ||
19 | - if (gender === '3,3') { | ||
20 | - lifestyleHomePage = true; | ||
21 | - } else { | ||
22 | - lifestyleHomePage = false; | ||
23 | - } | 16 | + // let gender = req.query.gender || '3,3'; |
24 | 17 | ||
25 | myCurrencyModel.myCurrency(uid, contentCode).then(result => { | 18 | myCurrencyModel.myCurrency(uid, contentCode).then(result => { |
26 | 19 | ||
@@ -36,8 +29,7 @@ const myCurrency = (req, res, next) => { | @@ -36,8 +29,7 @@ const myCurrency = (req, res, next) => { | ||
36 | title: '有货币', | 29 | title: '有货币', |
37 | pageFooter: true, | 30 | pageFooter: true, |
38 | yohoCoin: result.yohoCoin, | 31 | yohoCoin: result.yohoCoin, |
39 | - banner: result.banner, | ||
40 | - lifestyleHomePage: lifestyleHomePage | 32 | + banner: result.banner |
41 | }); | 33 | }); |
42 | }).catch(next); | 34 | }).catch(next); |
43 | }; | 35 | }; |
@@ -25,7 +25,6 @@ const bannerData = (contentCode) => { | @@ -25,7 +25,6 @@ const bannerData = (contentCode) => { | ||
25 | return serviceAPI.get('operations/api/v5/resource/get', { | 25 | return serviceAPI.get('operations/api/v5/resource/get', { |
26 | content_code: contentCode | 26 | content_code: contentCode |
27 | }).then((result) => { | 27 | }).then((result) => { |
28 | - // console.log(result) | ||
29 | 28 | ||
30 | if (result && result.code === 200) { | 29 | if (result && result.code === 200) { |
31 | 30 | ||
@@ -60,16 +59,16 @@ const currencyDetail = (uid, page, limit) => { | @@ -60,16 +59,16 @@ const currencyDetail = (uid, page, limit) => { | ||
60 | if (result && result.code === 200) { | 59 | if (result && result.code === 200) { |
61 | let total = parseInt(result.data.page_total, 10) + 1; | 60 | let total = parseInt(result.data.page_total, 10) + 1; |
62 | 61 | ||
63 | - if (page && page < total) { | 62 | + if (page && page <= total) { |
64 | return yohoCoin(uid).then(list => { | 63 | return yohoCoin(uid).then(list => { |
65 | 64 | ||
66 | - if (list.yohocoinNum && list.yohocoinNum === 0) { | 65 | + if (list.yohocoinNum && list.yohocoinNum !== 0) { |
67 | result.data = _.assign(result.data, { | 66 | result.data = _.assign(result.data, { |
68 | - money: false | 67 | + money: true |
69 | }); | 68 | }); |
70 | } else { | 69 | } else { |
71 | result.data = _.assign(result.data, { | 70 | result.data = _.assign(result.data, { |
72 | - money: true | 71 | + money: false |
73 | }); | 72 | }); |
74 | } | 73 | } |
75 | 74 | ||
@@ -86,25 +85,9 @@ const currencyDetail = (uid, page, limit) => { | @@ -86,25 +85,9 @@ const currencyDetail = (uid, page, limit) => { | ||
86 | }); | 85 | }); |
87 | }; | 86 | }; |
88 | 87 | ||
89 | -// const mayLike = (uid, page, limit, udid, gender, recPos, channel) => { | ||
90 | -// return api.get('', { | ||
91 | -// method: 'app.search.newLast7day', | ||
92 | -// uid: uid, | ||
93 | -// page: page, | ||
94 | -// limit: limit, | ||
95 | -// udid: udid, | ||
96 | -// rec_pos: recPos, | ||
97 | -// yh_channel: channel | ||
98 | -// }).then((result) => { | ||
99 | -// console.log(result); | ||
100 | -// }); | ||
101 | -// }; | ||
102 | - | ||
103 | module.exports = { | 88 | module.exports = { |
104 | myCurrency, | 89 | myCurrency, |
105 | currencyDetail, | 90 | currencyDetail, |
106 | bannerData, | 91 | bannerData, |
107 | yohoCoin | 92 | yohoCoin |
108 | - | ||
109 | - // mayLike | ||
110 | }; | 93 | }; |
@@ -18,18 +18,16 @@ | @@ -18,18 +18,16 @@ | ||
18 | {{/ yohoCoin}} | 18 | {{/ yohoCoin}} |
19 | </div> | 19 | </div> |
20 | <div class="banner"> | 20 | <div class="banner"> |
21 | - {{#banner}} | ||
22 | - {{#data}} | 21 | + {{# banner}} |
22 | + {{# data}} | ||
23 | <a href="{{url}}"> | 23 | <a href="{{url}}"> |
24 | <img src="{{image src 640 200 2}}" alt="img"> | 24 | <img src="{{image src 640 200 2}}" alt="img"> |
25 | </a> | 25 | </a> |
26 | - {{/data}} | ||
27 | - {{/banner}} | 26 | + {{/ data}} |
27 | + {{/ banner}} | ||
28 | </div> | 28 | </div> |
29 | 29 | ||
30 | - {{#if lifestyleHomePage}} | ||
31 | - {{> home/maybe-like-lifestyle}} | ||
32 | - {{else}} | 30 | + |
33 | {{> home/maybe-like}} | 31 | {{> home/maybe-like}} |
34 | - {{/if}} | 32 | + |
35 | </div> | 33 | </div> |
@@ -4,24 +4,55 @@ const mRoot = '../models'; | @@ -4,24 +4,55 @@ const mRoot = '../models'; | ||
4 | const headerModel = require('../../../doraemon/models/header'); // 头部model | 4 | const headerModel = require('../../../doraemon/models/header'); // 头部model |
5 | const mayLikeModel = require('../models/recom'); | 5 | const mayLikeModel = require('../models/recom'); |
6 | 6 | ||
7 | +/** | ||
8 | +* 你可能喜欢的BOYS或GIRLS的商品列表 | ||
9 | +*/ | ||
10 | + | ||
7 | const mayLike = (req, res, next) => { | 11 | const mayLike = (req, res, next) => { |
8 | let uid = req.user.uid || 8039759; | 12 | let uid = req.user.uid || 8039759; |
9 | - let page = req.body.page || 1; | 13 | + let page = req.query.page || 1; |
10 | let limit = 50; | 14 | let limit = 50; |
11 | - let gender = req.query.gender || '1,3'; | 15 | + let gender = req.query.gender || '2,3'; |
12 | let udid = req.sessionID || 'yoho'; | 16 | let udid = req.sessionID || 'yoho'; |
13 | let recPos = 100009; | 17 | let recPos = 100009; |
14 | let channel = req.query.channel || 1; | 18 | let channel = req.query.channel || 1; |
15 | 19 | ||
20 | + if (channel === 1 || channel === 2) { | ||
16 | mayLikeModel.mayLike(uid, page, limit, gender, udid, recPos, channel).then((result) => { | 21 | mayLikeModel.mayLike(uid, page, limit, gender, udid, recPos, channel).then((result) => { |
22 | + console.log(recPos); | ||
23 | + | ||
24 | + res.render('recom/goods', Object.assign({ | ||
25 | + layout: false | ||
26 | + }, result)); | ||
27 | + }).catch(next); | ||
28 | + } else if (channel === 4) { | ||
29 | + recPos = 100001; | ||
17 | 30 | ||
18 | - // res.render('../common/goods', { | ||
19 | - // layout: false | ||
20 | - // }); | 31 | + mayLikeModel.mayLike(uid, page, limit, gender, udid, recPos, channel).then((result) => { |
32 | + res.render('recom/goods', Object.assign({ | ||
33 | + layout: false | ||
34 | + }, result)); | ||
21 | }).catch(next); | 35 | }).catch(next); |
36 | + } | ||
22 | }; | 37 | }; |
23 | 38 | ||
39 | +/** | ||
40 | +* 你可能喜欢的潮童的商品列表 | ||
41 | +*/ | ||
42 | +const mayLikeKids = (req, res, next) => { | ||
43 | + let page = req.body.page || 1; | ||
44 | + let limit = 50; | ||
45 | + let channel = req.query.channel || 3; | ||
46 | + | ||
47 | + mayLikeModel.mayLikeKids(page, limit, channel).then((result) => { | ||
48 | + | ||
49 | + res.render('recom/goods', Object.assign({ | ||
50 | + layout: false | ||
51 | + }, result)); | ||
52 | + }).catch(next); | ||
53 | +}; | ||
24 | 54 | ||
25 | module.exports = { | 55 | module.exports = { |
26 | - mayLike | 56 | + mayLike, |
57 | + mayLikeKids | ||
27 | }; | 58 | }; |
1 | 'use strict'; | 1 | 'use strict'; |
2 | 2 | ||
3 | -const serviceAPI = global.yoho.ServiceAPI; | ||
4 | const api = global.yoho.API; | 3 | const api = global.yoho.API; |
5 | const _ = require('lodash'); | 4 | const _ = require('lodash'); |
6 | const camelCase = global.yoho.camelCase; | 5 | const camelCase = global.yoho.camelCase; |
7 | const logger = global.yoho.logger; | 6 | const logger = global.yoho.logger; |
8 | 7 | ||
8 | +const formatProduct = (list) => { | ||
9 | + | ||
10 | + list = list || []; | ||
11 | + list = camelCase(list); | ||
12 | + | ||
13 | + _.forEach(list, function(val) { | ||
14 | + let tag = []; | ||
15 | + | ||
16 | + if (val.isSoonSoldOut) { | ||
17 | + val.isSoonSoldOut = val.isSoonSoldOut === 'Y'; | ||
18 | + } | ||
19 | + | ||
20 | + tag.push({ | ||
21 | + isNew: val.isNew === 'Y', | ||
22 | + isDiscount: val.isDiscount === 'Y', | ||
23 | + isLimited: val.isLimited === 'Y', | ||
24 | + isYohood: val.isYohood === 'Y', | ||
25 | + isAdvance: val.isAdvance === 'Y' | ||
26 | + }); | ||
27 | + | ||
28 | + | ||
29 | + _.forEach(tag, function(data) { | ||
30 | + | ||
31 | + if (data.isDiscount === true && val.isSoonSoldOut === true) { | ||
32 | + data.isNew = true; | ||
33 | + data.isDiscount = false; | ||
34 | + } else if (data.isDiscount === true && (data.isNew === true || data.isLimited === true || data.isYohood === true || data.isAdvance === true)) { | ||
35 | + data.isDiscount = false; | ||
36 | + } else if (data.isYohood === true && data.isNew === true) { | ||
37 | + data.isNew = false; | ||
38 | + } | ||
39 | + }); | ||
40 | + | ||
41 | + val.tags = tag; | ||
42 | + }); | ||
43 | + | ||
44 | + | ||
45 | + return list; | ||
46 | +}; | ||
47 | + | ||
9 | const mayLike = (uid, page, limit, gender, udid, recPos, channel) => { | 48 | const mayLike = (uid, page, limit, gender, udid, recPos, channel) => { |
10 | return api.get('', { | 49 | return api.get('', { |
11 | method: 'app.search.newLast7day', | 50 | method: 'app.search.newLast7day', |
@@ -16,10 +55,50 @@ const mayLike = (uid, page, limit, gender, udid, recPos, channel) => { | @@ -16,10 +55,50 @@ const mayLike = (uid, page, limit, gender, udid, recPos, channel) => { | ||
16 | rec_pos: recPos, | 55 | rec_pos: recPos, |
17 | yh_channel: channel | 56 | yh_channel: channel |
18 | }).then((result) => { | 57 | }).then((result) => { |
19 | - // console.log(result); | 58 | + |
59 | + if (result && result.code === 200) { | ||
60 | + | ||
61 | + if (page > result.data.page_total) { | ||
62 | + return; | ||
63 | + } | ||
64 | + | ||
65 | + if (result.data.product_list) { | ||
66 | + | ||
67 | + return formatProduct(result.data.product_list); | ||
68 | + | ||
69 | + } | ||
70 | + } else { | ||
71 | + logger.error('mayLike cood 不是 200'); | ||
72 | + } | ||
73 | + }); | ||
74 | +}; | ||
75 | + | ||
76 | +const mayLikeKids = (page, limit, channel) => { | ||
77 | + return api.get('', { | ||
78 | + method: 'app.search.kids', | ||
79 | + page: page, | ||
80 | + limit: limit, | ||
81 | + yh_channel: channel | ||
82 | + }).then((result) => { | ||
83 | + | ||
84 | + if (result && result.code === 200) { | ||
85 | + | ||
86 | + if (page > result.data.page_total) { | ||
87 | + return; | ||
88 | + } | ||
89 | + | ||
90 | + if (result.data.product_list) { | ||
91 | + | ||
92 | + return formatProduct(result.data.product_list); | ||
93 | + | ||
94 | + } | ||
95 | + } else { | ||
96 | + logger.error('mayLikeKids cood 不是 200'); | ||
97 | + } | ||
20 | }); | 98 | }); |
21 | }; | 99 | }; |
22 | 100 | ||
23 | module.exports = { | 101 | module.exports = { |
24 | - mayLike | 102 | + mayLike, |
103 | + mayLikeKids | ||
25 | }; | 104 | }; |
@@ -38,6 +38,8 @@ router.get('/detail/consultform', auth, detail.consultform); // 商å“咨询表å | @@ -38,6 +38,8 @@ router.get('/detail/consultform', auth, detail.consultform); // 商å“咨询表å | ||
38 | router.get('/detail/comments', detail.comments); | 38 | router.get('/detail/comments', detail.comments); |
39 | router.post('/detail/consultsubmit', auth, detail.consultsubmit); // 商品咨询提交接口 | 39 | router.post('/detail/consultsubmit', auth, detail.consultsubmit); // 商品咨询提交接口 |
40 | router.get('/recom/maylike', recom.mayLike);// 你可能喜欢 | 40 | router.get('/recom/maylike', recom.mayLike);// 你可能喜欢 |
41 | +router.get('/recom/maylikekids', recom.mayLikeKids); // 潮童你可能喜欢 | ||
42 | +// router.get('/recom/maylikelife', recom.mayLikeLifestyle); // 创意生活你可能喜欢 | ||
41 | 43 | ||
42 | router.get('/sale', sale.index); | 44 | router.get('/sale', sale.index); |
43 | router.get('/sale/discount', sale.discount); | 45 | router.get('/sale/discount', sale.discount); |
apps/product/views/action/recom/goods.hbs
0 → 100644
1 | +{{#if this}} {{!-- 剔除值为false的项 --}} | ||
2 | + {{#each this}} | ||
3 | + <div class="good-info {{#if @root.saleViplogin}}sale-vip{{/if}}" data-id="{{productSkn}}" data-bp-id="guang_goodList_{{productName}}_false"> | ||
4 | + <div class="tag-container clearfix"> | ||
5 | + {{#each tags}} | ||
6 | + {{#if isNew}} | ||
7 | + <p class="good-tag new-tag">NEW</p> | ||
8 | + {{/if}} | ||
9 | + {{#if isAdvance}} | ||
10 | + <p class="good-tag renew-tag">再到着</p> | ||
11 | + {{/if}} | ||
12 | + {{#if isDiscount}} | ||
13 | + <p class="good-tag sale-tag">SALE</p> | ||
14 | + {{/if}} | ||
15 | + {{#if isYohoood}} | ||
16 | + <p class="good-tag running-man-tag">跑男同款</p> | ||
17 | + {{/if}} | ||
18 | + {{#if isLimited}} | ||
19 | + <p class="good-tag limit-tag">限量商品</p> | ||
20 | + {{/if}} | ||
21 | + {{/each}} | ||
22 | + </div> | ||
23 | + <div class="good-detail-img"> | ||
24 | + <a class="good-thumb" href="{{url}}"> | ||
25 | + <img class="lazy" data-original="{{image defaultImages 235 314}}"> | ||
26 | + </a> | ||
27 | + {{!-- {{log isSoonSoldOut}} --}} | ||
28 | + {{#if isSoonSoldOut}} | ||
29 | + <p class="few-tag">即将售罄</p> | ||
30 | + {{/if}} | ||
31 | + | ||
32 | + {{#if noStorage}} | ||
33 | + <div class="no-storage"> | ||
34 | + <div class="no-storage-img"></div> | ||
35 | + </div> | ||
36 | + {{/if}} | ||
37 | + </div> | ||
38 | + <div class="good-detail-text"> | ||
39 | + <div class="name"> | ||
40 | + <a href="{{url}}">{{productName}}</a> | ||
41 | + </div> | ||
42 | + <div class="price"> | ||
43 | + {{#if @root.saleViplogin}} | ||
44 | + <i class="vip-grade vip-grade-{{@root.vipLevel}}"></i> | ||
45 | + <span class="sale-price {{^marketPrice}}no-price{{/marketPrice}}">¥ | ||
46 | + {{#if @root.vipPrice1}}{{round vip1Price}}{{/if}} | ||
47 | + {{#if @root.vipPrice2}}{{round vip2Price}}{{/if}} | ||
48 | + {{#if @root.vipPrice3}}{{round vip3Price}}{{/if}} | ||
49 | + </span> | ||
50 | + {{else}} | ||
51 | + <span class="sale-price {{^marketPrice}}no-price{{/marketPrice}}">¥{{round salesPrice}}</span> | ||
52 | + {{/if}} | ||
53 | + {{#marketPrice}} | ||
54 | + <span class="market-price">¥{{round .}}</span> | ||
55 | + {{/marketPrice}} | ||
56 | + </div> | ||
57 | + {{#if @root.saleVip}} | ||
58 | + <div class="vip-info"> | ||
59 | + <i class="vip-icon"></i>更优惠 | ||
60 | + </div> | ||
61 | + {{/if}} | ||
62 | + </div> | ||
63 | + </div> | ||
64 | + {{/each}} | ||
65 | +{{/if}} |
1 | +<div class="maybe-like"> | ||
2 | + <ul id="maybe-like-nav" class="maybe-like-nav clearfix"> | ||
3 | + <li class="maybe-like-nav-item focus">新品到着</li> | ||
4 | + <li class="maybe-like-nav-item">人气单品</li> | ||
5 | + </ul> | ||
6 | + | ||
7 | + <div id="goods-list"> | ||
8 | + {{# goodsContainer}} | ||
9 | + <div class="goods-list {{^show}}hide{{/show}}"> | ||
10 | + {{# goods}} | ||
11 | + {{> goods}} | ||
12 | + {{/ goods}} | ||
13 | + </div> | ||
14 | + {{/ goodsContainer}} | ||
15 | + </div> | ||
16 | + | ||
17 | + <div id="load-more-info" class="load-more-info"> | ||
18 | + <div class="loading status hide"> | ||
19 | + 正在加载... | ||
20 | + </div> | ||
21 | + <span class="no-more status hide">没有更多啦</span> | ||
22 | + </div> | ||
23 | +</div> |
1 | {{#if this}} {{!-- 剔除值为false的项 --}} | 1 | {{#if this}} {{!-- 剔除值为false的项 --}} |
2 | + {{#each this}} | ||
2 | <div class="good-info {{#if @root.saleViplogin}}sale-vip{{/if}}" data-id="{{productSkn}}" data-bp-id="guang_goodList_{{productName}}_false"> | 3 | <div class="good-info {{#if @root.saleViplogin}}sale-vip{{/if}}" data-id="{{productSkn}}" data-bp-id="guang_goodList_{{productName}}_false"> |
3 | <div class="tag-container clearfix"> | 4 | <div class="tag-container clearfix"> |
4 | {{# tags}} | 5 | {{# tags}} |
@@ -27,11 +28,11 @@ | @@ -27,11 +28,11 @@ | ||
27 | <p class="few-tag">即将售罄</p> | 28 | <p class="few-tag">即将售罄</p> |
28 | {{/ isSoonSoldOut}} | 29 | {{/ isSoonSoldOut}} |
29 | 30 | ||
30 | - {{#if noStorage}} | 31 | + {{# noStorage}} |
31 | <div class="no-storage"> | 32 | <div class="no-storage"> |
32 | <div class="no-storage-img"></div> | 33 | <div class="no-storage-img"></div> |
33 | </div> | 34 | </div> |
34 | - {{/if}} | 35 | + {{/ noStorage}} |
35 | </div> | 36 | </div> |
36 | <div class="good-detail-text"> | 37 | <div class="good-detail-text"> |
37 | <div class="name"> | 38 | <div class="name"> |
@@ -59,4 +60,5 @@ | @@ -59,4 +60,5 @@ | ||
59 | {{/if}} | 60 | {{/if}} |
60 | </div> | 61 | </div> |
61 | </div> | 62 | </div> |
63 | + {{/each}} | ||
62 | {{/if}} | 64 | {{/if}} |
@@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
8 | {{# goodsContainer}} | 8 | {{# goodsContainer}} |
9 | <div class="goods-list {{^show}}hide{{/show}}"> | 9 | <div class="goods-list {{^show}}hide{{/show}}"> |
10 | {{# goods}} | 10 | {{# goods}} |
11 | - {{> good}} | 11 | + {{> common/goods}} |
12 | {{/ goods}} | 12 | {{/ goods}} |
13 | </div> | 13 | </div> |
14 | {{/ goodsContainer}} | 14 | {{/ goodsContainer}} |
@@ -4,6 +4,248 @@ | @@ -4,6 +4,248 @@ | ||
4 | * @date: 2015/10/12 | 4 | * @date: 2015/10/12 |
5 | */ | 5 | */ |
6 | 6 | ||
7 | +module.exports = function(specificGender) { | ||
8 | + var $ = require('yoho-jquery'), | ||
9 | + Hammer = require('yoho-hammer'), | ||
10 | + ellipsis = require('yoho-mlellipsis'), | ||
11 | + tip = require('../plugin/tip'), | ||
12 | + loading = require('../plugin/loading'), | ||
13 | + lazyLoad = require('yoho-jquery-lazyload'); | ||
14 | + | ||
15 | + var navHammer, | ||
16 | + winH = $(window).height(), | ||
17 | + $goodList = $('#goods-list'), | ||
18 | + searching = false, | ||
19 | + page = 0, | ||
20 | + gender = null, | ||
21 | + num, | ||
22 | + url, | ||
23 | + RECPOSE = '110001'; | ||
24 | + | ||
25 | + // The kidsType can be specified by the parameter. Add by @ZhaoBiao | ||
26 | + var kidsType = specificGender === 'kids' || $('.mobile-wrap').hasClass('kids-wrap') ? true : false, | ||
27 | + lifestyleType = specificGender === 'lifestyle' || | ||
28 | + $('.mobile-wrap').hasClass('lifestyle-wrap') ? true : false, | ||
29 | + yohoCoinType = $('.coin').length ? true : false, | ||
30 | + logisticType = $('.logistic-page').length ? true : false; | ||
31 | + var $curNav, | ||
32 | + index, | ||
33 | + $navList = $('#maybe-like-nav'); | ||
34 | + | ||
35 | + var $footer; | ||
36 | + | ||
37 | + ellipsis.init(); | ||
38 | + | ||
39 | + // ajax url | ||
40 | + if (kidsType) { | ||
41 | + | ||
42 | + url = '/product/recom/maylikekids'; | ||
43 | + } else if (lifestyleType) { | ||
44 | + | ||
45 | + // 有货币页面加载男生首页的数据 | ||
46 | + url = specificGender === 'lifestyle' ? '/product/recom/maylike?gender=1,3&rec_pos=100001' : '/product/recom/maylikelife'; | ||
47 | + } else if (yohoCoinType) { | ||
48 | + | ||
49 | + gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ? | ||
50 | + '1,3&rec_pos=100009' : '2,3&rec_pos=100009', | ||
51 | + url = '/product/recom/maylike?gender=' + gender; | ||
52 | + RECPOSE = 110009; | ||
53 | + | ||
54 | + } else if (logisticType) { // 物流页面 | ||
55 | + gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ? | ||
56 | + '1,3&rec_pos=100006' : '2,3&rec_pos=100006', | ||
57 | + url = '/product/recom/maylike?gender=' + gender; | ||
58 | + RECPOSE = 110006; | ||
59 | + | ||
60 | + } else { | ||
61 | + gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ? | ||
62 | + '1,3&rec_pos=100001' : '2,3&rec_pos=100002', | ||
63 | + url = '/product/recom/maylike?gender=' + gender; | ||
64 | + } | ||
65 | + | ||
66 | + // 日韩馆-你可能喜欢的 | ||
67 | + if ($('.mobile-wrap').hasClass('yoho-channel-page')) { | ||
68 | + url = '/product/recom/newPreference?template_id=' + $.queryString().template_id; | ||
69 | + } | ||
70 | + | ||
71 | + // 首页男生和女生,推荐位ID,埋点 | ||
72 | + if (window.location.pathname === '/boys') { | ||
73 | + RECPOSE = 110001; | ||
74 | + } else if (window.location.pathname === '/girls') { | ||
75 | + RECPOSE = 110002; | ||
76 | + } | ||
77 | + | ||
78 | + $curNav = $navList.children('.focus'); | ||
79 | + | ||
80 | + if (lifestyleType) { | ||
81 | + navHammer = $navList[0] ? new Hammer($navList[0]) : undefined; | ||
82 | + if (navHammer) { | ||
83 | + navHammer.on('tap', function(e) { | ||
84 | + var $this = $(e.target).closest('li'), | ||
85 | + $goods = $('.goods-list'), | ||
86 | + $content; | ||
87 | + | ||
88 | + e.preventDefault(); | ||
89 | + if ($this.hasClass('focus')) { | ||
90 | + return; | ||
91 | + } | ||
92 | + | ||
93 | + index = $this.index(); | ||
94 | + | ||
95 | + $this.addClass('focus'); | ||
96 | + $curNav.removeClass('focus'); | ||
97 | + | ||
98 | + $goods.not('.hide').addClass('hide'); | ||
99 | + $content = $goods.eq(index); | ||
100 | + $content.removeClass('hide'); | ||
101 | + | ||
102 | + $curNav = $this; | ||
103 | + | ||
104 | + $(document).trigger('scroll'); // Trigger lazyLoad | ||
105 | + e.srcEvent.stopPropagation(); | ||
106 | + }); | ||
107 | + } | ||
108 | + } | ||
109 | + | ||
110 | + loading.init($('.maybe-like')); | ||
111 | + | ||
112 | + function search() { | ||
113 | + if (searching) { | ||
114 | + return; | ||
115 | + } | ||
116 | + searching = true; | ||
117 | + | ||
118 | + loading.showLoadingMask(); | ||
119 | + | ||
120 | + // num = $goodList.find('.good-info').length; | ||
121 | + $.ajax({ | ||
122 | + type: 'GET', | ||
123 | + url: url, | ||
124 | + data: { | ||
125 | + page: page + 1 | ||
126 | + }, | ||
127 | + success: function(data) { | ||
128 | + var PRDID = []; | ||
129 | + if (data === ' ') { | ||
130 | + searching = false; | ||
131 | + loading.hideLoadingMask(); | ||
132 | + | ||
133 | + // 有货币页面不加载底部 | ||
134 | + if (gender && !specificGender) { | ||
135 | + if (gender === '1,3') { | ||
136 | + url = '/boys/bottomBanner'; | ||
137 | + } else { | ||
138 | + url = '/girls/bottomBanner'; | ||
139 | + } | ||
140 | + $.ajax({ | ||
141 | + type: 'GET', | ||
142 | + url: url, | ||
143 | + success: function(data) { | ||
144 | + if (data && data.img) { | ||
145 | + $('#load-more-img').show(); | ||
146 | + $('#load-more-img a').attr('href', data.url); | ||
147 | + $('#load-more-img a > img').attr('src', data.img); | ||
148 | + } | ||
149 | + }, | ||
150 | + error: function() { | ||
151 | + } | ||
152 | + }); | ||
153 | + | ||
154 | + } | ||
155 | + return; | ||
156 | + } | ||
157 | + | ||
158 | + // 加载到数据后,去除bottom样式,使得footer能够随着页面长度的增加改变位置 | ||
159 | + if (data.length > 1) { | ||
160 | + $footer ? null : $footer = $('#yoho-footer'); | ||
161 | + $footer.hasClass('bottom') ? $footer.removeClass('bottom') : null; | ||
162 | + } | ||
163 | + | ||
164 | + num = $goodList.find('.good-info').length; | ||
165 | + | ||
166 | + $goodList.append(data); | ||
167 | + | ||
168 | + // 2015/10/31 fei.hong: 修复第一页分页不显示图片的问题 | ||
169 | + if (num === 0) { | ||
170 | + lazyLoad($goodList.find('.good-info').find('img.lazy')); | ||
171 | + } else { | ||
172 | + lazyLoad($goodList.find('.good-info:gt(' + (num - 1) + ')').find('img.lazy')); | ||
173 | + } | ||
174 | + | ||
175 | + searching = false; | ||
176 | + loading.hideLoadingMask(); | ||
177 | + page++; | ||
178 | + | ||
179 | + $('.good-detail-text .name').each(function() { | ||
180 | + var $this = $(this), | ||
181 | + $title = $this.find('a'); | ||
182 | + | ||
183 | + $title[0].mlellipsis(2); | ||
184 | + }); | ||
185 | + | ||
186 | + // 为您优选埋点 start | ||
187 | + $(data).closest('.good-info').each(function() { | ||
188 | + PRDID.push($(this).data('id')); | ||
189 | + }); | ||
190 | + window.givePoint({ | ||
191 | + 'REC_POSE': RECPOSE, | ||
192 | + 'PRD_ID': PRDID.join(','), | ||
193 | + 'PRD_NUM': $(data).closest('.good-info').length, | ||
194 | + 'ACTION_ID': 0, | ||
195 | + 'page_num': RECPOSE === 110009 ? 1 : page | ||
196 | + }); | ||
197 | + | ||
198 | + // 为您优选埋点 end | ||
199 | + }, | ||
200 | + error: function() { | ||
201 | + tip.show('网络断开连接了~'); | ||
202 | + searching = false; | ||
203 | + loading.hideLoadingMask(); | ||
204 | + } | ||
205 | + }); | ||
206 | + } | ||
207 | + | ||
208 | + $('.maybe-like p').on('touchstart', function(e) { | ||
209 | + search(); | ||
210 | + }); | ||
211 | + | ||
212 | + function scrollHandler() { | ||
213 | + if ($(window).scrollTop() + winH >= $(document).height() - 200) { | ||
214 | + search(); | ||
215 | + } | ||
216 | + } | ||
217 | + | ||
218 | + // 优惠券页面直接加载你可能喜欢。add by @zhaobiao | ||
219 | + if (specificGender) { | ||
220 | + search(); | ||
221 | + } | ||
222 | + | ||
223 | + // srcoll to load more | ||
224 | + $(window).scroll(function() { | ||
225 | + window.requestAnimationFrame(scrollHandler); | ||
226 | + }); | ||
227 | + | ||
228 | + // 为您优选埋点 http://redmine.yoho.cn/issues/10116 | ||
229 | + $('.maybe-like .goods-list').on('click', 'a', function() { | ||
230 | + var index = $(this).closest('.good-info').index() + 1, | ||
231 | + pageNum = 50; | ||
232 | + window.givePoint({ | ||
233 | + 'REC_POSE': RECPOSE, | ||
234 | + 'PRD_ID': $(this).closest('.good-info').data('id'), | ||
235 | + 'PRD_NUM': index % pageNum === 0 ? pageNum : index % pageNum, | ||
236 | + 'ACTION_ID': 1, | ||
237 | + 'page_num': Math.ceil(index / pageNum) | ||
238 | + }); | ||
239 | + return true; | ||
240 | + }); | ||
241 | +}; | ||
242 | + | ||
243 | +/** | ||
244 | + * “你可能喜欢”模块JS | ||
245 | + * @author: liangzhifeng<zhifeng.liang@yoho.cn> | ||
246 | + * @date: 2015/10/12 | ||
247 | + */ | ||
248 | + | ||
7 | // module.exports = function(specificGender) { | 249 | // module.exports = function(specificGender) { |
8 | // var $ = require('yoho-jquery'), | 250 | // var $ = require('yoho-jquery'), |
9 | // Hammer = require('yoho-hammer'), | 251 | // Hammer = require('yoho-hammer'), |
@@ -245,245 +487,3 @@ | @@ -245,245 +487,3 @@ | ||
245 | // }); | 487 | // }); |
246 | // }; | 488 | // }; |
247 | 489 | ||
248 | - | ||
249 | -/** | ||
250 | - * “你可能喜欢”模块JS | ||
251 | - * @author: liangzhifeng<zhifeng.liang@yoho.cn> | ||
252 | - * @date: 2015/10/12 | ||
253 | - */ | ||
254 | - | ||
255 | -module.exports = function(specificGender) { | ||
256 | - var $ = require('yoho-jquery'), | ||
257 | - Hammer = require('yoho-hammer'), | ||
258 | - ellipsis = require('yoho-mlellipsis'), | ||
259 | - tip = require('../plugin/tip'), | ||
260 | - loading = require('../plugin/loading'), | ||
261 | - lazyLoad = require('yoho-jquery-lazyload'); | ||
262 | - | ||
263 | - var navHammer, | ||
264 | - winH = $(window).height(), | ||
265 | - $goodList = $('#goods-list'), | ||
266 | - searching = false, | ||
267 | - page = 0, | ||
268 | - gender = null, | ||
269 | - num, | ||
270 | - url, | ||
271 | - RECPOSE = '110001'; | ||
272 | - | ||
273 | - // The kidsType can be specified by the parameter. Add by @ZhaoBiao | ||
274 | - var kidsType = specificGender === 'kids' || $('.mobile-wrap').hasClass('kids-wrap') ? true : false, | ||
275 | - lifestyleType = specificGender === 'lifestyle' || | ||
276 | - $('.mobile-wrap').hasClass('lifestyle-wrap') ? true : false, | ||
277 | - yohoCoinType = $('.coin').length ? true : false, | ||
278 | - logisticType = $('.logistic-page').length ? true : false; | ||
279 | - var $curNav, | ||
280 | - index, | ||
281 | - $navList = $('#maybe-like-nav'); | ||
282 | - | ||
283 | - var $footer; | ||
284 | - | ||
285 | - ellipsis.init(); | ||
286 | - | ||
287 | - // ajax url | ||
288 | - if (kidsType) { | ||
289 | - | ||
290 | - url = '/product/recom/maylikekids'; | ||
291 | - } else if (lifestyleType) { | ||
292 | - | ||
293 | - // 有货币页面加载男生首页的数据 | ||
294 | - url = specificGender === 'lifestyle' ? '/product/recom/maylike?gender=1,3&rec_pos=100001' : '/product/recom/maylikelife'; | ||
295 | - } else if (yohoCoinType) { | ||
296 | - | ||
297 | - gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ? | ||
298 | - '1,3&rec_pos=100009' : '2,3&rec_pos=100009', | ||
299 | - url = '/product/recom/maylike?gender=' + gender; | ||
300 | - RECPOSE = 110009; | ||
301 | - | ||
302 | - } else if (logisticType) { // 物流页面 | ||
303 | - gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ? | ||
304 | - '1,3&rec_pos=100006' : '2,3&rec_pos=100006', | ||
305 | - url = '/product/recom/maylike?gender=' + gender; | ||
306 | - RECPOSE = 110006; | ||
307 | - | ||
308 | - } else { | ||
309 | - gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ? | ||
310 | - '1,3&rec_pos=100001' : '2,3&rec_pos=100002', | ||
311 | - url = '/product/recom/maylike?gender=' + gender; | ||
312 | - } | ||
313 | - | ||
314 | - // 日韩馆-你可能喜欢的 | ||
315 | - if ($('.mobile-wrap').hasClass('yoho-channel-page')) { | ||
316 | - url = '/product/recom/newPreference?template_id=' + $.queryString().template_id; | ||
317 | - } | ||
318 | - | ||
319 | - // 首页男生和女生,推荐位ID,埋点 | ||
320 | - if (window.location.pathname === '/boys') { | ||
321 | - RECPOSE = 110001; | ||
322 | - } else if (window.location.pathname === '/girls') { | ||
323 | - RECPOSE = 110002; | ||
324 | - } | ||
325 | - | ||
326 | - $curNav = $navList.children('.focus'); | ||
327 | - | ||
328 | - if (lifestyleType) { | ||
329 | - navHammer = $navList[0] ? new Hammer($navList[0]) : undefined; | ||
330 | - if (navHammer) { | ||
331 | - navHammer.on('tap', function(e) { | ||
332 | - var $this = $(e.target).closest('li'), | ||
333 | - $goods = $('.goods-list'), | ||
334 | - $content; | ||
335 | - | ||
336 | - e.preventDefault(); | ||
337 | - if ($this.hasClass('focus')) { | ||
338 | - return; | ||
339 | - } | ||
340 | - | ||
341 | - index = $this.index(); | ||
342 | - | ||
343 | - $this.addClass('focus'); | ||
344 | - $curNav.removeClass('focus'); | ||
345 | - | ||
346 | - $goods.not('.hide').addClass('hide'); | ||
347 | - $content = $goods.eq(index); | ||
348 | - $content.removeClass('hide'); | ||
349 | - | ||
350 | - $curNav = $this; | ||
351 | - | ||
352 | - $(document).trigger('scroll'); // Trigger lazyLoad | ||
353 | - e.srcEvent.stopPropagation(); | ||
354 | - }); | ||
355 | - } | ||
356 | - } | ||
357 | - | ||
358 | - loading.init($('.maybe-like')); | ||
359 | - | ||
360 | - function search() { | ||
361 | - if (searching) { | ||
362 | - return; | ||
363 | - } | ||
364 | - searching = true; | ||
365 | - | ||
366 | - loading.showLoadingMask(); | ||
367 | - | ||
368 | - // num = $goodList.find('.good-info').length; | ||
369 | - $.ajax({ | ||
370 | - type: 'GET', | ||
371 | - url: url, | ||
372 | - data: { | ||
373 | - page: page + 1 | ||
374 | - }, | ||
375 | - success: function(data) { | ||
376 | - var PRDID = []; | ||
377 | - if (data === ' ') { | ||
378 | - searching = false; | ||
379 | - loading.hideLoadingMask(); | ||
380 | - | ||
381 | - // 有货币页面不加载底部 | ||
382 | - if (gender && !specificGender) { | ||
383 | - if (gender === '1,3') { | ||
384 | - url = '/boys/bottomBanner'; | ||
385 | - } else { | ||
386 | - url = '/girls/bottomBanner'; | ||
387 | - } | ||
388 | - $.ajax({ | ||
389 | - type: 'GET', | ||
390 | - url: url, | ||
391 | - success: function(data) { | ||
392 | - if (data && data.img) { | ||
393 | - $('#load-more-img').show(); | ||
394 | - $('#load-more-img a').attr('href', data.url); | ||
395 | - $('#load-more-img a > img').attr('src', data.img); | ||
396 | - } | ||
397 | - }, | ||
398 | - error: function() { | ||
399 | - } | ||
400 | - }); | ||
401 | - | ||
402 | - } | ||
403 | - return; | ||
404 | - } | ||
405 | - | ||
406 | - // 加载到数据后,去除bottom样式,使得footer能够随着页面长度的增加改变位置 | ||
407 | - if (data.length > 1) { | ||
408 | - $footer ? null : $footer = $('#yoho-footer'); | ||
409 | - $footer.hasClass('bottom') ? $footer.removeClass('bottom') : null; | ||
410 | - } | ||
411 | - | ||
412 | - num = $goodList.find('.good-info').length; | ||
413 | - | ||
414 | - $goodList.append(data); | ||
415 | - | ||
416 | - // 2015/10/31 fei.hong: 修复第一页分页不显示图片的问题 | ||
417 | - if (num === 0) { | ||
418 | - lazyLoad($goodList.find('.good-info').find('img.lazy')); | ||
419 | - } else { | ||
420 | - lazyLoad($goodList.find('.good-info:gt(' + (num - 1) + ')').find('img.lazy')); | ||
421 | - } | ||
422 | - | ||
423 | - searching = false; | ||
424 | - loading.hideLoadingMask(); | ||
425 | - page++; | ||
426 | - | ||
427 | - $('.good-detail-text .name').each(function() { | ||
428 | - var $this = $(this), | ||
429 | - $title = $this.find('a'); | ||
430 | - | ||
431 | - $title[0].mlellipsis(2); | ||
432 | - }); | ||
433 | - | ||
434 | - // 为您优选埋点 start | ||
435 | - $(data).closest('.good-info').each(function() { | ||
436 | - PRDID.push($(this).data('id')); | ||
437 | - }); | ||
438 | - window.givePoint({ | ||
439 | - 'REC_POSE': RECPOSE, | ||
440 | - 'PRD_ID': PRDID.join(','), | ||
441 | - 'PRD_NUM': $(data).closest('.good-info').length, | ||
442 | - 'ACTION_ID': 0, | ||
443 | - 'page_num': RECPOSE === 110009 ? 1 : page | ||
444 | - }); | ||
445 | - | ||
446 | - // 为您优选埋点 end | ||
447 | - }, | ||
448 | - error: function() { | ||
449 | - tip.show('网络断开连接了~'); | ||
450 | - searching = false; | ||
451 | - loading.hideLoadingMask(); | ||
452 | - } | ||
453 | - }); | ||
454 | - } | ||
455 | - | ||
456 | - $('.maybe-like p').on('touchstart', function(e) { | ||
457 | - search(); | ||
458 | - }); | ||
459 | - | ||
460 | - function scrollHandler() { | ||
461 | - if ($(window).scrollTop() + winH >= $(document).height() - 200) { | ||
462 | - search(); | ||
463 | - } | ||
464 | - } | ||
465 | - | ||
466 | - // 优惠券页面直接加载你可能喜欢。add by @zhaobiao | ||
467 | - if (specificGender) { | ||
468 | - search(); | ||
469 | - } | ||
470 | - | ||
471 | - // srcoll to load more | ||
472 | - $(window).scroll(function() { | ||
473 | - window.requestAnimationFrame(scrollHandler); | ||
474 | - }); | ||
475 | - | ||
476 | - // 为您优选埋点 http://redmine.yoho.cn/issues/10116 | ||
477 | - $('.maybe-like .goods-list').on('click', 'a', function() { | ||
478 | - var index = $(this).closest('.good-info').index() + 1, | ||
479 | - pageNum = 50; | ||
480 | - window.givePoint({ | ||
481 | - 'REC_POSE': RECPOSE, | ||
482 | - 'PRD_ID': $(this).closest('.good-info').data('id'), | ||
483 | - 'PRD_NUM': index % pageNum === 0 ? pageNum : index % pageNum, | ||
484 | - 'ACTION_ID': 1, | ||
485 | - 'page_num': Math.ceil(index / pageNum) | ||
486 | - }); | ||
487 | - return true; | ||
488 | - }); | ||
489 | -}; |
1 | /** | 1 | /** |
2 | * 新有货币界面 | 2 | * 新有货币界面 |
3 | */ | 3 | */ |
4 | -var $ = require('yoho-jquery'); | 4 | +var $ = require('yoho-jquery'), |
5 | + lazyLoad = require('yoho-jquery-lazyload'); | ||
6 | + | ||
5 | require('../common'); | 7 | require('../common'); |
6 | 8 | ||
9 | +lazyLoad($('img.lazy')); | ||
10 | + | ||
7 | function getGender() { | 11 | function getGender() { |
8 | return window.cookie('_Channel') || 'boys'; | 12 | return window.cookie('_Channel') || 'boys'; |
9 | } | 13 | } |
-
Please register or login to post a comment