Authored by ccbikai(👎🏻🍜)

Merge branch 'release/usercenter'

... ... @@ -10,6 +10,7 @@ const favoriteModel = require('../models/favorite');
const headerModel = require('../../../doraemon/models/header'); // 头部model
const favorite = (req, res) => {
let tab = req.query.tab || '';
res.render('favorite', {
module: 'home',
... ... @@ -21,13 +22,14 @@ const favorite = (req, res) => {
pageFooter: true,
favorite: {
productUrl: '//m.yohobuy.com/product/new',
brandUrl: '//m.yohobuy.com/product/new'
brandUrl: '//m.yohobuy.com/product/new',
brandTab: tab === 'brand' ? true : false // 是否为品牌收藏页
}
});
};
let favProduct = (req, res, next) => {
let uid = req.user.uid;
let uid = req.user.uid || 12696231;
let page = req.query.page || 1;
let limit = 10;
... ... @@ -44,7 +46,7 @@ let favProduct = (req, res, next) => {
};
let favfavBrand = (req, res, next) => {
let uid = req.user.uid;
let uid = req.user.uid || 12696231;
let page = req.query.page || 1;
let limit = 10;
... ... @@ -63,7 +65,7 @@ let favfavBrand = (req, res, next) => {
};
let favoriteDelete = (req, res, next) => {
let uid = req.user.uid;
let uid = req.user.uid || 12696231;
let type = 'product';
let favId = req.body.id;
... ...
... ... @@ -17,20 +17,14 @@ const indexModel = require('../models/index');
*/
exports.index = (req, res, next) => {
let params = {
uid: req.user.uid
uid: req.user.uid,
channel: req.query.channel || 1,
udid: require('md5')(req.ip)
};
let refer = req.get('Referer') || `${global.yoho.config.siteUrl}/${req.cookies._Channel || ''}`;
let reqPath = req.baseUrl + req.path;
let backUrl = refer.indexOf(reqPath) === -1 ? refer : '';
backUrl && res.cookie('saleRefer', backUrl, {
domain: 'm.yohobuy.com'
});
backUrl = backUrl || req.cookies.saleRefer;
let headerData = headerModel.setNav({
navTitle: '个人中心',
backUrl: backUrl,
backUrl: '//m.yohobuy.com/?go=1',
});
indexModel.index(params).then(result => {
... ...
... ... @@ -48,7 +48,6 @@ const readdData = (req, res, next) => {
let uid = req.user.uid;
orderDetailModel.readdData(orderCode, uid).then((result) => {
console.log(result);
res.json(result);
}).catch(next);
};
... ...
'use strict';
const mRoot = '../models';
const recommendForYouModel = require(`${mRoot}/recommend-for-you`); // 领取优惠券 model
exports.userCenter = (req, res, next) => {
var udid = req.sessionID,
uid = req.user.uid || 0,
yhChannel = req.query.yh_channel || '1',
limit = 30;
recommendForYouModel.getPreference({
yh_channel: yhChannel,
udid: udid,
limit: limit,
rec_pos: '100004',
uid: uid
}).then((preferenceData) => {
if (preferenceData.code === 200) {
// 获取信息成功
}
res.render('recommend-for-you/index', {
layout: false,
result: preferenceData,
module: 'product',
page: 'recommend'
});
}).catch(next);
};
exports.cart = (req, res, next) => {
var udid = req.sessionID,
uid = req.user.uid || 0,
yhChannel = req.query.yh_channel || '1',
limit = 30;
recommendForYouModel.getPreference({
yh_channel: yhChannel,
udid: udid,
limit: limit,
rec_pos: '100003',
uid: uid
}).then((preferenceData) => {
if (preferenceData.code === 200) {
// 获取信息成功
}
res.render('recommend-for-you/index', {
layout: false,
result: preferenceData,
module: 'product',
page: 'recommend'
});
}).catch(next);
};
... ...
... ... @@ -73,13 +73,13 @@ const favProduct = (uid, page, limit) => {
if (val.marketPrice - val.salesPrice > 0) {
obj = _.assign(obj, {
discountPrice: val.salesPrice
discountPrice: '¥' + Number(val.salesPrice).toFixed(2),
});
}
if (val.priceDown > 0) {
obj = _.assign(obj, {
savePrice: '¥' + val.priceDown
savePrice: '¥' + Number(val.priceDown).toFixed(2),
});
} else {
obj = _.assign(obj, {
... ... @@ -96,7 +96,7 @@ const favProduct = (uid, page, limit) => {
obj = _.assign(obj, {
favId: val.productId,
title: val.productName,
price: '¥' + val.marketPrice,
price: '¥' + Number(val.marketPrice).toFixed(2),
invalidGoods: val.status === 0
});
... ... @@ -175,8 +175,8 @@ const favfavBrand = (uid, page, limit) => {
link: '/product/pro_' + data.productId + '_' +
data.goods[0].id + '/' + data.cnAlphabet + '.html',
imgUrl: data.defaultImages,
price: '¥' + data.marketPrice,
discount: data.marketPrice > data.salesPrice ? '¥' + data.salesPrice : false,
price: '¥' + Number(data.marketPrice).toFixed(2),
discount: data.marketPrice > data.salesPrice ? '¥' + Number(data.salesPrice).toFixed(2) : false,
});
});
... ...
... ... @@ -76,6 +76,17 @@ const _infoNum = (params) => {
};
/**
* 从接口获取地址列表
* @param params
*/
const _getAddressData = (params) => {
return api.get('', {
method: 'app.address.gethidden',
uid: params.uid
}, {code: 200});
};
/**
* 个人中心首页
* @param params
* @returns {function()}
... ... @@ -98,7 +109,8 @@ const index = (params) => {
_userData(params),
_noticeData(),
_favoriteData(params),
_infoNum(params)
_infoNum(params),
_getAddressData(params)
]).then(result => {
if (result[0] && result[0].data) {
Object.assign(finalResult, {
... ... @@ -114,6 +126,12 @@ const index = (params) => {
});
}
if (result[2] && result[2].data) {
Object.assign(finalResult, {
productFavoriteTotal: result[2].data.product_favorite_total
});
}
if (result[3] && result[3].data) {
Object.assign(finalResult, {
sendCargoNum: result[3].data.send_cargo_num,
... ... @@ -122,12 +140,16 @@ const index = (params) => {
yohoCoinNum: result[3].data.yoho_coin_num,
inboxTotal: result[3].data.inbox_total,
couponNum: result[3].data.coupon_num,
productFavoriteTotal: result[3].data.product_favorite_total,
brandFavoriteTotal: result[3].data.brand_favorite_total,
productBrowse: result[3].data.product_browse
});
}
if (result[4] && result[4].data) {
Object.assign(finalResult, {
addressNum: result[4].data.length
});
}
return finalResult;
});
... ...
... ... @@ -14,12 +14,9 @@ const closeReasons = () => {
return api.get('', {
method: 'app.SpaceOrders.closeReasons'
}).then((result) => {
// console.log(result)
if (result && result.code === 200) {
// console.log(result)
return result.data;
} else {
// console.log('bushi 200');
return {};
}
});
... ... @@ -164,7 +161,7 @@ const orderDetailData = (uid, orderCode) => {
uid: uid,
order_code: orderCode
}).then((result) => {
// console.log(result)
if (result && result.code === 200) {
let orderDetail = camelCase(result.data);
let goods = [];
... ... @@ -197,7 +194,7 @@ const orderDetailData = (uid, orderCode) => {
}
_.forEach(orderDetail.orderGoods, function(data) {
// console.log(data);
let obj = {};
let count = +data.buyNumber;
... ... @@ -289,7 +286,6 @@ const orderDetailData = (uid, orderCode) => {
cancelReason: resons
});
// console.log(orderDetail);
return orderDetail;
});
... ...
'use strict';
var api = global.yoho.API;
const camelCase = global.yoho.camelCase;
const helpers = global.yoho.helpers;
const _ = require('lodash');
/**
* 分享页面基础参数
* @param {object} sizeInfo [接口原始数据]
* @return {object} [description]
*/
const getPreferenceData = (data) => {
var dest = {};
let list = data.data || {};
list = camelCase(list);
let distGoods = [];
_.forEach(list.productList, function(value) {
if (!value.productSkn || !value.goodsList || !value.goodsList.length) {
return;
}
value.goodsId = value.goodsList[0].goodsId;
let goods = value;
goods.url = helpers.urlFormat(`/product/pro_${value.productId}_${value.goodsId}/${value.cnAlphabet}.html`);
if (_.get(goods, 'tags[0]', null)) {
goods.tags = [];
if (goods.isNew === 'Y') {
goods.tags.push({isNew: true});
} else if (goods.isAdvance === 'Y') {
goods.tags.push({isAdvance: true});
} else if (goods.isDiscount === 'Y') {
goods.tags.push({isDiscount: true});
} else if (goods.isYohoood === 'Y') {
goods.tags.push({isYohoood: true});
} else if (goods.isLimited === 'Y') {
goods.tags.push({isLimited: true});
}
}
distGoods.push(goods);
});
dest.code = list.code;
dest.goods = distGoods;
dest.rec_id = list.recId;
dest.message = list.message;
// 清空变量,释放内存
data = {};
return dest;
};
/**
* 获取为你优选数据
*/
exports.getPreference = (data) => {
var defaultParam = {
method: 'app.home.newPreference'
},
infoData = Object.assign(defaultParam, data); // 处理完成后,发给后端
return api.get('', infoData).then(result => {
return getPreferenceData(result);
}); // 所有数据返回一个 Promise,方便 Promise.all 调用
};
... ...
... ... @@ -28,6 +28,9 @@ const suggest = require(`${cRoot}/suggest`);
const message = require(`${cRoot}/message`);
const onlineService = require(`${cRoot}/onlineService`);
// recommend-for-you controller
const recommendForYou = require(`${cRoot}/recommend-for-you`);
// const myDetail = require(`${cRoot}/myDetail);
... ... @@ -128,4 +131,6 @@ router.get('/installment/agreement', installment.agreement);// æœåŠ¡åè®®é™æ€
router.get('/installment/server-crash', installment.serverCrash); // 服务器崩溃
router.get('/installment/bank-card', installment.bankCard); // 银行卡列表
router.get('/recommend-for-you/userCenter', recommendForYou.userCenter);// 为你优选
module.exports = router;
... ...
... ... @@ -8,7 +8,7 @@
<h2>{{title}}</h2>
<div class="fav-price">
{{# discountPrice}}
<span class="new-price">{{.}}</span>
<span class="new-price">{{.}}</span>
{{/ discountPrice}}
<span class="fav-price {{# discountPrice}}price-underline{{/ discountPrice}}">{{price}}</span>
</div>
... ...
... ... @@ -79,7 +79,7 @@
<a class="list-item" href="/home/address">
<span class="iconfont icon">&#xe637;</span>
地址管理
<span class="iconfont num">{{address_num}} &#xe604;</span>
<span class="iconfont num">{{addressNum}} &#xe604;</span>
</a>
</div>
<div class="group-list">
... ... @@ -125,5 +125,5 @@
{{> common/suspend-cart}}
</div>
{{> download_app}}
{{> download-app}}
... ...
{{# result}}
<div id="goods-container" class="goods-container">
<p class="title">
<span>为你优选新品</span>
</p>
<div class="new-goods container clearfix">
{{# goods}}
{{> common/goods}}
{{/ goods}}
</div>
</div>
{{/result}}
... ...
'use strict';
const mRoot = '../models';
const headerModel = require('../../../doraemon/models/header'); // 头部model
// const mRoot = '../models';
// const headerModel = require('../../../doraemon/models/header'); // 头部model
const mayLikeModel = require('../models/recom');
let genders = {
boys: '1,3',
girl: '2,3'
};
let channels = {
boys: 1,
girl: 2,
kids: 3,
lifestyle: 4
};
/**
* 你可能喜欢的BOYS或GIRLS的商品列表
* 你可能喜欢的BOYS或GIRLS或创意生活的商品列表
*/
const mayLike = (req, res, next) => {
let uid = req.user.uid;
let page = req.query.page || 1;
let limit = 50;
let gender = req.query.gender;
let gender = req.query.gender || req.cookies._Channel && genders[req.cookies._Channel] || '1,3';
let udid = req.sessionID || 'yoho';
let recPos = 100009;
let channel = req.query.channel || 1;
let channel = req.query.channel || req.cookies._Channel && channels[req.cookies._Channel] || 1;
if (channel === 1 || channel === 2) {
mayLikeModel.mayLike(uid, page, limit, gender, udid, recPos, channel).then((result) => {
res.render('recom/goods', Object.assign({
layout: false
}, result));
res.render('recom/goods', {
layout: false,
list: result
});
}).catch(next);
} else if (channel === 4) {
recPos = 100001;
gender = '1,3';
mayLikeModel.mayLike(uid, page, limit, gender, udid, recPos, channel).then((result) => {
res.render('recom/goods', Object.assign({
layout: false
}, result));
res.render('recom/goods', {
layout: false,
list: result
});
}).catch(next);
}
};
... ... @@ -41,13 +58,14 @@ const mayLike = (req, res, next) => {
const mayLikeKids = (req, res, next) => {
let page = req.body.page || 1;
let limit = 50;
let channel = req.query.channel || 3;
let channel = req.query.channel || req.cookies._Channel && channels[req.cookies._Channel] || 3;
mayLikeModel.mayLikeKids(page, limit, channel).then((result) => {
res.render('recom/goods', Object.assign({
layout: false
}, result));
res.render('recom/goods', {
layout: false,
list: result
});
}).catch(next);
};
... ...
... ... @@ -17,6 +17,9 @@ const formatProduct = (list) => {
val.isSoonSoldOut = val.isSoonSoldOut === 'Y';
}
val.url = '/product/pro_' + val.productId + '_' + val.goodsList[0].goodsId +
'/' + val.cnAlphabet + '.html';
tag.push({
isNew: val.isNew === 'Y',
isDiscount: val.isDiscount === 'Y',
... ... @@ -25,7 +28,6 @@ const formatProduct = (list) => {
isAdvance: val.isAdvance === 'Y'
});
_.forEach(tag, function(data) {
if (data.isDiscount === true && val.isSoonSoldOut === true) {
... ... @@ -53,21 +55,25 @@ const mayLike = (uid, page, limit, gender, udid, recPos, channel) => {
limit: limit,
udid: udid,
rec_pos: recPos,
yh_channel: channel
yh_channel: channel,
gender: gender
}).then((result) => {
if (result && result.code === 200) {
if (page > result.data.page_total) {
return;
}
if (result.data.page_total && page <= result.data.page_total) {
if (result.data.product_list) {
return formatProduct(result.data.product_list);
} else {
return false;
}
} else {
return false;
}
} else {
logger.error('mayLike cood 不是 200');
}
});
... ...
... ... @@ -41,7 +41,6 @@ router.get('/detail/comments', detail.comments); // 商品评价
router.post('/detail/consultsubmit', auth, detail.consultsubmit); // 商品咨询提交接口
router.get('/recom/maylike', recom.mayLike);// 你可能喜欢
router.get('/recom/maylikekids', recom.mayLikeKids); // 潮童你可能喜欢
// router.get('/recom/maylikelife', recom.mayLikeLifestyle); // 创意生活你可能喜欢
router.post('/detail/consultupvote', detail.consultUpvoteOrUseful); // 商品咨询提交接口
router.post('/detail/consultuseful', detail.consultUpvoteOrUseful); // 商品咨询提交接口
... ...
{{#if this}} {{!-- 剔除值为false的项 --}}
{{#each this}}
{{#if list}} {{!-- 剔除值为false的项 --}}
{{!-- {{log this}} --}}
{{#list}}
<div class="good-info {{#if @root.saleViplogin}}sale-vip{{/if}}" data-id="{{productSkn}}" data-bp-id="guang_goodList_{{productName}}_false">
<div class="tag-container clearfix">
{{#each tags}}
... ... @@ -61,5 +62,5 @@
{{/if}}
</div>
</div>
{{/each}}
{{/list}}
{{/if}}
... ...
{{#showDownloadApp}}
<div class="float-layer hide" id="float-layer-app">
<div class="float-layer" id="float-layer-app">
<div class="float-layer-left">
<span class="yoho-icon iconfont">&#xe60d;</span>
<p>新用户送惊喜礼包</p>
... ... @@ -8,7 +8,7 @@
<i class="close-icon iconfont">&#xe623;</i>
<div class="circle-rightbottom"></div>
</a>
<a href="javascript:void(0);" id="float-layer-btn">
<a href="http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho" id="float-layer-btn">
立即下载
</a>
</div>
... ...
... ... @@ -125,8 +125,10 @@ module.exports = function(specificGender) {
page: page + 1
},
success: function(data) {
// console.log(data)
var PRDID = [];
if (data === ' ') {
console.log(data);
searching = false;
loading.hideLoadingMask();
... ...
/**
* 底部JS
* @author: liangzhifeng<zhifeng.liang@yoho.cn>
* @date: 2015/10/26
*/
var $ = require('yoho-jquery'),
Hammer = require('yoho-hammer');
var floatLayerBtnHammer;
require('../common');
/**
* 获取url参数
*/
function getQueryString(name) {
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
var r = window.location.search.substr(1).match(reg);
if (r != null) {
return window.unescape(r[2]);
}
return null;
}
function downLoadApp() {
var appUrl = 'http://www.yohoshow.com/about/index/yohobuyqr/';
var clickedAt = new Date();
setTimeout(function() {
var mkt = getQueryString('mkt_code');
if ((new Date()) - clickedAt < 2000) {
if (mkt) {
appUrl += '?union_type=' + mkt;
}
window.location = appUrl;
}
}, 500);
}
$('#float-layer-close').on('touchend', function(e) {
$('#float-layer-app').hide();
window.setCookie('_float-layer-app', 'id490655927',
{
domain: '.yohobuy.com'
});
window.setCookie('_float-layer-app-close', 1,
{
domain: '.yohobuy.com',
expires: 1
});
return false;
});
if ($('#float-layer-btn') && $('#float-layer-btn')[0]) {
floatLayerBtnHammer = new Hammer($('#float-layer-btn')[0]);
floatLayerBtnHammer.on('tap', function(e) {
downLoadApp('bottom');
e.srcEvent.stopPropagation();
});
// if (typeof window.cookie === 'function' && !window.cookie('_float-layer-app')) {
// $('#float-layer-app').show();
// } else {
// $('#float-layer-app').hide();
// }
}
... ...
require('./recommend-for-you-user-center');
/**
* 个人中心首页
* @author: bikai<kai.bi@yoho.cn>
... ... @@ -11,11 +8,14 @@ var $ = require('yoho-jquery'),
var $userAvatar = $('.user-avatar'),
$listItem = $('.list-item');
var myImage = new Image(),
avatar;
require('../common');
require('./recommend-for-you-user-center');
require('../product/suspend-cart.js');
require('../common/footer');
// 部分老用户没有头像,显示默认头像
avatar = $userAvatar.data('avatar');
... ...
... ... @@ -12,7 +12,6 @@ var $recommendForYou = $('.recommend-for-you');
$.get('/product/recommend-for-you/userCenter').then(function(html) {
var PRDID = [];
var $recommendSonLen = $recommendForYou.find('.good-info').length;
$recommendForYou.html(html);
... ... @@ -24,6 +23,7 @@ $.get('/product/recommend-for-you/userCenter').then(function(html) {
PRDID.push($(this).data('id'));
});
let $recommendSonLen = $recommendForYou.find('.good-info').length;
if ($recommendSonLen === 0) {
$recommendForYou.hide();
... ...
... ... @@ -53,3 +53,76 @@
width: 100%;
}
}
.float-layer {
height: 128px;
background: rgba(68, 68, 68, 0.95);
position: fixed;
width: 100%;
bottom: 0;
left: 0;
z-index: 9999;
padding: 20px 0;
.float-layer-left {
padding-left: 44px;
overflow: hidden;
float: left;
img {
height: 44px;
float: left;
margin-right: 20px;
}
p {
float: left;
font-size: 32px;
height: 88px;
line-height: 88px;
color: white;
}
.yoho-icon {
float: left;
margin-right: 10px;
font-size: 44px;
line-height: 88px;
width: 88px;
height: 88px;
text-align: center;
color: #fff;
border-radius: 20px;
background-image: linear-gradient(#323232, #0f0f0f);
}
}
}
#float-layer-close {
position: absolute;
left: 0;
top: 0;
width: 100px;
height: 100px;
.close-icon {
position: absolute;
left: 0;
top: 0;
color: #C0C0C0;
z-index: 2;
}
}
#float-layer-btn {
position: absolute;
top: 50%;
right: 15px;
font-size: 32px;
padding: 0 10px;
height: 54px;
line-height: 54px;
background: white;
border-radius: 5px;
margin-top: -26px;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0.5);
&:link,
&:visited,
&:hover,
&:actived {
color: #000;
}
}
\ No newline at end of file
... ...