Authored by 郝肖肖

Merge branch 'master' into feature/ctx

... ... @@ -9,6 +9,9 @@ exports.category = (req, res, next) => {
let uid = req.user.uid || req.query.uid;
let params = {
uid: uid,
port: 1,
channel: req.query.channel,
season: req.query.season,
isApp: req.yoho.isApp,
scene: req.query.scene || 1
};
... ... @@ -42,6 +45,9 @@ exports.shop = (req, res, next) => {
let uid = req.user.uid || req.query.uid;
let params = {
uid: uid,
port: 1,
channel: req.query.channel,
season: req.query.season,
isApp: req.yoho.isApp,
scene: req.query.scene || 1
};
... ...
'use strict';
const _ = require('lodash');
class shareModel extends global.yoho.BaseModel {
constructor(ctx) {
... ... @@ -10,9 +11,19 @@ class shareModel extends global.yoho.BaseModel {
* @returns {*|Promise.<TResult>}
*/
getShareContent(params) {
let shareIdInt = _.parseInt(params.shareId);
if (shareIdInt) {
params.shareId = _.toString(shareIdInt);
} else {
return Promise.resolve({});
}
return this.get({
url: 'operations/api/v5/webshare/getShare',
data: {share_id: params.shareId},
data: {
share_id: params.shareId
},
api: global.yoho.ServiceAPI,
}).then(result => {
return result;
... ...
... ... @@ -78,7 +78,9 @@ class TideModel extends global.yoho.BaseModel {
crmRecommendShop(params) {
return this.get({
data: Object.assign({
method: 'app.product.crmRecommend.shop'
method: 'app.product.crmRecommend.shop',
imageType: 2,
imageSize: '314*352',
}, params)
});
}
... ... @@ -121,7 +123,7 @@ class TideModel extends global.yoho.BaseModel {
});
}
if (shopInfo.shopId || _.get(res[1], 'data.productList', []).length) {
if (shopInfo.imageUrl || _.get(res[1], 'data.productList', []).length) {
tide.shopInfo.push({
title: '# 为你精选 #',
shopInfo: shopInfo,
... ...
... ... @@ -454,17 +454,13 @@ class BuyNowController {
}
/**
* 输入优惠券码使用优惠券
* 兑换优惠券
*/
useCouponCode(req, res, next) {
co(function* () {
let result = yield req.ctx(BuyNowModel).usePromotionCode({
uid: req.user.uid,
product_sku: req.body.product_sku,
sku_type: req.body.sku_type,
buy_number: req.body.buy_number,
promotion_code: req.body.promotion_code
});
let result = yield req.ctx(shoppingModel).useCoupon(
req.user.uid, req.body.couponCode
);
res.json(result);
})().catch(next);
... ...
... ... @@ -267,7 +267,8 @@ const payAli = (req, res, next) => {
uid: req.user.uid,
udid: req.cookies.udid || require('yoho-md5')(req.ip) || 'yoho',
orderCode: req.query.out_trade_no,
contentCode: '78d0fb6c97d691863286edcb4d8abfa9'
contentCode: '78d0fb6c97d691863286edcb4d8abfa9',
client_id: req.cookies._yasvd || ''
};
// 如果没有uid,跳转到首页
... ...
... ... @@ -44,7 +44,7 @@ class payModel extends global.yoho.BaseModel {
return this.get({data: {
method: 'app.recommend.purchased',
productSkn: param.skn,
udid: param.uid,
uid: param.uid,
rec_pos: '100005',
limit: 2,
client_id: param.client_id
... ... @@ -72,7 +72,9 @@ class payModel extends global.yoho.BaseModel {
payment_amount: _.get(result, 'data.order_extInfo.payment_amount') ||
_.get(result, 'data.payment_amount'),
pay_expire: _.get(result, 'data.order_detail_info.ext.pay_expire') ||
_.get(result, 'data.pay_expire')
_.get(result, 'data.pay_expire'),
order_goods: _.get(result, 'data.order_goods'),
package_info: _.get(result, 'data.package_info', [])
}
};
}
... ... @@ -83,6 +85,8 @@ class payModel extends global.yoho.BaseModel {
return Promise.resolve({});
}
param.uid.appVersion = _.get(global, 'yoho.config.appVersion');
return this.get({data: {
method: 'app.SpaceOrders.detail',
uid: param.uid,
... ... @@ -95,21 +99,14 @@ class payModel extends global.yoho.BaseModel {
// 购买此商品的用户也购买了,要先从订单详情获取商品skn
_getOthersBuy(param) {
return Promise.all([
this.getOtherDetail(param)
]).then((result) => {
let goodSkn = '';
this.getOtherDetail(param).then(result => {
let skn = _.get(result, 'data.order_goods.0.product_skn', '');
if (result && result[0] && result[0].data && result[0].data.order_goods) {
goodSkn = result[0].data.order_goods[0].product_skn;
if (skn) {
return this._getOthersBuy2(Object.assign(param, { skn: skn }));
} else {
return Promise.resolve([]);
}
return this._getOthersBuy2(Object.assign(param, { skn: goodSkn }));
}).then((result) => {
return result;
});
}
... ...
... ... @@ -267,7 +267,7 @@ class shoppingModel extends global.yoho.BaseModel {
}
/**
* 购物车结算--使用优惠券
* 购物车结算--兑换优惠券
* @param uid int 用户uid
* @param couponCode string 优惠券代码
* @return
... ...
... ... @@ -59,11 +59,13 @@
</a>
{{/data}}
{{/banner}}
{{#if othersBuy}}
<div class="others-buy clearfix">
<p>购买此商品的用户也购买了</p>
{{# othersBuy}}
{{> common/goods}}
{{/ othersBuy}}
</div>
{{/if}}
{{> home/maybe-like}}
</div>
... ...
... ... @@ -185,13 +185,14 @@ module.exports = class extends global.yoho.BaseModel {
};
allList[key].forEach(row => {
if (row) {
obj.list.push({
name: row.brand_name,
isHot: row.is_hot === 'Y' ? true : false,
isNew: row.is_show_new === 'Y' ? true : false,
url: this._urlJump(parseInt(row.type, 10), row)
name: _.get(row, 'brand_name', ''),
isHot: _.get(row, 'is_hot') === 'Y' ? true : false,
isNew: _.get(row, 'is_show_new') === 'Y' ? true : false,
url: this._urlJump(parseInt(_.get(row, 'type'), 10), row)
});
}
});
resu.brandList.push(obj);
}
... ... @@ -207,9 +208,9 @@ module.exports = class extends global.yoho.BaseModel {
};
obj.list.push({
brandName: newList[key].brand_name,
url: this._urlJump(parseInt(newList[key].type, 10), newList[key]),
img: helpers.image(newList[key].brand_ico, 186, 115),
brandName: _.get(newList, `${key}.brand_name`, ''),
url: this._urlJump(parseInt(_.get(newList, `${key}.type`), 10), _.get(newList, `${key}`)),
img: helpers.image(_.get(newList, `${key}.brand_ico`), 186, 115),
});
resu.newBrandWall.push(obj);
}
... ...
... ... @@ -172,6 +172,8 @@ module.exports = class extends global.yoho.BaseModel {
return Promise.resolve({});
}
uid.appVersion = _.get(global, 'yoho.config.appVersion');
return this.get({
data: {
method: 'app.SpaceOrders.detail',
... ...
... ... @@ -323,7 +323,6 @@ const local = {
domain: 'm.yohobuy.com'
});
// 弱密码返回数据
let passwordWeakReturn;
... ...
... ... @@ -10,6 +10,7 @@
'use strict';
const _ = require('lodash');
const config = global.yoho.config;
const utils = require(global.utils);
const ResetModel = require('../models/reset');
... ... @@ -48,7 +49,16 @@ const passwordResetPage = (req, res) => {
*/
const passwordReset = (req, res, next) => {
let passwordWeakObj = req.session.passwordWeak;
let uid = (req.user && req.user.uid) || (passwordWeakObj && passwordWeakObj.uid);
let uid = req.user && req.user.uid;
if (!uid && passwordWeakObj && passwordWeakObj.uid && passwordWeakObj.session_key) {
uid = {
toString: () => {
return _.parseInt(passwordWeakObj.uid);
},
sessionKey: passwordWeakObj.session_key
};
}
if (!uid || !passwordWeakObj || !passwordWeakObj.token) {
return res.json({
... ...
... ... @@ -300,6 +300,10 @@ module.exports = class extends global.yoho.BaseModel {
* 搜索店铺的商品
*/
getShopGoods(params) {
if (!/^[0-9]*$/.test(params.shop_id)) {
return Promise.resolve({});
}
let finalParams = {
method: 'app.search.shop',
};
... ...
... ... @@ -155,6 +155,9 @@ router.get('/search/shop/goods', search.searchShopGoods); // 搜索店铺下的
router.get('/list/global(/:pathParams)?', rewrite.resolvePathParams, globalPro.list); // 全球购路由重写 全球购列表页
router.get('/index/index', rewrite.resolvePathParams, list.listNew); // 列表新的 URL
router.get('/list/index', rewrite.resolvePathParams, list.listNew); // 旧 兼容 PC 的链接
router.get('/list(/:pathParams)?', rewrite.resolvePathParams, list.listNew); // 列表新的 URL
router.get('/search/category',
cors,
... ...
... ... @@ -42,7 +42,7 @@ const domains = {
module.exports = {
app: 'h5',
appVersion: '6.5.3', // 调用api的版本
appVersion: '6.6.0', // 调用api的版本
appName: 'yohobuywap-node',
port: 6001,
siteUrl: '//m.yohobuy.com',
... ...
... ... @@ -20,6 +20,11 @@ module.exports = (limiter, policy) => {
try {
blacklist = JSON.parse(args[0]);
} catch (error) {
logger.error(error);
}
try {
whitelist = JSON.parse(args[1]);
} catch (error) {
logger.error(error);
... ...
{
"name": "yohobuywap-node",
"version": "6.6.1",
"version": "6.6.3",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ... @@ -15,7 +15,7 @@
"build:dll": "webpack --config ./public/build/webpack.dll.indexcss.config.js",
"build": "webpack --config ./public/build/webpack.dll.indexcss.config.js && webpack --config ./public/build/webpack.prod.config.js",
"debug": "DEBUG=\"express:*\" nodemon -e js,hbs -i public/ app.js",
"lint:css": "stylelint -s scss --cache --custom-formatter ./node_modules/stylelint-formatter-table",
"lint:css": "stylelint -s scss --config .stylelintrc.js --cache --custom-formatter ./node_modules/stylelint-formatter-table",
"lint:js": "eslint --ext .js,.vue --cache --format table",
"lint-css": "npm run -s lint:css -- ./**/*.{scss,css,vue}",
"lint-js": "npm run -s lint:js -- .",
... ... @@ -101,7 +101,7 @@
"css-loader": "^0.28.11",
"echarts": "^4.0.4",
"eslint": "^4.19.1",
"eslint-config-yoho": "^1.0.9",
"eslint-config-yoho": "~1.0.9",
"eslint-plugin-html": "^4.0.3",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"friendly-errors-webpack-plugin": "^1.7.0",
... ... @@ -131,7 +131,7 @@
"store": "^2.0.12",
"style-loader": "^0.21.0",
"stylelint": "^9.2.0",
"stylelint-config-yoho": "^1.3.0",
"stylelint-config-yoho": "~1.3.0",
"stylelint-formatter-table": "^1.0.2",
"vue": "^2.5.16",
"vue-infinite-scroll": "^2.0.1",
... ...
... ... @@ -64,12 +64,11 @@ function getGender() {
require('channel/maybe-like')({gender: getGender()});
// 你可能喜欢没有数据就隐藏
setTimeout(function() {
$(document).on('PAY_SUCCESS_PAGE_MAYBE_LIKE_LOAD', () => {
if ($('#goods-list').find('.good-info').length === 0) {
$('.maybe-like').hide();
}
}, 200);
});
function Marquee() {
prompt.scrollLeft(prompt.scrollLeft() + 1);
... ...
... ... @@ -213,8 +213,13 @@ module.exports = function(likeParameter) {
});
// 为您优选埋点 end
// 支付成功页,请求数据完成
$(document).trigger('PAY_SUCCESS_PAGE_MAYBE_LIKE_LOAD');
},
error: function() {
// 支付成功页,请求数据完成
$(document).trigger('PAY_SUCCESS_PAGE_MAYBE_LIKE_LOAD');
tip.show('网络断开连接了~');
searching = false;
loading.hideLoadingMask();
... ...
... ... @@ -6,7 +6,7 @@ const cookie = require('yoho-cookie');
const u = navigator.userAgent;
const isFromYOHO = /m\.yohobuy\.com/i.test(document.referrer);
const isApp = /yohobuy/i.test(u) ||
const isApp = /yoho/i.test(u) ||
!!window.yohoInterface ||
/app_version=/i.test(location.search) ||
/openrefer=/i.test(location.search);
... ...
... ... @@ -8,7 +8,6 @@ require('layout/_modal.css');
require('home/order-list.page.css');
let $ = require('yoho-jquery'),
Hammer = require('yoho-hammer'),
lazyLoad = require('yoho-jquery-lazyload'),
tip = require('plugin/tip'),
Swiper = require('yoho-swiper');
... ... @@ -33,8 +32,7 @@ let loading = require('plugin/loading');
let dialog = require('plugin/dialog');
let orderHammer,
$reaMask = $('.reason-mask'),
let $reaMask = $('.reason-mask'),
$refundReaMask = $('.refund-reason-mask'),
reasonSwiper,
refundReasonSwiper;
... ... @@ -222,8 +220,7 @@ function sureOrder(orderId) {
}
// 点击订单区域跳转订单详情页
orderHammer = new Hammer(document.getElementById('order-container'));
orderHammer.on('tap', function(e) {
$('#order-container').on('click', function(e) {
let $cur = $(e.target),
$order,
id,
... ...
... ... @@ -46,6 +46,8 @@ const PARAMMAP = {
const getParams = (pathParams) => {
let params = {};
pathParams = _.replace(pathParams, '.html', '');
if (pathParams) {
let paramsRaw = _.split(pathParams, '-');
... ...
... ... @@ -251,6 +251,14 @@ const getSearchParamsWithoutMethod = (params) => {
finalParams.brand = params.brand_id || params.brand;
}
if (params.shop_id && params.shop_id !== '0') { // 店铺ID
let shopIdInt = _.parseInt(params.shop_id);
if (shopIdInt) {
params.shop_id = _.toString(shopIdInt);
} else {
params.shop_id = '';
}
finalParams.shop_id = params.shop_id;
}
if (params.type) { // 排序类型
... ...