Authored by hf

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

... ... @@ -23,16 +23,17 @@ class Yohobuy
// const SERVICE_URL = 'http://service.api.yohobuy.com/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
// const API_URL = 'http://apih5.yoho.cn/';
// const API_URL = 'http://apih5.yoho.cn/';
// const API_URL2 = 'http://apih5.yoho.cn/';
// const SERVICE_URL = 'http://serviceh5.yoho.cn/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
/* 测试环境 */
const API_URL = 'http://testapi.yoho.cn:28078/';
const API_URL = 'http://testapi.yoho.cn:28078/';
const SERVICE_URL = 'http://testservice.yoho.cn:28077/';
const YOHOBUY_URL = 'http://www.yohobuy.com/';
/**
* 私钥列表
*
... ...
... ... @@ -583,8 +583,11 @@ class Helpers
$oneGoods['isVipPrice'] = $value['sales_price'] !== $value['last_vip_price'];
$oneGoods['count'] = $value['buy_number'];
if ($isValid) { // 库存不足
if ($isValid) {
// 库存不足
$oneGoods['lowStocks'] = ($value['buy_number'] > $value['storage_number']);
} else { // 失效商品
$oneGoods['inValid'] = true;
}
//gift=>是否赠品,advanceBuy=>是否加价购,soldOut=>失效商品;
... ...
... ... @@ -16,7 +16,7 @@ var $cartContent = $('.cart-content');
var navHammer,
cartType = $('#cartType').val();
var hasChecked = $('.cart-goods .icon-cb-checked').length > 0 ? true : false; //是否有选中商品
var hasChecked = $('.cart-content:not(.hide) .icon-cb-checked').length > 0 ? true : false; //是否有选中商品
require('./good');
... ... @@ -65,6 +65,11 @@ $('.freebie').on('touchend', function() {
});
$('.btn-balance').on('touchend', function() {
if ($('.low-stocks').length > 0) {
tip.show('库存不足无法结算');
return false;
}
if (hasChecked) {
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
} else {
... ...
... ... @@ -119,7 +119,7 @@ function resetColorZeroStock($siblingBlock) {
// 选择了颜色切换商品图片
function changeGoodImgWhenClickColor() {
if (hasChooseColor && curColorIndex) {
if (hasChooseColor && curColorIndex >= 0) {
$imgsThumb.addClass('hide').eq(curColorIndex).removeClass('hide');
}
}
... ... @@ -206,6 +206,7 @@ $yohoPage.on('touchstart', '.color-list .block', function() {
// 当前颜色块 切换勾选样式
$this.toggleClass('chosed');
curColorIndex = index;
$('#good-num').val(1);
// 设置按钮的样式和文字
updateConformButtonClassAndText();
... ... @@ -257,6 +258,7 @@ $yohoPage.on('touchstart', '.color-list .block', function() {
$this.toggleClass('chosed');
curSizeIndex = index;
$curSizeBlock = $this;
$('#good-num').val(1);
// 设置按钮的样式和文字
updateConformButtonClassAndText();
... ... @@ -275,6 +277,11 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
}
if (num === 1 || 0 === leftNum - 0) {
tip.show('您选择的数量不能为零~');
return;
}
if (num < 0) {
tip.show('您选择的数量不能为零~');
return;
}
... ... @@ -294,8 +301,8 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
}
//TODO:库存数验证
if (num > leftNum) {
$num.val(leftNum);
if (num > leftNum - 1) {
tip.show('您选择的数量超过了最大库存量~');
return;
}
$num.val(num + 1);
... ... @@ -306,17 +313,12 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
promotionId,
isEdit = 0,
numInCart = $('.num-tag').html() - 0,
num = parseInt($num.val(), 10);
//颜色尺码没有选择
if (!checkColorSizeNum()) {
return;
}
if (isNaN(num)) {
tip.show('您选择的数量不是一个数字~');
return;
}
//TODO status change
if ($('#chose-btn-sure').html() === '已售罄') {
... ... @@ -329,7 +331,10 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
tip.show('您选择的数量超过了最大库存量~');
return;
}
if (num < 0) {
tip.show('您选择的数量小于一件~');
return;
}
$chosed = $('.block-list>ul>li.chosed');
if (2 === $chosed.length && 0 === $chosed.closest('.zero-stock').length) {
... ... @@ -352,9 +357,15 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
cartType: queryString.cartType
}
}).done(function(res) {
var cartNum;
loading.hideLoadingMask();
if (res.code === 200) {
$('.num-tag').html(numInCart + buyNumber).removeClass('hide');
cartNum = res.data.goods_count;
if (cartNum > 99) {
cartNum = '99+';
}
$('.num-tag').html(cartNum).removeClass('hide');
confirming = false;
if (cbFn) {
... ...
... ... @@ -6,6 +6,7 @@
var $ = require('jquery'),
lazyLoad = require('yoho.lazyload'),
Hammer = require('yoho.hammer'),
tip = require('../plugin/tip'),
loading = require('../plugin/loading'),
chosePanel = require('./chose-panel');
... ... @@ -35,10 +36,22 @@ function getProductInfo(skn, promotionId) {
});
}
$page.on('touchend', '.chose', function() {
var $this = $(this),
id = $this.closest('.gift-advance-good').data('id'),
promotionId = $this.closest('.advance-block').data('promotion-id');
$page.find('.chose').each(function(i, elem) {
var choseHammer = new Hammer(elem);
getProductInfo(id, promotionId);
choseHammer.on('tap', function(e) {
var $this = $(e.target),
id = $this.closest('.gift-advance-good').data('id'),
promotionId = $this.closest('.advance-block').data('promotion-id');
getProductInfo(id, promotionId);
});
});
// $page.on('touchend', '.chose', function() {
// var $this = $(this),
// id = $this.closest('.gift-advance-good').data('id'),
// promotionId = $this.closest('.advance-block').data('promotion-id');
//
// getProductInfo(id, promotionId);
// });
... ...
... ... @@ -27,6 +27,13 @@ $('.shopping-cart-good .name').each(function() {
this.mlellipsis(2);
});
function GoodInfo(properties) {
this.goods_type = properties.goods_type;
this.buy_number = properties.buy_number;
this.product_sku = properties.product_sku;
this.selected = properties.selected;
}
//TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods
$('.cart-goods').on('touchstart', '.checkbox', function() {
var $this = $(this),
... ... @@ -34,30 +41,14 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
id = $good.data('id');
var goodsList = [],
goodInfo = {},
isSelected = true;
if ($this.hasClass('icon-cb-checked')) {
isSelected = true;
} else {
isSelected = false;
}
function GoodInfo(properties) {
this.goods_type = properties.goods_type;
this.buy_number = properties.buy_number;
this.product_sku = properties.product_sku;
this.selected = properties.selected;
}
goodInfo = {};
goodInfo.goods_type = cartType;
goodInfo.selected = isSelected ? 'N' : 'Y';
goodInfo.selected = $this.hasClass('icon-cb-checked') ? 'N' : 'Y';
goodInfo.product_sku = id;
goodInfo.buy_number = $good.find('.count').eq(0).text().trim().replace('×', '');
goodsList.push(new GoodInfo(goodInfo));
$.ajax({
type: 'post',
url: 'select',
... ... @@ -90,8 +81,8 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
rightBtnText: '确定'
}
}, function() {
var id = $this.closest('.shopping-cart-good').data('id');
var count = $this.data('count');
var id = $this.closest('.shopping-cart-good').data('id'),
count = $this.data('count');
$.ajax({
method: 'post',
... ... @@ -117,7 +108,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
tip.show('网络异常');
});
});
});
function requestUpdateAllGoodsCheckStatus(theGoods, successHandeler) {
... ... @@ -138,7 +128,7 @@ function requestUpdateAllGoodsCheckStatus(theGoods, successHandeler) {
tip.show(res.message);
}
},
error: function(err) {
error: function() {
tip.show('网络异常');
},
complete: function() {
... ... @@ -174,17 +164,10 @@ function didUpdateAllGoodsCheckStatus() {
}
function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) {
var goodInfo = {};
var $goods = $('.cart-content:not(.hide) .shopping-cart-good');
var $good = null;
var goodsList = [];
function GoodInfo(properties) {
this.goods_type = properties.goods_type;
this.buy_number = properties.buy_number;
this.product_sku = properties.product_sku;
this.selected = properties.selected;
}
var goodInfo = {},
$goods = $('.cart-content:not(.hide) .shopping-cart-good'),
$good = null,
goodsList = [];
goodInfo.goods_type = type;
goodInfo.selected = isSelected ? 'N' : 'Y';
... ... @@ -201,26 +184,9 @@ function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) {
requestUpdateAllGoodsCheckStatus(goodsList, handlerAfterTouch);
}
//是否要全选
function willBeSelected($this) {
var isSelected = true;
if ($this.hasClass('icon-cb-checked')) {
isSelected = true;
} else {
isSelected = false;
}
return isSelected;
}
//全选按钮点击事件
$selectAllBtn.on('touchend', function() {
var $this = $(this);
bottomCheckBoxHandeler(willBeSelected($this), cartType, didUpdateAllGoodsCheckStatus);
bottomCheckBoxHandeler($(this).hasClass('icon-cb-checked'), cartType, didUpdateAllGoodsCheckStatus);
});
$('.down').on('touchend', function() {
... ...
... ... @@ -93,8 +93,7 @@ function orderCompute() {
}).then(function(res) {
var priceHtml;
if (!res) {
tip.show('网络出错');
if (!res.length) {
window.location.reload();
} else {
/*if (res.order_amount) {
... ... @@ -106,8 +105,12 @@ function orderCompute() {
if (res.last_order_amount) {
res.last_order_amount = (+res.last_order_amount).toFixed(2);
}
$coinCheck.find('em').html('- ¥ ' + res.use_yoho_coin);
$coinUsed.html('已抵¥' + res.use_yoho_coin);
if (res.use_yoho_coin) {
$coinCheck.find('em').html('- ¥ ' + res.use_yoho_coin);
$coinUsed.html('已抵¥' + res.use_yoho_coin);
$coinCheck.find('em').show();
$coinUsed.show();
}
priceHtml = priceTmpl({
cartPayData: res.promotion_formula_list,
price: res.last_order_amount
... ... @@ -116,7 +119,6 @@ function orderCompute() {
$price.html(priceHtml);
}
}).fail(function() {
tip.show('网络出错');
window.location.reload();
});
}
... ... @@ -163,7 +165,6 @@ function submitOrder() {
var url;
if (!res) {
loading.hideLoadingMask();
tip.show('网络出错');
return;
}
... ... @@ -177,13 +178,13 @@ function submitOrder() {
}
window.setCookie('order-info', '');
window.location.href = url;
} else {
loading.hideLoadingMask();
tip.show(res.message || '网络出错');
} else if (res.message) {
tip.show(res.message);
}
}).fail(function() {
loading.hideLoadingMask();
tip.show('网络出错');
}).always(function() {
loading.hideLoadingMask();
});
}
... ... @@ -215,9 +216,7 @@ $('.coin').on('touchend', function() {
if ($this.find('.checkbox').hasClass('icon-cb-checked')) {
orderInfo('yohoCoin', $this.data('yoho-coin'));
$this.find('.coin-check em').show();
$this.find('.can-use').hide();
$this.find('.used').show();
} else {
orderInfo('yohoCoin', 0);
$this.find('.coin-check em').hide();
... ...
... ... @@ -39,17 +39,18 @@
.thumb {
float: left;
width: 80rem / $pxConvertRem;
width: 100rem / $pxConvertRem;
}
.text-info {
position: absolute;
height: auto;
left: pxToRem(95px);
top:50%;
transform: translateY(-50%);
.name {
font-size: 28rem / $pxConvertRem;
height: 74rem / $pxConvertRem;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.price{
... ...
... ... @@ -9,11 +9,14 @@
margin-top: -14rem / $pxConvertRem;
margin-left: 20rem / $pxConvertRem;
font-size: 28rem / $pxConvertRem;
color: #f0f0f0;
&.icon-cb-checked {
color: #000;
}
&.disabled {
color: #f0f0f0;
}
}
.few-tag{
... ... @@ -54,6 +57,10 @@
padding-right: 20rem / $pxConvertRem;
}
.fixed-height {
height: 2.7rem;
}
.thumb {
float: left;
width: 180rem / $pxConvertRem;
... ... @@ -65,54 +72,49 @@
.deps {
position: relative;
width: 380rem / $pxConvertRem;
height: 5.3rem;
margin-left: 4.7rem;
border-bottom: 1px solid #e0e0e0;
padding-top: 0.5rem;
padding: 0.5rem 0;
}
.name {
font-size: 18px;
color: #5a5a5a;
width: 80%;
display: inline-block;
width: 80%;
color: #5a5a5a;
font-size: 0.6rem;
}
.color-size-row {
margin: 0.2rem 0;
> span {
margin-right: 15rem / $pxConvertRem;
}
.color-size-row > span {
margin-right: 15rem / $pxConvertRem;
}
.color, .size {
font-size: 16px;
font-size: 0.6rem;
color: #b6b6b6;
}
.appear-date {
float: left;
color: $cartRed;
display: block;
margin-top: 4rem / $pxConvertRem;
font-size: 0.5rem;
}
.price {
font-size: 16px;
font-size: 0.6rem;
color: $cartRed;
}
.count {
font-size: 32rem / $pxConvertRem;
color: #999;
//margin-left: 22rem / $pxConvertRem;
display: inline-block;
width: 19%;
position: absolute;
text-align: center;
}
.sold-out, .low-stocks {
.low-stocks {
display: inline-block;
width: 100rem / $pxConvertRem;
height: 30rem / $pxConvertRem;
... ... @@ -122,20 +124,31 @@
color: #fff;
text-align: center;
float: right;
margin-top: 20rem / $pxConvertRem;
margin-right: 16rem / $pxConvertRem;
border-radius: 20rem / $pxConvertRem;
padding: 4rem / $pxConvertRem;
}
.sold-out {
background: #999;
border-radius: 20rem / $pxConvertRem;
}
.low-stocks {
background: #7f7f7f;
}
.vip {
display: inline-block;
color: #fff;
background: #d1021c;
border: 1px solid #9d0000;
@include border-radius(0.5rem);
padding: 4rem / $pxConvertRem 0.5rem;
margin-left: 0.2rem;
}
.la-tag {
margin-top: 0.3rem;
min-height: 1rem;
}
.icon-del,
.icon-edit {
position: absolute;
... ...
... ... @@ -7,6 +7,15 @@
.shopping-cart-page {
padding-bottom: 120rem / $pxConvertRem;
overflow-x: hidden;
background: #f0f0f0;
.yoho-tip {
z-index: 4;
}
.cart-content > * {
background: #fff;
}
.cart-nav {
color: #c6c6c6;
... ... @@ -111,23 +120,29 @@
.cart-goods {
border-bottom: 1px solid #e0e0e0;
margin-bottom: 0.75rem;
.shopping-cart-good:last-child .info {
border-bottom: none;
}
}
.invalid-goods {
border-top: 1px solid #e0e0e0;
border-bottom: 1px solid #e0e0e0;
margin: 0.75rem 0;
}
.freebie-and-advance-buy {
padding: 20rem / $pxConvertRem;
font-size: 24rem / $pxConvertRem;
border-bottom: 1px solid #e0e0e0;
border-top: 1px solid #e0e0e0;
> li {
box-sizing: border-box;
height: 90rem / $pxConvertRem;
line-height: 90rem / $pxConvertRem;
margin-bottom: 10rem / $pxConvertRem;
background: #f8f8f8;
padding: 0 20rem / $pxConvertRem;
&:last-child {
... ... @@ -152,6 +167,7 @@
}
.activity-title{
border-top: 1px solid #e0e0e0;
font-size: 32rem / $pxConvertRem;
padding: 20rem / $pxConvertRem 20rem / $pxConvertRem 0;
}
... ...
... ... @@ -119,7 +119,10 @@
}
.coupon-use {
box-sizing: border-box;
position: relative;
float: right;
padding-right: 30rem / $pxConvertRem;
color: #999;
text-align: right;
width: 360rem / $pxConvertRem;
... ... @@ -128,6 +131,9 @@
overflow: hidden;
.iconfont {
position: absolute;
top:0;
right: 0;
color: #999;
}
}
... ...
... ... @@ -11,7 +11,7 @@
{{/if}}
{{#if isEmptyCart}}
<div class="cart-zero">
<i class="iconfont">&#xe62c</i>
<i class="iconfont">&#xe640;</i>
<p>您的购物车暂无商品</p>
<a href="/product/new">随便逛逛</a>
</div>
... ...
... ... @@ -110,7 +110,7 @@
</ul>
<form id="msg" action="" method="post">
<textarea name="msg" rows="2" maxlength="40" placeholder="留言">{{msg}}</textarea>
<input type="text" name="msg" value="{{msg}}" maxlength="40" placeholder="留言">
</form>
</section>
... ...
... ... @@ -118,8 +118,7 @@
{{#cartInfo}}
<div class="cart-bar">
<span class="num-tag hide"></span>
<a href="{{cartUrl}}" class="num-incart iconfont">&#xe62c;</a>
<a href="{{cartUrl}}" class="num-incart iconfont"><span class="num-tag hide"></span>&#xe62c;</a>
{{#if addToCartUrl}}
<!-- <a id="addtoCart" href="{{addToCartUrl}}" class="addto-cart">加入购物车</a> -->
... ...
... ... @@ -2,13 +2,16 @@
{{# goods}}
{{> cart/good}}
{{/ goods}}
{{# notValidGoods}}
{{> cart/good}}
{{/ notValidGoods}}
</div>
{{#if notValidGoods}}
<div class="invalid-goods">
{{# notValidGoods}}
{{> cart/good}}
{{/ notValidGoods}}
</div>
{{/if}}
{{#if freebieOrAdvanceBuy}}
<ul class="freebie-and-advance-buy">
{{# freebie}}
... ... @@ -16,8 +19,8 @@
<a href="/cart/index/gift?cartType={{cartType}}">
<span class="iconfont">&#xe620;</span>
赠品
<span class="count">{{count}}</span>
<span class="iconfont icon-right-arrow">&#xe614;</span>
<span class="count">{{count}}</span>
</a>
</li>
{{/ freebie}}
... ... @@ -26,8 +29,8 @@
<a href="/cart/index/advanceBuy?cartType={{cartType}}">
<span class="iconfont">&#xe61b;</span>
加价购
<span class="count">{{advanceBuyCount}}</span>
<span class="iconfont icon-right-arrow">&#xe614;</span>
<span class="count">{{advanceBuyCount}}</span>
</a>
</li>
{{/if}}
... ... @@ -42,6 +45,7 @@
{{/if}}
{{/ promotionInfo}}
{{#if promotionInfo}}
<div class="activity">
<ul>
{{# promotionInfo}}
... ... @@ -49,6 +53,7 @@
{{/ promotionInfo}}
</ul>
</div>
{{/if}}
<div class="price-compute">
<p>
... ...
... ... @@ -52,7 +52,7 @@
<a class="btn btn-minus" href="javascript:void(0);">
<span class="iconfont {{#if promotionId}}disabled{{/if}}">&#xe625;</span>
</a>
<input id="good-num" class="good-num {{#if promotionId}}disabled{{/if}}" type="text" value="1" {{#if promotionId}}disabled="true"{{/if}}>
<input id="good-num" class="good-num disabled" type="text" value="1" disabled="true">
<a class="btn btn-plus" href="javascript:void(0);">
<span class="iconfont {{#if promotionId}}disabled{{/if}}">&#xe624;</span>
</a>
... ...
... ... @@ -10,9 +10,6 @@
{{#if price}}
<span class="price market-price">&yen;{{marketPrice}}</span>
{{/if}}
<span class="count">
×{{count}}
</span>
</p>
<button class="chose">选择</button>
</div>
... ...
... ... @@ -4,7 +4,7 @@
{{/if}}
{{#if showCheckbox}}
<span class="checkbox{{#if checked}} icon-cb-checked{{^}} icon-checkbox{{/if}} iconfont"></span>
<span class="checkbox{{#if checked}} icon-cb-checked{{^}} icon-checkbox {{#if lowStocks}}disabled{{/if}}{{/if}} iconfont"></span>
{{/if}}
<div class="info">
... ... @@ -19,51 +19,51 @@
{{/if}}
<div class="deps show">
<a href="{{link}}" class="name row">{{name}}</a>
<span class="count">
×{{count}}
</span>
<p class="row color-size-row">
{{#if color}}
<span class="color">
颜色:{{color}}
</span>
{{/if}}
<div class="fixed-height">
<a href="{{link}}" class="name row">{{name}}</a>
<span class="count">
×{{count}}
</span>
<p class="row color-size-row">
{{#if color}}
<span class="color">
颜色:{{color}}
</span>
{{/if}}
{{#if size}}
<span class="size">
尺码:{{size}}
</span>
{{/if}}
{{#if size}}
<span class="size">
尺码:{{size}}
</span>
{{/if}}
</p>
</p>
</div>
<p class="row">
<span class="price">
¥{{price}}
</span>
{{#if soldOut}}
<span class="sold-out">
已售罄
{{#if vip}}
<span class="vip">
VIP
</span>
{{/if}}
<span class="iconfont icon-del" data-count="{{count}}">&#xe621;</span>
</p>
{{#if lowStocks}}
<p class="row">
<p class="la-tag row clearfix">
{{#if lowStocks}}
<span class="low-stocks">
库存不足
</span>
</p>
{{/if}}
{{#if appearDate}}
<p class="row">
{{/if}}
{{#if appearDate}}
<span class="appear-date">
上市期:{{appearDate}}
</span>
</p>
{{/if}}
{{/if}}
</p>
</div>
</div>
</div>
... ...
... ... @@ -230,8 +230,7 @@ class LoginController extends AbstractAction
}
//判定是否需要绑定手机号
$isBind = $result['data']['is_bind'];
if ($isBind == 'N') {
if (isset($result['data']['is_bind']) && $result['data']['is_bind'] == 'N') {
$this->go(Helpers::url('/passport/bind/index', array('openId' => $access['openid'], 'sourceType' => 'qq', 'nickname' => $partnerInfo['nickname'])));
}
... ... @@ -267,8 +266,7 @@ class LoginController extends AbstractAction
$result = LoginData::signinByOpenID($partnerInfo['screen_name'], $access['uid'], 'sina');
}
//判定是否需要绑定手机号
$isBind = $result['data']['is_bind'];
if ($isBind == 'N') {
if (isset($result['data']['is_bind']) && $result['data']['is_bind'] == 'N') {
$this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['screen_name'])));
}
... ...