Merge branch 'release/usercenter'
Showing
23 changed files
with
391 additions
and
62 deletions
@@ -10,6 +10,7 @@ const favoriteModel = require('../models/favorite'); | @@ -10,6 +10,7 @@ const favoriteModel = require('../models/favorite'); | ||
10 | const headerModel = require('../../../doraemon/models/header'); // 头部model | 10 | const headerModel = require('../../../doraemon/models/header'); // 头部model |
11 | 11 | ||
12 | const favorite = (req, res) => { | 12 | const favorite = (req, res) => { |
13 | + let tab = req.query.tab || ''; | ||
13 | 14 | ||
14 | res.render('favorite', { | 15 | res.render('favorite', { |
15 | module: 'home', | 16 | module: 'home', |
@@ -21,13 +22,14 @@ const favorite = (req, res) => { | @@ -21,13 +22,14 @@ const favorite = (req, res) => { | ||
21 | pageFooter: true, | 22 | pageFooter: true, |
22 | favorite: { | 23 | favorite: { |
23 | productUrl: '//m.yohobuy.com/product/new', | 24 | productUrl: '//m.yohobuy.com/product/new', |
24 | - brandUrl: '//m.yohobuy.com/product/new' | 25 | + brandUrl: '//m.yohobuy.com/product/new', |
26 | + brandTab: tab === 'brand' ? true : false // 是否为品牌收藏页 | ||
25 | } | 27 | } |
26 | }); | 28 | }); |
27 | }; | 29 | }; |
28 | 30 | ||
29 | let favProduct = (req, res, next) => { | 31 | let favProduct = (req, res, next) => { |
30 | - let uid = req.user.uid; | 32 | + let uid = req.user.uid || 12696231; |
31 | let page = req.query.page || 1; | 33 | let page = req.query.page || 1; |
32 | let limit = 10; | 34 | let limit = 10; |
33 | 35 | ||
@@ -44,7 +46,7 @@ let favProduct = (req, res, next) => { | @@ -44,7 +46,7 @@ let favProduct = (req, res, next) => { | ||
44 | }; | 46 | }; |
45 | 47 | ||
46 | let favfavBrand = (req, res, next) => { | 48 | let favfavBrand = (req, res, next) => { |
47 | - let uid = req.user.uid; | 49 | + let uid = req.user.uid || 12696231; |
48 | let page = req.query.page || 1; | 50 | let page = req.query.page || 1; |
49 | let limit = 10; | 51 | let limit = 10; |
50 | 52 | ||
@@ -63,7 +65,7 @@ let favfavBrand = (req, res, next) => { | @@ -63,7 +65,7 @@ let favfavBrand = (req, res, next) => { | ||
63 | }; | 65 | }; |
64 | 66 | ||
65 | let favoriteDelete = (req, res, next) => { | 67 | let favoriteDelete = (req, res, next) => { |
66 | - let uid = req.user.uid; | 68 | + let uid = req.user.uid || 12696231; |
67 | let type = 'product'; | 69 | let type = 'product'; |
68 | let favId = req.body.id; | 70 | let favId = req.body.id; |
69 | 71 |
@@ -17,20 +17,14 @@ const indexModel = require('../models/index'); | @@ -17,20 +17,14 @@ const indexModel = require('../models/index'); | ||
17 | */ | 17 | */ |
18 | exports.index = (req, res, next) => { | 18 | exports.index = (req, res, next) => { |
19 | let params = { | 19 | let params = { |
20 | - uid: req.user.uid | 20 | + uid: req.user.uid, |
21 | + channel: req.query.channel || 1, | ||
22 | + udid: require('md5')(req.ip) | ||
21 | }; | 23 | }; |
22 | - let refer = req.get('Referer') || `${global.yoho.config.siteUrl}/${req.cookies._Channel || ''}`; | ||
23 | - let reqPath = req.baseUrl + req.path; | ||
24 | - let backUrl = refer.indexOf(reqPath) === -1 ? refer : ''; | ||
25 | - | ||
26 | - backUrl && res.cookie('saleRefer', backUrl, { | ||
27 | - domain: 'm.yohobuy.com' | ||
28 | - }); | ||
29 | - backUrl = backUrl || req.cookies.saleRefer; | ||
30 | 24 | ||
31 | let headerData = headerModel.setNav({ | 25 | let headerData = headerModel.setNav({ |
32 | navTitle: '个人中心', | 26 | navTitle: '个人中心', |
33 | - backUrl: backUrl, | 27 | + backUrl: '//m.yohobuy.com/?go=1', |
34 | }); | 28 | }); |
35 | 29 | ||
36 | indexModel.index(params).then(result => { | 30 | indexModel.index(params).then(result => { |
@@ -48,7 +48,6 @@ const readdData = (req, res, next) => { | @@ -48,7 +48,6 @@ const readdData = (req, res, next) => { | ||
48 | let uid = req.user.uid; | 48 | let uid = req.user.uid; |
49 | 49 | ||
50 | orderDetailModel.readdData(orderCode, uid).then((result) => { | 50 | orderDetailModel.readdData(orderCode, uid).then((result) => { |
51 | - console.log(result); | ||
52 | res.json(result); | 51 | res.json(result); |
53 | }).catch(next); | 52 | }).catch(next); |
54 | }; | 53 | }; |
apps/home/controllers/recommend-for-you.js
0 → 100644
1 | +'use strict'; | ||
2 | + | ||
3 | +const mRoot = '../models'; | ||
4 | +const recommendForYouModel = require(`${mRoot}/recommend-for-you`); // 领取优惠券 model | ||
5 | + | ||
6 | +exports.userCenter = (req, res, next) => { | ||
7 | + var udid = req.sessionID, | ||
8 | + uid = req.user.uid || 0, | ||
9 | + yhChannel = req.query.yh_channel || '1', | ||
10 | + limit = 30; | ||
11 | + | ||
12 | + recommendForYouModel.getPreference({ | ||
13 | + yh_channel: yhChannel, | ||
14 | + udid: udid, | ||
15 | + limit: limit, | ||
16 | + rec_pos: '100004', | ||
17 | + uid: uid | ||
18 | + }).then((preferenceData) => { | ||
19 | + | ||
20 | + if (preferenceData.code === 200) { | ||
21 | + // 获取信息成功 | ||
22 | + } | ||
23 | + res.render('recommend-for-you/index', { | ||
24 | + layout: false, | ||
25 | + result: preferenceData, | ||
26 | + module: 'product', | ||
27 | + page: 'recommend' | ||
28 | + }); | ||
29 | + }).catch(next); | ||
30 | +}; | ||
31 | + | ||
32 | +exports.cart = (req, res, next) => { | ||
33 | + var udid = req.sessionID, | ||
34 | + uid = req.user.uid || 0, | ||
35 | + yhChannel = req.query.yh_channel || '1', | ||
36 | + limit = 30; | ||
37 | + | ||
38 | + recommendForYouModel.getPreference({ | ||
39 | + yh_channel: yhChannel, | ||
40 | + udid: udid, | ||
41 | + limit: limit, | ||
42 | + rec_pos: '100003', | ||
43 | + uid: uid | ||
44 | + }).then((preferenceData) => { | ||
45 | + | ||
46 | + if (preferenceData.code === 200) { | ||
47 | + // 获取信息成功 | ||
48 | + } | ||
49 | + res.render('recommend-for-you/index', { | ||
50 | + layout: false, | ||
51 | + result: preferenceData, | ||
52 | + module: 'product', | ||
53 | + page: 'recommend' | ||
54 | + }); | ||
55 | + }).catch(next); | ||
56 | +}; |
@@ -73,13 +73,13 @@ const favProduct = (uid, page, limit) => { | @@ -73,13 +73,13 @@ const favProduct = (uid, page, limit) => { | ||
73 | 73 | ||
74 | if (val.marketPrice - val.salesPrice > 0) { | 74 | if (val.marketPrice - val.salesPrice > 0) { |
75 | obj = _.assign(obj, { | 75 | obj = _.assign(obj, { |
76 | - discountPrice: val.salesPrice | 76 | + discountPrice: '¥' + Number(val.salesPrice).toFixed(2), |
77 | }); | 77 | }); |
78 | } | 78 | } |
79 | 79 | ||
80 | if (val.priceDown > 0) { | 80 | if (val.priceDown > 0) { |
81 | obj = _.assign(obj, { | 81 | obj = _.assign(obj, { |
82 | - savePrice: '¥' + val.priceDown | 82 | + savePrice: '¥' + Number(val.priceDown).toFixed(2), |
83 | }); | 83 | }); |
84 | } else { | 84 | } else { |
85 | obj = _.assign(obj, { | 85 | obj = _.assign(obj, { |
@@ -96,7 +96,7 @@ const favProduct = (uid, page, limit) => { | @@ -96,7 +96,7 @@ const favProduct = (uid, page, limit) => { | ||
96 | obj = _.assign(obj, { | 96 | obj = _.assign(obj, { |
97 | favId: val.productId, | 97 | favId: val.productId, |
98 | title: val.productName, | 98 | title: val.productName, |
99 | - price: '¥' + val.marketPrice, | 99 | + price: '¥' + Number(val.marketPrice).toFixed(2), |
100 | invalidGoods: val.status === 0 | 100 | invalidGoods: val.status === 0 |
101 | }); | 101 | }); |
102 | 102 | ||
@@ -175,8 +175,8 @@ const favfavBrand = (uid, page, limit) => { | @@ -175,8 +175,8 @@ const favfavBrand = (uid, page, limit) => { | ||
175 | link: '/product/pro_' + data.productId + '_' + | 175 | link: '/product/pro_' + data.productId + '_' + |
176 | data.goods[0].id + '/' + data.cnAlphabet + '.html', | 176 | data.goods[0].id + '/' + data.cnAlphabet + '.html', |
177 | imgUrl: data.defaultImages, | 177 | imgUrl: data.defaultImages, |
178 | - price: '¥' + data.marketPrice, | ||
179 | - discount: data.marketPrice > data.salesPrice ? '¥' + data.salesPrice : false, | 178 | + price: '¥' + Number(data.marketPrice).toFixed(2), |
179 | + discount: data.marketPrice > data.salesPrice ? '¥' + Number(data.salesPrice).toFixed(2) : false, | ||
180 | }); | 180 | }); |
181 | }); | 181 | }); |
182 | 182 |
@@ -76,6 +76,17 @@ const _infoNum = (params) => { | @@ -76,6 +76,17 @@ const _infoNum = (params) => { | ||
76 | }; | 76 | }; |
77 | 77 | ||
78 | /** | 78 | /** |
79 | + * 从接口获取地址列表 | ||
80 | + * @param params | ||
81 | + */ | ||
82 | +const _getAddressData = (params) => { | ||
83 | + return api.get('', { | ||
84 | + method: 'app.address.gethidden', | ||
85 | + uid: params.uid | ||
86 | + }, {code: 200}); | ||
87 | +}; | ||
88 | + | ||
89 | +/** | ||
79 | * 个人中心首页 | 90 | * 个人中心首页 |
80 | * @param params | 91 | * @param params |
81 | * @returns {function()} | 92 | * @returns {function()} |
@@ -98,7 +109,8 @@ const index = (params) => { | @@ -98,7 +109,8 @@ const index = (params) => { | ||
98 | _userData(params), | 109 | _userData(params), |
99 | _noticeData(), | 110 | _noticeData(), |
100 | _favoriteData(params), | 111 | _favoriteData(params), |
101 | - _infoNum(params) | 112 | + _infoNum(params), |
113 | + _getAddressData(params) | ||
102 | ]).then(result => { | 114 | ]).then(result => { |
103 | if (result[0] && result[0].data) { | 115 | if (result[0] && result[0].data) { |
104 | Object.assign(finalResult, { | 116 | Object.assign(finalResult, { |
@@ -114,6 +126,12 @@ const index = (params) => { | @@ -114,6 +126,12 @@ const index = (params) => { | ||
114 | }); | 126 | }); |
115 | } | 127 | } |
116 | 128 | ||
129 | + if (result[2] && result[2].data) { | ||
130 | + Object.assign(finalResult, { | ||
131 | + productFavoriteTotal: result[2].data.product_favorite_total | ||
132 | + }); | ||
133 | + } | ||
134 | + | ||
117 | if (result[3] && result[3].data) { | 135 | if (result[3] && result[3].data) { |
118 | Object.assign(finalResult, { | 136 | Object.assign(finalResult, { |
119 | sendCargoNum: result[3].data.send_cargo_num, | 137 | sendCargoNum: result[3].data.send_cargo_num, |
@@ -122,12 +140,16 @@ const index = (params) => { | @@ -122,12 +140,16 @@ const index = (params) => { | ||
122 | yohoCoinNum: result[3].data.yoho_coin_num, | 140 | yohoCoinNum: result[3].data.yoho_coin_num, |
123 | inboxTotal: result[3].data.inbox_total, | 141 | inboxTotal: result[3].data.inbox_total, |
124 | couponNum: result[3].data.coupon_num, | 142 | couponNum: result[3].data.coupon_num, |
125 | - productFavoriteTotal: result[3].data.product_favorite_total, | ||
126 | brandFavoriteTotal: result[3].data.brand_favorite_total, | 143 | brandFavoriteTotal: result[3].data.brand_favorite_total, |
127 | productBrowse: result[3].data.product_browse | 144 | productBrowse: result[3].data.product_browse |
128 | }); | 145 | }); |
129 | } | 146 | } |
130 | 147 | ||
148 | + if (result[4] && result[4].data) { | ||
149 | + Object.assign(finalResult, { | ||
150 | + addressNum: result[4].data.length | ||
151 | + }); | ||
152 | + } | ||
131 | 153 | ||
132 | return finalResult; | 154 | return finalResult; |
133 | }); | 155 | }); |
@@ -14,12 +14,9 @@ const closeReasons = () => { | @@ -14,12 +14,9 @@ const closeReasons = () => { | ||
14 | return api.get('', { | 14 | return api.get('', { |
15 | method: 'app.SpaceOrders.closeReasons' | 15 | method: 'app.SpaceOrders.closeReasons' |
16 | }).then((result) => { | 16 | }).then((result) => { |
17 | - // console.log(result) | ||
18 | if (result && result.code === 200) { | 17 | if (result && result.code === 200) { |
19 | - // console.log(result) | ||
20 | return result.data; | 18 | return result.data; |
21 | } else { | 19 | } else { |
22 | - // console.log('bushi 200'); | ||
23 | return {}; | 20 | return {}; |
24 | } | 21 | } |
25 | }); | 22 | }); |
@@ -164,7 +161,7 @@ const orderDetailData = (uid, orderCode) => { | @@ -164,7 +161,7 @@ const orderDetailData = (uid, orderCode) => { | ||
164 | uid: uid, | 161 | uid: uid, |
165 | order_code: orderCode | 162 | order_code: orderCode |
166 | }).then((result) => { | 163 | }).then((result) => { |
167 | - // console.log(result) | 164 | + |
168 | if (result && result.code === 200) { | 165 | if (result && result.code === 200) { |
169 | let orderDetail = camelCase(result.data); | 166 | let orderDetail = camelCase(result.data); |
170 | let goods = []; | 167 | let goods = []; |
@@ -197,7 +194,7 @@ const orderDetailData = (uid, orderCode) => { | @@ -197,7 +194,7 @@ const orderDetailData = (uid, orderCode) => { | ||
197 | } | 194 | } |
198 | 195 | ||
199 | _.forEach(orderDetail.orderGoods, function(data) { | 196 | _.forEach(orderDetail.orderGoods, function(data) { |
200 | - // console.log(data); | 197 | + |
201 | let obj = {}; | 198 | let obj = {}; |
202 | let count = +data.buyNumber; | 199 | let count = +data.buyNumber; |
203 | 200 | ||
@@ -289,7 +286,6 @@ const orderDetailData = (uid, orderCode) => { | @@ -289,7 +286,6 @@ const orderDetailData = (uid, orderCode) => { | ||
289 | cancelReason: resons | 286 | cancelReason: resons |
290 | }); | 287 | }); |
291 | 288 | ||
292 | - // console.log(orderDetail); | ||
293 | return orderDetail; | 289 | return orderDetail; |
294 | }); | 290 | }); |
295 | 291 |
apps/home/models/recommend-for-you.js
0 → 100644
1 | +'use strict'; | ||
2 | + | ||
3 | +var api = global.yoho.API; | ||
4 | + | ||
5 | +const camelCase = global.yoho.camelCase; | ||
6 | +const helpers = global.yoho.helpers; | ||
7 | +const _ = require('lodash'); | ||
8 | + | ||
9 | +/** | ||
10 | + * 分享页面基础参数 | ||
11 | + * @param {object} sizeInfo [接口原始数据] | ||
12 | + * @return {object} [description] | ||
13 | + */ | ||
14 | +const getPreferenceData = (data) => { | ||
15 | + var dest = {}; | ||
16 | + | ||
17 | + let list = data.data || {}; | ||
18 | + | ||
19 | + list = camelCase(list); | ||
20 | + | ||
21 | + let distGoods = []; | ||
22 | + | ||
23 | + _.forEach(list.productList, function(value) { | ||
24 | + | ||
25 | + if (!value.productSkn || !value.goodsList || !value.goodsList.length) { | ||
26 | + return; | ||
27 | + } | ||
28 | + value.goodsId = value.goodsList[0].goodsId; | ||
29 | + | ||
30 | + let goods = value; | ||
31 | + | ||
32 | + goods.url = helpers.urlFormat(`/product/pro_${value.productId}_${value.goodsId}/${value.cnAlphabet}.html`); | ||
33 | + if (_.get(goods, 'tags[0]', null)) { | ||
34 | + goods.tags = []; | ||
35 | + if (goods.isNew === 'Y') { | ||
36 | + goods.tags.push({isNew: true}); | ||
37 | + } else if (goods.isAdvance === 'Y') { | ||
38 | + goods.tags.push({isAdvance: true}); | ||
39 | + } else if (goods.isDiscount === 'Y') { | ||
40 | + goods.tags.push({isDiscount: true}); | ||
41 | + } else if (goods.isYohoood === 'Y') { | ||
42 | + goods.tags.push({isYohoood: true}); | ||
43 | + } else if (goods.isLimited === 'Y') { | ||
44 | + goods.tags.push({isLimited: true}); | ||
45 | + } | ||
46 | + } | ||
47 | + distGoods.push(goods); | ||
48 | + }); | ||
49 | + | ||
50 | + | ||
51 | + | ||
52 | + dest.code = list.code; | ||
53 | + dest.goods = distGoods; | ||
54 | + dest.rec_id = list.recId; | ||
55 | + dest.message = list.message; | ||
56 | + | ||
57 | + // 清空变量,释放内存 | ||
58 | + data = {}; | ||
59 | + return dest; | ||
60 | +}; | ||
61 | + | ||
62 | +/** | ||
63 | + * 获取为你优选数据 | ||
64 | + */ | ||
65 | +exports.getPreference = (data) => { | ||
66 | + var defaultParam = { | ||
67 | + method: 'app.home.newPreference' | ||
68 | + }, | ||
69 | + infoData = Object.assign(defaultParam, data); // 处理完成后,发给后端 | ||
70 | + | ||
71 | + return api.get('', infoData).then(result => { | ||
72 | + | ||
73 | + return getPreferenceData(result); | ||
74 | + }); // 所有数据返回一个 Promise,方便 Promise.all 调用 | ||
75 | +}; |
@@ -28,6 +28,9 @@ const suggest = require(`${cRoot}/suggest`); | @@ -28,6 +28,9 @@ const suggest = require(`${cRoot}/suggest`); | ||
28 | const message = require(`${cRoot}/message`); | 28 | const message = require(`${cRoot}/message`); |
29 | const onlineService = require(`${cRoot}/onlineService`); | 29 | const onlineService = require(`${cRoot}/onlineService`); |
30 | 30 | ||
31 | +// recommend-for-you controller | ||
32 | +const recommendForYou = require(`${cRoot}/recommend-for-you`); | ||
33 | + | ||
31 | 34 | ||
32 | // const myDetail = require(`${cRoot}/myDetail); | 35 | // const myDetail = require(`${cRoot}/myDetail); |
33 | 36 | ||
@@ -128,4 +131,6 @@ router.get('/installment/agreement', installment.agreement);// æœåŠ¡åè®®é™æ€ | @@ -128,4 +131,6 @@ router.get('/installment/agreement', installment.agreement);// æœåŠ¡åè®®é™æ€ | ||
128 | router.get('/installment/server-crash', installment.serverCrash); // 服务器崩溃 | 131 | router.get('/installment/server-crash', installment.serverCrash); // 服务器崩溃 |
129 | router.get('/installment/bank-card', installment.bankCard); // 银行卡列表 | 132 | router.get('/installment/bank-card', installment.bankCard); // 银行卡列表 |
130 | 133 | ||
134 | +router.get('/recommend-for-you/userCenter', recommendForYou.userCenter);// 为你优选 | ||
135 | + | ||
131 | module.exports = router; | 136 | module.exports = router; |
@@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
8 | <h2>{{title}}</h2> | 8 | <h2>{{title}}</h2> |
9 | <div class="fav-price"> | 9 | <div class="fav-price"> |
10 | {{# discountPrice}} | 10 | {{# discountPrice}} |
11 | - <span class="new-price">¥{{.}}</span> | 11 | + <span class="new-price">{{.}}</span> |
12 | {{/ discountPrice}} | 12 | {{/ discountPrice}} |
13 | <span class="fav-price {{# discountPrice}}price-underline{{/ discountPrice}}">{{price}}</span> | 13 | <span class="fav-price {{# discountPrice}}price-underline{{/ discountPrice}}">{{price}}</span> |
14 | </div> | 14 | </div> |
@@ -79,7 +79,7 @@ | @@ -79,7 +79,7 @@ | ||
79 | <a class="list-item" href="/home/address"> | 79 | <a class="list-item" href="/home/address"> |
80 | <span class="iconfont icon"></span> | 80 | <span class="iconfont icon"></span> |
81 | 地址管理 | 81 | 地址管理 |
82 | - <span class="iconfont num">{{address_num}} </span> | 82 | + <span class="iconfont num">{{addressNum}} </span> |
83 | </a> | 83 | </a> |
84 | </div> | 84 | </div> |
85 | <div class="group-list"> | 85 | <div class="group-list"> |
@@ -125,5 +125,5 @@ | @@ -125,5 +125,5 @@ | ||
125 | {{> common/suspend-cart}} | 125 | {{> common/suspend-cart}} |
126 | </div> | 126 | </div> |
127 | 127 | ||
128 | -{{> download_app}} | 128 | +{{> download-app}} |
129 | 129 |
1 | 'use strict'; | 1 | 'use strict'; |
2 | 2 | ||
3 | -const mRoot = '../models'; | ||
4 | -const headerModel = require('../../../doraemon/models/header'); // 头部model | 3 | +// const mRoot = '../models'; |
4 | +// const headerModel = require('../../../doraemon/models/header'); // 头部model | ||
5 | const mayLikeModel = require('../models/recom'); | 5 | const mayLikeModel = require('../models/recom'); |
6 | 6 | ||
7 | +let genders = { | ||
8 | + boys: '1,3', | ||
9 | + girl: '2,3' | ||
10 | +}; | ||
11 | + | ||
12 | +let channels = { | ||
13 | + boys: 1, | ||
14 | + girl: 2, | ||
15 | + kids: 3, | ||
16 | + lifestyle: 4 | ||
17 | +}; | ||
18 | + | ||
7 | /** | 19 | /** |
8 | -* 你可能喜欢的BOYS或GIRLS的商品列表 | 20 | +* 你可能喜欢的BOYS或GIRLS或创意生活的商品列表 |
9 | */ | 21 | */ |
10 | 22 | ||
11 | const mayLike = (req, res, next) => { | 23 | const mayLike = (req, res, next) => { |
12 | let uid = req.user.uid; | 24 | let uid = req.user.uid; |
13 | let page = req.query.page || 1; | 25 | let page = req.query.page || 1; |
14 | let limit = 50; | 26 | let limit = 50; |
15 | - let gender = req.query.gender; | 27 | + let gender = req.query.gender || req.cookies._Channel && genders[req.cookies._Channel] || '1,3'; |
16 | let udid = req.sessionID || 'yoho'; | 28 | let udid = req.sessionID || 'yoho'; |
17 | let recPos = 100009; | 29 | let recPos = 100009; |
18 | - let channel = req.query.channel || 1; | 30 | + let channel = req.query.channel || req.cookies._Channel && channels[req.cookies._Channel] || 1; |
19 | 31 | ||
20 | if (channel === 1 || channel === 2) { | 32 | if (channel === 1 || channel === 2) { |
21 | mayLikeModel.mayLike(uid, page, limit, gender, udid, recPos, channel).then((result) => { | 33 | mayLikeModel.mayLike(uid, page, limit, gender, udid, recPos, channel).then((result) => { |
22 | 34 | ||
23 | - res.render('recom/goods', Object.assign({ | ||
24 | - layout: false | ||
25 | - }, result)); | 35 | + res.render('recom/goods', { |
36 | + layout: false, | ||
37 | + list: result | ||
38 | + }); | ||
39 | + | ||
26 | }).catch(next); | 40 | }).catch(next); |
27 | } else if (channel === 4) { | 41 | } else if (channel === 4) { |
42 | + | ||
28 | recPos = 100001; | 43 | recPos = 100001; |
44 | + gender = '1,3'; | ||
29 | 45 | ||
30 | mayLikeModel.mayLike(uid, page, limit, gender, udid, recPos, channel).then((result) => { | 46 | mayLikeModel.mayLike(uid, page, limit, gender, udid, recPos, channel).then((result) => { |
31 | - res.render('recom/goods', Object.assign({ | ||
32 | - layout: false | ||
33 | - }, result)); | 47 | + res.render('recom/goods', { |
48 | + layout: false, | ||
49 | + list: result | ||
50 | + }); | ||
34 | }).catch(next); | 51 | }).catch(next); |
35 | } | 52 | } |
36 | }; | 53 | }; |
@@ -41,13 +58,14 @@ const mayLike = (req, res, next) => { | @@ -41,13 +58,14 @@ const mayLike = (req, res, next) => { | ||
41 | const mayLikeKids = (req, res, next) => { | 58 | const mayLikeKids = (req, res, next) => { |
42 | let page = req.body.page || 1; | 59 | let page = req.body.page || 1; |
43 | let limit = 50; | 60 | let limit = 50; |
44 | - let channel = req.query.channel || 3; | 61 | + let channel = req.query.channel || req.cookies._Channel && channels[req.cookies._Channel] || 3; |
45 | 62 | ||
46 | mayLikeModel.mayLikeKids(page, limit, channel).then((result) => { | 63 | mayLikeModel.mayLikeKids(page, limit, channel).then((result) => { |
47 | 64 | ||
48 | - res.render('recom/goods', Object.assign({ | ||
49 | - layout: false | ||
50 | - }, result)); | 65 | + res.render('recom/goods', { |
66 | + layout: false, | ||
67 | + list: result | ||
68 | + }); | ||
51 | }).catch(next); | 69 | }).catch(next); |
52 | }; | 70 | }; |
53 | 71 |
@@ -17,6 +17,9 @@ const formatProduct = (list) => { | @@ -17,6 +17,9 @@ const formatProduct = (list) => { | ||
17 | val.isSoonSoldOut = val.isSoonSoldOut === 'Y'; | 17 | val.isSoonSoldOut = val.isSoonSoldOut === 'Y'; |
18 | } | 18 | } |
19 | 19 | ||
20 | + val.url = '/product/pro_' + val.productId + '_' + val.goodsList[0].goodsId + | ||
21 | + '/' + val.cnAlphabet + '.html'; | ||
22 | + | ||
20 | tag.push({ | 23 | tag.push({ |
21 | isNew: val.isNew === 'Y', | 24 | isNew: val.isNew === 'Y', |
22 | isDiscount: val.isDiscount === 'Y', | 25 | isDiscount: val.isDiscount === 'Y', |
@@ -25,7 +28,6 @@ const formatProduct = (list) => { | @@ -25,7 +28,6 @@ const formatProduct = (list) => { | ||
25 | isAdvance: val.isAdvance === 'Y' | 28 | isAdvance: val.isAdvance === 'Y' |
26 | }); | 29 | }); |
27 | 30 | ||
28 | - | ||
29 | _.forEach(tag, function(data) { | 31 | _.forEach(tag, function(data) { |
30 | 32 | ||
31 | if (data.isDiscount === true && val.isSoonSoldOut === true) { | 33 | if (data.isDiscount === true && val.isSoonSoldOut === true) { |
@@ -53,21 +55,25 @@ const mayLike = (uid, page, limit, gender, udid, recPos, channel) => { | @@ -53,21 +55,25 @@ const mayLike = (uid, page, limit, gender, udid, recPos, channel) => { | ||
53 | limit: limit, | 55 | limit: limit, |
54 | udid: udid, | 56 | udid: udid, |
55 | rec_pos: recPos, | 57 | rec_pos: recPos, |
56 | - yh_channel: channel | 58 | + yh_channel: channel, |
59 | + gender: gender | ||
57 | }).then((result) => { | 60 | }).then((result) => { |
58 | 61 | ||
59 | if (result && result.code === 200) { | 62 | if (result && result.code === 200) { |
60 | 63 | ||
61 | - if (page > result.data.page_total) { | ||
62 | - return; | ||
63 | - } | ||
64 | - | 64 | + if (result.data.page_total && page <= result.data.page_total) { |
65 | if (result.data.product_list) { | 65 | if (result.data.product_list) { |
66 | 66 | ||
67 | return formatProduct(result.data.product_list); | 67 | return formatProduct(result.data.product_list); |
68 | 68 | ||
69 | + } else { | ||
70 | + return false; | ||
69 | } | 71 | } |
70 | } else { | 72 | } else { |
73 | + return false; | ||
74 | + } | ||
75 | + | ||
76 | + } else { | ||
71 | logger.error('mayLike cood 不是 200'); | 77 | logger.error('mayLike cood 不是 200'); |
72 | } | 78 | } |
73 | }); | 79 | }); |
@@ -41,7 +41,6 @@ router.get('/detail/comments', detail.comments); // 商品评价 | @@ -41,7 +41,6 @@ router.get('/detail/comments', detail.comments); // 商品评价 | ||
41 | router.post('/detail/consultsubmit', auth, detail.consultsubmit); // 商品咨询提交接口 | 41 | router.post('/detail/consultsubmit', auth, detail.consultsubmit); // 商品咨询提交接口 |
42 | router.get('/recom/maylike', recom.mayLike);// 你可能喜欢 | 42 | router.get('/recom/maylike', recom.mayLike);// 你可能喜欢 |
43 | router.get('/recom/maylikekids', recom.mayLikeKids); // 潮童你可能喜欢 | 43 | router.get('/recom/maylikekids', recom.mayLikeKids); // 潮童你可能喜欢 |
44 | -// router.get('/recom/maylikelife', recom.mayLikeLifestyle); // 创意生活你可能喜欢 | ||
45 | 44 | ||
46 | router.post('/detail/consultupvote', detail.consultUpvoteOrUseful); // 商品咨询提交接口 | 45 | router.post('/detail/consultupvote', detail.consultUpvoteOrUseful); // 商品咨询提交接口 |
47 | router.post('/detail/consultuseful', detail.consultUpvoteOrUseful); // 商品咨询提交接口 | 46 | router.post('/detail/consultuseful', detail.consultUpvoteOrUseful); // 商品咨询提交接口 |
1 | -{{#if this}} {{!-- 剔除值为false的项 --}} | ||
2 | - {{#each this}} | 1 | +{{#if list}} {{!-- 剔除值为false的项 --}} |
2 | +{{!-- {{log this}} --}} | ||
3 | + {{#list}} | ||
3 | <div class="good-info {{#if @root.saleViplogin}}sale-vip{{/if}}" data-id="{{productSkn}}" data-bp-id="guang_goodList_{{productName}}_false"> | 4 | <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 | <div class="tag-container clearfix"> |
5 | {{#each tags}} | 6 | {{#each tags}} |
@@ -61,5 +62,5 @@ | @@ -61,5 +62,5 @@ | ||
61 | {{/if}} | 62 | {{/if}} |
62 | </div> | 63 | </div> |
63 | </div> | 64 | </div> |
64 | - {{/each}} | 65 | + {{/list}} |
65 | {{/if}} | 66 | {{/if}} |
1 | {{#showDownloadApp}} | 1 | {{#showDownloadApp}} |
2 | -<div class="float-layer hide" id="float-layer-app"> | 2 | +<div class="float-layer" id="float-layer-app"> |
3 | <div class="float-layer-left"> | 3 | <div class="float-layer-left"> |
4 | <span class="yoho-icon iconfont"></span> | 4 | <span class="yoho-icon iconfont"></span> |
5 | <p>新用户送惊喜礼包</p> | 5 | <p>新用户送惊喜礼包</p> |
@@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
8 | <i class="close-icon iconfont"></i> | 8 | <i class="close-icon iconfont"></i> |
9 | <div class="circle-rightbottom"></div> | 9 | <div class="circle-rightbottom"></div> |
10 | </a> | 10 | </a> |
11 | - <a href="javascript:void(0);" id="float-layer-btn"> | 11 | + <a href="http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho" id="float-layer-btn"> |
12 | 立即下载 | 12 | 立即下载 |
13 | </a> | 13 | </a> |
14 | </div> | 14 | </div> |
@@ -125,8 +125,10 @@ module.exports = function(specificGender) { | @@ -125,8 +125,10 @@ module.exports = function(specificGender) { | ||
125 | page: page + 1 | 125 | page: page + 1 |
126 | }, | 126 | }, |
127 | success: function(data) { | 127 | success: function(data) { |
128 | + // console.log(data) | ||
128 | var PRDID = []; | 129 | var PRDID = []; |
129 | if (data === ' ') { | 130 | if (data === ' ') { |
131 | + console.log(data); | ||
130 | searching = false; | 132 | searching = false; |
131 | loading.hideLoadingMask(); | 133 | loading.hideLoadingMask(); |
132 | 134 |
public/js/common/footer.js
0 → 100644
1 | +/** | ||
2 | + * 底部JS | ||
3 | + * @author: liangzhifeng<zhifeng.liang@yoho.cn> | ||
4 | + * @date: 2015/10/26 | ||
5 | + */ | ||
6 | + | ||
7 | +var $ = require('yoho-jquery'), | ||
8 | + Hammer = require('yoho-hammer'); | ||
9 | + | ||
10 | +var floatLayerBtnHammer; | ||
11 | + | ||
12 | +require('../common'); | ||
13 | + | ||
14 | +/** | ||
15 | + * 获取url参数 | ||
16 | + */ | ||
17 | +function getQueryString(name) { | ||
18 | + var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i'); | ||
19 | + var r = window.location.search.substr(1).match(reg); | ||
20 | + | ||
21 | + if (r != null) { | ||
22 | + return window.unescape(r[2]); | ||
23 | + } | ||
24 | + return null; | ||
25 | +} | ||
26 | + | ||
27 | +function downLoadApp() { | ||
28 | + var appUrl = 'http://www.yohoshow.com/about/index/yohobuyqr/'; | ||
29 | + var clickedAt = new Date(); | ||
30 | + | ||
31 | + setTimeout(function() { | ||
32 | + var mkt = getQueryString('mkt_code'); | ||
33 | + | ||
34 | + if ((new Date()) - clickedAt < 2000) { | ||
35 | + if (mkt) { | ||
36 | + appUrl += '?union_type=' + mkt; | ||
37 | + } | ||
38 | + window.location = appUrl; | ||
39 | + } | ||
40 | + }, 500); | ||
41 | +} | ||
42 | + | ||
43 | +$('#float-layer-close').on('touchend', function(e) { | ||
44 | + $('#float-layer-app').hide(); | ||
45 | + window.setCookie('_float-layer-app', 'id490655927', | ||
46 | + { | ||
47 | + domain: '.yohobuy.com' | ||
48 | + }); | ||
49 | + window.setCookie('_float-layer-app-close', 1, | ||
50 | + { | ||
51 | + domain: '.yohobuy.com', | ||
52 | + expires: 1 | ||
53 | + }); | ||
54 | + return false; | ||
55 | +}); | ||
56 | + | ||
57 | +if ($('#float-layer-btn') && $('#float-layer-btn')[0]) { | ||
58 | + floatLayerBtnHammer = new Hammer($('#float-layer-btn')[0]); | ||
59 | + floatLayerBtnHammer.on('tap', function(e) { | ||
60 | + downLoadApp('bottom'); | ||
61 | + e.srcEvent.stopPropagation(); | ||
62 | + }); | ||
63 | + | ||
64 | + // if (typeof window.cookie === 'function' && !window.cookie('_float-layer-app')) { | ||
65 | + // $('#float-layer-app').show(); | ||
66 | + // } else { | ||
67 | + // $('#float-layer-app').hide(); | ||
68 | + // } | ||
69 | +} |
1 | - | ||
2 | -require('./recommend-for-you-user-center'); | ||
3 | - | ||
4 | /** | 1 | /** |
5 | * 个人中心首页 | 2 | * 个人中心首页 |
6 | * @author: bikai<kai.bi@yoho.cn> | 3 | * @author: bikai<kai.bi@yoho.cn> |
@@ -11,11 +8,14 @@ var $ = require('yoho-jquery'), | @@ -11,11 +8,14 @@ var $ = require('yoho-jquery'), | ||
11 | 8 | ||
12 | var $userAvatar = $('.user-avatar'), | 9 | var $userAvatar = $('.user-avatar'), |
13 | $listItem = $('.list-item'); | 10 | $listItem = $('.list-item'); |
11 | + | ||
14 | var myImage = new Image(), | 12 | var myImage = new Image(), |
15 | avatar; | 13 | avatar; |
14 | + | ||
16 | require('../common'); | 15 | require('../common'); |
17 | require('./recommend-for-you-user-center'); | 16 | require('./recommend-for-you-user-center'); |
18 | require('../product/suspend-cart.js'); | 17 | require('../product/suspend-cart.js'); |
18 | +require('../common/footer'); | ||
19 | 19 | ||
20 | // 部分老用户没有头像,显示默认头像 | 20 | // 部分老用户没有头像,显示默认头像 |
21 | avatar = $userAvatar.data('avatar'); | 21 | avatar = $userAvatar.data('avatar'); |
@@ -12,7 +12,6 @@ var $recommendForYou = $('.recommend-for-you'); | @@ -12,7 +12,6 @@ var $recommendForYou = $('.recommend-for-you'); | ||
12 | 12 | ||
13 | $.get('/product/recommend-for-you/userCenter').then(function(html) { | 13 | $.get('/product/recommend-for-you/userCenter').then(function(html) { |
14 | var PRDID = []; | 14 | var PRDID = []; |
15 | - var $recommendSonLen = $recommendForYou.find('.good-info').length; | ||
16 | 15 | ||
17 | $recommendForYou.html(html); | 16 | $recommendForYou.html(html); |
18 | 17 | ||
@@ -24,6 +23,7 @@ $.get('/product/recommend-for-you/userCenter').then(function(html) { | @@ -24,6 +23,7 @@ $.get('/product/recommend-for-you/userCenter').then(function(html) { | ||
24 | PRDID.push($(this).data('id')); | 23 | PRDID.push($(this).data('id')); |
25 | }); | 24 | }); |
26 | 25 | ||
26 | + let $recommendSonLen = $recommendForYou.find('.good-info').length; | ||
27 | 27 | ||
28 | if ($recommendSonLen === 0) { | 28 | if ($recommendSonLen === 0) { |
29 | $recommendForYou.hide(); | 29 | $recommendForYou.hide(); |
@@ -53,3 +53,76 @@ | @@ -53,3 +53,76 @@ | ||
53 | width: 100%; | 53 | width: 100%; |
54 | } | 54 | } |
55 | } | 55 | } |
56 | + | ||
57 | +.float-layer { | ||
58 | + height: 128px; | ||
59 | + background: rgba(68, 68, 68, 0.95); | ||
60 | + position: fixed; | ||
61 | + width: 100%; | ||
62 | + bottom: 0; | ||
63 | + left: 0; | ||
64 | + z-index: 9999; | ||
65 | + padding: 20px 0; | ||
66 | + .float-layer-left { | ||
67 | + padding-left: 44px; | ||
68 | + overflow: hidden; | ||
69 | + float: left; | ||
70 | + img { | ||
71 | + height: 44px; | ||
72 | + float: left; | ||
73 | + margin-right: 20px; | ||
74 | + } | ||
75 | + p { | ||
76 | + float: left; | ||
77 | + font-size: 32px; | ||
78 | + height: 88px; | ||
79 | + line-height: 88px; | ||
80 | + color: white; | ||
81 | + } | ||
82 | + .yoho-icon { | ||
83 | + float: left; | ||
84 | + margin-right: 10px; | ||
85 | + font-size: 44px; | ||
86 | + line-height: 88px; | ||
87 | + width: 88px; | ||
88 | + height: 88px; | ||
89 | + text-align: center; | ||
90 | + color: #fff; | ||
91 | + border-radius: 20px; | ||
92 | + background-image: linear-gradient(#323232, #0f0f0f); | ||
93 | + } | ||
94 | + } | ||
95 | + } | ||
96 | + #float-layer-close { | ||
97 | + position: absolute; | ||
98 | + left: 0; | ||
99 | + top: 0; | ||
100 | + width: 100px; | ||
101 | + height: 100px; | ||
102 | + .close-icon { | ||
103 | + position: absolute; | ||
104 | + left: 0; | ||
105 | + top: 0; | ||
106 | + color: #C0C0C0; | ||
107 | + z-index: 2; | ||
108 | + } | ||
109 | + } | ||
110 | + #float-layer-btn { | ||
111 | + position: absolute; | ||
112 | + top: 50%; | ||
113 | + right: 15px; | ||
114 | + font-size: 32px; | ||
115 | + padding: 0 10px; | ||
116 | + height: 54px; | ||
117 | + line-height: 54px; | ||
118 | + background: white; | ||
119 | + border-radius: 5px; | ||
120 | + margin-top: -26px; | ||
121 | + -webkit-tap-highlight-color: rgba(0, 0, 0, 0.5); | ||
122 | + &:link, | ||
123 | + &:visited, | ||
124 | + &:hover, | ||
125 | + &:actived { | ||
126 | + color: #000; | ||
127 | + } | ||
128 | + } |
-
Please register or login to post a comment