Authored by ccbikai(👎🏻🍜)

Merge branch 'feature/crm' into release/5.7

... ... @@ -4,7 +4,8 @@ const model = require('../models/feature');
exports.index = function(req, res, next) {
model.index({
code: req.params.code,
type: req.query.type
type: req.query.type,
user_id: req.user.uid || 0
}).then((result) => {
if (!result) {
return next();
... ...
... ... @@ -8,38 +8,53 @@ const channels = {
};
exports.productLst = function(req, res, next) {
let keys = ['sort', 'misort', 'msort', 'gender', 'brand'],
params = {
uid: req.user.uid || req.query.uid,
udid: req.query.udid,
promotion: req.query.pid,
let uid = req.user.uid || req.query.uid;
let udid = req.query.udid;
let getProductList;
if (req.query.maybeLike) {
getProductList = model.maybeLikeList(Object.assign({
uid: uid,
udid: udid,
yh_channel: req.query.yh_channel || (req.cookies._Channel && channels[req.cookies._Channel]) || 1,
specified_sort: req.query.enum,
stocknumber: req.query.sn,
p_d: req.query.pd,
noDup: req.query.noDup,
limit: req.query.limit || 10
};
limit: req.query.limit
}, req.query));
} else {
let keys = ['sort', 'misort', 'msort', 'gender', 'brand'],
params = {
uid: uid,
udid: udid,
promotion: req.query.pid,
yh_channel: req.query.yh_channel || (req.cookies._Channel && channels[req.cookies._Channel]) || 1,
specified_sort: req.query.enum,
stocknumber: req.query.sn,
p_d: req.query.pd,
noDup: req.query.noDup,
limit: req.query.limit || 10
};
keys.forEach(function(k) {
if (req.query[k]) {
params[k] = req.query[k];
}
});
keys.forEach(function(k) {
if (req.query[k]) {
params[k] = req.query[k];
}
});
if (params.specified_sort) {
if (params.brand) {
params.limit = params.brand.split(',').length;
} else if (params.sort) {
params.limit = params.sort.split(',').length;
} else if (params.misort) {
params.limit = params.misort.split(',').length;
} else if (params.msort) {
params.limit = params.msort.split(',').length;
if (params.specified_sort) {
if (params.brand) {
params.limit = params.brand.split(',').length;
} else if (params.sort) {
params.limit = params.sort.split(',').length;
} else if (params.misort) {
params.limit = params.misort.split(',').length;
} else if (params.msort) {
params.limit = params.msort.split(',').length;
}
}
getProductList = model.productLst(params);
}
model.productLst(params).then((result) => {
getProductList.then((result) => {
res.jsonp(result);
}).catch(next);
};
... ...
... ... @@ -359,12 +359,24 @@ exports.receiveCoupon = (receiveData, uid) => {
};
exports.couponSend = (uid, token) => {
return api.get('', {
let data = {
method: 'app.coupons.couponSend',
uid: uid,
coupon_send_token: token
}).then(result => {
};
if (/:/.test(token)) {
let [couponId, personCouponId] = token.split(':');
data = {
method: 'app.promotion.getCoupon',
uid: uid,
couponId: couponId,
personCouponId: personCouponId
};
}
return api.get('', data).then(result => {
if (!result) {
result.code = 404;
... ...
... ... @@ -10,10 +10,8 @@ const _getProductBySkns = function(productObj) {
productObj.defaultPros = [];
if (result && result.data && result.data.product_list && result.code === 200) {
result.data.product_list.forEach(function(val) {
var goods_id = Array.isArray(val.goods_list) &&
val.goods_list.length ? val.goods_list[0].goods_id : null;
var obj = {
producturl: `//m.yohobuy.com/product/pro_${val.product_id}_${goods_id}/${val.cn_alphabet}.html?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":${val.product_skn}}}`, // eslint-disable-line
producturl: `//m.yohobuy.com/product/${val.product_skn}.html?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":${val.product_skn}}}`, // eslint-disable-line
productimg: helpers.image(val.default_images, 213, 284, 2, 60).replace('quality/80', 'quality/60'),
productname: val.product_name,
vipprice: val.vip_price,
... ... @@ -47,12 +45,14 @@ module.exports = {
if (params.type === 'preview') { // 开发/预览模式
data = yield api.get('', {
method: 'app.activity.template.ignoreCache',
activity_id: params.code
activity_id: params.code,
user_id: params.user_id
});
} else {
data = yield api.get('', { // 生产模式
method: 'app.activity.template',
activity_id: params.code
activity_id: params.code,
user_id: params.user_id
}, {
cache: true
});
... ... @@ -67,6 +67,14 @@ module.exports = {
f.component[0].type === 'productGroup' && f.component[0].defaultSkns) {
sknsArr.push(_getProductBySkns(f.component[0]));
}
if (f.component && f.component[0] &&
f.component[0].type === 'productGroup' && f.component[0].favourite_prds_enable === '1') {
f.component[0].searchCondition = Object.assign({
maybeLike: '1',
limit: '12'
}, f.component[0].searchCondition || {});
}
});
}
... ...
... ... @@ -39,5 +39,25 @@ module.exports = {
});
return data;
});
},
maybeLikeList: function(params) {
return api.get('', {
method: 'app.search.newLast7day',
uid: params.uid || 0,
udid: params.udid || 0,
yh_channel: params.yh_channel,
limit: params.limit,
need_filter: 'null'
}, {
cache: true
}).then(res => {
var data = [],
lst = (res && res.data && res.data.product_list) || [];
lst.forEach(function(o) {
o && data.push(_getProduct(o));
});
return data;
});
}
};
... ...
... ... @@ -14,7 +14,7 @@
{{#content.floors}}
{{#isEqualOr type 'sidebar'}}
{{! 侧悬浮}}
<div id="sidebar" pageid="{{param.sidebarPageId}}"></div>
<div id="sidebar" pageid="{{param.sidebarPageId}}"></div>
{{/isEqualOr}}
{{#isEqualOr type '' 'common_floor' 'fix'}}
{{! 普通楼层 顶悬浮}}
... ... @@ -41,7 +41,14 @@
{{#isEqualOr type 'coupon'}}
{{! 优惠券}}
<a class="anchor yoho-conpon" style="{{styleFormat this percent=1}}" data-token="{{token}}" href="{{#if url}}{{url}}{{else}}javascript:void(0);{{/if}}" fp="{{getAnalysis ../this @index}}"></a>
{{#if personCoupon}}
{{! 个性化优惠券,使用:分割}}
<a class="anchor yoho-conpon" style="{{styleFormat this percent=1}}" data-token="{{personCoupon.couponId}}:{{personCoupon.personCouponId}}"
href="{{#if url}}{{url}}{{else}}javascript:void(0);{{/if}}" fp="{{getAnalysis ../this @index}}"></a>
{{else}}
<a class="anchor yoho-conpon" style="{{styleFormat this percent=1}}" data-token="{{token}}"
href="{{#if url}}{{url}}{{else}}javascript:void(0);{{/if}}" fp="{{getAnalysis ../this @index}}"></a>
{{/if}}
{{/isEqualOr}}
{{#isEqualOr type 'yohoCoin'}}
... ... @@ -84,12 +91,12 @@
{{/repeat}}
</div>
{{/isEqualOr}}
{{#isEqualOr type 'productGroup'}}
{{! 商品池}}
<div class="product-container item{{numOfOneRow}}" {{#if proBgImg}}style="background:url({{image2 proBgImg q=60}})repeat;"{{/if}}>
<div class="product-container item{{numOfOneRow}}" {{#if proBgImg}}style="background:url({{image2 proBgImg q=60}}) repeat;background-size:100%;"{{/if}}>
<div class="product-source" condition='{{stringify searchCondition}}' fp="{{getAnalysis ../this @index}}"
{{#unless defaultPros.length}}
{{#unless defaultPros.length}}
{{#if searchCondition.item}}
cloneitem="{{searchCondition.item}}"
{{else}}
... ... @@ -130,7 +137,7 @@
<img class="brand-img lazy" data-original="{{image2 ../brandImg q=60}}">
</a>
{{/if}}
</div>
</div>
{{/defaultPros}}
{{else}}
<div class="feature-product-info novisible">
... ... @@ -158,7 +165,7 @@
{{#if brandImg}}
<a class="second-part {{#isEqualOr showBrandUrl '1'}}product-brand{{else}}product-detail{{/isEqualOr}}" href=''>
<div class="brand-div">
<span class="brand-name" {{#if fontColor}}style="color:{{fontColor}};"{{/if}}></span>
<span class="brand-name" {{#if fontColor}}style="color:{{fontColor}};"{{/if}}></span>
</div>
<img class="brand-img" src="{{image2 brandImg q=60}}">
</a>
... ... @@ -171,6 +178,6 @@
{{/component}}
</div>
{{/isEqualOr}}
{{/content.floors}}
{{/content.floors}}
{{/unless}}
</div>
\ No newline at end of file
</div>
... ...
... ... @@ -33,6 +33,11 @@ const _getUserProfile = (uid) => {
uid: uid
}, {
cache: true
}).catch(function() {
return {
code: 200,
data: {}
};
});
};
... ...
... ... @@ -88,7 +88,7 @@
<div class="margin-bottom"></div>
{{/if}}
{{/isEqual}}
{{#isEqual module_type 'RecommentProduct'}}
{{#isEqual module_type 'AppRecommendProduct'}}
<div class="index-goods-container" data-type="{{../type}}" data-skns="{{../skns}}" data-order="{{../order}}"></div>
{{#if ../isModuleMargin}}
<div class="margin-bottom"></div>
... ...
... ... @@ -11,17 +11,12 @@ const isProduction = process.env.NODE_ENV === 'production';
const isTest = process.env.NODE_ENV === 'test';
const domains = {
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
global: 'http://api-global.yohobuy.com',
store: 'http://192.168.102.210:8080/portal-gateway/',
// liveApi: 'http://api.live.yoho.cn/',
// singleApi: 'http://single.yoho.cn/',
global: 'http://global-test-soa.yohops.com:9999',
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/',
imSocket: 'ws://socket.yohobuy.com:10240',
imCs: 'http://im.yohobuy.com/api'
};
... ...
... ... @@ -48,7 +48,9 @@ module.exports = () => {
yoho.channel = channel;
// 判断请求是否来自app
yoho.isApp = req.query.app_version || req.query.appVersion || req.cookies.app_version;
yoho.isApp = (req.query.app_version && req.query.app_version !== 'false') ||
(req.query.appVersion && req.query.appVersion !== 'false') ||
req.cookies.app_version;
yoho.isWechat = /micromessenger/i.test(req.get('User-Agent') || '');
yoho.isWeibo = ua.indexOf('weibo') !== -1;
yoho.isqq = /MQQBrowser/i.test(req.get('User-Agent') || '');
... ...
... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2017-03-23 11:31:51
* @Last Modified by: Targaryen
* @Last Modified time: 2017-04-25 11:45:13
* @Last Modified time: 2017-05-02 11:17:31
*/
/** *****************
... ... @@ -95,7 +95,7 @@ $.each($goodsContainer, function(index, elem) {
let $result = $(result);
lazyLoad($result.find('img[class=lazy]'));
$(elem).html(result);
$(elem).html($result);
}
});
});
... ...
... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2017-03-23 11:02:31
* @Last Modified by: Targaryen
* @Last Modified time: 2017-04-26 16:33:07
* @Last Modified time: 2017-05-02 11:09:37
*/
/* 红人店铺数据处理 */
... ... @@ -174,14 +174,14 @@ const _tools = {
},
/**
* 商品列表
* 推荐商品列表
* @param {*} moduleData
*/
recommentProduct(moduleData) {
appRecommendProduct(moduleData) {
let displayType = _.parseInt(_.get(moduleData, 'properties.displayType', 0));
let result = {
module_type: 'RecommentProduct',
module_type: 'AppRecommendProduct',
type: displayType
};
... ... @@ -206,10 +206,7 @@ const _tools = {
break;
}
return {
module_type: 'RecommentProduct',
skns: skns,
};
return result;
}
};
... ... @@ -256,8 +253,8 @@ const floor = (decoratorsData) => {
case 'SknList':
skns = _.get(value, 'module_data.data').join(',');
break;
case 'RecommentProduct':
decorators.push(_tools.recommentProduct(value.module_data));
case 'AppRecommendProduct':
decorators.push(_tools.appRecommendProduct(value.module_data));
break;
default:
break;
... ...