Authored by zhangxiaoru

merge

Showing 52 changed files with 512 additions and 205 deletions
... ... @@ -349,7 +349,7 @@ exports.receiveCoupon = (receiveData, uid) => {
break;
default:
returnData = {
msg: '领券失败!',
msg: result.message || '领券失败!',
status: false
};
break;
... ...
... ... @@ -6,7 +6,7 @@
'use strict';
const service = global.yoho.ServiceAPI;
const service = global.yoho.StoreAPI;
const moment = require('moment');
// 格式年月日
... ...
... ... @@ -21,6 +21,9 @@ const index = (req, res) => {
signurl: helpers.urlFormat('/signin.html')
};
// 唤起 APP 的路径
res.locals.appPath = 'yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.shopcart","params":{}}';
res.render('index', Object.assign(pageData, {
title: '购物车',
module: 'cart',
... ... @@ -156,7 +159,8 @@ const add = (req, res, next) => {
return indexModel.addToCart(productSku, buyNumber, goodsType, isEdit, promotionId, uid, shoppingKey).then(data => {
if (!shoppingKey && _.has(data, 'data.shopping_key')) {
res.cookie('_SPK', data.data.shopping_key, {
expires: new Date(Date.now() + 86400 * 360)
expires: new Date(Date.now() + 86400 * 360),
domain: '.m.yohobuy.com'
});
}
data ? res.json(data) : res.status(400).json({
... ...
... ... @@ -70,23 +70,26 @@ exports.orderEnsure = (req, res, next) => {
addressModel.addressData(uid)
];
if (_.isUndefined(req.cookies._isNewUser)) {
allPromise.push(orderModel.isNewUser(uid));
}
/* tar note 170426 品众去除 */
// if (_.isUndefined(req.cookies._isNewUser)) {
// allPromise.push(orderModel.isNewUser(uid));
// }
return Promise.all(allPromise).then(result => {
let order = result[0];
let userProfile = result[1];
let address = result[2];
let isNewUser = result[3];
if (!_.isUndefined(isNewUser)) {
if (isNewUser) {
res.cookie('_isNewUser', true, actCkOpthn);
} else {
res.cookie('_isNewUser', false, actCkOpthn);
}
}
/* tar note 170426 品众去除 */
// let isNewUser = result[3];
// if (!_.isUndefined(isNewUser)) {
// if (isNewUser) {
// res.cookie('_isNewUser', true, actCkOpthn);
// } else {
// res.cookie('_isNewUser', false, actCkOpthn);
// }
// }
if (order.cartUrl) {
logger.info(`orderEnsure: order cartUrl has value:${order.cartUrl}, order data is null`);
... ...
... ... @@ -3,12 +3,27 @@
const api = global.yoho.API;
const cartCount = (uid, shoppingKey) => {
let params = {
method: 'app.Shopping.count'
};
return api.get('', {
method: 'app.Shopping.count',
uid: uid,
shopping_key: shoppingKey
}).then((result) => {
if (!uid && !shoppingKey) {
return Promise.resolve({});
}
if (uid) {
Object.assign(params, {
uid: uid
});
}
if (shoppingKey) {
Object.assign(params, {
shopping_key: shoppingKey
});
}
return api.get('', params).then((result) => {
return result;
});
};
... ...
... ... @@ -17,6 +17,7 @@ const helpers = global.yoho.helpers;
const _ = require('lodash');
const co = require('bluebird').coroutine;
const logger = global.yoho.logger;
const stringProcess = require(`${global.utils}/string-process`);
// 支付方式
const payments = {
... ... @@ -55,7 +56,7 @@ const _getOthersBuy2 = (param) => {
// 订单信息
const _getOtherDetail = (param) => {
if (!param.uid || !param.orderCode) {
if (!param.uid || !param.orderCode || !stringProcess.isNumeric(param.orderCode)) {
return Promise.resolve({});
}
... ...
... ... @@ -29,6 +29,9 @@ let index = (req, res, next) => {
};
let channel;
// 唤起 APP 的路径
res.locals.appPath = 'yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.attention","params":{"actiontype":"1"}}';
if (!req.query.channel) {
channel = '1';
} else if (!typeLib.channels[req.query.channel]) {
... ...
... ... @@ -7,6 +7,8 @@ const footerModel = require('../../../doraemon/models/footer_tab'); // 底部tab
const helpers = global.yoho.helpers;
let index = (req, res, next) => {
// 唤起 APP 的路径
res.locals.appPath = 'yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.attention","params":{"actiontype":"0"}}';
cateModel.getCateData(req.yoho.channel).then((result) => {
res.render('cate', {
... ...
... ... @@ -210,6 +210,10 @@ const index = (req, res, next) => {
res.set('Cache-Control', 'no-cache');
}
}
// 唤起 APP 的路径
res.locals.appPath = `yohobuy://yohobuy.com/goapp?openby:yohobuy= {"action":"go.guangchannel","params":{"id":${param.type}}}`;
res.render('guang', Object.assign(responseData, result, {
localCss: true
}));
... ...
... ... @@ -26,6 +26,9 @@ exports.index = (req, res, next) => {
let studentSwitch = !_.get(req.app.locals.wap, 'user.removeStudentIdentification', true);
// 唤起 APP 的路径
res.locals.appPath = 'yohobuy://yohobuy.com/goapp?openby:yohobuy= {"action":"go.mine"}';
indexModel.index(params).then(result => {
if (result) {
res.render('home', Object.assign(result, {
... ...
... ... @@ -8,12 +8,14 @@
const installmentModel = require('../models/installment');
const _ = require('lodash');
const helpers = global.yoho.helpers;
const logger = global.yoho.logger;
// 服务器报错页面
const _serverCrash = (res, params, err, next) => {
if (err && err.code === 401) {
return next(err);
}
logger.error(err);
params.title = params.title || '有货分期';
res.render('installment/server-crash', params);
};
... ... @@ -54,6 +56,7 @@ const _repaymentList = (req, res, next, opt, params) => {
const index = (req, res, next) => {
let uid = req.user.uid;
logger.info(`installment index info: client_type=${req.query.client_type},req.user.uid=${req.user.uid},req.query.uid=${req.query.uid},cookies=${JSON.stringify(req.cookies)}`); // eslint-disable-line
Promise.all([
installmentModel.getStauts(uid),
installmentModel.getSearchIntallment({
... ...
... ... @@ -145,8 +145,7 @@ const addressModify = (req, res, next) => {
addressModel.getAddressData({uid: uid}).then(result => {
let userAddressList = result;
let addressData = addressProcess.getAddressByAreaCode(areaCode,
_.get(userAddressList, 'data', [])) || {};
let addressData = addressProcess.getAddressByAreaCode(areaCode, _.get(userAddressList, 'data', [])) || {};
Object.assign(addressData, {
orderCode: orderCode,
... ... @@ -154,7 +153,7 @@ const addressModify = (req, res, next) => {
if (provinceAreaCode) {
// 不允许修改省份,字符串拆分
let areaArray = addressData.area.split(' ');
let areaArray = addressData.area ? addressData.area.split(' ') : [];
let area = _.slice(areaArray, 1);
Object.assign(addressData, {
... ...
... ... @@ -28,7 +28,7 @@ const _userData = (params) => {
code: 200
});
} else {
return false;
return Promise.resolve({});
}
};
... ...
... ... @@ -12,6 +12,7 @@ const helpers = global.yoho.helpers;
const api = global.yoho.API;
const serviceAPI = global.yoho.ServiceAPI;
const logger = global.yoho.logger;
const stringProcess = require(`${global.utils}/string-process`);
const API_TIMEOUT = 10000;
const codeContent = {
openN: '0876085ff46bed27f1a1eb6ee8b68987',
... ... @@ -207,7 +208,7 @@ const getStauts = (uid) => {
if (result && result.code === 200) {
return result.data.status;
} else {
logger.error('get installment open status return code is not 200');
logger.error(`get installment open status return code is not 200,uid:${uid},result=${JSON.stringify(result)}`); // eslint-disable-line
return Promise.reject(result);
}
});
... ... @@ -423,6 +424,10 @@ const getBankCards = (uid) => {
const getInstallmentOrderDetail = (params) => {
const method = 'app.SpaceOrders.installDetail';
if (!params.uid || !params.orderCode || !stringProcess.isNumeric(params.orderCode)) {
return Promise.resolve({});
}
return api.get('', {
method: method,
uid: params.uid,
... ...
... ... @@ -10,6 +10,7 @@ const _ = require('lodash');
const helpers = global.yoho.helpers;
const camelCase = global.yoho.camelCase;
const logger = global.yoho.logger;
const stringProcess = require(`${global.utils}/string-process`);
const CODE_LOGISTIC_BANNER = '1fc9b2484fcd559049f2f7e0db313f20'; // 物流详情banner资源码
... ... @@ -143,6 +144,10 @@ const _getOrderStatus = (order, showLogistics) => {
const orderDetailData = (uid, orderCode) => {
if (!uid || !orderCode || !stringProcess.isNumeric(orderCode)) {
return Promise.resolve({});
}
return api.get('', {
method: 'app.SpaceOrders.detail',
uid: uid,
... ...
... ... @@ -237,6 +237,8 @@ const sendCodeToMobileAPI = (req, res, next) => {
_.set(req.session, 'backupCaptch.timeout', Date.now() + 5 * 60 * 1000);
}
req.session.backupCaptchStep2 = true; // 允许跳到第二步
return res.json({
code: 200,
data: helpers.urlFormat('/passport/back/mobilecode', {
... ... @@ -286,14 +288,17 @@ const verifyCodeByMobileAPI = (req, res, next) => {
service.validateMobileCodeAsync(phoneNum, code, areaCode)
.then(result => {
if (result.code === 200) {
if (result.code === 200 && result.data) {
req.session.backcode = {
phoneNum: phoneNum,
token: result.data.token,
areaCode: areaCode,
code: code
};
res.json({
code: 200,
data: helpers.urlFormat('/passport/back/backcode', {
phoneNum: phoneNum,
token: result.data.token,
areaCode: areaCode
})
data: helpers.urlFormat('/passport/back/backcode')
});
} else {
res.json({
... ... @@ -309,16 +314,15 @@ const verifyCodeByMobileAPI = (req, res, next) => {
* 找回密码页面,设置新密码页面-手机
*/
const setNewPasswordByMobilePage = (req, res) => {
let phoneNum = req.query.phoneNum || '';
let token = req.query.token || '';
let areaCode = req.query.areaCode || '86';
let code = req.query.code || '';
let backcode = req.session.backcode;
if (!(code || (token && helpers.verifyMobile(phoneNum)))) {
if (!backcode || !(backcode.code || (backcode.token && helpers.verifyMobile(backcode.phoneNum)))) {
res.redirect(400);
return;
}
req.session.backcode = null;
res.render('back/new-password', Object.assign({
module: 'passport',
page: 'back-new-password',
... ... @@ -328,10 +332,10 @@ const setNewPasswordByMobilePage = (req, res) => {
headerText: '找回密码',
isPassportPage: true,
backNewPwd: true,
phoneNum: phoneNum,
token: token,
areaCode: areaCode,
code: code
phoneNum: backcode.phoneNum,
token: backcode.token,
areaCode: backcode.areaCode,
code: backcode.code
}));
};
... ... @@ -361,6 +365,20 @@ const setNewPasswordByMobileAPI = (req, res, next) => {
.catch(next);
};
/**
* 直接调用发短信接口的情况
*/
const verifySmsAllow = (req, res, next) => {
if (_.get(req, 'session.backupCaptch.verifyResult')) {
return next();
} else {
return res.json({
code: 400,
message: '非法请求'
});
}
};
module.exports = {
indexEmailPage,
sendCodeToEmailAPI,
... ... @@ -373,5 +391,6 @@ module.exports = {
verifyCodeByMobileAPI,
setNewPasswordByMobilePage,
setNewPasswordByMobileAPI,
generateCodeImg
generateCodeImg,
verifySmsAllow
};
... ...
... ... @@ -38,6 +38,7 @@ exports.imgCheck = (req, res, next) => {
}, '');
req.session.captcha = codeStr;
req.session.captchaTimeout = new Date().getTime() + 1000 * 60;
req.session.captchaSrc = result.data.verifiedGraphicCode;
return request(`${result.data.verifiedGraphicCode}?imageView2/0/format/jpg/q/70|watermark/2/text/${uuid.v4()}/fontsize/120/dissolve/10`).pipe(res); // eslint-disable-line
... ... @@ -52,6 +53,18 @@ exports.imgCheck = (req, res, next) => {
exports.validate = (req, res, next) => {
let captchaInput = req.body.captcha;
let captchaCode = _.get(req.session, 'captcha');
let captchaTimeout = _.get(req.session, 'captchaTimeout');
if (new Date().getTime() > captchaTimeout) {
_.set(req.session, 'captchaValidCount', 5);
req.session.captcha = null;
return res.json({
code: 400,
message: '验证码超时,请重试',
changeCaptcha: true,
captchaShow: true
});
}
let errorCount = _.get(req.session, 'captchaValidCount'); // 初始1次 + 后续4次, 同一个验证码 共5次
... ...
... ... @@ -117,8 +117,29 @@ const common = {
return next();
});
}
}
},
isLoginUser: (req, res, next) => {
// 微信里边已经登录的时候,不再跳转登录
if (req.user.uid) {
AuthHelper.profile(req.user.uid).then(function(result) {
if (result.code !== 200) {
return next();
}
let refer = req.query.refer || decodeURI(req.cookies.refer) || config.siteUrl;
if (/sign|login/.test(refer)) {
refer = `${config.siteUrl}/home`;
}
refer = utils.refererLimit(refer);
return res.redirect(refer);
}).catch(() => {
return next();
});
} else {
return next();
}
}
};
... ... @@ -280,19 +301,6 @@ const local = {
const wechat = {
login: (req, res, next) => {
// 微信里边已经登录的时候,不再跳转登录
// 与 5.6 的 session 有冲突
// if (req.user.uid) {
// let refer = req.query.refer || decodeURI(req.cookies.refer) || config.siteUrl;
// if (/sign|login/.test(refer)) {
// refer = `${config.siteUrl}/home`;
// }
// refer = utils.refererLimit(refer);
// return res.redirect(refer);
// }
// 设置为原链接标识originalUrl
req.session.originalUrl = 'true';
req.session.authState = uuid.v4();
... ...
... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2017-04-13 10:21:07
* @Last Modified by: Targaryen
* @Last Modified time: 2017-04-20 18:33:48
* @Last Modified time: 2017-04-24 10:52:08
*/
/* ********************
... ... @@ -49,9 +49,9 @@ const passwordResetPage = (req, res) => {
*/
const passwordReset = (req, res, next) => {
let passwordWeakObj = req.session.passwordWeak;
let uid = req.user && req.user.uid || passwordWeakObj.uid;
let uid = (req.user && req.user.uid) || (passwordWeakObj && passwordWeakObj.uid);
if (!uid || !passwordWeakObj.token) {
if (!uid || !passwordWeakObj || !passwordWeakObj.token) {
return res.json({
code: 400,
massage: '非法请求'
... ...
... ... @@ -75,7 +75,7 @@ router.post('/passport/sms_login/password.json', smsLogin.password);
router.get('/passport/login/user', login.user);
// 微信登录
router.get('/passport/login/wechat', login.common.beforeLogin, login.wechat.login);
router.get('/passport/login/wechat', login.common.beforeLogin, login.common.isLoginUser, login.wechat.login);
router.get('/passport/login/wechat/callback', login.wechat.callback);
// sina登录
... ... @@ -134,6 +134,7 @@ router.get('/passport/back/mobile', validateCode.load, back.indexMobilePage);//
router.get('/passport/back/mobilecode', back.verifyCodeByMobilePage);// 输入手机验证码页面
router.get('/passport/back/generatecodeimg.png', back.generateCodeImg);// 生成图片验证码
router.post('/passport/back/sendcode', validateCode.check, back.sendCodeToMobileAPI);// 发送手机验证码
router.post('/passport/back/sendcodeagain', back.verifySmsAllow, back.sendCodeToMobileAPI);// 重新发送手机验证码
router.post('/passport/back/verifycode', back.verifyCodeByMobileAPI);// 校验手机验证码
router.get('/passport/back/backcode', back.setNewPasswordByMobilePage);// 设置新密码页面
... ...
... ... @@ -69,6 +69,9 @@ const shop = {
params.brand = brandId;
// 唤起 APP 的路径
res.locals.appPath = `yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.brand","params":{"brand_id":"${brandId}"}}`;
let searchParam = Object.assign({
isApp: req.yoho.isApp,
brand: brandId,
... ... @@ -221,7 +224,7 @@ const shop = {
}
/* 红人店铺直接跳转 */
if (shopInfoResult.is_red_shop) {
if (shopInfoResult && shopInfoResult.is_red_shop) {
shop.redShop(req, res, next);
return false;
}
... ...
... ... @@ -7,11 +7,17 @@
const newsaleModel = require('../models/newsale');
const headerModel = require('../../../doraemon/models/header');
let yhchannels = {
'1,3': 1,
'2,3': 2
};
let channels = {
boys: '1,3',
girl: '2,3',
kids: '1,2,3',
lifestyle: '1,2,3'
boys: 1,
girls: 2,
kids: 3,
lifestyle: 4
};
const index = (req, res, next) => {
... ... @@ -56,10 +62,10 @@ const selectHotrank = (req, res, next) => {
let limit = 50;
let page = req.query.page || 1;
let notab = req.query.notab || 0;
let yhChannel = req.query.yh_channel || 1;
let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || '1,3';
let yhChannel = (req.query.gender && yhchannels[req.query.gender]) ||
(req.cookies._Channel && channels[req.cookies._Channel]) || 1;
newsaleModel.selectHotrank(yhChannel, gender, sort, tab_id, limit, page, notab).then((result) => {
newsaleModel.selectHotrank(yhChannel, sort, tab_id, limit, page, notab).then((result) => {
res.render('newsale/hotlist', {
layout: false,
... ...
... ... @@ -11,6 +11,7 @@ const helpers = global.yoho.helpers;
const api = global.yoho.API;
const searchModel = require('./search');
const productProcess = require(`${utils}/product-process`);
const stringProcess = require(`${global.utils}/string-process`);
/**
* 频道
... ... @@ -122,14 +123,22 @@ const _getShopDecorator = (shopId) => {
* @return array
*/
const _getShopInfo = (shopId, uid) => {
if (uid === 'undefined') {
uid = 0;
}
return api.get('', {
let finalParams = {
method: 'app.shops.getIntro',
shop_id: shopId,
uid: uid || 0
}, {code: 200}).then((result) => {
};
if (!shopId || !stringProcess.isNumeric(shopId)) {
return Promise.resolve({});
}
if (uid && uid !== 'undefined') {
Object.assign(finalParams, {
uid: uid
});
}
return api.get('', finalParams, {code: 200}).then((result) => {
return result && result.data;
});
};
... ... @@ -144,6 +153,10 @@ const getShopIntro = (shopId, uid) => {
shop_id: shopId
};
if (!shopId || !stringProcess.isNumeric(shopId)) {
return Promise.resolve({});
}
if (uid && uid !== 'undefined') {
params.uid = uid;
}
... ...
... ... @@ -40,10 +40,9 @@ const getHotRank = (codeKey) => {
});
};
const selectHotrank = (yhChannel, gender, sort, tabId, limit, page, notab) => {
const selectHotrank = (yhChannel, sort, tabId, limit, page, notab) => {
let param = {
method: 'app.search.top',
gender: gender,
yh_channel: yhChannel,
page: page,
limit: limit
... ...
... ... @@ -5,6 +5,7 @@
const api = global.yoho.API;
const singleAPI = global.yoho.SingleAPI;
const stringProcess = require(`${global.utils}/string-process`);
/**
* 频道
... ... @@ -41,6 +42,10 @@ exports.getIntro = shopId => {
shop_id: shopId
};
if (!shopId || !stringProcess.isNumeric(shopId)) {
return Promise.resolve({});
}
return api.get('', params, {cache: true, code: 200});
};
... ... @@ -77,12 +82,19 @@ exports.getShopCategory = (shopId, channel) => {
* 店铺收藏数量
*/
exports.favCount = (shopId, uid, channel, udid) => {
return singleAPI.get('favorite', {
let finalParams = {
method: 'app.favorite.queryFavoriteCountByShopIds',
favIds: shopId,
type: 'shop',
udid: udid,
uid: uid,
physical_channel: yhChannel[channel],
});
};
if (uid) {
Object.assign(finalParams, {
uid: uid
});
}
return singleAPI.get('favorite', finalParams);
};
... ...
... ... @@ -212,8 +212,8 @@ const _searchSales = (params) => {
* @param {[string]} uid
* @return {[array]}
*/
const _getUserProfile = (uid) => {
if (!uid) {
const _getUserProfile = (uid, params) => {
if (!uid || params.saleType !== '2') {
return Promise.resolve({
code: 200,
data: {}
... ... @@ -278,14 +278,15 @@ const getSearchData = (params, uid) => {
if (result && result.code === 200) {
return productProcess.processProductList(result.data.product_list || [], {
yh_channel: params.yh_channel,
showSale: false
showSale: false,
isApp: params.isApp
});
} else {
logger.error('api SALE product search code no 200');
return [];
}
}),
_getUserProfile(uid).then((result) => {
_getUserProfile(uid, params).then((result) => {
if (result && result.code === 200) {
return result.data.vip_info ? result.data.vip_info : {};
... ...
... ... @@ -123,7 +123,7 @@ router.get('/recommend-for-you/userCenter', recommendForYou.userCenter);
router.get('/recommend-for-you/cart', recommendForYou.cart);
router.get('/seckill', seckill.checkAppVer('5.1.0'), seckill.index); // 秒杀列表页
router.get('/seckill', seckill.index); // 秒杀列表页
router.get('/seckill/list', seckill.indexData);
router.post('/seckill/remind', seckill.remind); // only app; 秒杀提醒
... ...
... ... @@ -43,6 +43,9 @@
<div id="red-index" class="tab-panel red-shop-index active">
<div class="shop-coupon coupon-group"></div>
{{> reds-shop/modules}}
<div id="indexGoodsContainer" class="goods-container">
<div class="default-goods container clearfix"></div>
</div>
<div class="all-goods">
<a href="{{allGoodsUrl}}">点击查看全部商品</a>
</div>
... ...
<div class="seckill-list yoho-page">
<div id="seckill-list-loading" style="height: 100vh"></div>
</div>
<div class="floor-header-more">
<h2>限时热促</h2>
</div>
<div id="goodsContainer" class="goods-container hide" style="background-color: #fff">
<div id="container" class="default-goods container clearfix"></div>
</div>
\ No newline at end of file
... ...
<div class="item">
<a {{#if link}}href="{{link}}"{{/if}}>
{{#if isGood}}
{{#ifor triple double}}
<img class="item-pic" src="{{image2 src w=235 h=314}}" alt="">
{{#ifor triple double single}}
{{#within index 3}}
<img class="item-pic" src="{{image2 src w=235 h=314}}">
{{^}}
<img class="item-pic lazy" data-original="{{image2 src w=235 h=314}}">
{{/within}}
{{/ifor}}
{{^}}
<img class="item-pic" src="{{image2 src}}" alt="">
{{#within index 3}}
<img class="item-pic" src="{{image2 src}}" alt="">
{{^}}
<img class="item-pic lazy" data-original="{{image2 src}}">
{{/within}}
{{/if}}
</a>
... ...
... ... @@ -15,13 +15,13 @@
<ul class="swiper-wrapper">
{{#each ../pics}}
<li class="swiper-slide">
{{#if link}}
<a href="{{link}}">
<a{{#if link}} href="{{link}}"{{/if}}>
{{#within @../index 3}}
<img src="{{image2 src}}" alt="">
</a>
{{^}}
<img src="{{image2 src}}" alt="">
{{/if}}
{{^}}
<img class="lazy" data-original="{{image2 src}}" alt="">
{{/within}}
</a>
</li>
{{/each}}
</ul>
... ... @@ -51,7 +51,7 @@
{{#isEqual module_type 'SingleImage'}}
<div class="items-s1 clearfix">
{{#each ../pics}}
{{> reds-shop/item}}
{{> reds-shop/item index=@../index single=true}}
{{/each}}
</div>
{{#if ../isModuleMargin}}
... ... @@ -61,7 +61,7 @@
{{#isEqual module_type 'DoubleImage'}}
<div class="items-s2 clearfix">
{{#each ../pics}}
{{> reds-shop/item double=true}}
{{> reds-shop/item index=@../index double=true}}
{{/each}}
</div>
{{#if ../isModuleMargin}}
... ... @@ -71,7 +71,7 @@
{{#isEqual module_type 'TripleImage'}}
<div class="{{#isEqual ../displayType 1}}items-3-3{{/isEqual}}{{#isEqual ../displayType 2}}items-3-3 items-small{{/isEqual}}{{#isEqual ../displayType 3}}items-3-2 items-3-2-right{{/isEqual}}{{#isEqual ../displayType 4}}items-3-2 items-3-2-left{{/isEqual}} clearfix">
{{#each ../pics}}
{{> reds-shop/item triple=true}}
{{> reds-shop/item index=@../index triple=true}}
{{/each}}
</div>
{{#if ../isModuleMargin}}
... ... @@ -81,7 +81,7 @@
{{#isEqual module_type 'FourImage'}}
<div class="items-s4 clearfix">
{{#each ../pics}}
{{> reds-shop/item four=true}}
{{> reds-shop/item index=@../index four=true}}
{{/each}}
</div>
{{#if ../isModuleMargin}}
... ...
... ... @@ -14,9 +14,10 @@ const domains = {
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/',
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
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/',
... ... @@ -114,6 +115,7 @@ if (isProduction) {
api: 'http://api.yoho.yohoops.org/',
service: 'http://service.yoho.yohoops.org/',
global: 'http://api-global.yohobuy.com',
store: '', // 线上域名尚未确定
liveApi: 'http://api.live.yoho.cn/',
singleApi: 'http://single.yoho.cn/',
imSocket: 'wss://imsocket.yohobuy.com:443',
... ... @@ -162,7 +164,8 @@ if (isProduction) {
domains: {
api: process.env.TEST_API || 'http://api-test1.yohops.com:9999/',
service: process.env.TEST_SERVICE || 'http://service-test1.yohops.com:9999/',
global: process.env.TEST_GLOBAL || 'http://global-test-soa.yohops.com:9999',
global: process.env.TEST_GLOBAL || 'http://global-test-soa.yohops.com:9999/',
store: process.env.TEST_STORE || 'http://192.168.102.210:8080/portal-gateway/',
liveApi: process.env.TEST_LIVE || 'http://testapi.live.yohops.com:9999/',
singleApi: process.env.TEST_SINGLE || 'http://api-test1.yohops.com:9999/',
imSocket: process.env.TEST_IM_SOCKET || 'ws://socket.yohobuy.com:10240',
... ...
... ... @@ -51,6 +51,8 @@ exports.serverError = () => {
forceNoCache(res);
if (err && err.code === 401) {
logger.error(`401 error info:client_type=${req.query.client_type},req.user=${JSON.stringify(req.user)},req.query=${JSON.stringify(req.query)},cookies=${JSON.stringify(req.cookies)}`); // eslint-disable-line
if (req.xhr) {
return res.status(401).json(err);
} else if (req.yoho.isApp) {
... ...
... ... @@ -6,33 +6,36 @@ const authcode = require('../../utils/authcode');
module.exports = () => {
return (req, res, next) => {
// 从 SESSION 中获取到当前登录用户的 UID
if (req.session && _.isNumber(req.session.LOGIN_UID)) {
// 调用接口传参时切勿使用toString获得字符串
req.user.uid = {
toString: () => {
return req.session.LOGIN_UID;
},
sessionKey: req.session.SESSION_KEY
};
let userData = _.get(req.session, 'USER', {});
_.merge(req.user, userData);
}
if (!req.yoho.isApp) {
// 从 SESSION 中获取到当前登录用户的 UID
if (req.session && _.isNumber(req.session.LOGIN_UID)) {
// 调用接口传参时切勿使用toString获得字符串
req.user.uid = {
toString: () => {
return _.parseInt(req.session.LOGIN_UID);
},
sessionKey: req.session.SESSION_KEY
};
let userData = _.get(req.session, 'USER', {});
// session 没有读取到的时候,从 cookie 读取 UID
if (!req.user.uid && req.cookies._UID) {
let sessionKey = req.cookies._SESSION_KEY && authcode(req.cookies._SESSION_KEY, '_SESSION_KEY', 2592000000);
_.merge(req.user, userData);
}
// 调用接口传参时切勿使用toString获得字符串
req.user.uid = {
toString: () => {
return cookie.getUid(req);
},
sessionKey
};
}
// session 没有读取到的时候,从 cookie 读取 UID
if (!req.user.uid && req.cookies._UID) {
let sessionKey = req.cookies._SESSION_KEY &&
authcode(req.cookies._SESSION_KEY, '_SESSION_KEY', 2592000000);
// 调用接口传参时切勿使用toString获得字符串
req.user.uid = {
toString: () => {
return _.parseInt(cookie.getUid(req));
},
sessionKey
};
}
}
if (!req.user.uid &&
req.cookies.app_uid &&
req.cookies.app_uid !== '0' &&
... ...
... ... @@ -57,7 +57,7 @@
<link rel="apple-touch-startup-image" sizes="320x460" href="http://static.yohobuy.com/m/v1/img/startup/startup.png" media="screen and (max-device-width: 320)">
</head>
<body class="{{pageStyle}} {{#if isWechat}}wechat-body{{/if}} {{#if width750}}width750{{/if}} {{#if isPassportPage}}passport-body{{/if}} {{#if isStarIndexPage}}star-index-bg{{/if}} {{#if isStarDetailPage}}star-class-body{{/if}} {{#if isInstallmentPage}}installment-body{{/if}}">
<div class="main-wrap" id="main-wrap" {{#if appPath}}data-apppath='{{appPath}}'{{/if}}>
<div class="main-wrap" id="main-wrap" {{#if appPath}}data-apppath='{{{appPath}}}'{{/if}}>
{{#if systemUpdate}}
{{> updata}}
{{/if}}
... ...
... ... @@ -75,8 +75,8 @@
}, 1000);
}());
/* tar add 190222 */
window._fxcmd = window._fxcmd || [];
/* tar add 170426 品众代码去除 */
{{!--window._fxcmd = window._fxcmd || [];
_fxcmd.sid = 'bb3b16fa1106a6ab8619da0095755f32';
_fxcmd.trackAll = false;
// 参数配置(可选)...
... ... @@ -89,7 +89,7 @@
_pzfx.src = '//static.w3t.cn/fx/1/1/fx.js';
var sc = document.getElementsByTagName('script')[0];
sc.parentNode.insertBefore(_pzfx,sc);
}, 1000);
}, 1000);--}}
</script>
... ...
... ... @@ -22,6 +22,9 @@
</span>
{{/if}}
</p>
{{#if appearDate}}
<span class="appear-date">上市期:{{appearDate}}</span>
{{/if}}
<p class="row price-wrap">
<span class="price">
¥{{price}}
... ... @@ -29,9 +32,6 @@
<span class="count">
×{{count}}
</span>
{{#if appearDate}}
<span class="appear-date">上市期:{{appearDate}}</span>
{{/if}}
</p>
</div>
</div>
... ...
{
"name": "m-yohobuy-node",
"version": "5.6.1",
"version": "5.7.0",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ... @@ -26,7 +26,7 @@
"body-parser": "^1.16.1",
"captchapng": "0.0.1",
"cheerio": "^0.22.0",
"client-sessions": "^0.7.0",
"client-sessions": "^0.8.0",
"compression": "^1.6.2",
"connect-memcached": "^0.2.0",
"connect-multiparty": "^2.0.0",
... ... @@ -37,7 +37,7 @@
"lodash": "^4.17.4",
"memory-cache": "^0.1.6",
"moment": "^2.18.1",
"oneapm": "^1.2.20",
"oneapm": "^2.0.0",
"passport": "^0.3.2",
"passport-local": "^1.0.0",
"passport-qq": "0.0.3",
... ... @@ -50,15 +50,15 @@
"xml2js": "^0.4.17",
"yoho-express-session": "^2.0.0",
"yoho-md5": "^2.0.0",
"yoho-node-lib": "=0.2.22",
"yoho-node-lib": "=0.2.25",
"yoho-zookeeper": "^1.0.8"
},
"devDependencies": {
"autoprefixer": "^6.7.4",
"babel-core": "^6.24.1",
"babel-loader": "^6.4.1",
"babel-loader": "^7.0.0",
"babel-polyfill": "^6.23.0",
"babel-preset-env": "^1.3.3",
"babel-preset-env": "^1.4.0",
"css-loader": "^0.28.0",
"cssnano": "^3.10.0",
"eslint": "^3.19.0",
... ... @@ -66,7 +66,7 @@
"eslint-loader": "^1.7.1",
"eslint-plugin-html": "^2.0.1",
"extract-text-webpack-plugin": "^2.1.0",
"handlebars-loader": "^1.4.0",
"handlebars-loader": "^1.5.0",
"happypack": "^3.0.3",
"husky": "^0.13.3",
"nodemon": "^1.11.0",
... ... @@ -81,7 +81,7 @@
"postcss-pxtorem": "^4.0.0",
"postcss-scss": "^0.4.1",
"postcss-short": "^3.0.3",
"postcss-sprites": "^4.2.0",
"postcss-sprites": "^4.2.1",
"postcss-use": "^2.3.0",
"precss": "^1.4.0",
"shelljs": "^0.7.6",
... ... @@ -94,8 +94,8 @@
"vue": "^2.2.6",
"vue-loader": "^11.3.4",
"vue-template-compiler": "^2.2.6",
"webpack": "^2.3.3",
"webpack-dev-server": "^2.4.2",
"webpack": "^2.4.1",
"webpack-dev-server": "^2.4.4",
"webpack-uglify-parallel": "^0.1.3",
"yoho-cookie": "^1.2.0",
"yoho-fastclick": "^1.0.6",
... ...
... ... @@ -27,7 +27,7 @@ _.mergeWith(baseConfig, {
}]
},
devServer: {
host: '0.0.0.0',
host: devInfo.host,
port: devInfo.port,
publicPath: devInfo.publicPath,
contentBase: [path.join(__dirname, './bundle/'), path.join(__dirname, '../')],
... ...
... ... @@ -235,7 +235,9 @@ function pullPicBig(cIndex) {
$('.swiper-pagination-bullet:eq(' + cIndex + ')').click();
mySwiper.slideTo(cIndex, 1000, false);
$('.big-pic').show();
$('.foot-btn').hide();
if ($('.share-photography').length === 0) {
$('.foot-btn').hide();
}
$('.swiper-slide img').each(
function() {
let newTop = (w_height - $(this).height()) / 2;
... ... @@ -298,7 +300,10 @@ $(
}
if ($('.clearCookie').length > 0) {
clearCookieArr(3);
$('.foot-btn').on('click', function() {
clearCookieArr(3);
chosenDefault();
});
}
// 默认选中菜单
... ...
... ... @@ -323,15 +323,15 @@ function submitOrder() {
}, true);
}
/* tar add 190222 */
if (window._fxcmd) {
window._fxcmd.push(['trackOrder', {
oid: res.data.order_code,
otp: res.data.order_amount,
u_info: cookie.get('_UID'),
u_type: cookie.get('_isNewUser') ? 1 : 0
}, []]);
}
/* tar add 170426 品众代码去除 */
// if (window._fxcmd) {
// window._fxcmd.push(['trackOrder', {
// oid: res.data.order_code,
// otp: res.data.order_amount,
// u_info: cookie.get('_UID'),
// u_type: cookie.get('_isNewUser') ? 1 : 0
// }, []]);
// }
cookie.remove(['order-info', 'activity-info']);
window.location.href = url;
... ...
... ... @@ -118,7 +118,7 @@ module.exports = function(useInRegister, useForBind, useForRelate) {
$.ajax({
type: 'POST',
url: (useForBind || useForRelate) ? '/passport/bind/sendBindMsg' : '/passport/' + urlMid + '/sendcode',
url: (useForBind || useForRelate) ? '/passport/bind/sendBindMsg' : '/passport/' + urlMid + '/sendcodeagain',
data: {
phoneNum: phoneNum,
areaCode: areaCode
... ...
... ... @@ -6,6 +6,9 @@
let $ = require('yoho-jquery'),
ImgCheck = require('plugin/img-check'),
tip = require('plugin/tip');
let loading = require('plugin/loading');
const validType = {
IMG_CHECK: 1,
GEETEST: 2
... ... @@ -94,7 +97,9 @@ class Validate {
}
return Promise.resolve({captcha});
} else {
loading.showLoadingMask();
return new Promise((resolve) => {
loading.hideLoadingMask();
this.$container.removeClass('hide');
this.captchaObj.onSuccess(() => {
resolve(this.captchaObj.getValidate());
... ...
let $ = require('yoho-jquery'),
Swiper = require('yoho-swiper'),
lazyLoad = require('yoho-jquery-lazyload'),
loading = require('plugin/loading');
loading = require('plugin/loading'),
qs = require('yoho-qs');
let page = 1,
winH,
... ... @@ -34,7 +35,8 @@ function hotrank(pageIndex, sortIndex, tabId, noTab) {
data: {
page: pageIndex,
tab_id: tabId,
notab: noTab
notab: noTab,
gender: qs.gender
},
success: function(data) {
if (data === ' ') {
... ...
... ... @@ -45,22 +45,26 @@ seckillObj = {
self.$productList = $('.product-list');
// 在app webview中click捕获不到translate样式后的新位置
let $navLis = $el.$navUl.find('>li');
$navLis.on('touchmove', function() {
self.navMove = true;
});
$navLis.on('touchend', function(event) {
if (self.navMove) {
self.navMove = false;
return;
}
setTimeout(() => {
self.selectTime(event.currentTarget);
}, 200);
$el.$navUl.find('>li').click(function(event) {
self.selectTime(event.currentTarget);
});
// 在app webview中click捕获不到translate样式后的新位置
// let $navLis = $el.$navUl.find('>li');
// $navLis.on('touchmove', function() {
// self.navMove = true;
// });
// $navLis.on('touchend', function(event) {
// if (self.navMove) {
// self.navMove = false;
// return;
// }
// setTimeout(() => {
// self.selectTime(event.currentTarget);
// }, 200);
// });
$(window).resize(function() {
self.initNav();
});
... ... @@ -115,6 +119,7 @@ seckillObj = {
tap: true,
eventPassthrough: true,
preventDefault: true,
HWCompositing: false,
bounceTime: 400,
bounceEasing: {
style: 'cubic-bezier(0.333333, 0.666667, 0.666667, 1)'
... ... @@ -466,3 +471,5 @@ window.seckillRefresh = function() {
$(function() {
seckillObj.init();
});
require('./seckill/goods-list');
... ...
/*
* @Author: Targaryen
* @Date: 2017-04-21 13:36:34
* @Last Modified by: Targaryen
* @Last Modified time: 2017-04-21 14:17:40
*/
const $ = require('yoho-jquery');
const lazyLoad = require('yoho-jquery-lazyload');
const yoho = require('yoho-app');
const qs = require('yoho-qs');
const cookie = require('yoho-cookie');
/**
* 获取 APP 传过来的参数
*/
const getChannel = {
1: 'boys',
2: 'girls',
3: 'kids',
4: 'lifestyle',
'1,2,3,4': 'all'
};
let $goodsContainer = $('#goodsContainer');
let $container = $('#container');
let channel = getChannel[qs.yh_channel] || cookie.get('_Channel');
let page = 1;
let beforeScroll = document.body.scrollTop; // 滚动前位置记录
let onSearching = false; // 是否正在搜索
const loadGoodsList = () => {
if (onSearching) {
return false;
}
onSearching = true;
$.ajax({
method: 'get',
url: location.protocol + '//m.yohobuy.com/product/sale/search?type=discount&order=1',
data: {
yh_channel: channel,
page: page++,
isApp: yoho.isApp
},
complete: function() {
onSearching = false;
},
success: function(result) {
let $result = $(result);
let noResult = !result || result.length < 1 || (result.list && result.list.length < 1);
if (noResult) {
return false;
}
$container.append($result);
$goodsContainer.removeClass('hide');
lazyLoad($result.find('img'));
}
});
};
/**
* 当scroll到1/2$goodsContainer高度后继续请求下一页数据
*/
const scrollHandler = function() {
if ($(window).scrollTop() > $goodsContainer.height() * 0.6) {
loadGoodsList();
}
};
/**
* 滚动加载
*/
$(window).scroll(function() {
setTimeout(function() {
let afterScroll = document.body.scrollTop;
if (afterScroll - beforeScroll > 0) {
window.requestAnimationFrame(scrollHandler);
beforeScroll = afterScroll;
} else {
return false;
}
}, 5);
});
$(function() {
loadGoodsList();
});
... ...
... ... @@ -2,19 +2,64 @@
* @Author: Targaryen
* @Date: 2017-03-23 11:31:51
* @Last Modified by: Targaryen
* @Last Modified time: 2017-04-14 11:17:55
* @Last Modified time: 2017-04-25 11:45:13
*/
/** *****************
* 红人店铺首页
********************/
const Swiper2 = require('yoho-swiper2');
const lazyLoad = require('yoho-jquery-lazyload');
let tip = require('../../plugin/tip');
let $goodsContainer = $('.index-goods-container');
let $indexGoodsContaniner = $('#indexGoodsContainer');
let $collect = $('#collect');
const shopId = $('#shopId').val();
lazyLoad($('.lazy'));
/**
* 异步检测是否已经收藏
*/
$.ajax({
type: 'GET',
url: location.protocol + '//m.yohobuy.com/product/index/shopFav',
xhrFields: {
withCredentials: true
},
data: {
shopId: shopId
},
success: function(data) {
if (data.collect) {
$collect.attr('class', 'already-collect pull-left');
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
/**
* 店铺轮播图
*/
if ($('.shop-swiper')) {
let num = $('.shop-swiper').length;
for (let i = 1; i <= num; i++) {
new Swiper2('.shop-swiper-' + i, {
lazyLoading: true,
lazyLoadingInPrevNext: true,
loop: true,
autoplay: 3000,
slideElement: 'li',
paginationClickable: true,
pagination: $(this).closest('.shop-swiper-' + i).find('.pagination-inner').get(0)
});
}
}
/**
* 异步加载推荐商品
*/
... ... @@ -47,51 +92,33 @@ $.each($goodsContainer, function(index, elem) {
},
data: data,
success: function(result) {
let $result = $(result);
lazyLoad($result.find('img[class=lazy]'));
$(elem).html(result);
}
});
});
/**
* 异步检测是否已经收藏
* 异步加载首页全部商品
*/
$.ajax({
type: 'GET',
url: location.protocol + '//m.yohobuy.com/product/index/shopFav',
url: '/product/search/search',
xhrFields: {
withCredentials: true
},
data: {
shopId: shopId
shop_id: shopId
},
success: function(data) {
if (data.collect) {
$collect.attr('class', 'already-collect pull-left');
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
success: function(result) {
let $result = $(result);
/**
* 店铺轮播图
*/
if ($('.shop-swiper')) {
let num = $('.shop-swiper').length;
for (let i = 1; i <= num; i++) {
new Swiper2('.shop-swiper-' + i, {
lazyLoading: true,
lazyLoadingInPrevNext: true,
loop: true,
autoplay: 3000,
slideElement: 'li',
paginationClickable: true,
pagination: $(this).closest('.shop-swiper-' + i).find('.pagination-inner').get(0)
});
lazyLoad($result.find('img[class=lazy]'));
$indexGoodsContaniner.find('.container').html($result);
}
}
});
/**
* 店铺收藏取消收藏操作
... ...
... ... @@ -360,6 +360,8 @@
.appear-date {
color: #f00;
float: right;
margin-right: 30px;
}
}
... ...
... ... @@ -53,6 +53,8 @@ body {
.goods-container {
overflow: hidden;
background-color: #fff;
padding-left: 15px;
.goods-box {
.no-result {
... ...
... ... @@ -4,8 +4,9 @@
.tips {
font-size: 24px;
line-height: 1.4;
color: #b0b0b0;
padding: 30px 30px 185px;
color: #666;
padding: 30px;
background-color: #fff;
h5 {
font-size: 25px;
... ...
... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2017-03-23 17:12:53
* @Last Modified by: Targaryen
* @Last Modified time: 2017-04-20 10:19:41
* @Last Modified time: 2017-04-25 15:54:23
*/
// 红人店铺首页
... ... @@ -230,16 +230,29 @@
/* 四张小图 */
.items-s4 {
border-bottom: 1px solid #e0e0e0;
.item {
float: left;
width: 25%;
border-top: 1px solid #e0e0e0;
border-right: 1px solid #e0e0e0;
}
.item:last-child {
border-right: none;
}
.item-info {
text-align: center;
background-color: #f5f7f6;
color: #000;
position: relative;
.text {
line-height: 36px;
}
.name,
.price {
display: none;
... ...
... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2017-03-23 11:02:31
* @Last Modified by: Targaryen
* @Last Modified time: 2017-04-20 15:41:44
* @Last Modified time: 2017-04-26 16:33:07
*/
/* 红人店铺数据处理 */
... ... @@ -34,7 +34,7 @@ const _linkhandle = (linkParent) => {
switch (parseInt(linkParent.linkType, 10)) {
case 0:
return helpers.urlFormat('', {
categoryId: linkParent.resource
filter_poolId: linkParent.resource
}, 'list');
case 1:
return helpers.urlFormat('/product/' + linkParent.resource + '.html');
... ... @@ -339,8 +339,11 @@ const pushGoodsInfo = (decorators, goodsList) => {
decorators[key].pics[subKey].marketPrice = marketPrice ? '¥' + marketPrice : '';
decorators[key].pics[subKey].isGood = true;
if (value.module_type === 'TripleImage' || value.module_type === 'DoubleImage') {
decorators[key].pics[subKey].src = imageSrc;
if (value.module_type === 'TripleImage' ||
value.module_type === 'DoubleImage' ||
value.module_type === 'SingleImage') {
// decorators[key].pics[subKey].src = imageSrc; // 为了和 APP 统一,图暂时不取商品图
} else if (value.module_type === 'FourImage') {
decorators[key].pics[subKey].isGood = false;
} else {
... ...