Authored by Lynnic

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

... ... @@ -8,6 +8,7 @@ var $ = require('jquery'),
lazyLoad = require('yoho.lazyload'),
Handlebars = require('yoho.handlebars'),
tip = require('../plugin/tip'),
loading = require('../plugin/loading'),
chosePanel = require('./chose-panel');
var panelTmpl,
... ... @@ -27,6 +28,7 @@ $.get('/cart/index/giftinfoTpl', function(html) {
});
function getProductInfo(skn, promotionId) {
loading.showLoadingMask();
$.get('/cart/index/giftinfo', {
skn: skn,
promotionId: promotionId
... ... @@ -48,6 +50,8 @@ function getProductInfo(skn, promotionId) {
}
}).fail(function() {
tip.show('网络错误');
}).always(function() {
loading.hideLoadingMask();
});
}
... ...
... ... @@ -29,16 +29,56 @@ if ($names.length > 0) {
$names[0].mlellipsis(2);
}
//获取当前购物车类型
function getCartType() {
var $navItem = $('.cart-nav ').find('li'),
type = 'ordinary';
if ($navItem.eq(0).hasClass('active')) {
type = 'ordinary';
} else {
type = 'advance';
}
return type;
}
//TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods
$('.cart-goods').on('touchstart', '.checkbox', function() {
var $this = $(this),
id = $(this).closest('.shopping-cart-good').data('id');
$good = $this.closest('.shopping-cart-good'),
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.goods_type = getCartType();
goodInfo.selected = isSelected ? 'Y' : 'N';
goodInfo.product_sku = id;
goodInfo.buy_number = $good.find('.count').eq(0).text().trim().replace('×', '');
goodsList.push(new GoodInfo(goodInfo));
$.ajax({
type: 'GET',
url: '/cart/index/select',
type: 'post',
url: 'select',
data: {
id: id
skuList: JSON.stringify(goodsList)
}
}).then(function(data) {
if (data.code === 200) {
... ... @@ -49,9 +89,9 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
}
$.ajax({
type: 'GET',
url: '/cart/index/getCartData',
url: 'getCartData',
data: {
skuList: JSON.stringfy(id)
id: id
},
success: function(data) {
if (data) {
... ... @@ -64,7 +104,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
tip.show('网络错误');
}
});
} else if (data.code === 200) {
} else if (data.code === 400) {
tip.show('网络错误');
}
}).fail(function() {
... ... @@ -95,13 +135,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
e.stopPropagation();
//手动触发docTouchEvt清除因点击到del按钮上而被阻止冒泡到doc上的事件从而清除已打开的删除面板
//docTouchEvt();
//
//$curDelPanel = $(this).closest('.shopping-cart-good').children('.opt-panel').removeClass('hide');
//
//$(document).on('touchstart', docTouchEvt);
dialog.showDialog({
dialogText: '您确定要从购物车中删除吗?',
hasFooter: {
... ... @@ -136,30 +169,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
});
// .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
// }
// });
//})
function requestUpdateAllGoodsCheckStatus(theGoods, successHandeler) {
if (requesting) {
return;
... ... @@ -236,24 +245,11 @@ function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) {
goodsList.push(new GoodInfo(goodInfo));
});
console.log(goodsList);
requestUpdateAllGoodsCheckStatus(goodsList, handlerAfterTouch);
}
//获取当前购物车类型
function getCartType() {
var $navItem = $('.cart-nav ').find('li'),
type = 'ordinary';
if ($navItem.eq(0).hasClass('active')) {
type = 'ordinary';
} else {
type = 'advance';
}
return type;
}
//是否要全选
function willBeSelected() {
... ...
... ... @@ -43,6 +43,8 @@ function request() {
requesting = false;
end = true;
window.rePosFooter();
}).fail(function() {
$recommendForYou.hide();
});
... ... @@ -50,7 +52,7 @@ function request() {
}
function scrollHandler() {
if (!end || $(window).scrollTop() + winH >= $(document).height() - 50) {
if (!end || $(window).scrollTop() + winH >= $(document).height() - 200) {
request();
}
}
... ...
... ... @@ -15,7 +15,7 @@
}
.help {
padding: 30px 30px;
font-size: 16px;
font-size: 24px;
line-height: 1.5;
color: #444;
}
... ... @@ -36,8 +36,7 @@
</ul>
<p>其他说明:</p>
<ul>
<li>1. YOHO!BUY有货对用户在本站进行晒单评价的文字、图片享有使用权利;</li>
<li>2. 用户所晒单评价的文字、图片提交发布后,默认同步YOHO!SHOW平台;</li>
<li>YOHO!BUY有货对用户在本站进行晒单评价的文字、图片享有使用权利</li>
</ul>
</div>
</body>
... ...
... ... @@ -3,9 +3,9 @@
{{> cart/good}}
{{/ goods}}
{{# $notValidGoods}}
{{# notValidGoods}}
{{> cart/good}}
{{/ $notValidGoods}}
{{/ notValidGoods}}
</div>
... ...
... ... @@ -5,8 +5,8 @@
<a class="swiper-slide" href="{{url}}">
<img class="swiper-lazy img-box" data-src="{{thumb}}">
<div class="price">
<span class="sale-price {{^price}}no-price{{/price}}">¥{{salePrice}}</span>
{{#price}}<span class="old-price">¥{{.}}</span>{{/price}}
<span class="sale-price {{^price}}no-price{{/price}}">&yen;{{salePrice}}</span>
{{#price}}<span class="old-price">&yen;{{.}}</span>{{/price}}
</div>
<div class="swiper-lazy-preloader"></div>
</a>
... ...
... ... @@ -218,7 +218,7 @@ class OrderModel
//已发货状态,给查看物流URL
$result['unreceived'] = true;
$result['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $order['order_code']));
if ($showLogistics) {
if ($showLogistics && isset($order['caption'])) {
$result['logisticsCompany'] = $order['caption'];
$result['logisticsNum'] = $order['express_number'];
}
... ... @@ -248,9 +248,9 @@ class OrderModel
//待收货状态,给查看物流url
$result['unreceived'] = true;
$result['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $order['order_code']));
if ($showLogistics) {
$result['logisticsCompany'] = isset($order['caption']) ? $order['caption'] : '';
$result['logisticsNum'] = isset($order['express_number']) ? $order['express_number'] : '';
if ($showLogistics && isset($order['caption'])) {
$result['logisticsCompany'] = $order['caption'];
$result['logisticsNum'] = $order['express_number'];
}
break;
case 6:
... ...
... ... @@ -646,7 +646,7 @@ class CartModel
// 缩略图
foreach ($val['images_list'] as $image) {
$thumbImageList[] = array(
'img' => Helpers::getImageUrl($image['image_url'], 60, 60)
'img' => Helpers::getImageUrl($image['image_url'], 80, 106)
);
}
... ...
... ... @@ -241,7 +241,7 @@ class DetailModel
'numInCart' => 0,
'goodsInstore' => $baseInfo['storage'], // 库存量
);
$soldOut = $totalStorageNum === 0;
$soldOut = ($baseInfo['storage'] == 0) || ($totalStorageNum === 0);
$notForSale = $baseInfo['attribute'] == 2;
// 显示加入购物车链接
if (!$soldOut && !$notForSale) {
... ... @@ -346,7 +346,7 @@ class DetailModel
$referenceList = array();
// 判断是否显示参考尺码
$showReference = $boyReference || $girlReference;
$showReference = ($boyReference && !empty($sizeInfo['sizeInfoBo']['sizeBoList'][0]['boyReferSize'])) || ($girlReference && !empty($sizeInfo['sizeInfoBo']['sizeBoList'][0]['girlReferSize']) );
if ($showReference) {
$referenceList[0] = array('param' => $referenceName);
}
... ...
... ... @@ -49,6 +49,7 @@ class IndexController extends AbstractAction
// 渲染模板
$this->_view->display('index', $data);
}
/*
* 异步获取购物车数据
*/
... ... @@ -80,7 +81,7 @@ class IndexController extends AbstractAction
if ($this->isAjax()) {
$productId = $this->post('skuList', 0);
$uid = $this->getUid(true);
$shoppingKey = $this->getSession('shoppingKey');
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = CartModel::selectGoods($uid, $productId, $shoppingKey);
}
... ... @@ -101,7 +102,7 @@ class IndexController extends AbstractAction
if ($this->isAjax()) {
$productId = $this->post('id', 0);
$uid = $this->getUid(true);
$shoppingKey = $this->getSession('shoppingKey');
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = CartModel::removeFromCart($uid, $productId, $shoppingKey);
}
... ... @@ -192,6 +193,7 @@ class IndexController extends AbstractAction
/*
* 获取购物车加价购商品数据模板
* 需要返回模板的html代码,不能渲染
*/
public function giftinfoTplAction()
{
... ... @@ -207,11 +209,11 @@ class IndexController extends AbstractAction
{
$result = array();
// if ($this->isAjax()) {
if ($this->isAjax()) {
$skn = $this->get('skn', null);
$promotionId = $this->get('promotionId', null);
$result = CartModel::giftProductData($skn, $promotionId);
// }
}
if (empty($result)) {
echo ' ';
... ... @@ -228,7 +230,7 @@ class IndexController extends AbstractAction
$result = array();
if ($this->isAjax()) {
$shoppingKey = $this->getSession('shoppingKey');
$shoppingKey = Helpers::getShoppingKeyByCookie();
$uid = $this->getUid(true);
$sku= $this->post('sku', 0);
... ... @@ -252,7 +254,7 @@ class IndexController extends AbstractAction
$result = array();
if ($this->isAjax()) {
$shoppingKey = $this->getSession('shoppingKey');
$shoppingKey = Helpers::getShoppingKeyByCookie();
$uid = $this->getUid(true);
$params = array();
... ...
... ... @@ -17,8 +17,7 @@ class BindController extends AbstractAction
public function indexAction()
{
$refer = $this->get('refer');
if (!empty($refer))
{
if (!empty($refer)) {
$this->setCookie('refer', $refer);
}
... ... @@ -28,15 +27,15 @@ class BindController extends AbstractAction
$sourceType = $this->get('sourceType');
$nickname = $this->get('nickname');
$data = array(
'bindIndex'=>true,//js标识
'backUrl' => '/', // 返回的URL链接
'bindIndex' => true, //js标识
'backUrl' => Helpers::url('/signin.html'), // 返回的URL链接
'showHeaderImg' => true, // 控制显示头部图片
'isPassportPage' => true, // 模板中模块标识
'sourceType' => $sourceType, // 第三方登录来源
'platform'=>$sourceType,
'platform' => $sourceType,
'openId' => $openId, // openId
'areaCode'=>'+86',//默认区号
'countrys'=>RegData::getAreasData(),//国别码
'areaCode' => '+86', //默认区号
'countrys' => RegData::getAreasData(), //国别码
'nickname' => $nickname, //昵称
);
... ... @@ -49,18 +48,17 @@ class BindController extends AbstractAction
*/
public function codeAction()
{
$this->setTitle('验证手机');
$openId = $this->get('openId');
$sourceType = $this->get('sourceType');
$nickname = $this->get('nickname');
$areaCode = $this->get('areaCode', '86');
$isReg = $this->get('isReg');
$phoneNum=$this->get('phoneNum');
$phoneNum = $this->get('phoneNum');
$data = array(
'bindCode'=>true,//js标识
'backUrl' => '/', // 返回的URL链接
'bindCode' => true, //js标识
'backUrl' => Helpers::url('/signin.html'), // 返回的URL链接
'showHeaderImg' => true, // 控制显示头部图片
'isPassportPage' => true, // 模板中模块标识
'sourceType' => $sourceType, // 第三方登录来源
... ... @@ -68,7 +66,7 @@ class BindController extends AbstractAction
'nickname' => $nickname, //昵称
'isReg' => $isReg, //是否是已注册过的手机号
'areaCode' => $areaCode, //国别码
'phoneNum'=>$phoneNum,//手机号码
'phoneNum' => $phoneNum, //手机号码
);
// 渲染模板
... ... @@ -80,16 +78,15 @@ class BindController extends AbstractAction
*/
public function passwordAction()
{
$this->setTitle('重新设置登录密码');
$openId = $this->get('openId');
$sourceType = $this->get('sourceType');
$nickname = $this->get('nickname');
$areaCode = $this->get('areaCode', '86');
$phoneNum=$this->get('phoneNum');
$phoneNum = $this->get('phoneNum');
$data = array(
'bindPwd'=>true,//js标识
'backUrl' => '/', // 返回的URL链接
'bindPwd' => true, //js标识
'backUrl' => Helpers::url('/signin.html'), // 返回的URL链接
'showHeaderImg' => true, // 控制显示头部图片
'isPassportPage' => true, // 模板中模块标识
'sourceType' => $sourceType, // 第三方登录来源
... ... @@ -108,11 +105,9 @@ class BindController extends AbstractAction
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do
{
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax())
{
if (!$this->isAjax()) {
break;
}
... ... @@ -123,27 +118,21 @@ class BindController extends AbstractAction
$nickname = $this->post('nickname');
if (!is_numeric($phoneNum) || !$openId || !$areaCode || !$sourceType)
{
if (!is_numeric($phoneNum) || !$openId || !$areaCode || !$sourceType) {
break;
}
$res = BindData::bindCheck($phoneNum, $openId, $sourceType);
if (!isset($res['code']))
{
if (!isset($res['code'])) {
break;
}
if ($res['code'] == 200)
{
if ($res['code'] == 200) {
$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' => $res['code'], 'message' => $res['message'], 'data' => isset($res['data']) ? $res['data'] : '');
}
else
{
$data = array('code' => $res['code'], 'message' => $res['message'], 'data' => isset($res['data'])?$res['data']:'');
}
}
while (false);
} while (false);
$this->echoJson($data);
}
... ... @@ -153,29 +142,24 @@ class BindController extends AbstractAction
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do
{
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax())
{
if (!$this->isAjax()) {
break;
}
$phoneNum = $this->post('phoneNum');
$areaCode = $this->post('areaCode');
if (!is_numeric($phoneNum))
{
if (!is_numeric($phoneNum)) {
break;
}
$data = BindData::sendBindMsg($areaCode,$phoneNum);
if (!isset($data['code']))
{
$data = BindData::sendBindMsg($areaCode, $phoneNum);
if (!isset($data['code'])) {
break;
}
}
while (false);
} while (false);
$this->echoJson($data);
}
... ... @@ -185,11 +169,9 @@ class BindController extends AbstractAction
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do
{
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax())
{
if (!$this->isAjax()) {
break;
}
... ... @@ -197,18 +179,15 @@ class BindController extends AbstractAction
$code = $this->post('code');
$areaCode = $this->post('areaCode');
if (!is_numeric($phoneNum) || !$code)
{
if (!is_numeric($phoneNum) || !$code) {
break;
}
$data = BindData::checkBindCode($areaCode,$phoneNum, $code);
if (!isset($data['code']))
{
$data = BindData::checkBindCode($areaCode, $phoneNum, $code);
if (!isset($data['code'])) {
break;
}
}
while (false);
} while (false);
$this->echoJson($data);
}
... ... @@ -218,11 +197,9 @@ class BindController extends AbstractAction
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do
{
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax())
{
if (!$this->isAjax()) {
break;
}
... ... @@ -233,42 +210,33 @@ class BindController extends AbstractAction
$nickname = $this->post('nickname');
$password = $this->post('password');
if (!is_numeric($phoneNum) || !$openId || !$sourceType || !$areaCode)
{
if (!is_numeric($phoneNum) || !$openId || !$sourceType || !$areaCode) {
break;
}
$res = BindData::bindMobile($openId, $nickname, $sourceType, $phoneNum, $areaCode, $password);
if (!isset($res['code']))
{
if (!isset($res['code'])) {
break;
}
//绑定成功,跳转页面
$refer = $this->getCookie('refer');
if (empty($refer))
{
if (empty($refer)) {
$refer = SITE_MAIN . '/?go=1';
}
else
{
} else {
$refer = rawurldecode($refer);
}
if (isset($res['code']) && $res['code'] == 200 && !empty($res['data']['uid']))
{
if (isset($res['code']) && $res['code'] == 200 && !empty($res['data']['uid'])) {
$token = Helpers::makeToken($res['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->setSession('_TOKEN', $token);
$refer = Helpers::syncUserSession($res['data']['uid'], $refer);
$data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('refer' => $refer));
}
else
{
} else {
$data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('refer' => $refer));
}
}
while (false);
} while (false);
$this->echoJson($data);
}
... ...
... ... @@ -79,7 +79,7 @@ class LoginController extends AbstractAction
$refer = $this->server('HTTP_REFERER', SITE_MAIN);
$token = $this->get('token');
if (!empty($token)) {
$this->go( Helpers::logoutSession($token, $refer) );
$this->go(Helpers::logoutSession($token, $refer));
}
$this->go($refer);
... ... @@ -184,10 +184,8 @@ class LoginController extends AbstractAction
}
//判定是否需要绑定手机号
$isBind = $result['data']['is_bind'];
if ($isBind == 'N')
{
$this->go(Helpers::url('/passport/bind/index',array('openId'=>$userId,'sourceType'=>'alipay','nickname'=>$realName)));
if (isset($result['data']['is_bind']) && $result['data']['is_bind'] == 'N') {
$this->go(Helpers::url('/passport/bind/index', array('openId' => $userId, 'sourceType' => 'alipay', 'nickname' => $realName)));
}
$refer = $this->getCookie('refer');
... ... @@ -217,37 +215,29 @@ class LoginController extends AbstractAction
/* 获取QQ腾讯用户的详细信息 */
$partnerInfo = $qqconnect->getUserInfo($access);
$result = array();
if (!empty($partnerInfo) && isset($partnerInfo['nickname']))
{
if (!empty($partnerInfo) && isset($partnerInfo['nickname'])) {
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq');
}
//判定是否需要绑定手机号
$isBind = $result['data']['is_bind'];
if ($isBind == 'N')
{
$this->go(Helpers::url('/passport/bind/index',array('openId'=>$access['openid'],'sourceType'=>'qq','nickname'=>$partnerInfo['nickname'])));
if ($isBind == 'N') {
$this->go(Helpers::url('/passport/bind/index', array('openId' => $access['openid'], 'sourceType' => 'qq', 'nickname' => $partnerInfo['nickname'])));
}
$refer = $this->getCookie('refer');
if (empty($refer))
{
if (empty($refer)) {
$refer = SITE_MAIN . '/?go=1';
}
else
{
} else {
$refer = rawurldecode($refer);
}
if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid']))
{
if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) {
$token = Helpers::makeToken($result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->setSession('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
}
else
{
} else {
$this->go($refer);
}
}
... ... @@ -268,9 +258,8 @@ class LoginController extends AbstractAction
}
//判定是否需要绑定手机号
$isBind = $result['data']['is_bind'];
if ($isBind == 'N')
{
$this->go(Helpers::url('/passport/bind/index',array('openId'=>$access['uid'],'sourceType'=>'sina','nickname'=>$partnerInfo['screen_name'])));
if ($isBind == 'N') {
$this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['screen_name'])));
}
$refer = $this->getCookie('refer');
... ...