Authored by ccbikai(👎🏻🍜)

Merge remote-tracking branch 'origin/release/5.1.2'

... ... @@ -13,6 +13,7 @@ const yohoLib = require('yoho-node-lib');
const express = require('express');
const path = require('path');
const compression = require('compression');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const favicon = require('serve-favicon');
... ... @@ -65,6 +66,7 @@ app.use(bodyParser.urlencoded({
extended: false
}));
app.use(cookieParser());
app.use(compression());
app.use(session({
name: 'yohobuy_session_cookie',
... ... @@ -74,7 +76,7 @@ app.use(session({
app.use((req, res, next) => {
req.user = {}; // 全局的用户数据
req.yoho = {}; // req和res绑定yoho对象,用于传递全局数据, 如req.yoho.channel等
req.app.locals.wap = app.locals.wap; //zookeper对象赋值
if (!req.session.id) {
req.session.id = uuid.v4();
}
... ... @@ -94,6 +96,7 @@ try {
const setPageInfo = require('./doraemon/middleware/set-pageinfo');
const devtools = require('./doraemon/middleware/devtools');
const seo = require('./doraemon/middleware/seo');
const pageCache = require('./doraemon/middleware/page-cache');
// YOHO 前置中间件
app.use(subDomain());
... ... @@ -107,16 +110,8 @@ try {
app.use(devtools());
}
// set no cache
app.use((req, res, next) => {
if (req.get('X-Requested-With') === 'XMLHttpRequest') {
res.set('Cache-Control', 'no-cache');
}
next();
});
app.use(pageCache());
require('./dispatch')(app);
app.all('*', errorHanlder.notFound()); // 404
// YOHO 后置中间件
... ...
... ... @@ -22,6 +22,10 @@ exports.index = (req, res, next) => {
}
model.floor(param, req.yoho.isApp, req.query.app_version).then(result => {
if (!result.length) {
res.set('Cache-Control', 'no-cache');
}
res.render('coupon-floor', {
module: 'activity',
page: 'coupon-floor',
... ...
... ... @@ -26,13 +26,6 @@ app.use(global.yoho.hbs({
helpers: Object.assign({}, global.yoho.helpers, helpers)
}));
// for zookeeper, inject locals
app.use((req, res, next) => {
req.app.locals.wap = app.locals.wap;
next();
});
// router
app.use(require('./router'));
... ...
... ... @@ -15,13 +15,6 @@ app.on('mount', function(parent) {
Object.assign(app.locals, parent.locals);
});
// for zookeeper, inject locals
app.use((req, res, next) => {
req.app.locals.wap = app.locals.wap;
next();
});
// router
app.use(require('./router'));
... ...
... ... @@ -26,13 +26,6 @@ app.use(global.yoho.hbs({
helpers: global.yoho.helpers
}));
// for zookeeper, inject locals
app.use((req, res, next) => {
req.app.locals.wap = app.locals.wap;
next();
});
// router
app.use(require('./router'));
... ...
... ... @@ -38,6 +38,10 @@ let _channelPage = (req, res, data) => {
gender: data.gender,
uid: _.toString(req.user.uid)
}).then(result => {
if (!result.content.length || !result.sideNav.length) {
res.set('Cache-Control', 'no-cache');
}
// result.content = [{
// seckill: true,
// data: {
... ...
... ... @@ -13,6 +13,7 @@ var app = express();
var doraemon = path.join(__dirname, '../../doraemon/views'); // parent view root
app.on('mount', function(parent) {
delete parent.locals.settings; // 不继承父 App 的设置
Object.assign(app.locals, parent.locals);
});
... ... @@ -26,13 +27,6 @@ app.use(global.yoho.hbs({
helpers: global.yoho.helpers
}));
// for zookeeper, inject locals
app.use((req, res, next) => {
req.app.locals.wap = app.locals.wap;
next();
});
// router
app.use(require('./router'));
... ...
... ... @@ -36,6 +36,8 @@ const _packageAd = (params) => {
gender: 1,
limit: 1000,
page: 1
}, {
cache: true
}).then(result => {
return result;
... ... @@ -49,7 +51,10 @@ const _packageList = (params) => {
method: 'app.brand.newBrandList',
yh_channel: params.channel
}, { code: 200 }).then(result => {
}, {
cache: true,
code: 200
}).then(result => {
return result;
... ... @@ -269,7 +274,10 @@ const getBrandForSearch = (channel) => {
method: 'app.brand.brandlist',
yh_channel: channel || 1
}, { code: 200 }).then(result => {
}, {
cache: true,
code: 200
}).then(result => {
return result;
... ... @@ -289,7 +297,9 @@ const branchSearchHistory = (params) => {
uid: params.uid,
records: params.records || ''
}, { code: 200 }).then(result => {
}, {
code: 200
}).then(result => {
return result;
... ... @@ -316,7 +326,10 @@ const branchSearchHot = () => {
return api.get('', {
method: 'app.search.hotBrands'
}, { code: 200 }).then(result => {
}, {
cache: true,
code: 200
}).then(result => {
return result;
... ...
... ... @@ -204,10 +204,14 @@ const _getChannelList = () => {
}
});
return Object.keys(list).length ? list : channelList;
return Object.keys(list).length ? list : {
channelList: channelList
};
} else {
logger.error('channel select code is not 200');
return channelList;
return {
channelList: channelList
};
}
});
};
... ... @@ -252,8 +256,8 @@ let getChannelData = (params) => {
let navGender = _.cloneDeep(params.gender);
return Promise.all([_getChannelResource(params), _getLeftNav(navGender)]).then((data) => {
channelData.content = data[0]; // 资源位数据
channelData.sideNav = data[1]; // 侧边栏数据
channelData.content = data[0] || []; // 资源位数据
channelData.sideNav = data[1] || []; // 侧边栏数据
return channelData;
});
... ... @@ -270,7 +274,9 @@ let getBottomBannerData = (gender) => {
if (gender === 'boys' || gender === 'girls') {
return api.get('operations/api/v5/resource/get', {
content_code: bottomBannerCode[gender] // eslint-disable-line
}, true);
}, {
cache: true
});
}
return Promise.resolve({
code: 400,
... ...
... ... @@ -54,6 +54,11 @@ const editor = (req, res, next) => {
build.push(guangProcess.formatArticle(articleData, true, isApp, false, uid));
});
if (!build.length) {
res.set('Cache-Control', 'no-cache');
}
res.render('index/list', Object.assign({
page: 'index-editor',
title: title,
... ... @@ -169,6 +174,11 @@ const index = (req, res, next) => {
};
indexModel.getArticle(param).then(result => {
if (result && result.guang && result.guang.infos) {
if (!result.guang.infos.length) {
res.set('Cache-Control', 'no-cache');
}
}
res.render('guang', Object.assign(responseData, result));
}).catch(next);
};
... ...
... ... @@ -26,13 +26,6 @@ app.use(global.yoho.hbs({
helpers: global.yoho.helpers
}));
// for zookeeper, inject locals
app.use((req, res, next) => {
req.app.locals.wap = app.locals.wap;
next();
});
// router
app.use(require('./router'));
... ...
... ... @@ -14,6 +14,8 @@ const getAllChannels = (params) => {
return api.get('', {
method: 'app.blk.getAllChannels',
app_type: params.app_type
}, {
cache: true
}).then(result => {
let data = {channel: []};
... ... @@ -49,7 +51,12 @@ const getProductBatch = (param, options) => {
param.productSkn = _.isArray(param.productSkn) ? param.productSkn : [param.productSkn];
return api.get('', {
method: 'h5.product.batch',
productSkn: param.productSkn.join(',')
productSkn: param.productSkn.join(','),
yh_channel: param.yh_channel,
page: param.page,
limit: param.limit
}, {
cache: true
}).then(result => {
let data = {};
... ... @@ -87,7 +94,9 @@ const getResources = (params, options) => {
params.platform = 'iphone';
}
return serviceAPI.get('operations/api/v5/resource/get', params).then(result => {
return serviceAPI.get('operations/api/v5/resource/get', params, {
cache: true
}).then(result => {
let data = {
goods: {},
recommend: {}
... ...
... ... @@ -6,9 +6,11 @@
<div class="header-content clearfix">
<p class="name-islike-container">
<span class="name">{{brand_name}}</span>
{{#unless @root.wap.plustar.removeCollect}}
<a id="brand-like" class="brand-islike iconfont" href="{{likeUrl}}">
&#xe605;
</a>
{{/unless}}
</p>
<div id="more-intro-click-range" class="clearfix">
<div id="intro" class="intro">
... ... @@ -100,7 +102,9 @@
<input id="jump-to-app" type="hidden" value="{{jumpToApp}}">
<input id="brandId" type="hidden" value="{{brand_id}}">
<input id="clientType" type="hidden" value="{{clientType}}">
{{#unless @root.wap.plustar.removeRelatedPost}}
<input id="related-infos-demote" type="hidden" value="1">
{{/unless}}
{{!-- wx-share --}}
<input id="shareLink" type="hidden" value="{{shareLink}}">
<input id="shareImg" type="hidden" value="{{shareImg}}">
... ...
... ... @@ -26,13 +26,6 @@ app.use(global.yoho.hbs({
helpers: global.yoho.helpers
}));
// for zookeeper, inject locals
app.use((req, res, next) => {
req.app.locals.wap = app.locals.wap;
next();
});
// router
app.use(require('./router'));
... ...
... ... @@ -127,8 +127,9 @@
<span class="iconfont num">&#xe604;</span>
</a>
</div>
{{> common/recommend-for-you}}
{{#unless @root.wap.ucenter.removePrefer}}
{{> common/recommend-for-you}}
{{/unless}}
{{> common/suspend-cart}}
</div>
... ...
... ... @@ -44,7 +44,7 @@ function doPassportCallback(openId, nickname, sourceType, req, res) {
refer: refer
});
} else if (result.code === 200 && result.data.uid) {
return AuthHelper.syncUserSession(result.data.uid, req, res).then(() => {
return AuthHelper.syncUserSession(result.data.uid, req, res, result.data.session_key).then(() => {
return refer;
});
}
... ... @@ -161,7 +161,7 @@ const local = {
}
user.session = refer;
user.href = refer;
AuthHelper.syncUserSession(user.uid, req, res).then(() => {
AuthHelper.syncUserSession(user.uid, req, res, user.session_key).then(() => {
res.json({
code: 200,
data: user
... ...
... ... @@ -28,13 +28,6 @@ app.use(global.yoho.hbs({
helpers: global.yoho.helpers
}));
// for zookeeper, inject locals
app.use((req, res, next) => {
req.app.locals.wap = app.locals.wap;
next();
});
require('./auth');
app.use(passport.initialize());
app.use(passport.session());
... ...
... ... @@ -60,7 +60,12 @@ class Auth {
return api.get('', param);
}
static syncUserSession(uid, req, res) {
static syncUserSession(uid, req, res, sessionKey) {
if (sessionKey) {
global.yoho.cache.set(`java_session_key:${uid}`, sessionKey).catch(() => {
global.yoho.logger.error('write session key fail');
});
}
return Auth.profile(uid).then((userInfo) => {
let token = sign.makeToken(uid);
let data = userInfo.data;
... ...
... ... @@ -135,6 +135,10 @@ const _shop = (req, res, shopId) => {
result.hotList[key].tags.isHot = true;
});
if (!result.storeName) {
res.set('Cache-Control', 'no-cache');
}
res.render('shop/index', {
module: 'product',
page: 'shop',
... ... @@ -292,6 +296,10 @@ const brand = (req, res, next) => {
}).then(brandHome => {
params.brandHome = brandHome;
if (!brandHome.id) {
res.set('Cache-Control', 'no-cache');
}
res.render('search/goods-list', {
module: 'product',
page: 'search-list',
... ...
'use strict';
const mRoot = '../models';
const _ = require('lodash');
const recommendForYouModel = require(`${mRoot}/recommend-for-you`); // 领取优惠券 model
exports.userCenter = (req, res, next) => {
... ... @@ -33,7 +34,9 @@ exports.cart = (req, res, next) => {
uid = req.user.uid || 0,
yhChannel = req.query.yh_channel || '1',
limit = 30;
if (_.get(req, 'app.locals.wap.cart.removePrefer', false)) {
return res.send('');
}
recommendForYouModel.getPreference({
yh_channel: yhChannel,
udid: udid,
... ... @@ -52,4 +55,5 @@ exports.cart = (req, res, next) => {
page: 'recommend'
});
}).catch(next);
};
... ...
... ... @@ -79,6 +79,10 @@ let index = (req, res, next) => {
res.locals.pageChannel = {};
res.locals.pageChannel[req.cookies._Channel] = true;
}
if (!result.length) {
res.set('Cache-Control', 'no-cache');
}
res.render('sale/index', Object.assign(params.renderData, {
content: result,
floorHeader: {
... ...
... ... @@ -132,8 +132,16 @@ const list = (req, res, next) => {
*/
const index = (req, res, next) => {
let title = '搜索';
searchModel.getSearchIndex().then((result) => {
((render) => {
if (_.get(req, 'app.locals.wap.search.removeHotSearch', false)) {
render([]);
} else {
searchModel.getSearchIndex().then((result) => {
render(result);
}).catch(next);
}
})((result) => {
res.render('search/index', {
module: 'product',
page: 'search-index',
... ... @@ -148,7 +156,8 @@ const index = (req, res, next) => {
}
});
}).catch(next);
})
};
/**
... ...
... ... @@ -27,13 +27,6 @@ app.use(global.yoho.hbs({
helpers: global.yoho.helpers
}));
// for zookeeper, inject locals
app.use((req, res, next) => {
req.app.locals.wap = app.locals.wap;
next();
});
// router
app.use(require('./router'));
... ...
... ... @@ -343,6 +343,8 @@ let getintroIntro = (data) => {
return api.get('', {
method: 'app.product.intro',
product_skn: data.productskn
}, {
cache: true
}).then(result => {
result = $.load(result);
... ...
... ... @@ -8,6 +8,8 @@ const logger = global.yoho.logger;
const getHotRank = (codeKey) => {
return serviceAPI.get('operations/api/v5/resource/get', {
content_code: codeKey
}, {
cache: true
}).then((result) => {
if (result && result.code === 200) {
... ... @@ -53,7 +55,9 @@ const selectHotrank = (yhChannel, gender, sort, tabId, limit, page, notab) => {
param.tab_id = tabId;
}
return api.get('', param).then((result) => {
return api.get('', param, {
cache: true
}).then((result) => {
if (result && result.code === 200 && result.data.product_list) {
... ...
... ... @@ -251,6 +251,8 @@ const getFuzzyDatas = (params) => {
return api.get('', {
method: 'app.search.fuzzy',
keyword: params
}, {
cache: true
}).then((result) => {
if (result && result.code === 200) {
return result.data;
... ... @@ -270,7 +272,10 @@ const searchKeyActivity = (params) => {
return api.get('', {
method: 'app.search.word',
query: params
}, {code: 200}).then(result => {
}, {
cache: true,
code: 200
}).then(result => {
if (result.data) {
return result.data;
} else {
... ...
... ... @@ -124,6 +124,9 @@
<div class="chose-panel"></div>
<div class="cart-bar data-bind">
{{#unless @root.wap.common.removeCartCount}}
<input type="hidden" id="remove-cart-count" value="1">
{{/unless}}
<a href="" class="num-incart iconfont"><span class="num-tag hide"></span>&#xe62c;</a>
<a id="addtoCart" href="javascript:;" class="addto-cart add-to-cart-url data-bind"></a>
<a id="soldOut" href="javascript:;" class="sold-out data-bind">已售罄</a>
... ...
'use strict';
const SECOND = 1;
const MINUTE = 60 * SECOND;
const cachePage = {
'/': 5 * MINUTE,
// 频道页
'/boys': 30 * SECOND,
'/girls': 30 * SECOND,
'/kids': 30 * SECOND,
'/lifestyle': 30 * SECOND,
// 商品分类
'/cate': 5 * MINUTE,
// 商品详情页
'/product/\\/pro_([\\d]+)_([\\d]+)\\/(.*)/': 30 * MINUTE,
'/product/\\/show_([\\d]+)/': 30 * MINUTE,
// 逛
'/guang/': 1 * MINUTE,
'/guang/info/index': 10 * MINUTE,
'/guang/author/index': 1 * MINUTE,
'/guang/tags/index': 1 * MINUTE,
'/guang/plustar': 1 * MINUTE,
'/guang/plustar/brandinfo': 1 * MINUTE,
'/guang/star': 1 * MINUTE,
// 领券中心
'/activity/coupon/floor': 5 * MINUTE,
// 商品列表
'/product/list/index': 1 * MINUTE,
'/product/index/index': 1 * MINUTE,
'/product/index/brand': 1 * MINUTE,
'/product/new': 1 * MINUTE,
// 秒杀列表
'/product/seckill': 30 * SECOND,
// 秒杀详情
'/product/^\\/seckill\\/pro_([\\d]+)_([\\d]+)/': 30 * MINUTE,
'/product/^\\/seckill\\/show_([\\d]+)/': 30 * MINUTE,
// sale
'/product/sale': 5 * MINUTE,
'/product/sale/discount': 5 * MINUTE,
'/product/sale/vip': 5 * MINUTE,
'/product/sale/breakingYards': 5 * MINUTE,
'/product/sale/discount/detail': 5 * MINUTE,
// 奥莱
'/product/outlet': 30 * SECOND,
'/product/outlet/activity': 1 * MINUTE,
// 品牌一览
'/brands': 5 * MINUTE,
'/brands/search': 1 * MINUTE
};
module.exports = cachePage;
... ...
... ... @@ -67,7 +67,7 @@ module.exports = {
port: '4444' // influxdb port
},
console: {
level: 'debug',
level: 'error',
colorize: 'all',
prettyPrint: true
}
... ... @@ -78,7 +78,7 @@ module.exports = {
appSecret: 'ce21ae4a3f93852279175a167e54509b'
}
},
zookeeperServer: false // '10.66.1.97:2181'
zookeeperServer: '192.168.102.168:2188'
};
if (isProduction) {
... ... @@ -103,7 +103,8 @@ if (isProduction) {
interfaceShunt: {
open: false,
url: 'http://123.206.2.55/strategy'
}
},
zookeeperServer: '10.66.1.97:2181'
});
} else if (isTest) {
Object.assign(module.exports, {
... ...
'use strict';
const cachePage = require('../../config/cache');
const logger = global.yoho.logger;
const _ = require('lodash');
function urlJoin(a, b) {
if (_.endsWith(a, '/') && _.startsWith(b, '/')) {
return a + b.substring(1, b.length);
} else if (!_.endsWith(a, '/') && !_.startsWith(b, '/')) {
return a + '/' + b;
} else {
return a + b;
}
}
module.exports = () => {
return (req, res, next) => {
function onRender() {
let route = req.route ? req.route.path : '';
let appPath = req.app.mountpath;
if (_.isArray(route) && route.length > 0) {
route = route[0];
}
let key = urlJoin(appPath, route.toString()); // route may be a regexp
req.app.set('etag', false);
logger.debug(`route: ${key} cache = ${cachePage[key]}`);
// 如果存在cache配置,并且业务代码中没有设置
if (cachePage[key] && res.get('Cache-Control') !== 'no-cache') {
res.set({
'Cache-Control': 'max-age=' + cachePage[key]
});
res.removeHeader('Pragma');
res.removeHeader('Expires');
} else if (req.get('X-Requested-With') === 'XMLHttpRequest') {
res.set('Cache-Control', 'no-cache');
} else {
res.set({
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Expires: new Date(1900, 0, 1, 0, 0, 0, 0)
});
}
}
res.on('render', onRender);
next();
};
};
... ...
... ... @@ -4,5 +4,6 @@
</a>
{{#unless @root.wap.common.removeCartCount}}
<span class="cart-count hide">0</span>
<input type="hidden" id="remove-cart-count" value="1">
{{/unless}}
</div>
... ...
{
"name": "m-yohobuy-node",
"version": "5.1.1",
"version": "5.1.2",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ... @@ -21,6 +21,7 @@
"bluebird": "^3.4.6",
"body-parser": "^1.15.2",
"cheerio": "^0.22.0",
"compression": "^1.6.2",
"connect-multiparty": "^2.0.0",
"cookie-parser": "^1.4.3",
"cookie-session": "^1.2.0",
... ... @@ -38,7 +39,7 @@
"request-promise": "^3.0.0",
"serve-favicon": "^2.3.0",
"uuid": "^2.0.3",
"yoho-node-lib": "^0.1.24",
"yoho-node-lib": "0.1.28",
"yoho-zookeeper": "^1.0.3"
},
"devDependencies": {
... ...
... ... @@ -7,22 +7,24 @@
var $ = require('yoho-jquery');
var $cart = $('#suspend-cart');
if ($('#remove-cart-count').length) {
$.ajax({
type: 'GET',
url: '/cart/index/count',
success: function(data) {
var count;
$.ajax({
type: 'GET',
url: '/cart/index/count',
success: function(data) {
var count;
if (data.code === 200) {
count = data.data.cart_goods_count;
if (count > 99) {
count = '99+';
}
if (count === 0) {
$('.cart-count').remove();
if (data.code === 200) {
count = data.data.cart_goods_count;
if (count > 99) {
count = '99+';
}
if (count === 0) {
$('.cart-count').remove();
}
$cart.find('.cart-count').html(count).removeClass('hide');
}
$cart.find('.cart-count').html(count).removeClass('hide');
}
}
});
});
}
... ...
... ... @@ -7,7 +7,7 @@ var $ = require('yoho-jquery'),
module.exports = function(callback) {
var brandId = $('#brandId').val();
var clientType = $('#clientType').val();
if (brandId) {
if (brandId && $('#related-infos-demote').length) {
$.ajax({
type: 'POST',
url: '/guang/plustar/brandinfoAsync',
... ...
... ... @@ -88,54 +88,54 @@ moreHammer.on('tap', function(e) {
e.preventDefault(); // 防止收缩后误点到商品产生跳转
});
// 品牌收藏
likeHammer = new Hammer(document.getElementById('brand-like'));
likeHammer.on('tap', function(e) {
var opt = 'ok',
$this = $(e.target);
// jumpToApp = 1表示APP未登录的情况,此时不发送ajax请求而由a链接直接跳转APP
// if (jumpToApp === '1') {
// return true;
// }
e.preventDefault();
if ($this.hasClass('like')) {
opt = 'cancel';
}
$.ajax({
type: 'POST',
url: '/guang/opt/favoriteBrand',
data: {
id: brandId,
opt: opt,
uid: uid,
isBrand: 'brand'
},
success: function(data) {
if (data.code === 200) {
$this.toggleClass('like');
tip.show(data.message);
} else if (data.code === 400 || data.code === 412) {
if (jumpToApp === '1') {
var url = location.href + '&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http:\/\/guang.m.yohobuy.com\/plustar\/brandinfo","param":{"id":'
+ window.queryString.id + '}},"requesturl":{"url":"\/guang\/api\/v1\/favorite\/togglebrand","param":{"brand_id":"' + $('#brand-info').data('id') + '"}},"priority":"Y"}}';
$('body').append('<a href=' + url + ' style="display:none;"><span class="jump-login">&nbsp;</span></a>');
$('.jump-login').click();
if ($('#brand-like').length) {
// 品牌收藏
likeHammer = new Hammer(document.getElementById('brand-like'));
likeHammer.on('tap', function(e) {
var opt = 'ok',
$this = $(e.target);
// jumpToApp = 1表示APP未登录的情况,此时不发送ajax请求而由a链接直接跳转APP
// if (jumpToApp === '1') {
// return true;
// }
e.preventDefault();
if ($this.hasClass('like')) {
opt = 'cancel';
}
$.ajax({
type: 'POST',
url: '/guang/opt/favoriteBrand',
data: {
id: brandId,
opt: opt,
uid: uid,
isBrand: 'brand'
},
success: function(data) {
if (data.code === 200) {
$this.toggleClass('like');
tip.show(data.message);
} else if (data.code === 400 || data.code === 412) {
if (jumpToApp === '1') {
var url = location.href + '&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http:\/\/guang.m.yohobuy.com\/plustar\/brandinfo","param":{"id":'
+ window.queryString.id + '}},"requesturl":{"url":"\/guang\/api\/v1\/favorite\/togglebrand","param":{"brand_id":"' + $('#brand-info').data('id') + '"}},"priority":"Y"}}';
$('body').append('<a href=' + url + ' style="display:none;"><span class="jump-login">&nbsp;</span></a>');
$('.jump-login').click();
} else {
location.href = data.data; // 未登录跳转登录页面
}
} else {
location.href = data.data; // 未登录跳转登录页面
tip.show(data.message);
}
} else {
tip.show(data.message);
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
return false;
});
return false;
});
}
// console.log($('.logo').attr('src'))
... ...
... ... @@ -13,8 +13,10 @@ var myImage = new Image(),
avatar;
require('../common');
require('./recommend-for-you-user-center');
require('../product/suspend-cart.js');
if ($('.recommend-for-you').length) {
require('./recommend-for-you-user-center');
}
require('../common/suspend-cart');
require('../common/footer');
// 部分老用户没有头像,显示默认头像
... ...
... ... @@ -126,25 +126,27 @@ require('./detail/page-render')(function() {
require('./detail/consultform');
require('./detail/recommend-for-you-product-desc');
// 购物车商品数量
$.ajax({
type: 'GET',
url: '/cart/index/count',
success: function(data) {
var count;
if (data.code === 200) {
count = data.data.cart_goods_count || 0;
if (count === 0) {
return false;
}
if (count > 99) {
count = '99+';
if ($('#remove-cart-count').length) {
// 购物车商品数量
$.ajax({
type: 'GET',
url: '/cart/index/count',
success: function(data) {
var count;
if (data.code === 200) {
count = data.data.cart_goods_count || 0;
if (count === 0) {
return false;
}
if (count > 99) {
count = '99+';
}
$cart.find('.num-tag').html(count).removeClass('hide');
}
$cart.find('.num-tag').html(count).removeClass('hide');
}
}
});
});
}
if ($('.good-detail-page').length > 0) {
$('#yoho-footer').css('border-top', '1px solid #e0e0e0');
... ...
... ... @@ -128,25 +128,27 @@ require('./detail/page-render')(function() {
require('./detail/consultform');
require('./detail/recommend-for-you-product-desc');
// 购物车商品数量
$.ajax({
type: 'GET',
url: '/cart/index/count',
success: function(data) {
var count;
if (data.code === 200) {
count = data.data.cart_goods_count || 0;
if (count === 0) {
return false;
}
if (count > 99) {
count = '99+';
if ($('#remove-cart-count').length) {
// 购物车商品数量
$.ajax({
type: 'GET',
url: '/cart/index/count',
success: function(data) {
var count;
if (data.code === 200) {
count = data.data.cart_goods_count || 0;
if (count === 0) {
return false;
}
if (count > 99) {
count = '99+';
}
$cart.find('.num-tag').html(count).removeClass('hide');
}
$cart.find('.num-tag').html(count).removeClass('hide');
}
}
});
});
}
if ($('.good-detail-page').length > 0) {
$('#yoho-footer').css('border-top', '1px solid #e0e0e0');
... ...
... ... @@ -8,21 +8,23 @@ var $ = require('yoho-jquery');
var $cart = $('#suspend-cart');
$.ajax({
type: 'GET',
url: '/cart/index/count',
success: function(data) {
var count;
if ($('#remove-cart-count').length) {
$.ajax({
type: 'GET',
url: '/cart/index/count',
success: function(data) {
var count;
if (data.code === 200) {
count = data.data.cart_goods_count;
if (count > 99) {
count = '99+';
if (data.code === 200) {
count = data.data.cart_goods_count;
if (count > 99) {
count = '99+';
}
if (count === 0) {
$('.cart-count').remove();
}
$cart.find('.cart-count').html(count).removeClass('hide');
}
if (count === 0) {
$('.cart-count').remove();
}
$cart.find('.cart-count').html(count).removeClass('hide');
}
}
});
});
}
\ No newline at end of file
... ...