Authored by OF1706

Merge branch 'feature/shoppingCart' of http://git.yoho.cn/fe/yohobuy-node into feature/shoppingCart

... ... @@ -531,15 +531,18 @@ const formatCart = (cartDataRet, uid, shoppingKey, cartDelList) => {
})
};
let giftsList = formatPriceGifts(_.get(ordCartData, 'gift_list'));
let priceGifts = formatPriceGifts(_.get(ordCartData, 'price_gift'));
// let giftsList = formatPriceGifts(_.get(ordCartData, 'gift_list'));
// let priceGifts = formatPriceGifts(_.get(ordCartData, 'price_gift'));
let goodsList = formatCartGoods(_.get(ordCartData, 'goods_list'), false, false, false, analysisData);
result.ordinaryCart = {
// 全场可选的赠品
gifts: giftsList, // chelper.formatGifts(_.get(ordCartData, 'gift_list')),
// gifts: giftsList, // chelper.formatGifts(_.get(ordCartData, 'gift_list')),
// 全场可选的加价购商品列表
priceGifts: priceGifts, // chelper.formatPriceGifts(_.get(ordCartData, 'price_gift')),
// priceGifts: priceGifts, // chelper.formatPriceGifts(_.get(ordCartData, 'price_gift')),
giftsPromotionInfos: formatPoolPromotionInfos(_.get(ordCartData, 'g_gift_list')),
priceGiftsPromotionInfos: formatPoolPromotionInfos(_.get(ordCartData, 'g_price_gift_list')),
// 已选择的全场加价购和赠品
goodsList: goodsList,
... ...
... ... @@ -8,6 +8,15 @@
const api = global.yoho.API;
/**
* 获取用户信息API
* @param uid [number] uid
*/
const getUserProfileAsync = (uid) => api.get('', {
method: 'app.passport.profile',
uid: uid
});
/**
* 购物车结算API
* @param uid [number] uid
* @param cartType [string] 购物车类型,ordinary表示普通, advance表示预售
... ... @@ -161,6 +170,7 @@ const orderSubmitAsync = (uid, cartType, addressId, deliveryTime, deliveryWay, p
};
module.exports = {
getUserProfileAsync,
getOrderPaymentAsync,
getUesrCouponAsync,
getOrderComputeAsync,
... ...
... ... @@ -76,10 +76,18 @@ const handlePaymentInfo = (d, address) => {
d.shopping_cart_data.hasCoin = _.round(d.yoho_coin * 100); // 有货币稀释
let pskn = [], psku = [];
let pnum = 0;
_.forEach(d.goods_list, g => {
// link to goods
g.linkToGoods = helper.urlFormat(`/product/pro_${g.product_id}_${g.goods_id}/${g.cn_alphabet}.html`,
'', 'item');
// yas 统计数据
pskn.push(g.product_skn);
psku.push(g.product_sku);
pnum += g.buy_number * 1;
});
resData.goodsList = d.goods_list;
... ... @@ -95,7 +103,12 @@ const handlePaymentInfo = (d, address) => {
redEnvelopes: d.red_envelopes,
useRedEnvelopes: d.use_red_envelopes
}),
invoices: d.invoices
invoices: d.invoices,
countData: {
pnum: pnum,
pskn: pskn.join(','),
psku: psku.join(',')
}
});
return resData;
... ...
... ... @@ -24,13 +24,18 @@ const index = (uid, cartType) => {
return Promise.all([
ensureApi.getOrderPaymentAsync(uid, cartType, 0),
addressApi.getAddressListAsync(uid)
addressApi.getAddressListAsync(uid),
ensureApi.getUserProfileAsync(uid)
]).then(result => {
let data = _.get(result, '[0].data', false);
let address = _.get(result, '[1].data', []);
let receiver = _.get(result, '[2].data.mobile', '');
if (data) {
Object.assign(resData, ensureHandle.handlePaymentInfo(data, address));
Object.assign(resData, ensureHandle.handlePaymentInfo(data, address), {
receiverMobile: receiver,
hideReceiverMobile: _.replace(receiver, /(\d{3})\d{4}(\d{4,9})/, '$1****$2')
});
}
return resData;
... ... @@ -74,6 +79,7 @@ const submit = (uid, cartType, p) => {
ordercode: d.order_code
});
}
return result;
}
);
... ...
... ... @@ -76,7 +76,7 @@
</div>
<div class="goods-wrap">
<div class="block-title">订单商品信息<a href="/cart/cart" id="go-cart-btn" class="right">返回购物车修改 ></a></div>
<div class="block-title">订单商品信息<a href="/cart/cart" class="right"><span id="go-cart-btn">返回购物车修改 ></span></a></div>
{{#with shoppingCartData}}
{{#isY is_multi_package}}
<div class="multi-package-row">
... ... @@ -126,7 +126,7 @@
</thead>
<tbody>
{{#each goodsList}}
<tr>
<tr class="goods-item">
<td{{#if @first}} class="border-top"{{/if}}></td>
<td class="border-top">
<a class="image" href="{{linkToGoods}}">
... ... @@ -260,6 +260,10 @@
</div>
{{/ shoppingCartData}}
{{# countData}}
<p id="hide-count-data" data-pnum="{{pnum}}" data-pskn="{{pskn}}" data-psku="{{psku}}"></p>
{{/ countData}}
{{> ensure-tpl}}
{{/ content}}
</div>
... ...
... ... @@ -124,7 +124,7 @@
{{/each}}
</div>
</li>
<li class="receiver invoice-row">
<li class="receiver invoice-row" data-full="{{receiverMobile}}" data-hide="{{hideReceiverMobile}}">
<span class="row-title">
<em>*</em>
手机号码:
... ...
... ... @@ -18,14 +18,14 @@ module.exports = {
domains: {
// test3
// singleApi: 'http://api-test3.yohops.com:9999/',
// api: 'http://api-test3.yohops.com:9999/',
// service: 'http://service-test3.yohops.com:9999/',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
// api: 'http://192.168.102.205:8080/gateway/',
api: 'http://dev-api.yohops.com:9999/',
service: 'http://dev-service.yohops.com:9999/',
// api: 'http://dev-api.yohops.com:9999/',
// service: 'http://dev-service.yohops.com:9999/',
// api: 'http://192.168.102.205:8080/gateway/',
// service: 'http://dev-service.yohops.com:9999/',
... ...
... ... @@ -94,28 +94,7 @@
{{#if promotionInfos}}
<div class="gift-sell mt20">
{{#promotionInfos}}
<div class="gift-sell-info"
data-role="promotion-wrap"
data-promotionid="{{promotionId}}">
<code class="order-pay-mark
{{#unless isReach}}order-pay-mark-white{{/unless}}">
{{tag}}
</code>{{promotionTitle}}
{{>mix/cart/cart-promotion-btn}}
{{!--{{#if isPriceGift}}
{{#if isNotReach}}
<a class="btn-clear blue order-pay-link" target="_blank" href="{{promotionPageUrl}}">去凑单&nbsp;></a>
{{/if}}
{{/if}}--}}
{{#if isNotReach}}
<a class="btn-clear blue order-pay-link" target="_blank" href="{{promotionPageUrl}}">去凑单&nbsp;></a>
{{/if}}
{{!--{{> cart-sel-gift-tpl }}--}}
{{!--<textarea data-role="gifts-cansel" class="hide" data-promotionid="{{promotionId}}">{{{giftGoodsListStr}}}</textarea>--}}
</div>
{{>mix/cart/cart-promotion-info}}
{{/promotionInfos}}
</div>
{{/if}}
... ... @@ -175,63 +154,20 @@
{{#if hasGlobalBlock}}
<div class="gift-sell mt20">
{{#gifts}}
<div class="gift-sell-info"
data-role="promotion-wrap"
data-promotionid="{{promotionId}}">
<code class="order-pay-mark">
{{tag}}
</code>{{promotionTitle}}
{{#if isGift}}
<a class="order-pay-link" href="javascript:void(0);"
data-role="gift-sel-btn">领赠品</a>
{{/if}}
{{#if isPriceGift}}
<a href="javascript:void(0);"
class="order-pay-link"
data-role="pg-sel-btn">去换购</a>
{{!--<a class="btn-clear blue order-pay-link"
target="_blank" href="{{promotionPageUrl}}">去凑单&nbsp;></a>--}}
{{/if}}
{{!--{{> cart-sel-gift-tpl }}--}}
{{!--<textarea data-role="gifts-cansel" class="hide"
data-promotionid="{{promotionId}}">{{{giftGoodsListStr}}}</textarea>--}}
</div>
{{/gifts}}
{{#priceGifts}}
<div class="gift-sell-info"
data-role="promotion-wrap"
data-promotionid="{{promotionId}}">
<code class="order-pay-mark">
{{tag}}
</code>{{promotionTitle}}
{{#if isGift}}
<a class="order-pay-link" href="javascript:void(0);"
data-role="gift-sel-btn">领赠品</a>
{{/if}}
{{#if isPriceGift}}
<a href="javascript:void(0);"
class="order-pay-link"
data-role="pg-sel-btn">去换购</a>
<a class="btn-clear blue order-pay-link" target="_blank" href="{{promotionPageUrl}}">去凑单&nbsp;></a>
{{/if}}
{{!--{{> cart-sel-gift-tpl }}--}}
{{!--<textarea data-role="gifts-cansel" class="hide" data-promotionid="{{promotionId}}">{{{giftGoodsListStr}}}</textarea>--}}
</div>
{{/priceGifts}}
{{#giftsPromotionInfos}}
{{>mix/cart/cart-promotion-info}}
{{/giftsPromotionInfos}}
{{#priceGiftsPromotionInfos}}
{{>mix/cart/cart-promotion-info}}
{{/priceGiftsPromotionInfos}}
{{#promotionInfos}}
<p class="gift-sell-info">{{#if tag}}<code class="order-pay-mark">{{tag}}</code>{{/if}}{{promotionTitle}}
<!--<a class="btn-clear blue" data-together-id="6">去凑单&nbsp;&gt;</a>-->
</p>
{{#eq promotionId 0}}
<p class="gift-sell-info">{{#if tag}}<code class="order-pay-mark">{{tag}}</code>{{/if}}
{{promotionTitle}}
<!--<a class="btn-clear blue" data-together-id="6">去凑单&nbsp;&gt;</a>-->
</p>
{{/eq}}
{{/promotionInfos}}
</div>
{{/if}}
... ...
... ... @@ -88,20 +88,3 @@
</div>
</div>
</div>
<!--
<div class="yoho-dialog cart-preSell-dialog"
data-role="cart-pre-sell"
style="margin-top:-200px;margin-left: -350px; display:none;">
<span class="close">
<i class="iconfont">&#xe60d;</i>
</span>
<div class="content">
<div class="detail-body">
</div>
</div>
</div>
-->
... ...
{{#if isGift}}
{{#if isEmpty}}
<a class="order-pay-link" href="javascript:void(0);">已抢光</a>
{{/if}}
{{#if isNotReach}}
<a class="order-pay-link" href="javascript:void(0);"
data-role="gift-view-btn">查看赠品</a>{{/if}}
... ...
<div class="gift-sell-info"
data-role="promotion-wrap"
data-promotionid="{{promotionId}}">
<code class="order-pay-mark {{#unless isReach}}order-pay-mark-white{{/unless}}">
{{tag}}
</code>{{promotionTitle}}
{{> mix/cart/cart-promotion-btn}}
{{#if isNotReach}}
<a class="btn-clear blue order-pay-link" target="_blank" href="{{promotionPageUrl}}">去凑单&nbsp;></a>
{{/if}}
</div>
... ...
... ... @@ -2,13 +2,6 @@
<p class="sell-class-title">
{{#if isGift}}选赠品:{{/if}}<!--选赠品:-->
{{#if isPriceGift}}{{promotionTitle}}{{/if}}
{{!--<em class="slide-img-title">
<span class="active">{{promotionTitle}}</span>
<!--<code class="spacing">|</code>
<span>59元加价购</span>
<code class="spacing">|</code>
<span>99元加价购</span>-->
</em>--}}
</p>
<div class="side-img-dd">
<ul class="img-list">
... ...
<!-- 凑单 -->
<div class="detail-body" id="goodsTogetherDetail">
<div class="detail-goods">
<div class="detail-bigpic">
<div class="bigpic">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="piclist">
<span class="pre"></span>
<div class="con">
<ul>
<li class="active"><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
</ul>
</div>
<span class="next"></span>
</div>
</div>
<div class="detail-bigpic none">
<div class="bigpic">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="piclist">
<span class="pre"></span>
<div class="con">
<ul>
<li class="active"><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
</ul>
</div>
<span class="next"></span>
</div>
</div>
<div class="detail-info">
<div class="title">
<h2>哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈{{name}}</h2>
</div>
<div class="price">
<span class="newprice">现价:<b class="promotion-price">¥7777{{salePrice}}</b></span>
<span class="activityprice">活动价:<b class="promotion-price">¥5555{{marketPrice}}</b></span>
</div>
<div class="order">
<dl>
<dd class="colorBox">选颜色:</dd>
<dt>
<div class="colorBox">
<ul>
<li class="color active">
<p class="{{#if focus}}atcive{{/if}}"><span></span><img src=""></p>
<span>{{name}}</span>
</li>
<li class="color">
<p class="{{#if focus}}atcive{{/if}}"><span></span><img src=""></p>
<span>{{name}}</span>
</li>
</ul>
</div>
</dt>
</dl>
<dl>
<dd class="showSizeBox">选尺码:</dd>
<dt>
<div class="showSizeBox">
<span data-sku="{{sku}}" data-num="{{num}}" class="disabled">40码{{name}}</span>
<span data-sku="{{sku}}" data-num="{{num}}">40码{{name}}</span>
<span data-sku="{{sku}}" data-num="{{num}}">40码{{name}}</span>
<span data-sku="{{sku}}" data-num="{{num}}">40码{{name}}</span>
</div>
<p class="size-p">内长&nbsp;25.5com</p>
</dt>
</dl>
<dl>
<dd>选件数:</dd>
<dt>
<div class="amount_wrapper">
<input type="text" id="num" class="num" value="1" readonly="readonly">
<a class="amount cut"><i class="iconfont">&#xe6c1;</i></a>
<a class="amount add"><i class="iconfont">&#xe6c0;</i></a>
</div>
</dt>
</dl>
</div>
<div class="submit">
<button class="btn-red"><i class="addCart iconfont">&#xe600;</i>添加到购物车</button>
<button class="btn-favCount"><i class="favCount iconfont">&#xe68f;</i>收藏商品</button>
</div>
</div>
<div class="detail-size">
<h3>尺码信息(单位:厘米)</h3>
<table style="margin-bottom:100px;">
<thead>
<tr>
<th width="{{width}}">吊牌吃吗</th>
<th width="{{width}}">吊牌吃吗</th>
<th width="{{width}}">吊牌吃吗</th>
<th width="{{width}}">吊牌吃吗
</td>
<th width="{{width}}">吊牌吃吗
</td>
<th width="{{width}}">吊牌吃吗
</td>
</tr>
</thead>
<tbody>
<tr>
<td>6666{{.}}</td>
</tr>
<tr>
<td>4444{{.}}</td>
</tr>
</tbody>
</table>
<div class="size-info">
※ 以上尺寸为实物实际测量,因测量方式不同会有略微误差,相关数据仅作参考,以收到实物为准。
</div>
</div>
</div>
</div>
<input value="{{addToCart}}" id="addToCart" type="hidden"/>
... ... @@ -30,21 +30,6 @@
</div>
</div>
{{/each}}
<!--<div class="dt active">
40
</div>
<div class="dt">
42
</div>
<div class="dt">
44
</div>
<div class="dt">
46
</div>
<div class="dt disabled">
48
</div>-->
</div>
<div class="button-group">
<button class="button-sure">确定</button>
... ... @@ -61,21 +46,5 @@
{{/if}}
</div>
{{/ colors}}
<!--<div class="bigImg">
<img src="#"/>
<img src="{{image defaultImg 100 134}}" class="img-preview" title="{{defaultColor}}"/>
</div>
<div class="bigImg none">
<img src="#"/>
</div>
<div class="bigImg none">
<img src="#"/>
</div>
<div class="bigImg none">
<img src="#"/>
</div>
<div class="bigImg none">
<img src="#"/>
</div>-->
</div>
</div>
... ...
... ... @@ -17,19 +17,6 @@ $cartnewTips.find('.btn_close').click(function() {
$cartnewTips.fadeOut();
});
// 滚动到第一个选中的商品
/* function scrollToFirst() {
var $selected = $cartListWrap.find('li[data-role="pitem"] .cart-item-check.cart-item-checked:eq(0)');
var top = 0;
if ($selected.length > 0) {
top = $selected.offset().top - 36;
$('html,body').scrollTop(top);
}
return false;
}*/
function toastNoStore(parent, info) {
var tipInfo = info || '您勾选的商品库存不足';
... ... @@ -43,9 +30,7 @@ function toastNoStore(parent, info) {
}
Cart = {
/* addToCart: function(params) {
},*/
toggleSelectOne: function() { // 单选
var $this = $(this);
... ... @@ -136,13 +121,6 @@ Cart = {
new RConfirm(content, function() {
capi.cartItemDel(selectArray, true, [countJSON]);
});
/* new RConfirm({
content: content,
cb: function() {
capi.cartItemDel(selectArray, true, countJSON);
}
}).show();*/
},
delAll: function() {
... ...
... ... @@ -33,9 +33,28 @@ var address = require('./order-new/address'),
var coinTpl = Hbs.compile($('#yoho-coin-tpl').html());
var promotionTpl = Hbs.compile($('#promotion-list-tpl').html());
var yasCountData = $('#hide-count-data').data();
$('#hide-count-data').remove();
require('../common');
require('../simple-header');
if (!$('.goods-item').length) {
new dialog.Dialog({
content: '暂无可结算商品,请返回购物车重新选择',
className: 'ensure-back-alert',
btns: [{
id: 'back-sure',
btnClass: ['back-sure'],
name: '返回购物车',
cb: function() {
$('#go-cart-btn').trigger('click');
}
}]
}).show();
}
order.cartType = window.queryString().type || 1;
// FE Helper
... ... @@ -669,12 +688,14 @@ $('#order-submit').click(function() {
content: subTip,
className: 'ensure-hint-confirm',
btns: [{
id: 'hint-sure',
btnClass: ['confirm-sure'],
name: '重新选择商品',
cb: function() {
$('#go-cart-btn').trigger('click');
}
}, {
id: 'hint-cancel',
btnClass: ['confirm-cancel'],
name: '继续结算',
cb: function() {
... ... @@ -685,7 +706,10 @@ $('#order-submit').click(function() {
}).show();
} else {
location.href = data.data.url;
yas.givePoint('YB_SC_TOPAY_CLICK', {ORDER_CODE: rdata.order_code, PRD_NUM: yasCountData.pnum,
ORDER_AMOUNT: rdata.order_amount, PRO_SKN: yasCountData.pskn, PRO_SKU: yasCountData.psku,
UNIONCOOKIE: encodeURIComponent(rdata.unionKey + '') || ''});
location.href = rdata.url;
}
} else if (data.message) {
new dialog.Alert(data.message).show();
... ... @@ -699,6 +723,5 @@ multiPackage.init();
coupon.init();
yohoCoin.init();
// 订单确认页默认埋点
yas.givePoint('YB_SC_ORDER_ENSURE');
... ...
... ... @@ -13,7 +13,8 @@ var $invoiceRadio = $('#invoice-radio');
var invoiceTpl = $('#invoice-chose-tpl').html();
var invoiceInfo = {};
var invoiceInfo = {},
defaultReceiver = {};
function validateInvoice($el, info) {
var pass = true;
... ... @@ -34,6 +35,8 @@ function validateInvoice($el, info) {
if (!info.receiver) {
$receiverTip.removeClass('hide').find('em').html('请填写手机号码');
pass = false;
} else if (info.receiver === defaultReceiver.hide) {
$receiverTip.addClass('hide');
} else if (!/^[0-9]{11}$/.test(info.receiver)) {
$receiverTip.removeClass('hide').find('em').html('手机号码不正确');
pass = false;
... ... @@ -119,7 +122,7 @@ function bindInvoiceInfo($el, info) {
$('.rbc-' + info.contentId, $el).trigger('click');
}
$('#receiver-phone', $el).val(info.receiver || '');
$('#receiver-phone', $el).val(info.receiver || defaultReceiver.hide || '');
}
function packInvoiceInfo($el) {
... ... @@ -212,6 +215,10 @@ function invoiceEditDialog(baseInfo) {
]
});
if (!defaultReceiver.full) {
defaultReceiver = invoice.$el.find('.receiver').data();
}
bindInvoiceEvent(invoice.$el);
bindInvoiceInfo(invoice.$el, baseInfo);
... ... @@ -247,6 +254,6 @@ exports.getInvoice = function() {
invoicesType: invoiceInfo.invocesType,
invoicesTitle: invoiceInfo.titleName,
invoicesContent: invoiceInfo.contentId,
receiver: invoiceInfo.receiver
receiver: invoiceInfo.receiver === defaultReceiver.hide ? defaultReceiver.full : invoiceInfo.receiver
};
};
... ...
... ... @@ -1101,6 +1101,23 @@
}
}
.ensure-back-alert {
> .close {
display: none;
}
.content {
padding: 40px 0;
}
.back-sure {
width: 100px;
color: #fff;
background-color: #000;
cursor: pointer;
}
}
.ope-address-dialog {
$red: #d0021b;
width: 450px;
... ...