Authored by 郭成尧

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

... ... @@ -20,15 +20,10 @@ const path = require('path');
const compression = require('compression');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const uuid = require('uuid');
const moment = require('moment');
const pkg = require('./package.json');
const cookieSession = require('client-sessions');
const memcachedSession = require('yoho-express-session');
const memcached = require('connect-memcached');
const hbsEvent = require('./config/hbsevent');
const MemcachedStore = memcached(memcachedSession);
const _ = require('lodash');
const app = express();
... ... @@ -107,67 +102,7 @@ app.use(bodyParser.urlencoded({
app.use(cookieParser());
app.use(compression());
const sessionStore = new MemcachedStore({
hosts: config.memcache.session,
prefix: 'yohobuy_session:',
reconnect: 5000,
timeout: 1000,
retries: 0
});
app.use(memcachedSession({
proxy: true,
resave: false,
saveUninitialized: true,
unset: 'destroy',
secret: '82dd7e724f2c6870472c89dfa43cf48d',
name: 'yohobuy_session',
cookie: {
domain: 'yohobuy.com',
httpOnly: false
},
store: sessionStore
}));
app.use(cookieSession({
requestKey: 'session2',
cookieName: 'yohobuy_session_cookie',
secret: '82dd7e724f2c6870472c89dfa43cf48d',
cookie: {
domain: 'yohobuy.com',
ephemeral: true
}
}));
app.use((req, res, next) => {
if (req.session) {
let sessionKeys = Object.keys(req.session || {});
let backSessionKeys = Object.keys(req.session2.sessionBack || {});
if (backSessionKeys.length > sessionKeys.length) {
let differences = _.difference(backSessionKeys, sessionKeys);
_.forEach(differences, d => {
req.session[d] = req.session2.sessionBack[d];
});
}
req.session2.sessionBack = req.session;
} else {
req.session = new memcachedSession.Session(req);
req.session.cookie = new memcachedSession.Cookie({
domain: 'yohobuy.com',
httpOnly: false
});
req.session = _.assign(req.session, req.session2.sessionBack);
}
if (!req.sessionID) {
req.sessionID = uuid.v4();
}
next();
});
require('./doraemon/middleware/yoho-session')(app);
app.use((req, res, next) => {
req.user = {}; // 全局的用户数据
... ...
... ... @@ -25,7 +25,8 @@ module.exports = class extends global.yoho.BaseModel {
result.data.isApp = isApp;
result.data.copyUrl = result.data.shareUrl.replace(/"/g, '"').replace(/=/g, ':');
result.data.copyUrl = result.data.shareUrl ?
result.data.shareUrl.replace(/"/g, '"').replace(/=/g, ':') : '';
return result.data;
} else {
... ...
... ... @@ -53,7 +53,7 @@ module.exports = {
yh_channel: params.yh_channel,
limit: params.limit,
need_filter: 'null',
rec_pos: '100008',
rec_pos: '100004',
gender: params.gender || gender[params.yh_channel]
}, {
cache: true
... ...
... ... @@ -115,12 +115,16 @@ const _getRes = () => {
// 潮流口令
const _getCode = (uid) => {
if (uid) {
return api.get('', {
method: 'app.invitecode.my',
uid: uid
}, {
code: 200
});
} else {
return Promise.resolve({});
}
};
const _getTrendPop = (contentCode) => {
... ...
... ... @@ -16,6 +16,7 @@ class SimilarModel extends global.yoho.BaseModel {
product_skn: params.skn
},
param: {
cache: true,
code: 200
}
};
... ...
const config = global.yoho.config;
const memcachedSession = require('yoho-express-session');
const _ = require('lodash');
const uuid = require('uuid');
const cookieSession = require('client-sessions');
const memcached = require('connect-memcached');
const MemcachedStore = memcached(memcachedSession);
/**
* 该中间件主要把 express-session 和 client-session 集中起来处理,如果 memcached 出错了,使用 cookie session
* @param opts.backSession cookieSession 的键名
* @returns {function(*=, *=, *)}
*/
function yohoSession(opts) {
return (req, res, next) => {
let notUseMemcached = _.get(req.app.locals.wap, 'session.removeMemcached', false);
opts.backSession = opts.backSession || 'session2';
if (req.session && !notUseMemcached) {
req.sessionError = false;
} else {
// 重建 session
res.emit('sessionError');
req.sessionError = true;
req.sessionID = uuid.v4();
req.session = new memcachedSession.Session(req, req[opts.backSession].sessionBack);
req.session.cookie = new memcachedSession.Cookie({
domain: 'yohobuy.com',
httpOnly: false
});
}
Object.defineProperty(req.session, 'reset', {
configurable: true,
enumerable: false,
value: function() {
req.session.destroy();
req[opts.backSession].reset();
},
writable: false
});
// 备份数据
req[opts.backSession].sessionBack = req.session;
next();
};
}
module.exports = (app) => {
app.use(memcachedSession({ // eslint-disable-line
proxy: true,
resave: false,
saveUninitialized: true,
unset: 'destroy',
secret: '82dd7e724f2c6870472c89dfa43cf48d',
name: 'yohobuy_session',
cookie: {
domain: 'yohobuy.com',
httpOnly: false
},
store: new MemcachedStore({
hosts: config.memcache.session,
prefix: 'yohobuy_session:',
reconnect: 5000,
timeout: 1000,
retries: 0
})
}));
app.use(cookieSession({ // eslint-disable-line
requestKey: 'session2',
cookieName: 'yohobuy_session_cookie',
secret: '82dd7e724f2c6870472c89dfa43cf48d',
cookie: {
domain: 'yohobuy.com',
ephemeral: true
}
}));
app.use(yohoSession({
backSession: 'session2'
}));
};
... ...
{
"name": "m-yohobuy-node",
"version": "6.0.1",
"version": "6.10.0",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -485,10 +485,11 @@ class ChosePanel {
}
$chosePanel.find('.left-num').text(numText);
$chosePanel.find('.size-info').text(selectSku.sizeInfo).removeClass('hide');
$chosePanel.find('.size-rec').text(selectSku.sizeRec).removeClass('hide');
$chosePanel.find('.size-rec').text(selectSku.sizeRec || '').removeClass('hide');
} else {
$chosePanel.find('.left-num').text('');
$chosePanel.find('.size-info').text('').addClass('hide');
$chosePanel.find('.size-rec').text('').addClass('hide');
}
}
... ...
... ... @@ -34,7 +34,9 @@ if ($loadMoreInfo.length > 0) {
$noMore = $loadMoreInfo.children('.no-more');
}
info.initSwiper(curType);
if ($('.swiper-container').length > 0) {
info.initSwiper(curType);
}
info.initInfosEvt($infoList);
... ...
const store = require('store');
const expirePlugin = require('store/plugins/expire');
store.addPlugin(expirePlugin);
const engine = require('store/src/store-engine');
const storages = [
require('store/storages/sessionStorage')
];
const plugins = [
require('store/plugins/defaults'),
require('store/plugins/expire')
];
const store = engine.createStore(storages, plugins);
module.exports = {
get: (...params) => {
store.enabled = false; // 暂时屏蔽
return store.enabled ? store.get(...params) : false;
},
set: (...params) => {
store.enabled = false; // 暂时屏蔽
return store.enabled ? store.set(...params, new Date().getTime() + 180000) : false;
}
};
... ...
... ... @@ -150,6 +150,14 @@ class ProductListWithFilter {
});
}
// 点击排序,重新筛选
if (params && params.navTouch) {
delete params.navTouch;
this.nav.end = false;
} else if (this.nav && this.nav.end) { // 滚动加载,加载结束标识
return false;
}
// 有参数,参数优先,滚动加载相关参数重置
if (params && !params.filtering) {
Object.assign(this.defaultOpt, params);
... ... @@ -160,10 +168,6 @@ class ProductListWithFilter {
this.beforeScroll = document.body.scrollTop;
}
if (this.nav && this.nav.end) {
return false;
}
if (!this.onSearching) {
let catchKey = this.searchUrl + '?' + $.param(this.defaultOpt);
... ... @@ -193,8 +197,11 @@ class ProductListWithFilter {
});
},
success: (result) => {
cacheStore.set(catchKey, result);
this.dataRender(result);
if (result && result.length) {
cacheStore.set(catchKey, result);
}
},
error: () => {
let $divide = $('.search-divide');
... ... @@ -231,7 +238,7 @@ class ProductListWithFilter {
// 初始化filter&注册filter回调
filter.initFilter({
fCbFn: () => {
this.getGoodsList();
this.getGoodsList({ navTouch: true });
},
hCbFn: () => {
... ... @@ -364,7 +371,7 @@ class ProductListWithFilter {
this.defaultOpt.type = this.navType;
Object.assign(this.defaultOpt, this.nav);
this.getGoodsList();
this.getGoodsList({navTouch: true});
}
}
... ...
... ... @@ -13,11 +13,15 @@
width: 193px;
margin-right: 10px;
&:nth-of-type(2n) {
margin-right: 10px;
}
&:nth-of-type(3n) {
margin-right: 0;
}
.product-detail-img {
.product-detail-imgbox .product-detail-img {
height: 257px;
}
... ...
... ... @@ -74,9 +74,9 @@
.coupon-left {
position: absolute;
width: 158px;
width: 185px;
overflow: hidden;
margin: 0 35px;
margin: 0 0 0 35px;
height: inherit;
}
... ...
... ... @@ -74,9 +74,9 @@
.coupon-left {
position: absolute;
width: 165px;
width: 160px;
overflow: hidden;
margin: 0 30px;
margin: 0 0 0 30px;
height: inherit;
}
... ...