Authored by zhangxiaoru

yohocoin

... ... @@ -8,21 +8,36 @@
const myCurrencyModel = require('../models/myCurrency');
const headerModel = require('../../../doraemon/models/header'); // 头部model
const _ = require('lodash');
const myCurrency = (req, res, next) => {
let uid = req.user.uid || 8039759;
let contentCode = '05afedf76886d732573f10f7451a1703';
let gender = req.query.gender || '1,3';
let lifestyleHomePage = '';
myCurrencyModel.myCurrency(uid).then(result => {
if(gender === '3,3') {
lifestyleHomePage = true;
} else {
lifestyleHomePage = false;
}
myCurrencyModel.myCurrency(uid, contentCode).then(result => {
res.render('currency-new', {
module: 'home',
page: 'currency',
pageHeader: headerModel.setNav({
page: 'currency-new',
pageHeader: _.assign(headerModel.setNav({
navTitle: '有货币'
}), {
currencyPage: true,
navBtn: false
}),
title: '有货币',
pageFooter: true,
yohoCoin: result
yohoCoin: result.yohoCoin,
banner: result.banner,
lifestyleHomePage: lifestyleHomePage
});
}).catch(next);
};
... ... @@ -37,11 +52,15 @@ const currencyDetail = (req, res, next) => {
res.render('currency-detail', {
module: 'home',
page: 'currency-detail',
pageHeader: headerModel.setNav({
pageHeader: _.assign(headerModel.setNav({
navTitle: '有货币明细'
}), {
currencyDetailPage: true,
navBtn: false
}),
title: '有货币明细',
pageFooter: true,
money: result.money
});
}).catch(next);
... ... @@ -64,6 +83,6 @@ let ajaxCurrencyDetail = (req, res, next) => {
module.exports = {
myCurrency,
currencyDetail,
ajaxCurrencyDetail
ajaxCurrencyDetail,
};
... ...
'use strict';
const serviceAPI = global.yoho.ServiceAPI;
const api = global.yoho.API;
const _ = require('lodash');
const camelCase = global.yoho.camelCase;
const logger = global.yoho.logger;
const myCurrency = (uid) => {
const yohoCoin = (uid) => {
return api.get('', {
method: 'app.yoho.yohocoin',
uid: uid
... ... @@ -20,18 +20,34 @@ const myCurrency = (uid) => {
});
};
// const banner = (CODE_YOHOCOIN_BANNER) => {
// return api.get('', {
// content_code: 'CODE_YOHOCOIN_BANNER',
// }).then((result) => {
// console.log(content_code)
// if(result && result.code === 200) {
// return camelCase(result.data);
// } else {
// logger.error('youho币总数 cood 不是 200');
// }
// })
// };
const bannerData = (contentCode) => {
return serviceAPI.get('operations/api/v5/resource/get', {
content_code: contentCode
}).then((result) => {
//console.log(result)
if (result && result.code === 200) {
return result.data
} else {
logger.error('banner is not 200');
return {};
}
});
};
const myCurrency = (uid, contentCode) => {
return Promise.all([yohoCoin(uid), bannerData(contentCode)])
.then((result) => {
return {
yohoCoin: result[0],
banner: result[1]
};
});
};
const currencyDetail = (uid, page, limit) => {
return api.get('', {
... ... @@ -40,7 +56,7 @@ const currencyDetail = (uid, page, limit) => {
page: page,
limit: limit
}).then((result) => {
// console.log(result)
if (result && result.code === 200) {
let total = parseInt(result.data.page_total, 10) + 1;
... ... @@ -70,7 +86,24 @@ const currencyDetail = (uid, page, limit) => {
});
};
const mayLike = (uid, page, limit, udid, gender, recPos, channel) => {
return api.get('', {
method: 'app.search.newLast7day',
uid: uid,
page: page,
limit: limit,
udid: udid,
rec_pos: recPos,
yh_channel: channel
}).then((result) => {
console.log(result)
});
}
module.exports = {
myCurrency,
currencyDetail
currencyDetail,
bannerData,
yohoCoin,
mayLike
};
... ...
... ... @@ -19,11 +19,17 @@
</div>
<div class="banner">
{{#banner}}
{{#data}}
<a href="{{url}}">
<img src="{{img}}" alt="img">
<img src="{{image src 640 200 2}}" alt="img">
</a>
{{/data}}
{{/banner}}
</div>
{{!-- {{> home/maybe_like}} --}}
{{#if lifestyleHomePage}}
{{> home/maybe-like-lifestyle}}
{{else}}
{{> home/maybe-like}}
{{/if}}
</div>
\ No newline at end of file
... ...
<div class="yoho-coin-page yoho-page">
{{# yohoCoin}}
<p class="coin-num">
<em>{{coinNum}}</em>
YOHO币
</p>
<section>
<p class="title">YOHO币</p>
<hr>
<p>
<span class="sub-title">YOHO币是什么,有什么用?</span>
YOHO币是有货商城的虚拟货币,与现金比例1:1,没有任何使用期限,YOHO币可直接用于有货线上购物使用,不可转让他人,不可兑换为现金。使用YOHO币支付的金额不可计入消费金额。
</p>
<p>
<span class="sub-title">如何查看自己的YOHO币?</span>
<span class="path">登录 > 个人中心 > 我的YOHO币</span>
</p>
<p>
<span class="sub-title">YOHO币如何购买支付?</span>
在购买支付页面输入您要使用的YOHO币金额即可完成支付
<div class="remark">
<span></span>
如果超过了我们约定的期限的非正常退货,我们将会于您的退款金额中直接扣除赠送YOHO币等值的金额。赠送给您的YOHO币还将保留在您的账户中,敬请谅解。
</div>
</p>
</section>
{{/ yohoCoin}}
</div>
\ No newline at end of file
... ...
<div class="maybe-like">
<ul id="maybe-like-nav" class="maybe-like-nav clearfix">
<li class="maybe-like-nav-item focus">新品到着</li>
<li class="maybe-like-nav-item">人气单品</li>
</ul>
<div id="goods-list">
{{# goodsContainer}}
<div class="goods-list {{^show}}hide{{/show}}">
{{# goods}}
{{> good}}
{{/ goods}}
</div>
{{/ goodsContainer}}
</div>
<div id="load-more-info" class="load-more-info">
<div class="loading status hide">
正在加载...
</div>
<span class="no-more status hide">没有更多啦</span>
</div>
</div>
\ No newline at end of file
... ...
<div class="maybe-like">
<p class="title">
<i class="icon"></i>
<span>你可能喜欢</span>
</p>
<div id="goods-list" class="goods-list clearfix"></div>
</div>
<div class="load-more-img hide" id="load-more-img">
<a href="">
<img src="">
</a>
</div>
... ...
<div class="maybe-like">
<p class="title">
<i class="icon"></i>
<span>你可能喜欢</span>
</p>
<div id="goods-list" class="goods-list clearfix"></div>
</div>
<div class="load-more-img hide" id="load-more-img">
<a href="">
<img src="">
</a>
</div>
... ...
... ... @@ -4,6 +4,254 @@
* @date: 2015/10/12
*/
// module.exports = function(specificGender) {
// var $ = require('yoho-jquery'),
// Hammer = require('yoho-hammer'),
// ellipsis = require('yoho-mlellipsis'),
// tip = require('../plugin/tip'),
// loading = require('../plugin/loading'),
// lazyLoad = require('yoho-jquery-lazyload');
// var navHammer,
// winH = $(window).height(),
// $goodList = $('#goods-list'),
// searching = false,
// page = 0,
// gender = null,
// num,
// url,
// RECPOSE = '';
// // The kidsType can be specified by the parameter. Add by @ZhaoBiao
// var kidsType = specificGender === 'kids' || $('.mobile-wrap').hasClass('kids-wrap') ? true : false,
// lifestyleType = specificGender === 'lifestyle' ||
// $('.mobile-wrap').hasClass('lifestyle-wrap') ? true : false,
// yohoCoinType = $('.coin').length ? true : false;
// var $curNav,
// index,
// $navList = $('#maybe-like-nav');
// var $footer;
// var bottomBannerLoaded;
// ellipsis.init();
// // ajax url
// if (kidsType) {
// url = '/product/recom/maylikekids';
// } else if (lifestyleType) {
// //有货币页面加载男生首页的数据
// url = specificGender === 'lifestyle' ? '/product/recom/maylike?gender=1,3&rec_pos=100001' : '/product/recom/maylikelife';
// } else if (yohoCoinType) {
// gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ?
// '1,3&rec_pos=100009' : '2,3&rec_pos=100009',
// url = '/product/recom/maylike?gender=' + gender;
// RECPOSE = 110009;
// } else if (logisticType) { //物流页面
// gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ?
// '1,3&rec_pos=100006' : '2,3&rec_pos=100006',
// url = '/product/recom/maylike?gender=' + gender;
// RECPOSE = 110006;
// } else {
// gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ?
// '1,3&rec_pos=100001' : '2,3&rec_pos=100002',
// url = '/product/recom/maylike?gender=' + gender;
// }
// // 首页男生和女生,推荐位ID,埋点
// if (window.location.pathname === '/boys') {
// RECPOSE = 110001;
// } else if (window.location.pathname === '/girls') {
// RECPOSE = 110002;
// }
// $curNav = $navList.children('.focus');
// if (lifestyleType) {
// navHammer = $navList[0] ? new Hammer($navList[0]) : null;
// if (navHammer) {
// navHammer.on('tap', function(e) {
// var $this = $(e.target).closest('li'),
// $goods = $('.goods-list'),
// $content;
// e.preventDefault();
// if ($this.hasClass('focus')) {
// return;
// }
// index = $this.index();
// $this.addClass('focus');
// $curNav.removeClass('focus');
// $goods.not('.hide').addClass('hide');
// $content = $goods.eq(index);
// $content.removeClass('hide');
// $curNav = $this;
// $(document).trigger('scroll'); // Trigger lazyLoad
// e.srcEvent.stopPropagation();
// });
// }
// }
// loading.init($('.maybe-like'));
// function search() {
// if (searching) {
// return;
// }
// searching = true;
// loading.showLoadingMask();
// // num = $goodList.find('.good-info').length;
// $.ajax({
// type: 'GET',
// url: url,
// data: {
// page: page + 1
// },
// success: function(data) {
// var PRDID = [];
// if (data === ' ') {
// loading.hideLoadingMask();
// // 有货币页面不加载底部
// if (gender && !specificGender) {
// if (bottomBannerLoaded) {
// return;
// }
// url = '/channel/bottomBanner';
// $.ajax({
// type: 'GET',
// url: url,
// data: {
// gender: gender
// },
// success: function(res) {
// res = res.data;
// bottomBannerLoaded = true;
// if (res && res.img) {
// $('#load-more-img').show();
// $('#load-more-img a').attr('href', res.url);
// $('#load-more-img a > img').attr('src', res.img);
// }
// }
// });
// }
// return;
// } else {
// searching = false;
// }
// // 加载到数据后,去除bottom样式,使得footer能够随着页面长度的增加改变位置
// if (data.length > 1) {
// $footer ? null : $footer = $('#yoho-footer');
// $footer.hasClass('bottom') ? $footer.removeClass('bottom') : null;
// }
// num = $goodList.find('.good-info').length;
// $goodList.append(data);
// // 2015/10/31 fei.hong: 修复第一页分页不显示图片的问题
// if (num === 0) {
// lazyLoad($goodList.find('.good-info').find('img.lazy'));
// } else {
// lazyLoad($goodList.find('.good-info:gt(' + (num - 1) + ')').find('img.lazy'));
// }
// loading.hideLoadingMask();
// page++;
// $('.good-detail-text .name').each(function() {
// var $this = $(this),
// $title = $this.find('a');
// $title[0].mlellipsis(2);
// });
// // 为您优选埋点 start
// PRDID = [];
// $(data).closest('.good-info').each(function() {
// PRDID.push($(this).data('id'));
// });
// window.givePoint({
// REC_POSE: RECPOSE,
// PRD_ID: PRDID.join(','),
// PRD_NUM: $(data).closest('.good-info').length,
// ACTION_ID: 0,
// page_num: page
// });
// // 为您优选埋点 end
// },
// error: function() {
// tip.show('网络断开连接了~');
// searching = false;
// loading.hideLoadingMask();
// }
// });
// }
// $('.maybe-like p').on('touchstart', function() {
// search();
// });
// function scrollHandler() {
// if ($(window).scrollTop() + winH >= $(document).height() - 200) {
// search();
// }
// }
// // 优惠券页面直接加载你可能喜欢。add by @zhaobiao
// if (specificGender) {
// search();
// }
// // srcoll to load more
// $(window).scroll(function() {
// window.requestAnimationFrame(scrollHandler);
// });
// // 为您优选埋点
// $('.maybe-like .goods-list').on('click', 'a', function() {
// var pageNum = 50;
// index = $(this).closest('.good-info').index() + 1;
// window.givePoint({
// REC_POSE: RECPOSE,
// PRD_ID: $(this).closest('.good-info').data('id'),
// PRD_NUM: index % pageNum === 0 ? pageNum : index % pageNum,
// ACTION_ID: 1,
// page_num: Math.ceil(index / pageNum)
// });
// return true;
// });
// };
/**
* “你可能喜欢”模块JS
* @author: liangzhifeng<zhifeng.liang@yoho.cn>
* @date: 2015/10/12
*/
module.exports = function(specificGender) {
var $ = require('yoho-jquery'),
Hammer = require('yoho-hammer'),
... ... @@ -20,37 +268,55 @@ module.exports = function(specificGender) {
gender = null,
num,
url,
RECPOSE = '';
RECPOSE = '110001';
// The kidsType can be specified by the parameter. Add by @ZhaoBiao
//The kidsType can be specified by the parameter. Add by @ZhaoBiao
var kidsType = specificGender === 'kids' || $('.mobile-wrap').hasClass('kids-wrap') ? true : false,
lifestyleType = specificGender === 'lifestyle' ||
$('.mobile-wrap').hasClass('lifestyle-wrap') ? true : false;
$('.mobile-wrap').hasClass('lifestyle-wrap') ? true : false,
yohoCoinType = $('.coin').length ? true : false,
logisticType = $('.logistic-page').length ? true : false;
var $curNav,
index,
$navList = $('#maybe-like-nav');
var $footer;
var bottomBannerLoaded;
ellipsis.init();
// ajax url
//ajax url
if (kidsType) {
url = '/product/recom/maylikekids';
} else if (lifestyleType) {
// 有货币页面加载男生首页的数据
url = specificGender === 'lifestyle' ? '/product/recom/maylike?gender=1,3' : '/product/recom/maylikelife';
//有货币页面加载男生首页的数据
url = specificGender === 'lifestyle' ? '/product/recom/maylike?gender=1,3&rec_pos=100001' : '/product/recom/maylikelife';
} else if (yohoCoinType) {
gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ?
'1,3&rec_pos=100009' : '2,3&rec_pos=100009',
url = '/product/recom/maylike?gender=' + gender;
RECPOSE = 110009;
} else if (logisticType) { //物流页面
gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ?
'1,3&rec_pos=100006' : '2,3&rec_pos=100006',
url = '/product/recom/maylike?gender=' + gender;
RECPOSE = 110006;
} else {
gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ?
'1,3' : '2,3';
'1,3&rec_pos=100001' : '2,3&rec_pos=100002',
url = '/product/recom/maylike?gender=' + gender;
}
// 首页男生和女生,推荐位ID,埋点
//日韩馆-你可能喜欢的
if ($('.mobile-wrap').hasClass('yoho-channel-page')) {
url = '/product/recom/newPreference?template_id=' + $.queryString().template_id;
}
//首页男生和女生,推荐位ID,埋点
if (window.location.pathname === '/boys') {
RECPOSE = 110001;
} else if (window.location.pathname === '/girls') {
... ... @@ -60,7 +326,7 @@ module.exports = function(specificGender) {
$curNav = $navList.children('.focus');
if (lifestyleType) {
navHammer = $navList[0] ? new Hammer($navList[0]) : null;
navHammer = $navList[0] ? new Hammer($navList[0]) : undefined;
if (navHammer) {
navHammer.on('tap', function(e) {
var $this = $(e.target).closest('li'),
... ... @@ -83,7 +349,7 @@ module.exports = function(specificGender) {
$curNav = $this;
$(document).trigger('scroll'); // Trigger lazyLoad
$(document).trigger('scroll'); //Trigger lazyLoad
e.srcEvent.stopPropagation();
});
}
... ... @@ -99,7 +365,7 @@ module.exports = function(specificGender) {
loading.showLoadingMask();
// num = $goodList.find('.good-info').length;
//num = $goodList.find('.good-info').length;
$.ajax({
type: 'GET',
url: url,
... ... @@ -108,40 +374,36 @@ module.exports = function(specificGender) {
},
success: function(data) {
var PRDID = [];
if (data === ' ') {
searching = false;
loading.hideLoadingMask();
// 有货币页面不加载底部
if (gender && !specificGender) {
if (bottomBannerLoaded) {
return;
if (gender === '1,3') {
url = '/boys/bottomBanner';
} else {
url = '/girls/bottomBanner';
}
url = '/channel/bottomBanner';
$.ajax({
type: 'GET',
url: url,
data: {
gender: gender
},
success: function(res) {
res = res.data;
bottomBannerLoaded = true;
if (res && res.img) {
success: function(data) {
if (data && data.img) {
$('#load-more-img').show();
$('#load-more-img a').attr('href', res.url);
$('#load-more-img a > img').attr('src', res.img);
$('#load-more-img a').attr('href', data.url);
$('#load-more-img a > img').attr('src', data.img);
}
},
error: function() {
}
});
}
return;
} else {
searching = false;
}
// 加载到数据后,去除bottom样式,使得footer能够随着页面长度的增加改变位置
//加载到数据后,去除bottom样式,使得footer能够随着页面长度的增加改变位置
if (data.length > 1) {
$footer ? null : $footer = $('#yoho-footer');
$footer.hasClass('bottom') ? $footer.removeClass('bottom') : null;
... ... @@ -158,6 +420,7 @@ module.exports = function(specificGender) {
lazyLoad($goodList.find('.good-info:gt(' + (num - 1) + ')').find('img.lazy'));
}
searching = false;
loading.hideLoadingMask();
page++;
... ... @@ -168,20 +431,18 @@ module.exports = function(specificGender) {
$title[0].mlellipsis(2);
});
// 为您优选埋点 start
PRDID = [];
//为您优选埋点 start
$(data).closest('.good-info').each(function() {
PRDID.push($(this).data('id'));
});
window.givePoint({
REC_POSE: RECPOSE,
PRD_ID: PRDID.join(','),
PRD_NUM: $(data).closest('.good-info').length,
ACTION_ID: 0,
page_num: page
'REC_POSE': RECPOSE,
'PRD_ID': PRDID.join(','),
'PRD_NUM': $(data).closest('.good-info').length,
'ACTION_ID': 0,
'page_num': RECPOSE === 110009 ? 1 : page
});
// 为您优选埋点 end
//为您优选埋点 end
},
error: function() {
tip.show('网络断开连接了~');
... ... @@ -191,7 +452,7 @@ module.exports = function(specificGender) {
});
}
$('.maybe-like p').on('touchstart', function() {
$('.maybe-like p').on('touchstart', function(e) {
search();
});
... ... @@ -206,24 +467,21 @@ module.exports = function(specificGender) {
search();
}
// srcoll to load more
//srcoll to load more
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
// 为您优选埋点
//为您优选埋点 http://redmine.yoho.cn/issues/10116
$('.maybe-like .goods-list').on('click', 'a', function() {
var pageNum = 50;
index = $(this).closest('.good-info').index() + 1;
var index = $(this).closest('.good-info').index() + 1,
pageNum = 50;
window.givePoint({
REC_POSE: RECPOSE,
PRD_ID: $(this).closest('.good-info').data('id'),
PRD_NUM: index % pageNum === 0 ? pageNum : index % pageNum,
ACTION_ID: 1,
page_num: Math.ceil(index / pageNum)
'REC_POSE': RECPOSE,
'PRD_ID': $(this).closest('.good-info').data('id'),
'PRD_NUM': index % pageNum === 0 ? pageNum : index % pageNum,
'ACTION_ID': 1,
'page_num': Math.ceil(index / pageNum)
});
return true;
});
... ...
/**
* 新有货币界面
*/
var $ = require('yoho-jquery');
require('../common');
function getGender() {
return window.cookie('_Channel') || 'boys';
}
require('../channel/maybe-like')(getGender());
... ...