Authored by Aiden Xu

Merge remote-tracking branch 'origin/feature/installment' into feature/installment

... ... @@ -10,11 +10,43 @@ const installmentModel = require('../models/installment');
const _ = require('lodash');
const helpers = global.yoho.helpers;
// 判断是否已经获取到了开通的状态值
const _reviewStatus = (status) => {
if (status === 1) {
return {
review: {
url: helpers.urlFormat('/product/new')
}
};
} else if (status === 2) {
return installmentModel.getSearchIntallment().then((goods) => {
return {
success: {
price: '5000',
installmentOnly: {
title: '分期专享',
goods: goods
}
}
};
});
} else if (status === 3) {
return {
error: {
url: helpers.urlFormat('/product/new')
}
};
}
};
const index = (req, res) => {
let query = req.query.query || '';
let uid = req.user.uid || 3236556;
Promise.all([installmentModel.getStauts(uid), installmentModel.getSearchIntallment()]).then((result) => {
// status:0 未申请 1审核中 2已开通 3 审核未通过
let openStatus = result[0];
if (openStatus === 0) {
... ... @@ -57,6 +89,10 @@ const index = (req, res) => {
}, data);
});
}
} else if (openStatus === 1) {
res.redirect('/home/installment/review?status=' + openStatus);
} else {
res.redirect('/home/installment/review?status=' + openStatus);
}
}).then((result) => {
result.pageHeader = _.assign({
... ... @@ -75,46 +111,27 @@ const index = (req, res) => {
};
const review = (req, res) => {
let openStatus = req.query.status || false;
let uid = req.user.uid || 20000032;
let data = {
module: 'home',
page: 'installment',
title: '有货分期',
pageHeader: headerModel.setNav({
navTitle: '有货分期',
navBtn: false
})
};
installmentModel.getStauts(uid).then((status) => {
if (status === 1) {
return {
review: {
url: helpers.urlFormat('//m.yohobuy.com/product/new')
}
};
} else if (status === 2) {
return installmentModel.getSearchIntallment().then((goods) => {
return {
success: {
price: '5000',
installmentOnly: {
title: '分期专享',
goods: goods
}
}
};
});
} else if (status === 3) {
return {
error: {
url: helpers.urlFormat('//m.yohobuy.com/product/new')
}
};
}
}).then((params) => {
res.render('installment/open-result', _.assign({
module: 'home',
page: 'installment',
title: '有货分期',
pageHeader: headerModel.setNav({
navTitle: '有货分期',
navBtn: false
})
}, params));
});
if (openStatus) {
res.render('installment/open-result', _.assign(data, _reviewStatus(+openStatus)));
} else {
installmentModel.getStauts(uid).then((status) => {
return _reviewStatus(status);
}).then((params) => {
res.render('installment/open-result', _.assign(data, params));
});
}
};
... ...
... ... @@ -4,7 +4,8 @@
* @date: 2016/08/01
*/
'use strict';
const utils = '../../../utils';
const productProcess = require(`${utils}/product-process`);
const api = global.yoho.API;
const logger = global.yoho.logger;
... ... @@ -21,7 +22,7 @@ const getStauts = (uid) => {
alg: 'SALT_MD5',
code: 200,
data: {
status: 2
status: 0
},
md5: '6d729d4b35f10fc73531210bd7ecff91',
message: 'success'
... ... @@ -91,13 +92,133 @@ const getQueryAmtInfo = (uid) => {
// 分期专享推荐商品
const getSearchIntallment = () => {
return api.get('', {
return api.post('', {
method: 'app.search.instalment',
limit: '50',
order: 's_t_desc'
}, {
cache: true
}).then((result) => {
result = {
alg: 'SALT_MD5',
code: 200,
data: {
product_list: [
{
brand_domain: '5cm',
brand_id: 4,
brand_name: '5CM',
cn_alphabet: '5CMPeiShi5CXTIT0600S66',
default_images: 'http://img13.static.yhbimg.com/goodsimg/2016/02/21/07/026d569b2db7d9ce9339a79bcb3fe420f8.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
edit_time: 1456119592,
gender: '1',
goods_list: [
{
color_code: '333333',
color_id: '2',
color_name: '黑色',
color_value: '',
cover_1: '',
cover_2: '',
goods_id: '476147',
images_url: 'http://img13.static.yhbimg.com/goodsimg/2016/02/21/07/026d569b2db7d9ce9339a79bcb3fe420f8.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
is_default: 'N',
product_skc: '346699',
status: '1'
}
],
is_advance: 'N',
is_discount: 'N',
is_limited: 'N',
is_new: 'Y',
is_outlets: 2,
is_promotion: 104,
is_soon_sold_out: 'N',
is_special: 'N',
market_price: 359,
max_sort_id: 8,
middle_sort_id: 66,
product_id: 373507,
product_name: '5CM 字母印花领带',
product_skn: 51206745,
sales_num: 0,
sales_phrase: '春潮新势力',
sales_price: 359,
shelve_time: 1457140500,
small_sort_id: 77,
status: 1,
stock_number: 25,
storage_num: 25,
tags: [
'is_new'
],
vip1_price: 341.05,
vip2_price: 323.1,
vip3_price: 315.92,
vip_discount_type: 1,
vip_price: 0
}, {
brand_domain: '5cm',
brand_id: 4,
brand_name: '5CM',
cn_alphabet: '5CMPeiShi5CXTIT0603S66',
default_images: 'http://img12.static.yhbimg.com/goodsimg/2016/02/21/07/02d463c9f8945ad14f824e8ba35efb9555.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
edit_time: 1456119581,
gender: '1',
goods_list: [
{
color_code: '333333',
color_id: '2',
color_name: '黑色',
color_value: '',
cover_1: '',
cover_2: '',
goods_id: '476153',
images_url: 'http://img12.static.yhbimg.com/goodsimg/2016/02/21/07/02d463c9f8945ad14f824e8ba35efb9555.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
is_default: 'N',
product_skc: '346702',
status: '1'
}
],
is_advance: 'N',
is_discount: 'N',
is_limited: 'N',
is_new: 'Y',
is_outlets: 2,
is_promotion: 104,
is_soon_sold_out: 'N',
is_special: 'N',
market_price: 359,
max_sort_id: 8,
middle_sort_id: 66,
product_id: 373513,
product_name: '5CM 字母印花领结',
product_skn: 51206748,
sales_num: 0,
sales_phrase: '春潮新势力',
sales_price: 359,
shelve_time: 1457140500,
small_sort_id: 77,
status: 1,
stock_number: 19,
storage_num: 19,
tags: [
'is_new'
],
vip1_price: 341.05,
vip2_price: 323.1,
vip3_price: 315.92,
vip_discount_type: 1,
vip_price: 0
}
],
rec_id: '00f185af-936a-4053-97f8-1c802cb91e8b'
},
md5: 'ace93d0f598db0bebec30234381c0cbf',
message: 'Product List.'
};
if (result && result.code === 200) {
return result.data;
return productProcess.processProductList(result.data.product_list);
} else {
logger.error('get instalment promote goods return is not 200');
return '';
... ...
var $ = require('yoho-jquery'),
ellipsis = require('yoho-mlellipsis'),
tip = require('../plugin/tip'),
loading = require('../plugin/loading');
lazyLoad = require('yoho-jquery-lazyload');
var winH = $(window).height(),
$installmentOnly = $('.installment-only'),
searching = false,
page = 0;
var $installmentOnly = $('.installment-only');
var $this, $title;
lazyLoad($('img.lazy'));
ellipsis.init();
function search() {
if (searching) {
return;
}
searching = true;
$('.good-detail-text .name').each(function() {
$this = $(this);
$title = $this.find('a');
loading.showLoadingMask();
$.ajax({
type: 'GET',
url: '/product/recom/maylike?gender=1,3',
data: {
page: page + 1
},
success: function(data) {
if (data === '') {
loading.hideLoadingMask();
} else {
searching = false;
$('#goods-list').append(data);
loading.hideLoadingMask();
page++;
$('.good-detail-text .name').each(function() {
var $this = $(this),
$title = $this.find('a');
$title[0].mlellipsis(2);
});
}
},
error: function() {
tip.show('网络断开连接了~');
searching = false;
loading.hideLoadingMask();
}
});
}
function scrollHandler() {
if ($(window).scrollTop() + winH >= $(document).height() - 200) {
search();
}
}
// srcoll to load more
$(window).scroll(function() {
if ($installmentOnly.length > 0) {
window.requestAnimationFrame(scrollHandler);
}
$title[0].mlellipsis(2);
});
if ($installmentOnly.length > 0) {
$('.installment-page').css({
background: '#efefef'
});
search();
}
if ($('.installment-bg').length > 0) {
... ...
... ... @@ -5,6 +5,7 @@
height: auto;
overflow: hidden;
padding-bottom: 70px;
border-bottom: 1px solid #dedee0;
}
.open-info {
... ... @@ -67,6 +68,10 @@
font-size: 16PX;
border-bottom: 1px solid #dedee0;
}
#goods-list {
margin: 15px 0 0 15px;
}
}
.review-icon {
... ...