Authored by 刘传洋

m

... ... @@ -28,6 +28,12 @@ const getProductInfo = (req, res, next) => {
}).catch(next);
};
/**
* 获取产品数据json信息
* @param req
* @param res
* @param next
*/
const getProductData = (req, res, next) => {
let pid = req.query.productId || '';
... ... @@ -63,6 +69,12 @@ const setShoppingCookie = (req, res) => {
});
};
/**
* 首页迷你购物车数据信息json
* @param req
* @param res
* @param next
*/
const miniCart = (req, res, next) => {
let uid = req.user.uid;
... ... @@ -89,8 +101,7 @@ const miniCart = (req, res, next) => {
*/
const cart = (req, res, next) => {
let uid = req.user.uid; // 8040155; // req.user.uid; 20422448
// console.log('====================> ' + uid);
let uid = req.user.uid;
let shoppingKey = helper.getShoppingKeyByCookie(req);
let cartDelList = req.cookies['cart-del-list'];
... ... @@ -247,8 +258,6 @@ const moveToFav = (req, res) => {
co(function * () {
let uid = req.user.uid;
// let shoppingKey = helper.getShoppingKeyByCookie(req);
let skuList = req.body.skuList;
let hasPromotion = req.body.hasPromotion || false;
let isReFav = !!req.body.isReFav || false;
... ... @@ -350,7 +359,9 @@ const getIncreasePurchase = (req, res) => {
});
};
// 修改购物车商品颜色和尺寸
/**
* 修改购物车商品颜色和尺寸
*/
const modifyProduct = (req, res, next) => {
const uid = req.user && req.user.uid;
const shoppingKey = helper.getShoppingKeyByCookie(req);
... ... @@ -360,15 +371,16 @@ const modifyProduct = (req, res, next) => {
const swapData = req.body.swapData;
service.modifyProduct({swapData, shoppingKey, uid}, uid, shoppingKey, cartDelList).then((result) => {
/* if (result.code === 200) {
} else {
res.json(result);
}*/
res.send(result);
}).catch(next);
};
/**
* 换购赠品或加价购
* @param req
* @param res
* @param next
*/
const swapGift = (req, res, next) => {
let uid = req.user && req.user.uid;
... ...
... ... @@ -143,45 +143,6 @@ const addToFav = (uid, skuList /* , hasPromotion*/) =>{
return api.get('', param);
};
/**
* 获取购物车商品详情数据
*
* @param int $uid 用户ID
* @param int $skn 商品skn
* @return array 接口返回的数据
*/
const cartProductData = (uid, skn) => {
let param = {
method: 'app.product.data',
product_skn: skn,
showcomment: 'N',
uid: uid
};
return api.get('', param);
};
/**
* 获取加价购商品详情数据
*
* @param int $skn 商品skn
* @param int $promotionId 加价购商品促销ID
* @return array 接口返回的数据
*/
const giftProductData = (skn, promotionId) => {
let param = {
method: 'app.product.gift',
product_skn: skn,
promotion_id: promotionId
};
return api.get('', param);
};
/**
* 增减购物车商品数量
*
... ... @@ -221,160 +182,6 @@ const modifyProductNum = (uid, sku, increaseNum, decreaseNum, shoppingKey) => {
};
/**
* 修改购物车商品数据
*
* @param int $uid 用户ID
* @param string $swapData 商品数据
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
const modifyCartProduct = (uid, swapData, shoppingKey) => {
let param = {
method: 'app.Shopping.swap',
swap_data: swapData
};
if (uid) {
param.uid = uid;
}
if (shoppingKey) {
param.shopping_key = shoppingKey;
}
return api.get('', param);
};
/**
* 购物车结算
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通, advance表示预售
* @param int $isUseYohoCoin 是否使用有货币,默认0不使用, 1使用
* @return array 接口返回的数据
*/
const cartPay = (uid, cartType, isUseYohoCoin) => {
let param = {
method: 'app.Shopping.payment',
cart_type: cartType,
yoho_coin_mode: isUseYohoCoin || 0,
uid: uid
};
if (_.indexOf(['ordinary', 'advance'], cartType) === -1) {
return {
code: 400,
message: '购物车参数类型有误!',
data: {}
};
}
return api.get('', param);
};
/**
* 购物车结算--支付方式和配送方式选择
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通, advance表示预售
* @param int $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运
* @param int $paymentType 支付方式,1表示在线支付,2表示货到付款
* @param string $couponCode 优惠券码
* @param string $promotionCode 优惠码
* @param mixed $yohoCoin 使用的有货币数量
* @param int $redEnvelopes 红包
* @return array 接口返回的数据
*/
const orderCompute = (uid, cartType, deliveryWay, paymentType, couponCode, promotionCode, yohoCoin, redEnvelopes) =>{
let param = {
method: 'app.Shopping.compute',
cart_type: cartType,
delivery_way: deliveryWay,
payment_type: paymentType,
check_yohocoin_amount: 'Y', // 控制是否判断有货币超出订单金额
uid: uid
};
if (_.indexOf(['ordinary', 'advance'], cartType) === -1) {
return {
code: 400,
message: '购物车参数类型有误!',
data: {}
};
}
if (couponCode) {
param.coupon_code = couponCode;
}
if (promotionCode) {
param.promotion_code = promotionCode;
}
if (yohoCoin) {
param.use_yoho_coin = yohoCoin;
}
if (redEnvelopes) {
param.use_red_envelopes = redEnvelopes;
}
return api.get('', param);
};
/**
* 购物车结算--使用优惠券
*
* @param int $uid 用户ID
* @param string $couponCode 优惠券代码
* @return array 接口返回的数据
*/
const searchCoupon = (uid, couponCode) => {
let param = {
method: 'app.Shopping.useCoupon',
coupon_code: couponCode,
uid: uid
};
return api.get('', param);
};
/**
* 购物车结算--获取优惠券列表
*
* @param int $uid 用户ID
* @return array 接口返回的数据
*/
const getCouponList = (uid, limit) => {
let param = {
method: 'app.coupons.lists',
type: 'notuse',
page: 1,
limit: limit || 10,
uid: uid
};
return api.get('', param);
};
/**
* 购物车结算--获取用户可用和不可用的优惠券列表
*
* @param int $uid 用户ID
* @return array 接口返回的数据
*/
const getListCoupon = (uid) => {
let param = {
method: 'app.Shopping.listCoupon',
uid: uid
};
return api.get('', param);
};
/**
* 购物车数量
*
* @param int $uid 用户ID
... ... @@ -417,103 +224,11 @@ const togetherProduct = (page) => {
};
/**
* 浏览记录数据
*
* @param int $uid 用户ID
* @param int $udid 客户端唯一标识
* @param int $page 第几页,默认为1
* @param int $limit 限制多少条,默认100
* @return array 接口返回的数据
*/
const browseRecord = (uid, udid, page, limit) => {
let param = {
method: 'app.browse.product',
uid: uid,
udid: udid,
page: page || 1,
limit: limit || 10
};
return api.get('', param);
};
/**
* 通过搜索查询商品信息
*
* 备注:因默认的搜索方法会有过滤, 浏览记录不需要过滤
*
* @param string $query 查询的条件
* @param int $limit 查询的限制数
* @return array
*/
const browseRecordFromSearch = (query, limit) => {
let param = {
method: 'web.search.search',
order: 'shelve_time:desc',
page: 1,
viewNum: limit || 10,
query: query
};
return api.get('', param);
};
/**
* 选择支付,校验时间间隔,插入数据
* @param string $uid
* @param string $orderCode
* @param int $payment 14:银联手机支付 15:支付宝手机 18:支付宝wap(wap) 19:微信支付 22:微信wap(wap) 26:QQ钱包手机支付
* @return type
*/
const savePrePayInfo = (uid, orderCode, payment) => {
let param = {
method: 'app.order.savePrePayInfo',
uid: uid,
orderCode: orderCode,
payment: payment
};
return api.get('', param);
};
/**
* 电子票添加和查询
* @param int $uid 用户ID
* @param type int $productSku 产品sku
* @param type int $buyNumber 购买数量,范围1-4
* @param type int $yohoCoin 有货币
* @return type []
* 判断商品列表是否收藏情况
* @param uid
* @param pidList
* @returns {Promise.<T>}
*/
const addTicket = (uid, productSku, buyNumber, yohoCoin) => {
let param = {
method: 'app.shopping.ticket',
uid: Number(uid),
product_sku: Number(productSku),
buy_number: Number(buyNumber)
};
// 有货币转换成元,1有货币等于一分钱
if (yohoCoin && yohoCoin > 0) {
param.use_yoho_coin = yohoCoin / 100;
}
return api.get('', param).then(ret => {
// 展览票不显示区域,上面要求的。@高扬、@徐洪云,2016/7/6
if (ret && ret.data && ret.data.goods_list) {
_.forEach(() => {
// it.size_name = it.product_skn * 1 === EXHIBITION_TICKET ? '' : it.size_name;
// ret.data.goods_list[key] = it;
});
}
return ret;
});
};
const checkUserIsFavProductList = (uid, pidList) => {
pidList = _.isArray(pidList) ? pidList : [];
... ... @@ -649,21 +364,9 @@ module.exports = {
selectGoods,
removeFromCart,
addToFav,
cartProductData,
giftProductData,
modifyProductNum,
modifyCartProduct,
cartPay,
orderCompute,
searchCoupon,
getCouponList,
getListCoupon,
cartCount,
togetherProduct,
browseRecord,
browseRecordFromSearch,
savePrePayInfo,
addTicket,
checkUserIsFavProductList,
newPreference,
modifyProduct,
... ...
... ... @@ -411,6 +411,13 @@ const getCoupons = (uid) => api.get('', {
return result;
});
/**
* 购物车数据
* @param uid
* @param shoppingKey
* @param cartDelList
* @returns {*}
*/
const getCartData = (uid, shoppingKey, cartDelList) => {
return cartApi.cartData(uid, shoppingKey).then(cartDataRet => {
return chelper.formatCart(cartDataRet, uid, shoppingKey, cartDelList);
... ... @@ -734,9 +741,6 @@ const getRecommendProduct = (channel, uid, udid, page) => {
let item = {
id: it.product_id,
skn: it.product_skn,
// href: Helpers::getUrlBySkc($value['product_id'],
// $value['goods_list'][0]['product_skc'], $value['cn_alphabet']),
title: it.product_name,
img: it.default_images ? helpers.image(it.default_images, 190, 250) : '',
alt: it.product_name,
... ... @@ -757,8 +761,6 @@ const getRecommendProduct = (channel, uid, udid, page) => {
});
Object.assign(result.data, {
// hasPrev: page > 1,
// hasNext: plist.length >= end,
item: items
});
... ... @@ -813,13 +815,6 @@ const getTogetherProduct = (page) => {
price: Number(it.price.sales_price)
};
// 商品链接
/* let cnAlphaBet = it.cn_alphabet ? it.cn_alphabet : md5(it.product_name);
let firstGoods = it.goods_list && it.goods_list[0];
let productSkc = firstGoods && firstGoods.product_skc;
item.href = helpers.url(`/product/pro_${it.product_id}_${productSkc}/${cnAlphaBet}.html`, null, 'item');*/
if (item.price !== Number(it.price.market_price)) {
it.marketPrice = Number(it.price.market_price);
}
... ... @@ -840,6 +835,13 @@ const getTogetherProduct = (page) => {
})();
};
/**
* 修改购物车商品
* @param param
* @param uid
* @param shoppingKey
* @param cartDelList
*/
const modifyProduct = (param, uid, shoppingKey, cartDelList) => {
return co(function * () {
... ... @@ -861,6 +863,15 @@ const modifyProduct = (param, uid, shoppingKey, cartDelList) => {
})();
};
/**
* 重选赠品或加价购商品
* @param uid
* @param shoppingKey
* @param promotionId
* @param newSkn
* @param newSku
* @param cartDelList
*/
const swapGift = (uid, shoppingKey, promotionId, newSkn, newSku, cartDelList) => {
return co(function * () {
... ... @@ -883,6 +894,12 @@ const swapGift = (uid, shoppingKey, promotionId, newSkn, newSku, cartDelList) =>
};
/**
* 查询指定优惠下的可选赠品或加价购
* @param promotionId 优惠ID
* @param uid
* @param shoppingKey
*/
const queryUserPromotionGift = (promotionId, uid, shoppingKey) => {
return co(function * () {
... ... @@ -932,6 +949,11 @@ const queryUserPromotionGift = (promotionId, uid, shoppingKey) => {
};
/**
* 首页mini购物车数据
* @param uid
* @param shoppingKey
*/
const getMiniCartData = (uid, shoppingKey) => {
return co(function * () {
... ... @@ -990,20 +1012,20 @@ const getMiniCartData = (uid, shoppingKey) => {
};
module.exports = {
getProductInfoAsync, // 获取某一个商品详情主页面
getCartData,
getCartCount,
addToCart,
selectGoods,
modifyProductNum,
removeFromCart,
addToFav,
checkUserIsFav,
getRecommendProduct,
getTogetherProduct,
modifyProduct,
swapGift,
queryUserPromotionGift,
getCoupons, // 获取优惠券列表
getMiniCartData
getProductInfoAsync, /** 获取商品信息 **/
getCartData, /** 购物车数据 **/
getCartCount, /** 得到购物车数量 **/
addToCart, /** 加入到购物车 **/
selectGoods, /** 选中/取消选中商品 **/
modifyProductNum, /** 修改商品数量 **/
removeFromCart, /** 从购物车中删除 **/
addToFav, /** 移入收藏 **/
checkUserIsFav, /** 判断商品是否已收藏 **/
getRecommendProduct, /** 为您优选商品 **/
getTogetherProduct, /** 凑单商品 **/
modifyProduct, /** 修改购物车商品 **/
swapGift, /** 重选赠品或加价购商品 **/
queryUserPromotionGift, /** 查询指定优惠下的可选赠品或加价购 **/
getCoupons, /** 获取优惠券列表 **/
getMiniCartData /** 首页mini购物车数据 **/
};
... ...
... ... @@ -5,6 +5,12 @@
'use strict';
/**
* and 逻辑运算
* {{and arg1 arg2 ...}}
* {{#and arg1 arg2 ...}}{{/and}}
* @returns {*}
*/
exports.and = function() {
let options = arguments[arguments.length - 1];
... ... @@ -31,6 +37,10 @@ exports.and = function() {
}
};
/**
* or 逻辑运算 {{or arg1 arg2 ... }}
* @returns {*}
*/
exports.or = function() {
let options = arguments[arguments.length - 1];
let ret = false;
... ... @@ -56,6 +66,13 @@ exports.or = function() {
}
};
/**
* 大于逻辑 v1 > v2
* @param v1
* @param v2
* @param options
* @returns {*}
*/
exports.gt = function(v1, v2, options) {
var ret = v1 > v2;
... ... @@ -71,6 +88,13 @@ exports.gt = function(v1, v2, options) {
}
};
/**
* 大于等于逻辑 v1 >= v2
* @param v1
* @param v2
* @param options
* @returns {*}
*/
exports.ge = function(v1, v2, options) {
var ret = v1 >= v2;
... ... @@ -86,6 +110,13 @@ exports.ge = function(v1, v2, options) {
}
};
/**
* 小于逻辑 v1 < v2
* @param v1
* @param v2
* @param options
* @returns {*}
*/
exports.lt = function(v1, v2, options) {
var ret = v1 < v2;
... ... @@ -101,6 +132,13 @@ exports.lt = function(v1, v2, options) {
}
};
/**
* 小于等于逻辑 v1 <= v2
* @param v1
* @param v2
* @param options
* @returns {*}
*/
exports.le = function(v1, v2, options) {
var ret = v1 <= v2;
... ... @@ -116,6 +154,13 @@ exports.le = function(v1, v2, options) {
}
};
/**
* 相等逻辑 v1 === v2
* @param v1
* @param v2
* @param options
* @returns {*}
*/
exports.eq = function(v1, v2, options) {
var ret = v1 === v2;
... ...
... ... @@ -36,7 +36,12 @@
<a {{#unless isOffShelve}}href="{{link}}" target="_blank"{{/unless}}>
{{#if tag}}<code class="good-mark">{{tag}}</code>{{/if}}{{productTitle}}
</a>
<em class="pay-pro-detail"><span><b title="{{productColor}}">颜色:{{productColor}}</b> 尺码:{{productSize}}<i class="iconfont">&#xe6c7;</i></span></em>
<em class="{{#unless isOffShelve}}pay-pro-detail{{/unless}}">
<span>
<b title="{{productColor}}">颜色:{{productColor}}</b>
尺码:{{productSize}}<i class="iconfont">&#xe6c7;</i>
</span>
</em>
{{#and isAdvance preSellDate}}
<span class="presell">上市期:{{preSellDate}}</span>
{{/and}}
... ... @@ -84,7 +89,7 @@
<p class="tip-message tip-message-coin"><i class="yoho-coin"></i>{{yohoIcon}}有货币</p>
{{/if}}
</div>
<div style="width:100px;" class="cart-operation td">
<div style="width:100px;" class="cart-operation td">
<span class="cart-del-btn" data-role="cart-del-btn">删除</span>
<span class="cart-col-btn" data-role="cart-mov2fav-btn">移入收藏</span>
</div>
... ...
... ... @@ -134,7 +134,7 @@ Cart = {
promotion_id: $item.data('promotionid') || 0
});
if (!$this.data('gift')) {
if (!$this.data('gift') && !$item.hasClass('tr-disabled')) {
countJSON = {
productPrice: $item.find('.product-price').text(),
productTitle: $item.find('.pay-pro-info a').text(),
... ... @@ -146,7 +146,7 @@ Cart = {
}
new RConfirm(content, function() {
capi.cartItemDel(selectArray, true, [countJSON]);
capi.cartItemDel(selectArray, true, countJSON ? [countJSON] : '');
});
},
delAll: function() {
... ...
... ... @@ -21,12 +21,12 @@ function pyStat() {
}
});
window.py('event', 'viewCart', {
window.py && window.py('event', 'viewCart', {
money: money,
items: items
}).track('MC.Ok.7NFMIlCH_F_LE2riRlF2r_');
}
$(function() {
setTimeout(pyStat, 0);
setTimeout(pyStat, 3000);
});
... ...