Authored by Rock Zhang

Merge branch 'feature/cart' of git.dev.yoho.cn:web/yohobuy into feature/cart

... ... @@ -1261,7 +1261,7 @@
chosed: true,
name: '黄色',
colorNum:10,
shortUrl:'',
sizeNumStr:'10/20/30' //对应的商品尺码数目,用斜杠分割
},
...
... ... @@ -1271,7 +1271,8 @@
id: 2,
chosed: true,
name: 'X',
sizeNum: 2
sizeNum: 2,
colorNumStr:'10/20/30' //对应的商品颜色数目用斜杠分割
},
...
],
... ...
... ... @@ -5,6 +5,7 @@
*/
var $ = require('jquery'),
lazyLoad = require('yoho.lazyload'),
Hammer = require('yoho.hammer');
var $cartContent = $('.cart-content');
... ... @@ -13,6 +14,8 @@ var navHammer;
require('./good');
lazyLoad($('img.lazy'));
navHammer = new Hammer(document.getElementsByClassName('cart-nav')[0]);
navHammer.on('tap', function(e) {
var $this = $(e.target).closest('li');
... ...
... ... @@ -58,21 +58,51 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
}).on('touchstart', '#chose-btn-sure', function() {
//确定
}).on('touchstart', '.block', function() {
}).on('touchstart', '.block', function(e) {
//尺寸颜色点选
var $this = $(this);
if ($this.hasClass('.chosed') || $this.hasClass('disable')) {
var $this = $(this),
$that = $(e.target).closest('.chose-items'),
numArray,
index;
if ($this.hasClass('chosed')) {
$this.parent().find('.block').removeClass('chosed');
$that.find('.num .left-num').html('');
} else if ($this.hasClass('disable')) {
$this.css('background-color', '#000');
return;
} else if (!$this.hasClass('chosed')) {
$this.siblings('.chosed').removeClass('chosed');
$this.addClass('chosed');
index = $this.index();
//根据颜色切换图片
if ($this.closest('.block-list').hasClass('color-list')) {
$('.chose-panel .basic-info').find('.thumb').addClass('hide').eq(index).removeClass('hide');
}
//剩余的商品数
if ($that.find('.color-list ul>li').hasClass('chosed') && $that.find('.size-list ul>li').hasClass('chosed')) {
numArray = $this.closest('.block-list').siblings(':first').find('.chosed').data('numstr').split('/');
$that.find('.num .left-num').html('剩余' + numArray[index] + '件');
} else {
$that.find('.num .left-num').html('');
}
//点击切换
}
$this.siblings('.chosed').removeClass('chosed');
$this.addClass('chosed');
}).on('touchstart', '.btn-minus', function() {
var num = +$num.val();
if (num === 1) {
//若颜色和尺码没有被同时选中,则不能点击
if ($('.block-list>ul>li.chosed').length < 2) {
return;
}
if (num === 0) {
return;
}
... ... @@ -80,6 +110,11 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
}).on('touchstart', '.btn-plus', function() {
var num = +$num.val();
//若颜色和尺码没有被同时选中,则不能点击
if ($('.block-list>ul>li.chosed').length < 2) {
return;
}
//TODO:库存数验证
$num.val(num + 1);
});
... ...
... ... @@ -8,78 +8,151 @@ var $ = require('jquery'),
ellipsis = require('mlellipsis'),
lazyLoad = require('yoho.lazyload');
var chosePanel = require('./chose-panel');
var dialog = require('../me/dialog'),
tip = require('../plugin/tip');
var $curDelPanel;
var $names;
//删除面板显示后任何点击行为都将触发隐藏面板
function docTouchEvt() {
$curDelPanel && $curDelPanel.addClass('hide');
//chosePanel = require('./chose-panel');
//
$(document).off('touchstart', docTouchEvt);
}
var cartType = 'ordinary';
//var $curDelPanel;
////删除面板显示后任何点击行为都将触发隐藏面板
//function docTouchEvt() {
// $curDelPanel && $curDelPanel.addClass('hide');
//
// //
// $(document).off('touchstart', docTouchEvt);
//}
ellipsis.init();
lazyLoad($('.lazy'));
lazyLoad({
try_again_css: 'order-failure'
});
$('.name')[0].mlellipsis(2);
$names = $('.name');
if ($names.length > 0) {
$names[0].mlellipsis(2);
}
//TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods
$('.cart-goods').on('touchstart', '.checkbox', function() {
var $this = $(this);
if ($this.hasClass('icon-cb-checked')) {
$this.removeClass('icon-cb-checked').addClass('icon-checkbox');
} else {
$this.removeClass('icon-checkbox').addClass('icon-cb-checked');
}
}).on('touchstart', '.icon-edit', function() {
var id = $(this).closest('.shopping-cart-good').data('id');
var $this = $(this),
id = $(this).closest('.shopping-cart-good').data('id');
$.ajax({
type: 'GET',
url: '/shoppingCart/goodinfo',
url: '/shoppingCart/select',
data: {
id: id
},
success: function(data) {
if (data.code === 200) {
chosePanel.show(data.data);
}
}).then(function(data) {
if (data.code === 200) {
if ($this.hasClass('icon-cb-checked')) {
$this.removeClass('icon-cb-checked').addClass('icon-checkbox');
} else {
$this.removeClass('icon-checkbox').addClass('icon-cb-checked');
}
}
$.ajax({
type: 'GET',
url: '/shoppingCart/getCartData',
data: {
id: id
},
success: function(data) {
if (data) {
$('#good-totalprice').html('¥' + data.commonCart.price);
$('#good-activityPrice').html('¥' + data.commonCart.activityPrice);
$('#good-total').html(data.commonCart.count + '件总计:¥' + data.commonCart.sumPrice);
}
},
error: function() {
tip.show('网络错误');
}
});
}).fail(function() {
tip.show('网络错误');
});
}).on('touchstart', '.icon-edit', function() {
}).on('touchstart', '.icon-del', function(e) {
var $this = $(this);
e.stopPropagation();
//手动触发docTouchEvt清除因点击到del按钮上而被阻止冒泡到doc上的事件从而清除已打开的删除面板
docTouchEvt();
$curDelPanel = $(this).closest('.shopping-cart-good').children('.opt-panel').removeClass('hide');
$(document).on('touchstart', docTouchEvt);
}).on('touchstart', '.opt-panel', function() {
var $this = $(this),
id = $this.closest('.shopping-cart-good').data('id'),
url;
if ($this.closest('.put-in-favorite').length > 0) {
//移入收藏夹
url = '/shoppingCart/col';
} else {
//删除
url = '/shoppingCart/del';
}
//docTouchEvt();
//
//$curDelPanel = $(this).closest('.shopping-cart-good').children('.opt-panel').removeClass('hide');
//
//$(document).on('touchstart', docTouchEvt);
$.ajax({
type: 'POST',
url: url,
data: {
id: id
dialog.showDialog({
dialogText: '您确定要从购物车中删除吗?',
hasFooter: {
leftBtnText: '取消',
rightBtnText: '确定'
}
}, function() {
var id = $this.closest('.shopping-cart-good').data('id');
$.ajax({
method: 'post',
url: '/shoppingCart/del',
data: {
id: id
}
}).then(function(data) {
if (data.code === 200) {
dialog.showDialog({
dialogText: '删除成功',
autoHide: true,
fast: true
});
history.go(0);
}
}).fail(function() {
dialog.showDialog({
autoHide: true,
dialogText: '网络错误~'
});
});
});
});
// .on('touchstart', '.opt-panel', function() {
// var $this = $(this),
// id = $this.closest('.shopping-cart-good').data('id'),
// url;
//
// if ($this.closest('.put-in-favorite').length > 0) {
//
// //移入收藏夹
// url = '/shoppingCart/col';
// } else {
//
// //删除
// url = '/shoppingCart/del';
// }
//
// $.ajax({
// type: 'POST',
// url: url,
// data: {
// id: id
// }
// });
//})
$('.btn-balance').on('touchend', function() {
window.location.href = '/shoppingCart/orderEnsure?cartType=' + cartType;
});
... ...
... ... @@ -79,6 +79,11 @@
left: 0;
top: 20rem / $pxConvertRem;
}
>span.left-num{
position: absolute;
left: pxToRem(380px);
top: 20rem / $pxConvertRem;
}
}
.block {
... ... @@ -99,6 +104,11 @@
background-position: bottom right;
color: #e10;
}
&.disable {
color: #e0e0e0;
border-color: #e0e0e0;
}
}
.num {
... ...
... ... @@ -32,26 +32,26 @@
<div class="price-compute">
<p class="sum-price">
<span class="title">总价</span>
¥{{price}}
<span id="good-totalprice">¥{{price}}</span>
</p>
<p class="activity-price">
<span class="title">
活动价
<i class="minus">-</i>
</span>
¥{{activityPrice}}
<span id="good-activityPrice">¥{{activityPrice}}</span>
</p>
</div>
<div class="balance">
<span class="iconfont icon-cb-checked"></span>
<p>
<span>
<span id="good-total">
{{count}}件总计:¥{{sumPrice}}
</span>
<span class="tip">(不含运费)</span>
</p>
<button class="btn-balance">
<a class="btn-balance">
结算
</button>
</a>
</div>
\ No newline at end of file
... ...
... ... @@ -3,7 +3,13 @@
<div class="main">
<div class="infos">
<div class="basic-info">
<img class="thumb" src={{thumb}}>
{{#thumbs}}
{{#if @first}}
<img class="thumb" src={{img}}>
{{else}}
<img class="thumb hide" src={{img}}>
{{/if}}
{{/thumbs}}
<div class="text-info">
<p class="name">{{name}}</p>
<p class="price">
... ... @@ -15,21 +21,21 @@
</div>
</div>
<div class="chose-items">
<div class="color-list">
<div class="color-list block-list">
<span>颜色</span>
<ul class="clearfix" data-type="color">
{{# colors}}
<li class="block {{#if chosed}}chosed{{/if}}" data-id={{id}}>
<li class="block {{#if chosed}}chosed{{/if}} {{#unless colorNum}}disable{{/unless}}" data-id={{id}} data-numstr="{{sizeNumStr}}">
{{name}}
</li>
{{/ colors}}
</ul>
</div>
<div class="size-list">
<div class="size-list block-list">
<span>尺码</span>
<ul class="clearfix {{#if @first}}{{^}}hide{{/if}}" data-type="size" >
<ul class="clearfix" data-type="size" >
{{# sizes}}
<li class="block {{#if chosed}}chosed{{/if}}" data-id={{id}}>
<li class="block {{#if chosed}}chosed{{/if}} {{#unless sizeNum}}disable{{/unless}}" data-id={{id}} data-numstr="{{colorNumStr}}">
{{name}}
</li>
{{/ sizes}}
... ... @@ -44,8 +50,9 @@
<input id="good-num" class="good-num" type="text" value={{num}}>
<a class="btn btn-plus" href="javascript:void(0);">
<span class="iconfont">&#xe624;</span>
</a>
</a>
</div>
<span class="left-num"></span>
</div>
</div>
</div>
... ...
... ... @@ -22,6 +22,9 @@
<span class="price">
¥{{price}}
</span>
<span class="price">
¥{{salePrice}}
</span>
<span class="count">
×{{count}}
</span>
... ...
... ... @@ -51,7 +51,7 @@
</p>
</div>
</div>
<div class="opt-panel hide">
<!--<div class="opt-panel hide">
<div class="put-in-favorite">
<span class="iconfont">&#xe622;</span>
<span>移入</span>
... ... @@ -61,5 +61,5 @@
<span class="iconfont">&#xe626;</span>
删除
</div>
</div>
</div>-->
</div>
... ...
... ... @@ -883,6 +883,7 @@ class HomeController extends AbstractAction
{
$this->setTitle('YOHO币');
$this->setNavHeader('YOHO币', true, false);
$data['money'] = '0';
$page = $this->post('page',1);
$size = $this->post('size', 20);
... ... @@ -907,7 +908,7 @@ class HomeController extends AbstractAction
$page = $this->post('page',1);
$size = $this->post('size', 20);
$data = UserModel::getYohoCoinLists($this->_uid,$page,$size);
// $data = UserModel::getYohoCoinLists(3965746,$page,$size);
//$data = UserModel::getYohoCoinLists(3965746,$page,$size);
$this->_view->display('ajax-currency-detail', array(
'currency' => $data['list'],
'pageFooter' => true,
... ...
... ... @@ -383,15 +383,17 @@ class UserModel
// 调用接口获取YOHO币
$yohoCoin = UserData::yohoCoinData($uid, $page, $limit, 'post');
// 处理YOHO币数据
$coinList = $yohoCoin['data']['coinlist'];
$data['money'] = $yohoCoin['data']['total'];
foreach($coinList as $key => $val){
$result[$key]['title'] = $val['message'];
$result[$key]['time'] = $val['date'];
if($val['num'] > 0){
$val['num'] = '+'.$val['num'];
if(isset($yohoCoin['data']) && !empty($yohoCoin['data'])){
$coinList = $yohoCoin['data']['coinlist'];
$data['money'] = $yohoCoin['data']['total'];
foreach($coinList as $key => $val){
$result[$key]['title'] = $val['message'];
$result[$key]['time'] = $val['date'];
if($val['num'] > 0){
$val['num'] = '+'.$val['num'];
}
$result[$key]['count'] = $val['num'];
}
$result[$key]['count'] = $val['num'];
}
$data['list'] = $result;
return $data;
... ...
... ... @@ -56,8 +56,8 @@ class BindController extends AbstractAction
$nickname = $this->get('nickname');
$areaCode = $this->get('areaCode', '86');
$isReg = $this->get('isReg');
$mobile=$this->get('mobile');
$phoneNum=$this->get('phoneNum');
$data = array(
'bindIndex'=>true,//js标识
'backUrl' => '/', // 返回的URL链接
... ... @@ -68,7 +68,7 @@ class BindController extends AbstractAction
'nickname' => $nickname, //昵称
'isReg' => $isReg, //是否是已注册过的手机号
'areaCode' => $areaCode, //国别码
'phoneNum'=>$mobile,//手机号码
'phoneNum'=>$phoneNum,//手机号码
);
// 渲染模板
... ... @@ -114,31 +114,31 @@ class BindController extends AbstractAction
break;
}
$mobile = $this->post('mobile');
$phoneNum = $this->post('phoneNum');
$openId = $this->post('openId');
$areaCode = $this->post('areaCode', '86');
$sourceType = $this->post('sourceType');
$nickname = $this->post('nickname');
if (!is_numeric($mobile) || !$openId || !$areaCode || !$sourceType)
if (!is_numeric($phoneNum) || !$openId || !$areaCode || !$sourceType)
{
break;
}
$res = BindData::bindCheck($mobile, $openId, $sourceType);
$res = BindData::bindCheck($phoneNum, $openId, $sourceType);
if (!isset($res['code']))
{
break;
}
if ($res['code'] == 200)
{
$next = Helpers::url('/passport/bind/code', array('isReg' => $res['data']['is_register'], 'openId' => $openId, 'sourceType' => $sourceType, 'nickname' => $nickname, 'areaCode' => $areaCode, 'mobile' => $mobile));
$next = Helpers::url('/passport/bind/code', array('isReg' => $res['data']['is_register'], 'openId' => $openId, 'sourceType' => $sourceType, 'nickname' => $nickname, 'areaCode' => $areaCode, 'phoneNum' => $phoneNum));
$data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('isReg' => $res['data']['is_register'], 'next' => $next));
}
else
{
$data = array('code' => 500, 'message' => $res['message'], 'data' => $res['data']);
$data = array('code' => $res['code'], 'message' => $res['message'], 'data' => $res['data']);
}
}
while (false);
... ... @@ -159,15 +159,15 @@ class BindController extends AbstractAction
break;
}
$mobile = $this->post('mobile');
$phoneNum = $this->post('phoneNum');
$areaCode = $this->post('areaCode');
if (!is_numeric($mobile))
if (!is_numeric($phoneNum))
{
break;
}
$data = BindData::sendBindMsg($areaCode,$mobile);
$data = BindData::sendBindMsg($areaCode,$phoneNum);
if (!isset($data['code']))
{
break;
... ... @@ -191,16 +191,16 @@ class BindController extends AbstractAction
break;
}
$mobile = $this->post('mobile');
$phoneNum = $this->post('phoneNum');
$msgCode = $this->post('msgCode');
$areaCode = $this->post('areaCode');
if (!is_numeric($mobile) || !$msgCode)
if (!is_numeric($phoneNum) || !$msgCode)
{
break;
}
$data = BindData::checkBindCode($areaCode,$mobile, $msgCode);
$data = BindData::checkBindCode($areaCode,$phoneNum, $msgCode);
if (!isset($data['code']))
{
break;
... ... @@ -224,19 +224,19 @@ class BindController extends AbstractAction
break;
}
$mobile = $this->post('mobile');
$phoneNum = $this->post('phoneNum');
$openId = $this->post('openId');
$areaCode = $this->post('areaCode', '86');
$sourceType = $this->post('sourceType');
$nickname = $this->post('nickname');
$password = $this->post('password');
if (!is_numeric($mobile) || !$openId || !$sourceType || !$areaCode)
if (!is_numeric($phoneNum) || !$openId || !$sourceType || !$areaCode)
{
break;
}
$res = BindData::bindMobile($openId, $nickname, $sourceType, $mobile, $areaCode, $password);
$res = BindData::bindMobile($openId, $nickname, $sourceType, $phoneNum, $areaCode, $password);
if (!isset($res['code']))
{
break;
... ...