Authored by ccbikai(👎🏻🍜)

Merge branch 'release/newSearch' of git.yoho.cn:fe/yohobuywap-node into release/newSearch

... ... @@ -14,7 +14,7 @@ const helpers = global.yoho.helpers;
/**
* 店铺 - 基础模板
*/
const _baseShop = (req, res, shopInfo) => {
const _baseShop = (req, res, shopInfo, shopId) => {
listModel.getBaseShopData(req.query, shopInfo).then(result => {
... ... @@ -27,13 +27,31 @@ const _baseShop = (req, res, shopInfo) => {
title: result.shopName,
goodList: result,
showDownloadApp: true,
pageFooter: true
pageFooter: true,
shopId: shopId,
});
});
};
/**
* 基础模板收藏
*/
const baseShopFav = (req, res) => {
let isApp = req.query.app_version || req.query.appVersion || false;
let uid = isApp ? req.query.uid : req.user.uid;
let shopId = req.query.shopId;
listModel.getShopData(req, shopId, uid, isApp).then(result => {
res.json({
code: 200,
collect: result.goBrand && result.goBrand.isFavorite === 'Y' ? true : false,
});
});
};
/**
* 店铺首页
* @return int
*/
... ... @@ -42,6 +60,7 @@ const _shop = (req, res, shopId) => {
let pageHeader = {};
let uid = 0;
// pagecache前端判断
if (!isApp) {
pageHeader = {
pageHeader: _.assign({
... ... @@ -55,21 +74,23 @@ const _shop = (req, res, shopId) => {
navTitle: false
}))
};
uid = req.user.uid;
} else {
uid = req.query.uid;
req.session.appUid = uid;
res.cookie('appUid', uid, {
domain: 'yohobuy.com',
expires: new Date(Date.now() + 2592000000) // 有效期一年
});
}
// uid = req.user.uid;
// } else {
// uid = req.query.uid;
// req.session.appUid = uid;
// res.cookie('appUid', uid, {
// domain: 'yohobuy.com',
// expires: new Date(Date.now() + 2592000000) // 有效期一年
// });
// }
listModel.getShopData(req, shopId, uid, isApp).then(result => {
if (result.goBrand) {
/* 若店铺使用基础模板跳转基础模板 */
_baseShop(req, res, result.goBrand);
_baseShop(req, res, result.goBrand, shopId);
} else {
result = _.assign(result, pageHeader);
... ... @@ -79,12 +100,46 @@ const _shop = (req, res, shopId) => {
shopIndex: result,
shopHeadHide: true,
gender: req.query.gender,
channel: req.query.channel
channel: req.query.channel,
shopId: shopId,
});
}
});
};
/**
* app设置cookie
*/
const shopAppCookie = (req, res) => {
let uid = req.query.uid;
req.session.appUid = uid;
res.cookie('appUid', uid, {
domain: 'yohobuy.com',
expires: new Date(Date.now() + 2592000000) // 有效期一年
});
res.json({
code: 200,
msg: 'app cookie set',
});
};
/**
* 前端请求判断shop是否收藏
*/
const shopFav = (req, res) => {
let isApp = req.query.app_version || req.query.appVersion || false;
let uid = isApp ? req.query.uid : req.user.uid;
let shopId = req.query.shopId;
listModel.getShopData(req, shopId, uid, isApp).then(result => {
res.json({
code: 200,
collect: result.collect,
});
});
};
// 品类落地页
const category = (req, res) => {
let params = Object.assign({}, req.query);
... ... @@ -126,6 +181,7 @@ const brand = (req, res, next) => {
}
listModel.getBrandLogoByDomain(domain).then((result) => {
brandLogo = result;
title = brandLogo.name;
... ... @@ -177,13 +233,27 @@ const brand = (req, res, next) => {
}),
goodList: params,
showDownloadApp: true,
pageFooter: true
pageFooter: true,
domain: req.query.domain,
});
});
}
}).catch(next);
};
const brandFav = (req, res) => {
let domain = req.query.domain;
let uid = req.user.uid;
let brandId = 0;
listModel.getBrandLogoByDomain(domain).then((result) => {
brandId = result.id;
listModel.getBrandIntro(brandId, uid).then(result2 => {
res.json(result2);
});
});
};
/**
* 店铺简介
* @param req
... ... @@ -270,5 +340,11 @@ module.exports = {
category,
brand,
favoriteBrand,
shopIntro
shopIntro,
// pagecache新增
brandFav,
shopAppCookie,
shopFav,
baseShopFav,
};
... ...
... ... @@ -381,7 +381,6 @@ const _formShopData = (data, shopId, isApp) => {
formatData.favId = shopId;
formatData.shopId = '';
}
return formatData;
};
... ... @@ -492,11 +491,9 @@ const getShopData = (req, shopId, uid, isApp) => {
const getBrandIntro = (brandId, uid) => {
let param = {};
if (uid) {
param = {
uid: uid
};
}
param = {
uid: uid,
};
return api.get('', _.assign({
method: 'app.brand.getBrandIntro',
... ...
... ... @@ -96,6 +96,10 @@ router.get('/index/index', list.category);
// 品牌 | 店铺
router.get('/index/brand', list.brand);
router.get('/index/brandFav', list.brandFav);
router.get('/index/shopAppCookie', list.shopAppCookie);
router.get('/index/shopFav', list.shopFav);
router.get('/index/baseShopFav', list.baseShopFav);
// 店铺介绍
router.get('/index/intro', list.shopIntro);
... ...
... ... @@ -32,11 +32,7 @@
<img class="logo" src="{{image logoImg 500 500}}">
<p class="store-name">{{storeName}}</p>
<div class="collect">
{{#if collect}}
<div class="already-collect" id="collect"></div>
{{else}}
<div class="not-collect buriedpoint" id="collect" data-bp-id="shop_branner_collect_1"></div>
{{/if}}
<div class="not-collect buriedpoint" id="collect" data-bp-id="shop_branner_collect_1"></div>
</div>
</div>
</div>
... ... @@ -220,3 +216,5 @@
{{> common/filter}}
{{/ shopIndex}}
{{> common/query-param}}
<input type="text" class="shopid" style="display:none" value={{shopId}} />
... ...
... ... @@ -37,7 +37,7 @@
<a class="btn-intro" href="javascript:void(0);">
品牌介绍
</a>
<a class="btn-col{{#if collected}} coled{{/if}}" href="javascript:void(0);">
<a class="btn-col" href="javascript:void(0);">
<span class="iconfont">&#xe622;</span>
<span class="txt"></span>
</a>
... ... @@ -65,7 +65,7 @@
<a class="btn-intro" href="javascript:void(0);">
店铺介绍
</a>
<a class="btn-col{{#if collected}} coled{{/if}}" href="javascript:void(0);">
<a class="btn-col" href="javascript:void(0);">
<span class="iconfont">&#xe622;</span>
<span class="txt"></span>
</a>
... ... @@ -140,3 +140,6 @@
{{> common/suspend-cart}}
{{/ goodList}}
<input type="text" class="domain" style="display:none" value={{domain}}>
<input type="text" class="shopId" style="display:none" value={{shopId}}>
... ...
... ... @@ -71,6 +71,43 @@ require('../../common');
ellipsis.init();
// pageCache 获取是否收藏
(function() {
if ($('.domain').val()) {
$.ajax({
url: '/product/index/brandFav',
data: {
domain: $('.domain').val()
},
dataType: 'json',
success: function(data) {
if (data.collected) {
$('.brand-header .btn-col').addClass('coled');
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
} else {
$.ajax({
url: '/product/index/baseShopFav',
data: {
shopId: $('.shopId').val()
},
dataType: 'json',
success: function(data) {
if (data.collect) {
$('.brand-header .btn-col').addClass('coled');
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
}
}());
// 搜索输入联动
function inputAction() {
var $searchAssociate = $('.search-associate');
... ...
... ... @@ -42,6 +42,38 @@ var winH = $(window).height(),
require('../../common');
// pagecache判断app设置cookie,判断是否收藏
(function() {
var param = location.search;
var isApp = param.indexOf('app_version') > -1 || param.indexOf('appVersion') > -1;
if (isApp) {
$.ajax({
type: 'GET',
url: '/product/index/shopAppCookie',
error: function() {
tip.show('网络断开连接了~');
}
});
}
$.ajax({
type: 'GET',
url: '/product/index/shopFav',
data: {
shopId: $('.shopid').val(),
},
success: function(data) {
if (data.collect) {
$collect.attr('class', 'already-collect');
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
}());
// 默认筛选条件
var defaultOpt = require('../../common/query-param');
... ...