Authored by 姜枫

Merge branch 'qCloud' of http://git.yoho.cn/fe/yohobuywap-node into qCloud

Showing 56 changed files with 445 additions and 144 deletions
... ... @@ -11,9 +11,6 @@ global.Promise = require('bluebird');
const yohoLib = require('yoho-node-lib');
// 全局注册library
yohoLib.global(config);
const express = require('express');
const path = require('path');
const bodyParser = require('body-parser');
... ... @@ -31,12 +28,15 @@ app.locals.version = pkg.version;
// 访问域名层级
app.set('subdomain offset', 3);
// 全局注册library
yohoLib.global(config);
// 指定libray目录
global.utils = path.resolve('./utils');
const logger = global.yoho.logger;
// 访问域名层级
app.set('subdomain offset', 3);
app.use(global.yoho.hbs({
extname: '.hbs',
... ...
... ... @@ -22,7 +22,7 @@ app.use(global.yoho.hbs({
extname: '.hbs',
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: path.join(__dirname, 'views/partial'),
partialsDir: path.join(__dirname, 'views/partial', `${doraemon}/partial`),
views: path.join(__dirname, 'views/action'),
helpers: Object.assign({}, global.yoho.helpers, helpers)
}));
... ...
... ... @@ -9,6 +9,7 @@ const service = global.yoho.ServiceAPI;
const helpers = global.yoho.helpers;
const _ = require('lodash');
const _indexBoys = () => {
return service.get('/operations/api/v5/resource/home', {
content_code: '797c299afc4170452cf7b2048806b6b8',
... ... @@ -33,6 +34,7 @@ const index = () => {
_indexBoys(),
_index()
]).then(result => {
let resu = {
swiper: [],
floorAdList: [],
... ...
... ... @@ -29,5 +29,4 @@ router.post('/brands/searchAsync', brandController.searchAsync); // 品牌搜索
router.post('/brands/addBrandSearch', brandController.addBrandSearch); // 添加品牌搜索记录
router.get('/brands/delBrandHistory', brandController.delBrandHistory); // 删除品牌搜索记录
module.exports = router;
... ...
... ... @@ -43,7 +43,7 @@ const editor = (req, res, next) => {
articleListData = datas[1];
let build = [];
if (articleListData.data.list.artList) {
if (articleListData.data && articleListData.data.list && articleListData.data.list.artList) {
articleListData.data.list.artList.forEach(articleData => {
build.push(guangProcess.formatArticle(articleData, true, isApp, false, uid));
});
... ...
... ... @@ -55,6 +55,10 @@ const _pageArticleContent = (articleContent, isApp, gender) => {
contents.push(build);
joinContentFunc(++i, len);
} else if (art.weixinPublic) {
build.weixinPublic = art.weixinPublic;
contents.push(build);
joinContentFunc(++i, len);
} else if (art.goods && art.goods.data) { // 相关推荐
let reco = [],
skns = [],
... ... @@ -65,34 +69,38 @@ const _pageArticleContent = (articleContent, isApp, gender) => {
skns.push(goods.id);
arr[goods.id] = goods.src;
});
// 通过SKN获取商品信息
productDetailModel.productInfoBySkns(skns).then((product) => {
if (product.data.product_list) {
let d = [];
if (product && product.data) {
if (product.data.product_list) {
let d = [];
for (let o = 0; o < product.data.product_list.length; o++) {
let goods = product.data.product_list[o];
for (let o = 0; o < product.data.product_list.length; o++) {
let goods = product.data.product_list[o];
// 最多显示4个
if (o > 3) {
break;
// 最多显示4个
if (o > 3) {
break;
}
d.push(guangProcess.formatProduct(goods, false, true, true, 235, 314, isApp, true, gender));
}
d.push(guangProcess.formatProduct(goods, false, true, true, 235, 314, isApp, true, gender));
d.forEach(p => {
if (arr[p.id]) {
p.thumb = helpers.image(arr[p.id], 235, 314);
reco.push(p);
}
});
}
d.forEach(p => {
if (arr[p.id]) {
p.thumb = helpers.image(arr[p.id], 235, 314);
reco.push(p);
}
});
}
// 多个商品
if (product.data.product_list.length > 1) {
build.relatedReco = reco;
} else if (product.data.product_list.length === 1) { // 单个商品
build.relatedReco = reco[0];
// 多个商品
if (product.data.product_list.length && (product.data.product_list.length > 1)) {
build.relatedReco = reco;
} else if (product.data.product_list.length === 1) { // 单个商品
build.relatedReco = reco[0];
}
}
contents.push(build);
joinContentFunc(++i, len);
});
... ... @@ -115,7 +123,7 @@ const _pageArticleContent = (articleContent, isApp, gender) => {
// 通过SKN获取商品信息
productDetailModel.productInfoBySkns(skns).then((product) => {
if (product.data.product_list) {
if (product && product.data && product.data.product_list) {
let g = [];
product.data.product_list.forEach(_ => {
... ... @@ -151,10 +159,11 @@ const _pageArticleContent = (articleContent, isApp, gender) => {
} else {
resolve(contents);
}
}
};
joinContentFunc(0, articleContent.length);
});
}
};
/**
* [处理品牌数据]
* @param {[array]} getBrand [品牌原数据]
... ... @@ -165,7 +174,8 @@ const _relatedBrand = (getBrand) => {
brand.thumb = brand.thumb.replace('http://', '//');
});
return relatedBrand;
}
};
/**
* [处理标签数据]
* @param {[array]} tags [标签原数据]
... ... @@ -182,7 +192,8 @@ const _relatedTag = (tags, isApp) => {
relatedTag.push(value);
});
return relatedTag;
}
};
/**
* [处理相关文章数据]
* @param {[array]} getOtherArticle [相关文章原数据]
... ... @@ -200,7 +211,8 @@ const _relatedInfo = (getOtherArticle, isApp) => {
relatedInfo.push(value);
});
return relatedInfo;
}
};
/**
* [处理分享内容]
* @param {[int]} id [资讯id]
... ... @@ -219,12 +231,13 @@ const _shareInfo = (id, getArticle) => {
shareInfo.shareImg = helpers.image(getArticle.cover_image, 640, 320);
}
return shareInfo;
}
};
/**
* [逛资讯详情页]
*/
const index = (req, res, next) => {
let id = req.query.id,
let id = req.query.id || req.params.id,
gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || 1,
isApp = req.query.app_version || req.query.appVersion || false, // 标识是不是APP访问的
parameter = {},
... ... @@ -286,12 +299,13 @@ const index = (req, res, next) => {
pageView: detail.getArticle.pageViews,
content: []
};
if (detail.getArticleContent) {
//生成内容部分
// 生成内容部分
return _pageArticleContent(detail.getArticleContent, isApp, gender).then((contents) => {
guang.detail.content = contents;
// 相关品牌
if (detail.getBrand && detail.getBrand.length) {
guang.relatedBrand = _relatedBrand(detail.getBrand);
... ... @@ -335,6 +349,7 @@ const index = (req, res, next) => {
}
}).catch(next);
};
/**
* [逛mini内容页]
*/
... ... @@ -369,12 +384,13 @@ const mini = (req, res, next) => {
pageView: detail.getArticle.pageViews,
content: []
};
if (detail.getArticleContent) {
//生成内容部分
// 生成内容部分
return _pageArticleContent(detail.getArticleContent, isApp, gender).then((contents) => {
guang.detail.content = contents;
// 相关品牌
if (detail.getBrand && detail.getBrand.length) {
guang.relatedBrand = _relatedBrand(detail.getBrand);
... ... @@ -430,16 +446,17 @@ const foryoho = (req, res, next) => {
data.brand = detail.getBrand;
if (detail.getArticleContent) {
//生成内容部分
// 生成内容部分
return _pageArticleContent(detail.getArticleContent, isApp, gender).then((contents) => {
data.content = contents;
//内容中的相关推荐和悬浮商品移到data层级
// 内容中的相关推荐和悬浮商品移到data层级
let relatedRecoIndex = data.content.findIndex((cont) => {
return typeof cont.relatedReco !== 'undefined';
})
});
let collocationIndex = data.content.findIndex((cont) => {
return typeof cont.collocation !== 'undefined';
})
});
if (relatedRecoIndex > 0) {
data.goods = data.content[relatedRecoIndex].relatedReco;
data.content.splice(relatedRecoIndex, 1);
... ... @@ -457,7 +474,7 @@ const foryoho = (req, res, next) => {
}
}).catch(next);
}
};
module.exports = {
index,
... ...
... ... @@ -5,6 +5,8 @@
*/
'use strict';
const serviceAPI = global.yoho.ServiceAPI;
const api = global.yoho.API;
const _ = require('lodash');
const URI_PACKAGE_ARTICLE = 'guang/service/v2/article/';
const URI_PACKAGE_AUTHOR = 'guang/service/v1/author/';
... ... @@ -98,11 +100,36 @@ const packageData = (id, isApp) => {
cache: true
}));
}
if (isApp) {
promises.push(api.get('', {
method: 'app.resources.getSingleTemplate',
module: 'wechat',
key: 'guang_detail_wechat'
}));
}
return Promise.all(promises).then(datas => {
let getArticleContent = datas[1].data;
if (isApp && datas[4].data) {
let preCount = 0;
let i;
for (i = 0; i < getArticleContent.length; i++) {
if (getArticleContent[i].singleImage || getArticleContent[i].text || getArticleContent[i].smallPic) {
preCount++;
}
}
getArticleContent.splice(preCount, 0, {weixinPublic: datas[4].data});
}
result.getAuthor = datas[0].data;
result.getArticleContent = datas[1].data;
result.getArticleContent = getArticleContent;
result.getBrand = datas[2].data;
if (datas.length === 4) {
if (datas.length === 5 && isApp || datas.length === 4 && !isApp) {
result.getOtherArticle = datas[3].data;
}
return result;
... ...
... ... @@ -11,6 +11,7 @@ const cRoot = './controllers';
const star = require(cRoot + '/star');
const homeController = require(`${cRoot}/index`);
const plusstar = require(cRoot + '/plusstar');
const index = require(cRoot + '/index');
const opt = require(cRoot + '/opt');
const info = require(cRoot + '/info');
... ... @@ -43,6 +44,7 @@ router.post('/opt/praiseArticle', opt.praiseArticle); // 资讯文章点赞 (H5
router.post('/opt/favoriteBrand', opt.favoriteBrand); // 品牌收藏
router.get('/info/index', info.index); // 逛详情页
router.get('/:id.html', info.index); // 逛详情页(兼容 PC 跳转过来的链接)
router.get('/info/mini', info.mini); // 逛mini内容页
router.get('/info/foryoho', info.foryoho); // 逛foryoho内容页
... ...
... ... @@ -39,6 +39,16 @@
</div>
{{/if}}
{{#if weixinPublic}}
<div class="weixin post-block">
{{#each weixinPublic}}
<a href='//m.yohobuy.com/?openby:yohobuy={"action":"go.copy","params":{"text":"{{wechat_id}}"}}' class="ems-cnpl">
<img class="weixin-img" src="{{image src 280 210 1}}">
</a>
{{/each}}
</div>
{{/if}}
{{#if collocation}}
<div class="post-block collocation-block">
<ul class="thumb-container">
... ...
... ... @@ -308,12 +308,20 @@ const postAccount = (req, res) => {
};
const startingService = (req, res) => {
const banks = ['农业银行', '中国银行', '工商银行', '建设银行', '光大银行', '兴业银行', '邮储银行', '民生银行', '中信银行', '广发银行'];
if (new Date() >= new Date('2016-10-18 00:00:00')) {
// 2016年10月12日至17日 平安银行业务暂停(平安银行期间不支持服务)
banks.push('平安银行');
}
res.render('installment/starting-service', {
module: 'home',
page: 'installment.starting-service',
title: '开通有货分期',
navTitle: '开通有货分期',
navBtn: false
navBtn: false,
banks: banks.join('、')
});
};
... ...
... ... @@ -32,6 +32,7 @@ exports.order = (req, res, next) => {
navTitle: '我的订单'
}),
title: 'Yoho!Buy 有货',
pageFooter: true,
order: result
});
}).catch(next);
... ...
... ... @@ -110,6 +110,9 @@ const favProduct = (uid, page, limit) => {
return resu;
} else {
logger.error('收藏商品 cood 不是 200');
return {
total: 0,
};
}
});
};
... ... @@ -190,6 +193,9 @@ const favfavBrand = (uid, page, limit) => {
return resu;
} else {
logger.error('收藏品牌 cood 不是 200');
return {
total: 0,
};
}
});
};
... ...
... ... @@ -134,7 +134,11 @@ const index = (params) => {
if (result[2] && result[2].data) {
Object.assign(finalResult, {
productFavoriteTotal: result[2].data.product_favorite_total
productFavoriteTotal: _.get(result[2], 'data.product_favorite_total', '0')
});
} else {
Object.assign(finalResult, {
productFavoriteTotal: '0'
});
}
... ... @@ -146,8 +150,13 @@ const index = (params) => {
yohoCoinNum: result[3].data.yoho_coin_num,
inboxTotal: result[3].data.inbox_total,
couponNum: result[3].data.coupon_num,
brandFavoriteTotal: result[3].data.brand_favorite_total,
productBrowse: result[3].data.product_browse
brandFavoriteTotal: _.get(result[3], 'data.brand_favorite_total', '0'),
productBrowse: _.get(result[3], 'data.product_browse', '0')
});
} else {
Object.assign(finalResult, {
brandFavoriteTotal: '0',
productBrowse: '0'
});
}
... ...
... ... @@ -43,8 +43,6 @@ const _assignExpressInfo = (showLogistics, order, result) => {
const _getOrderStatus = (order, showLogistics) => {
let result = {};
// let order.status = 3;
if (order.isCancel === 'Y') {
return {
canceled: true
... ... @@ -54,7 +52,7 @@ const _getOrderStatus = (order, showLogistics) => {
// 先判断订单付款方式,根据不同的付款方式计算订单状态。(注:货到付款没有待付款状态)
// 支付方式为非货到付款时,计算订单状态。
if (parseInt(order.paymentType, 10) !== 2) {
switch (order.status) {
switch (parseInt(order.status, 10)) {
case 0:
/* 待付款 */
... ...
... ... @@ -133,7 +133,4 @@ router.get('/installment/bank-card', installment.bankCard); // 银行卡列表
router.get('/recommend-for-you/userCenter', recommendForYou.userCenter);// 为你优选
router.get('/installment/server-crash', installment.serverCrash); // 服务器崩溃
router.get('/installment/bank-card', installment.bankCard); // 银行卡列表
module.exports = router;
... ...
... ... @@ -48,8 +48,10 @@
</a>
{{/notice}}
</div>
<div class="my-order">
{{^}}
<div class="my-order my-order-top">
{{/if}}
<div class="my-order">
<a class="order-title" href="/home/orders">
我的订单
<span class="iconfont">
... ...
... ... @@ -78,9 +78,7 @@
<div class="notice-area">
<div class="notice-cont">
<h2>支持银行</h2>
<p>农业银行、中国银行、工商银行、建设银行、</p>
<p>光大银行、兴业银行、邮储银行、民生银行、</p>
<p>平安银行、中信银行、广发银行</p>
<p>{{banks}}</p>
</div>
<div class="think-ok">我知道了</div>
</div>
... ...
'use strict';
exports.index = (req, res) => {
res.render('app-update', {
width750: true,
});
};
... ...
... ... @@ -64,7 +64,7 @@ class Auth {
return Auth.profile(uid).then((userInfo) => {
let token = sign.makeToken(uid);
let data = userInfo.data;
let encryptionUid = aes.encryptionUid(data.uid);
let encryptionUid = aes.encryptionUid(uid);
if (data) {
let uidCookie = `${data.profile_name}::${encryptionUid}::${data.vip_info.title}::${token}`;
... ...
... ... @@ -13,6 +13,7 @@ const back = require(cRoot + '/back');
const bind = require(cRoot + '/bind');
const reg = require(cRoot + '/reg');
const smsLogin = require(cRoot + '/sms');
const update = require(cRoot + '/update');
const router = express.Router(); // eslint-disable-line
... ... @@ -107,4 +108,9 @@ router.get('/passport/back/backcode', back.setNewPasswordByMobilePage);// 设置
router.post('/passport/back/passwordbyemail', back.setNewPasswordByEmailAPI);// 依据邮箱验证码修改密码
router.post('/passport/back/passwordbymobile', back.setNewPasswordByMobileAPI);// 依据手机验证码修改密码
/**
* 提示升级app
*/
router.get('/passport/update', update.index);
module.exports = router;
... ...
<section class='app_update'>
<button>立即升级</button>
</section>
\ No newline at end of file
... ...
... ... @@ -15,6 +15,25 @@ const helpers = global.yoho.helpers;
const productProcess = require(`${utils}/product-process`);
/**
* 从 useragent 获取 uid
* @returns {*}
* @private
*/
const _getUidFromUserAgent = (req) => {
let userAgent = _.split(req.headers['user-agent'], ';');
let uidString = '';
_.forEach(userAgent, value => {
if (_.startsWith(value, 'uid')) {
uidString = value;
return;
}
});
return _.split(uidString, '=')[1];
};
/**
* 店铺 - 基础模板
*/
const _baseShop = (req, res, shopInfo, shopId) => {
... ... @@ -30,9 +49,9 @@ const _baseShop = (req, res, shopInfo, shopId) => {
goodList: result,
showDownloadApp: true,
pageFooter: true,
title: shopInfo.shopName + '|' + shopInfo.shopName + '潮流服装服饰-Yoho!Buy有货',
keywords: shopInfo.shopName + ',' + shopInfo.shopName + '服装服饰,' + shopInfo.shopName + '潮流服装服饰',
description: shopInfo.shopName + '|Yoho!Buy有货' + shopInfo.shopName + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
title: shopInfo.shop_name + '|' + shopInfo.shop_name + '潮流服装服饰-Yoho!Buy有货',
keywords: shopInfo.shop_name + ',' + shopInfo.shop_name + '服装服饰,' + shopInfo.shop_name + '潮流服装服饰',
description: shopInfo.shop_name + '|Yoho!Buy有货' + shopInfo.shop_name + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
shopId: shopId,
shopPage: true
});
... ... @@ -44,8 +63,14 @@ const _baseShop = (req, res, shopInfo, shopId) => {
* 基础模板收藏
*/
const baseShopFav = (req, res) => {
let allowOrigin = _.get(req, 'headers.origin', null) ?
req.headers.origin : req.protocol + '://' + req.headers.host;
res.setHeader('Access-Control-Allow-Origin', allowOrigin);
res.setHeader('Access-Control-Allow-Credentials', 'true');
let isApp = req.query.app_version || req.query.appVersion || false;
let uid = isApp ? req.query.uid : req.user.uid;
let uid = req.user.uid || req.query.uid || req.cookies.appUid || _getUidFromUserAgent(req);
let shopId = req.query.shopId;
listModel.getShopData(req, shopId, uid, isApp).then(result => {
... ... @@ -80,6 +105,13 @@ const _shop = (req, res, shopId) => {
navTitle: false
}))
};
} 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 => {
... ... @@ -90,7 +122,7 @@ const _shop = (req, res, shopId) => {
} else {
listModel.searchProductBySkn(result.hotListproductSkn).then(hotList => {
result = _.assign(result, pageHeader, {
hotList: productProcess.processProductList(hotList)
hotList: productProcess.processProductList(hotList, {isApp: isApp})
});
_.forEach(result.hotList, (value, key) => {
... ... @@ -106,9 +138,9 @@ const _shop = (req, res, shopId) => {
shopHeadHide: true,
gender: req.query.gender,
channel: req.query.channel,
title: result.storeName + '|' + result.storeName + '潮流服装服饰-Yoho!Buy有货',
keywords: result.storeName + ',' + result.storeName + '服装服饰,' + result.storeName + '潮流服装服饰',
description: result.storeName + '|Yoho!Buy有货' + result.storeName + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
title: result.seoTitle + '|' + result.seoTitle + '潮流服装服饰-Yoho!Buy有货',
keywords: result.seoTitle + ',' + result.seoTitle + '服装服饰,' + result.seoTitle + '潮流服装服饰',
description: result.seoTitle + '|Yoho!Buy有货' + result.seoTitle + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
shopId: shopId,
shopPage: true
});
... ... @@ -122,6 +154,12 @@ const _shop = (req, res, shopId) => {
* app设置cookie
*/
const shopAppCookie = (req, res) => {
let allowOrigin = _.get(req, 'headers.origin', null) ?
req.headers.origin : req.protocol + '://' + req.headers.host;
res.setHeader('Access-Control-Allow-Origin', allowOrigin);
res.setHeader('Access-Control-Allow-Credentials', 'true');
let uid = req.query.uid;
req.session.appUid = uid;
... ... @@ -139,14 +177,20 @@ const shopAppCookie = (req, res) => {
* 前端请求判断shop是否收藏
*/
const shopFav = (req, res) => {
let allowOrigin = _.get(req, 'headers.origin', null) ?
req.headers.origin : req.protocol + '://' + req.headers.host;
res.setHeader('Access-Control-Allow-Origin', allowOrigin);
res.setHeader('Access-Control-Allow-Credentials', 'true');
let isApp = req.query.app_version || req.query.appVersion || false;
let uid = isApp ? req.query.uid : req.user.uid;
let uid = req.user.uid || req.query.uid || req.cookies.appUid || _getUidFromUserAgent(req);
let shopId = req.query.shopId;
listModel.getShopFav(req, shopId, uid, isApp).then(result => {
res.json({
code: 200,
collect: result.is_favorite === 'Y',
collect: _.get(result, 'is_favorite', '') === 'Y'
});
});
};
... ... @@ -206,7 +250,7 @@ const brand = (req, res, next) => {
}, params);
// 无店铺:0--->品牌页 无单品店有多品店:1--->搜索页 有单品店:2--->店铺页面
if (brandLogo.type === '2' && brandLogo.shopId) {
if (req.query.from !== 'search' && brandLogo.type === '2' && brandLogo.shopId) {
_shop(req, res, brandLogo.shopId);
} else { // 获取品牌店铺信息
listModel.getBrandShops(brandId).then(brandShop => {
... ... @@ -321,12 +365,19 @@ const favoriteBrand = (req, res, next) => {
let opt = req.query.opt || 'ok';
let type = req.query.type || 'product';
let appVersion = req.query.appVersion || false;
let refer = req.get('Referer') || `${global.yoho.config.siteUrl}/${req.cookies._Channel || ''}`;
let refer = req.get('referer');
let url = helpers.urlFormat('/signin.html') + '?refer=' + refer;
if (appVersion === 'true') {
uid = req.cookies.appUid;
url = `${url}&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":${decodeURI(req.cookies.refer)},"param":{}},"requesturl":{"param":{},"url":""},"priority":"Y"}}`; // eslint-disable-line
if (appVersion && appVersion !== 'false') {
uid = req.query.uid ? crypto.decrypt('', req.query.uid) : req.cookies.appUid;
if (!uid || uid === 'undefined') {
uid = _getUidFromUserAgent(req);
}
url = `${refer}&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"${refer}","param":{}},"requesturl":{"param":{"method":"app.favorite.add","id":"${id}","fav_id":"${id}","type":"shop"},"url":"${_.get(global, 'yoho.API.ApiUrl', '')}"},"priority":"Y"}}`; // eslint-disable-line
}
if (!id) {
... ... @@ -399,32 +450,49 @@ const userCoupon = (req, res, next) => {
}
let cryptCouponId = crypto.decrypt('', req.query.couponID);
let uid = req.user.uid;
if (req.yoho.isApp !== 'false') {
uid = req.query.uid ? crypto.decrypt('', req.query.uid) : req.cookies.appUid;
if (req.user.uid) {
if (!uid || uid === 'undefined') {
uid = _getUidFromUserAgent(req);
}
}
if (uid) {
listModel.receiveCoupon(
req.user.uid,
uid,
cryptCouponId
).then(result => {
res.json(result);
return;
}).catch(next);
} else {
let refer = req.headers.referer || req.headers.origin;
let toUrl = helpers.urlFormat('/signin.html', {refer: refer});
let refer = req.get('referer');
if (req.yoho.isApp) {
toUrl += '&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' +
if (req.yoho.isApp !== 'false') {
let toUrl = refer + '&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' +
refer +
'","param":{}},"requesturl":{"param":{"method":"app.promotion.getCoupon","couponId":"' +
cryptCouponId +
'"},"url":"' +
_.get(global, 'yoho.API.ApiUrl', '') +
'"},"priority":"Y"}}';
res.json({
code: 4401,
url: toUrl
});
} else {
res.json({
code: 4401,
url: helpers.urlFormat('/signin.html', {refer: refer})
});
}
res.json({
code: 4401,
url: toUrl
});
}
};
... ...
... ... @@ -46,12 +46,12 @@ const list = (req, res, next) => {
query = query.toLowerCase();
_.forEach(result[0], obj => {
if (query === obj.brandDomain && /^[a-z0-9]+$/i.test(obj.brandName)) { // 精确查品牌域名
if (query === obj.brandDomain) { // 精确查品牌域名
domain = query;
return false;
}
if (query === obj.brandName || query === obj.brandName || query === obj.brandName && /^[a-z0-9]+$/i.test(obj.brandName)) { // 精确查品牌名称
if (query === obj.brandName || query === obj.brandName || query === obj.brandName) { // 精确查品牌名称
domain = obj.brandDomain;
return false;
}
... ...
... ... @@ -1861,8 +1861,6 @@ let _detailDataPkgAsync = (origin, uid, vipLevel, ua) => {
};
/**
* [根据商品SKN获取商品的简要信息]
* @param {[array]} skns [skns]
... ...
... ... @@ -34,8 +34,8 @@ const _processBrandShops = (list) => {
url: helpers.urlFormat('/product/index/brand/', {
shop_id: item.shop_id
}),
thumb: helpers.image(item.brandIco, 75, 40),
name: item.brandName
thumb: helpers.image(item.brand_ico, 75, 40),
name: item.brand_name
});
}
});
... ... @@ -94,7 +94,7 @@ const _getShopDecorator = (shopId) => {
cache: true,
code: 200
}).then((result) => {
return result.data;
return (result && result.data) || {};
});
};
... ... @@ -105,6 +105,9 @@ const _getShopDecorator = (shopId) => {
* @return array
*/
const _getShopInfo = (shopId, uid) => {
if (uid === 'undefined') {
uid = 0;
}
return api.get('', {
method: 'app.shops.getIntro',
shop_id: shopId,
... ... @@ -182,7 +185,7 @@ const receiveCoupon = (uid, couponId) => {
method: 'app.promotion.getCoupon',
couponId: couponId,
uid: uid
}, {code: 200}).then(result => {
}).then(result => {
return result;
});
};
... ... @@ -362,20 +365,27 @@ const _formShopData = (data, shopId, isApp) => {
title: '全部商品'
};
let moreUrl = helpers.urlFormat('', {
shop_id: shopId,
order: 's_n_d',
title: '人气单品'
}, 'search'); // 人气单品的链接
if (isApp) {
moreUrl = 'openby:yohobuy={"action":"go.list","params":{"shop_id":"' + shopId + '","title":"人气单品"}}';
}
formatData = _.assign({
shopIntro: _.get(data, 'shopInfo.shop_intro', ''),
logoImg: _.get(data, 'shopInfo.shop_logo', ''),
storeName: (_.get(data, 'shopInfo.is_show_shop_name', '') === 'Y') ?
_.get(data, 'shopInfo.shop_name', '') : '',
seoTitle: _.get(data, 'shopInfo.shop_name', ''),
collect: _.get(data, 'shopInfo.is_favorite', '') === 'Y',
url: helpers.urlFormat('', {
shop_id: shopId
}, 'search'), // 搜索链接
more_url: helpers.urlFormat('', {
shop_id: shopId,
order: 's_n_d',
title: '人气单品'
}, 'search') // 人气单品的链接
more_url: moreUrl
}, formatData);
if (single) { // 单品点
... ... @@ -450,7 +460,7 @@ const getBaseShopData = (params, shopInfo) => {
cartUrl: helpers.urlFormat('/cart/index/index')
};
let shopId = params.shop_id || shopInfo.shopsId;
let shopId = params.shop_id || shopInfo.shops_id;
return api.all([
_getShopDecorator(shopId),
... ... @@ -500,7 +510,7 @@ const getShopData = (req, shopId, uid, isApp) => {
return _getShopInfo(shopId, uid).then(shopInfoResult => {
/* 基础店铺返回程序内的跳转信号,跳转到基础店铺 */
if (shopInfoResult.shop_template_type && parseInt(shopInfoResult.shop_template_type, 10) === 1) {
if (shopInfoResult && shopInfoResult.shop_template_type && parseInt(shopInfoResult.shop_template_type, 10) === 1) {
return {
goBrand: shopInfoResult
};
... ... @@ -510,7 +520,6 @@ const getShopData = (req, shopId, uid, isApp) => {
_getShopDecorator(shopId),
searchModel.getFilterSearchData({
shop_id: shopId,
gender: req.query.gender || '1,3',
channel: channel
}),
_shopCouponsList(shopId, uid)
... ... @@ -528,7 +537,7 @@ const getShopData = (req, shopId, uid, isApp) => {
if (result[1]) {
shopFilterSearchData.filter = productProcess.processFilter(result[1].filter || []);
shopFilterSearchData.goods = productProcess.processProductList(result[1].product_list || []);
shopFilterSearchData.goods = productProcess.processProductList(result[1].product_list || [], {isApp: isApp});
}
/* 店鋪優惠券 */
... ... @@ -547,6 +556,7 @@ const getShopData = (req, shopId, uid, isApp) => {
shopFilterSearchData,
{
shopId: shopId,
uid: uid ? crypto.encryption('', uid + '') : '',
coverChannel: channel,
shopCoupons: shopCoupons,
shopCouponsOne: shopCoupons.length === 1
... ... @@ -740,20 +750,34 @@ const getShopCategory = (params) => {
_.forEach(resultCopy, value => {
finalResult.class.push({
name: value.categoryName
name: value.category_name
});
_.forEach(value.sub, (subValue, subKey) => {
value.sub[subKey].url = helpers.urlFormat('/product/search/list', {
shop_id: params.shopId,
sort: _.get(value, 'relation_parameter.sort', ''),
title: subValue.categoryName,
query: subValue.categoryName
sort: _.get(subValue, 'relation_parameter.sort', ''),
title: subValue.category_name,
query: subValue.category_name
});
});
let subCategory = [
{
category_name: '全部' + value.category_name,
url: helpers.urlFormat('/product/search/list', {
shop_id: params.shopId,
sort: _.get(value, 'relation_parameter.sort', ''),
title: '全部' + value.category_name,
query: value.category_name
})
}
];
subCategory = subCategory.concat(value.sub);
finalResult.category.push({
subcategory: value.sub
subcategory: subCategory
});
});
... ...
... ... @@ -27,8 +27,6 @@ const mayLike = (uid, page, limit, gender, udid, recPos, channel) => {
} else {
return false;
}
} else {
return false;
}
} else {
... ...
... ... @@ -22,9 +22,9 @@
{{# category}}
<ul class="sub-level">
{{# subcategory}}
<li class="buriedpoint" data-bp-id="shop_sublevel_{{categoryName}}_1">
<li class="buriedpoint" data-bp-id="shop_sublevel_{{category_name}}_1">
<a href={{url}}>
{{categoryName}}
{{category_name}}
</a>
</li>
{{/ subcategory}}
... ...
... ... @@ -10,6 +10,7 @@
<input type="hidden" name="brand" value="{{brand}}">
<input type="hidden" name="favId" value="{{favId}}">
<input type="hidden" name="coverChannel" value="{{coverChannel}}">
<input type="hidden" name="uid" value="{{uid}}">
{{#unless appVersion}}
<div class="search-area">
... ... @@ -121,7 +122,7 @@
</div>
<div class="discount-area first" id="navlist2">
<ul id="list-nav" class="home-sub-nav list-nav clearfix">
<ul id="list-nav" class="home-sub-nav list-nav pos-list clearfix">
<li data-bp-id="shop_listnav_new_1" class="new active buriedpoint">
<a href="javascript:void(0);">
<span class="spanTest">最新</span>
... ...
... ... @@ -18,7 +18,6 @@ module.exports = {
assetUrl: '//localhost:5001',
domains: {
api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
// liveApi: 'http://api.live.yoho.cn/',
// singleApi: 'http://single.yoho.cn/',
... ...
... ... @@ -23,5 +23,4 @@ const seoMap = {
/* eslint-enable */
};
module.exports = seoMap;
... ...
... ... @@ -12,8 +12,4 @@
立即下载
</a>
</div>
{{/showDownloadApp}}
\ No newline at end of file
{{/showDownloadApp}}
\ No newline at end of file
... ...
... ... @@ -42,10 +42,15 @@
},
"devDependencies": {
"autoprefixer": "^6.3.7",
<<<<<<< HEAD
"ava": "^0.16.0",
"babel-preset-es2015": "^6.14.0",
"babel-register": "^6.14.0",
"cheerio": "^0.22.0",
=======
"babel-preset-es2015": "^6.14.0",
"babel-register": "^6.14.0",
>>>>>>> master
"eslint": "^3.0.1",
"eslint-config-yoho": "^1.0.1",
"gulp": "^3.9.1",
... ...
... ... @@ -171,7 +171,7 @@ gulp.task('font', () => {
// postcss compile in pro
gulp.task('postcss', ['assets'], () => {
return gulp.src(['scss/index.css', 'scss/shop.css'])
return gulp.src(['scss/shop.css', 'scss/index.css'])
.pipe(postcss(postcssPlugin(env.pro)))
.pipe(cssnano({
safe: true
... ...
... ... @@ -58,6 +58,12 @@ $categoryContainer.on('touchend', function(e) {
$cur, index;
$cur = $this.closest('.p-level-item');
// 第一次单击右则空白处,出现冒泡
if ($(e.target).closest('.sub-level').length <= 0) {
e.preventDefault();
}
if ($cur.length > 0) {
index = $cur.index();
$subLevel = $this.closest('.content').find('.sub-level');
... ...
... ... @@ -131,6 +131,8 @@ module.exports = function(specificGender) {
searching = false;
loading.hideLoadingMask();
$('.maybe-like').hide();
// 有货币页面不加载底部
if (gender && !specificGender) {
gender = gender.substr(0, 3);
... ...
... ... @@ -23,7 +23,7 @@ $.get('/product/recommend-for-you/userCenter').then(function(html) {
PRDID.push($(this).data('id'));
});
let $recommendSonLen = $recommendForYou.find('.good-info').length;
var $recommendSonLen = $recommendForYou.find('.good-info').length;
if ($recommendSonLen === 0) {
$recommendForYou.hide();
... ...
... ... @@ -10,19 +10,28 @@ var qrCheck = {
},
init: function() {
var ifr,
var // ifr,
u = navigator.userAgent.toLowerCase(),
isiOS = u.indexOf('os') > -1 || u.indexOf('iphone') > -1 || u.indexOf('mac') > -1 || u.indexOf('ipad') > -1,
qr = this.getQuery('qr');
qr = this.getQuery('qr'),
isApp = this.getQuery('app_version');
if (qr) {
if (qr && isApp) {
location.href = '//m.yohobuy.com/passport/update';
}
if (qr && !isApp) {
if (isiOS) {
window.location = 'yohobuy://http://m.yohobuy.com/signin.html?qr=' + qr;
} else {
ifr = document.createElement('iframe');
ifr.src = 'yohobuy://http://m.yohobuy.com/signin.html?qr=' + qr;
ifr.style.display = 'none';
document.body.appendChild(ifr);
// 安卓跳下载
location.href = '//m.yohobuy.com/passport/update';
// 安卓暂时不处理
// ifr = document.createElement('iframe');
// ifr.src = 'yohobuy://http://m.yohobuy.com/signin.html?qr=' + qr;
// ifr.style.display = 'none';
// document.body.appendChild(ifr);
}
// time = Date.now();
... ...
var $ = require('yoho-jquery');
// $('body').height($(window).height());
// $('.app_update').height($(window).height()).width($(window).width());
$('button').on('click', function() {
window.location = 'http://www.yohoshow.com/about/index/yohobuyqr';
});
... ...
... ... @@ -139,7 +139,8 @@ function initFilter(opt) {
var $this = $(e.target),
$cur;
// e.preventDefault();//防止透点
//这行不能注释,iphone下会出现穿透
e.preventDefault();//防止透点
if ($this.closest('.filter-body').length > 0) {
$cur = $this.closest('.sub-item');
... ...
... ... @@ -8,7 +8,7 @@
module.exports = function() {
var $ = require('yoho-jquery');
var _weChatInterface = '/life/getSignPackage';
var _weChatInterface = '//m.yohobuy.com/life/getSignPackage';
$.getJSON(_weChatInterface + '?pageurl=' +
encodeURIComponent(location.href.split('#')[0]) + '&callback=?', function(json) {
... ...
... ... @@ -34,6 +34,11 @@ $categoryContainer.on('touchend', function(e) {
$cur = $this.closest('.p-level-item');
// 第一次单击右则空白处,出现冒泡
if ($(e.target).closest('.sub-level').length <= 0) {
e.preventDefault();
}
$subLevelContainer = $this.closest('.content').find('.sub-level-container');
$subLevelContainer.removeClass('hide');
... ...
... ... @@ -187,12 +187,16 @@ $search.on('touchend', function() {
}
$history.html(html);
if (html !== '') {
$clearHistory.removeClass('hide');
$historySearch.removeClass('hide');
}
// window.rePosFooter();
window.rePosFooter();
} else {
$historySearch.hide();
$clearHistory.hide();
}
}
}());
... ...
... ... @@ -2,7 +2,8 @@ var $ = require('yoho-jquery'),
Swiper = require('yoho-swiper'),
tip = require('../../plugin/tip');
var appVersion = $('input[name="app_version"]').val();
var appVersion = $('input[name="app_version"]').val(),
uid = $('input[name="uid"]').val();
$('.coupon-content .receive-btn').closest('.swiper-slide').on('click', function() {
var that = this,
... ... @@ -19,7 +20,8 @@ $('.coupon-content .receive-btn').closest('.swiper-slide').on('click', function(
url: location.protocol + '//m.yohobuy.com/product/index/userCoupon',
data: {
couponID: code,
app_version: appVersion
app_version: appVersion,
uid: uid
},
xhrFields: {
withCredentials: true
... ...
... ... @@ -36,6 +36,7 @@ var $subNav = $('.home-sub-nav'),
brand = $('input[name="brand"]').val(),
coverChannel = $('input[name="coverChannel"]').val(),
favId = $('input[name="favId"]').val();
uid = $('input[name="uid"]').val();
var winH = $(window).height(),
noResult = '<p class="no-result">未找到相关搜索结果</p>';
... ... @@ -51,6 +52,9 @@ require('../../common');
$.ajax({
type: 'GET',
url: '/product/index/shopAppCookie',
xhrFields: {
withCredentials: true
},
error: function() {
tip.show('网络断开连接了~');
}
... ... @@ -60,6 +64,9 @@ require('../../common');
$.ajax({
type: 'GET',
url: '/product/index/shopFav',
xhrFields: {
withCredentials: true
},
data: {
shopId: $('.shopid').val(),
},
... ... @@ -917,7 +924,7 @@ $nav2.on('touchstart', 'li', function(e) {
// });
$('#shop-category').click(function() {
let subGroup = $('.sub-group');
var subGroup = $('.sub-group');
if (subGroup.hasClass('hide')) {
$('.sub-group').removeClass('hide');
... ... @@ -948,7 +955,8 @@ $collect.on('touchstart', function() {
id: favId ? favId : shopId,
appVersion: appVersion,
opt: opt,
type: 'shop'
type: 'shop',
uid: uid
},
xhrFields: {
withCredentials: true
... ...
... ... @@ -491,4 +491,27 @@
}
}
}
.weixin {
margin: 20px 0;
text-align: center;
padding: 0 20px;
.ems-cnpl {
width: 47.3%;
display: inline-block;
background: #ededed;
position: relative;
overflow: hidden;
.weixin-img {
width: 100%;
height: 100%;
}
}
a:nth-child(1) {
margin-right: 20px;
}
}
}
... ...
... ... @@ -4,7 +4,7 @@
}
li {
width: 580px;
width: 100%;
height: 200px;
margin-bottom: 30px;
position: relative;
... ...
... ... @@ -160,4 +160,14 @@
&:actived {
color: #000;
}
}
.circle-rightbottom {
position: absolute;
width: 25PX;
height: 0PX;
border:0 solid #323232;
border-bottom:25PX solid #323232;
border-radius:0 0 25PX 0;
}
\ No newline at end of file
... ...
... ... @@ -130,7 +130,7 @@
content: "";
position: absolute;
right: 0;
top: 24px;
top: 12px;
width: 0;
height: 44px;
border-right: 4px solid #fff;
... ... @@ -145,9 +145,15 @@
padding: 0;
height: 88px;
.link-item p {
font-size: 32px;
line-height: 88px;
.link-item {
p {
font-size: 32px;
line-height: 88px;
}
&:after {
top: 24px;
}
}
}
}
... ... @@ -200,6 +206,10 @@
&.highlight {
background: #eee;
}
.iconfont {
font-size: 16PX;
}
}
.order-type {
... ... @@ -241,6 +251,10 @@
}
}
.my-order-top {
margin-top: 30px;
}
.group-list {
margin-bottom: 30px;
border-top: 1px solid #e0e0e0;
... ...
... ... @@ -271,7 +271,7 @@
height: 60px;
position: absolute;
left: 50%;
top: 50%;
top: 47%;
margin-top: -18px;
margin-left: -250px;
z-index: 8;
... ...
... ... @@ -42,7 +42,7 @@
height: 60px;
position: absolute;
left: 50%;
top: 50%;
top: 47%;
margin-top: -18px;
margin-left: -250px;
z-index: 8;
... ...
.app_update {
background: resolve("./app-update.png");
background-size: 100% 100%;
width: 100%;
height: height("./app-update.png");
button {
position: absolute;
left: 50%;
bottom: 220px;
height: 90px;
width: 470px;
margin-left: -235px;
padding: 0;
background: #444;
color: #fff;
font-size: 30px;
border-radius: 10px;
}
}
... ...
... ... @@ -6,3 +6,4 @@
@import "code";
@import "bind";
@import "success";
@import "app-update";
... ...
... ... @@ -3,9 +3,11 @@
position: relative;
padding: 14px 22px;
background: #f8f8f8;
form {
width: 100%;
}
.search-icon {
position: absolute;
font-size: 24px;
... ... @@ -16,7 +18,7 @@
input {
height: 56px;
width: 378px;
width: 480px;
border-radius: 28px;
padding: 0 52px;
font-size: 24px;
... ... @@ -149,7 +151,6 @@
margin-top: 38px;
}
}
}
.search-associate {
... ... @@ -194,9 +195,11 @@
position: relative;
padding: 14px 22px;
background: #f8f8f8;
form {
width: 100%;
}
.search-icon {
position: absolute;
font-size: 24px;
... ...
... ... @@ -68,6 +68,11 @@ module.exports = (list) => {
floor.data.data = floor.data.image;
}
// 单张轮播图
floor.singleImage &&
floor.data.length === 1 &&
(floor.singleOne = true);
formatData.push(floor);
});
... ...