Authored by biao

resolve confilct

... ... @@ -443,13 +443,13 @@ class Helpers
* @param string $areaMobile
* @return boolean
*/
public static function verifyAreaMobile($areaMobile)
public static function verifyAreaMobile($areaMobile, $area)
{
if (empty($areaMobile)) {
return false;
}
if (!strpos($areaMobile, '-')) {
return self::areaMobielVerify($areaMobile);
return self::areaMobielVerify($areaMobile, $area);
} else {
$mobileData = explode('-', $areaMobile);
if (count($mobileData) != 2) {
... ... @@ -601,7 +601,7 @@ class Helpers
}
/**
* 格式化加价购商品
* 格式化加价购和赠品商品
*
* @param array $advanceGoods 加价购商品列表
* @param int $count 计商品件数
... ... @@ -615,6 +615,7 @@ class Helpers
$oneGoods = array();
foreach ($advanceGoods as $value) {
$gift = array();
$gift['promotionId'] = $value['promotion_id'];
$gift['promotionTitle'] = $value['promotion_title'];
foreach ($value['goods_list'] as $single) {
... ...
... ... @@ -8,13 +8,13 @@ var $ = require('jquery'),
lazyLoad = require('yoho.lazyload'),
Hammer = require('yoho.hammer');
var chosePanel = require('./chose-panel'),
cartInfo = require('./cart-info').cartInfo;
var chosePanel = require('./chose-panel');
var $cartContent = $('.cart-content');
var navHammer,
cartType = 'ordinary';
cartType = 'ordinary',
cartInfo;
require('./good');
... ... @@ -28,6 +28,12 @@ navHammer.on('tap', function(e) {
return;
}
if (cartType === 'ordinary') {
cartType = 'advance';
} else {
cartType = 'ordinary';
}
$this.siblings('.active').removeClass('active');
$this.addClass('active');
... ... @@ -41,7 +47,7 @@ navHammer.on('tap', function(e) {
$('.btn-balance').on('touchend', function() {
window.location.href = '/shoppingCart/orderEnsure?cartType=' + cartType;
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
});
//$('.advance-buy').on('touchend', function() {
... ...
... ... @@ -12,7 +12,25 @@ var $ = require('jquery');
// var $page = $('.yoho-page');
var $num,
$chosed;
$chosed,
re = /\d+/,
leftNum,
$colorList = $('.color-list ul>li'),
$sizeList = $('.size-list ul>li'),
firstColorId = $colorList.eq(0).data('id'),
colorIndex;
//初始化购物车面板显示
$sizeList.each(function() {
colorIndex = $(this).data('colorid');
if (colorIndex === firstColorId) {
$(this).removeClass('hide');
}
});
// confirm;
// var tpl;
... ... @@ -35,8 +53,11 @@ var $num,
// $num = $('#good-num');
// }
function show() {
$('.chose-panel').show();
$('body').css('overflow', 'hidden');
$num = $('#good-num');
}
... ... @@ -58,10 +79,43 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
remove();
}).on('touchstart', '#chose-btn-sure', function() {
//确定
}).on('touchstart', '.block', function(e) {
// var productSku,
// buyNumber = $('#good-num') - 0;
// promotionId,
// goodsType,
// isEdit;
// //确定
// $chosed = $('.block-list>ul>li.chosed');
// if (2 === $chosed.length && 2 !== $chosed.closest('.zero-stock').length) {
// if (confirm) {
// return false;
// }
// confirm = true;
// loading.showLoadingMask();
// $.ajax({
// method: 'POST',
// url: '/cart/index/add',
// data: {
// product_id: productId,
// content: content
// }
// }).done(function(res) {
// if (res.code === 200) {
// loading.hideLoadingMask();
// confirm = false;
// remove();
// }
// }).fail(function() {
// tip.show('网络出了点问题~');
// confirm = false;
// });
// }
//尺寸颜色点选
}).on('touchstart', '.block', function(e) {
var $this = $(this),
$that = $(e.target).closest('.chose-items'),
numArray,
... ... @@ -96,6 +150,19 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
}
});
} else if ($chosed.length === 1 && $this.hasClass('chosed')) {
if ($this.closest('.block-list').hasClass('color-list')) {
$sizeList.addClass('hide');
//切换尺码信息
$sizeList.each(function() {
colorIndex = $(this).data('colorid');
if (colorIndex === $this.data('id')) {
$(this).removeClass('hide');
}
});
}
numArray = $chosed.data('numstr').split('/');
$siblingBlock.find('.block').removeClass('zero-stock');
for (i = 0; i < numArray.length; i++) {
... ... @@ -104,6 +171,9 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
}
}
} else if ($chosed.length === 1 && !$this.hasClass('chosed')) {
$('#chose-btn-sure').css('background-color', '#eb0313');
$('#chose-btn-sure').html('确定');
$siblingBlock.find('ul>li').each(function() {
$(this).removeClass('zero-stock');
if (0 === $(this).data('num') - 0) {
... ... @@ -123,19 +193,23 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
if (2 === $chosed.closest('.zero-stock').length) {
$('#chose-btn-sure').css('background-color', '#c0c0c0');
$('#chose-btn-sure').html('已售罄');
} else {
$('#chose-btn-sure').css('background-color', '#eb0313');
$('#chose-btn-sure').html('确定');
}
}
}).on('touchstart', '.btn-minus', function() {
var num = +$num.val(),
$chosed = $('.block-list>ul>li.chosed');
$chosed = $('.block-list>ul>li.chosed'),
leftNum = re.exec($('.num .left-num').html());
//若颜色和尺码没有被同时选中,则不能点击
if ($chosed.length < 2) {
return;
}
if (num === 0) {
if (num === 1 || 0 === leftNum - 0) {
return;
}
... ... @@ -147,6 +221,10 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
if ($('.block-list>ul>li.chosed').length < 2) {
return;
}
leftNum = re.exec($('.num .left-num').html());
if (num - 0 === leftNum - 0 || 0 === leftNum - 0) {
return;
}
//TODO:库存数验证
$num.val(num + 1);
... ...
... ... @@ -5,25 +5,52 @@
*/
var $ = require('jquery'),
lazyLoad = require('yoho.lazyload');
lazyLoad = require('yoho.lazyload'),
Handlebars = require('yoho.handlebars'),
tip = require('../plugin/tip'),
chosePanel = require('./chose-panel');
//var chosePanel = require('./chose-panel');
var panelTmpl,
$page = $('.gift-advance-page'),
$chosePanel = $('#chose-panel');
lazyLoad($('.lazy'));
//$('.gift-advance-page').on('touchstart', '.chose', function() {
// var id = $(this).closest('.gift-advance-good').data('id');
//
// $.ajax({
// type: 'GET',
// url: '/shoppingCart/goodinfo',
// data: {
// id: id
// },
// success: function(data) {
// if (data.code === 200) {
// chosePanel.show(data.data);
// }
// }
// });
//});
\ No newline at end of file
$.get('/cart/index/giftinfoTpl', function(html) {
if (!html) {
tip.show('网络错误');
return;
}
panelTmpl = Handlebars.compile(html);
}).fail(function() {
tip.show('网络错误');
});
function getProductInfo(skn, promotionId) {
$.get('/cart/index/giftinfo', {
skn: skn,
promotionId: promotionId
}).then(function(res) {
if (!res) {
tip.show('网络错误');
return;
}
console.log(res);
if (res.code === 200) {
$chosePanel.html(panelTmpl(res.data));
chosePanel.show();
} else {
tip.show(res.message || '网络错误');
}
}).fail(function() {
tip.show('网络错误');
});
}
$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);
});
... ...
... ... @@ -47,7 +47,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
$.ajax({
type: 'GET',
url: '/shoppingCart/select',
url: '/cart/index/select',
data: {
id: id
}
... ... @@ -61,7 +61,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
}
$.ajax({
type: 'GET',
url: '/shoppingCart/getCartData',
url: '/cart/index/getCartData',
data: {
id: id
},
... ... @@ -82,18 +82,22 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
});
}).on('touchstart', '.icon-edit', function() {
var $this = $(this),
$cartgood = $this.closest('.shopping-cart-good'),
$viewGood = $cartgood.find('.deps'),
$editGoot = $cartgood.find('.calculate-num');
if ($viewGood.hasClass('show')) {
$viewGood.removeClass('show').addClass('hide');
$editGoot.removeClass('hide').addClass('show');
} else {
$viewGood.removeClass('hide').addClass('show');
$editGoot.removeClass('show').addClass('hide');
}
//var $this = $(this);
//
//var $cartgood = $this.closest('.shopping-cart-good');
//
////var id = $this.closest('.shopping-cart-good').data('id');
//
//var $viewGood = $cartgood.find('.deps');
// $editGoot = $cartgood.find('.calculate-num');
//
//if ($viewGood.hasClass('show')) {
// $viewGood.removeClass('show').addClass('hide');
// $editGoot.removeClass('hide').addClass('show');
//} else {
// $viewGood.removeClass('hide').addClass('show');
// $editGoot.removeClass('show').addClass('hide');
//}
}).on('touchstart', '.icon-del', function(e) {
... ... @@ -119,7 +123,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
$.ajax({
method: 'post',
url: '/shoppingCart/del',
url: '/cart/index/del',
data: {
id: id
}
... ... @@ -282,10 +286,6 @@ $selectAllBtn.on('touchend', function() {
$('.btn-balance').on('touchend', function() {
window.location.href = '/shoppingCart/orderEnsure?cartType=' + 'ordinary';
});
$('.down').on('touchend', function() {
chosePanel.show();
});
... ... @@ -294,7 +294,7 @@ $('.cut').on('touchend', function() {
$.ajax({
type: 'GET',
url: '/shoppingCart/modify',
url: '/cart/index/modify',
data: {
old_product_sku: id,
new_product_sku: id,
... ...
... ... @@ -17,7 +17,8 @@ var dispatchModeHammer,
$invoice = $('.invoice'),
$price = $('.price-cal'),
payType,
priceTmpl = Handlebars.compile($('#tmpl-price').html());
priceTmpl = Handlebars.compile($('#tmpl-price').html()),
queryString = $.queryString();
lazyLoad();
... ... @@ -101,7 +102,7 @@ function submitOrder() {
url: '/cart/index/orderSub',
data: {
addressId: orderInfo('addressId'),
cartType: orderInfo('cartType'),
cartType: queryString.cartType || queryString.carttype || 'ordinary',
deliveryId: orderInfo('deliveryId'),
deliveryTimeId: orderInfo('deliveryTimeId'),
invoiceText: $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'),
... ... @@ -132,7 +133,7 @@ function submitOrder() {
window.location.href = url;
} else {
loading.hideLoadingMask();
tip.show(res.messege || '网络出错');
tip.show(res.message || '网络出错');
}
}).fail(function() {
loading.hideLoadingMask();
... ...
... ... @@ -199,9 +199,9 @@ $yohoPage.on('touchstart', '.tap-hightlight', function() {
$(this).removeClass('highlight');
});
$('.nav-home').on('touchstart', function() {
$('.homebuttom').toggleClass('none');
});
// $('.nav-home').on('touchstart', function() {
// $('.homebuttom').toggleClass('none');
// });
(function() {
var lastTime = 0,
... ...
... ... @@ -80,7 +80,7 @@ optHammer.on('tap', function(e) {
} else {
tip.show(res.message || '网络错误');
}
window.location.reload();
window.location.href = '/home/orders';
}).fail(function() {
tip.show('网络错误');
});
... ...
... ... @@ -9,6 +9,7 @@
background: rgba(0,0,0,.3);
z-index:3;
.main {
position: absolute;
height: pxToRem(610px);
... ... @@ -86,6 +87,10 @@
}
}
.size-list li.hide {
display: none;
}
.block {
float: left;
display: block;
... ...
... ... @@ -2,7 +2,7 @@
<div class="gift-advance-page yoho-page">
{{#if advanceBuyPage}}
{{# advanceBuy}}
<div class="advance-block">
<div class="advance-block" data-promotion-id="{{promotionId}}">
<p class="title">{{title}}</p>
{{#goods}}
{{> cart/gift-advance-good}}
... ... @@ -10,11 +10,11 @@
</div>
{{/ advanceBuy}}
{{else}}
{{# gift}}
{{# freebie}}
{{> cart/gift-advance-good}}
{{/ gift}}
{{/ freebie}}
{{/if}}
<div id="chose-panel"></div>
</div>
{{> layout/footer}}
... ...
{{#cartInfo}}
<div class="chose-panel">
<div class="main">
<div class="infos">
<div class="basic-info">
<div class="basic-info" >
{{#thumbs}}
{{#if @first}}
<img class="thumb" src={{img}}>
... ... @@ -25,7 +25,7 @@
<span>颜色</span>
<ul class="clearfix" data-type="color">
{{# colors}}
<li class="block {{#if chosed}}chosed{{/if}} {{#unless colorNum}}zero-stock{{/unless}}" data-num="{{colorNum}}" data-numstr="{{sizeNumStr}}" data-skcid="{{skcId}}">
<li class="block {{#if chosed}}chosed{{/if}} {{#unless colorNum}}zero-stock{{/unless}}" data-num="{{colorNum}}" data-id="{{id}}" data-numstr="{{sizeNumStr}}" data-skcid="{{skcId}}">
{{name}}
</li>
{{/ colors}}
... ... @@ -33,9 +33,10 @@
</div>
<div class="size-list block-list">
<span>尺码</span>
<ul class="clearfix" data-type="size" >
{{# sizes}}
<li class="block {{#if chosed}}chosed{{/if}} {{#unless sizeNum}}zero-stock{{/unless}}" data-id={{id}} data-num="{{sizeNum}}" data-numstr="{{colorNumStr}}" data-skuid="{{skuId}}" data-goodid="{{goodId}}">
<li class="block hide {{#if chosed}}chosed{{/if}} {{#unless sizeNum}}zero-stock{{/unless}}" data-id={{id}} data-colorid="{{colorId}}" data-num="{{sizeNum}}" data-numstr="{{colorNumStr}}" data-skuid="{{skuId}}" data-goodid="{{goodsId}}">
{{name}}
</li>
{{/ sizes}}
... ... @@ -47,7 +48,7 @@
<a class="btn btn-minus" href="javascript:void(0);">
<span class="iconfont">&#xe625;</span>
</a>
<input id="good-num" class="good-num" type="text" value={{num}}>
<input id="good-num" class="good-num" type="text" value="1">
<a class="btn btn-plus" href="javascript:void(0);">
<span class="iconfont">&#xe624;</span>
</a>
... ... @@ -57,7 +58,8 @@
</div>
</div>
<div class="btn-wrap">
<button id="chose-btn-sure" class="btn btn-sure">加入购物车</button>
<button id="chose-btn-sure" class="btn btn-sure">确定</button>
</div>
</div>
</div>
{{/cartInfo}}
\ No newline at end of file
... ...
... ... @@ -6,19 +6,6 @@
<div class="deps">
<p class="name row">{{name}}</p>
<p class="row">
{{#if color}}
<span class="color">
颜色:{{color}}
</span>
{{/if}}
{{#if size}}
<span class="size">
尺码:{{size}}
</span>
{{/if}}
</p>
<p class="row">
<span class="price">
¥{{price}}
</span>
... ...
... ... @@ -47,7 +47,7 @@
{{/if}}
<span class="iconfont icon-edit">&#xe61e;</span>
<span class="iconfont icon-del">&#xe621;</span>
</p>
<p class="row">
... ...
... ... @@ -4,14 +4,17 @@
<a href="{{#if backUrl}}{{backUrl}}{{^}}javascript:history.go(-1);{{/if}}" class="iconfont nav-back">&#xe610;</a>
{{/navBack}}
{{#navHome}}
<a class="iconfont nav-home">&#xe611;</a>
<a href="{{.}}" class="iconfont nav-home">&#xe611;</a>
{{/navHome}}
{{#navPhone}}
<a href="{{.}}" class="iconfont nav-home">&#xe63e;</a>
{{/navPhone}}
{{#navTitle}}
<p class="nav-title">{{.}}</p>
{{/navTitle}}
{{# navBtn}}
<!-- <span class="nav-btn">{{.}}</span> -->
<i class="iconfont nav-home">&#xe638;</i>
<!-- <i class="iconfont nav-home">&#xe638;</i> -->
{{/ navBtn}}
</header>
<div class="homebuttom none">
... ...
... ... @@ -41,11 +41,12 @@ class HomeController extends AbstractAction
{
// 设置网站标题
$this->setTitle('个人中心');
$this->setNavHeader('个人中心', SITE_MAIN . '/?go=1', '', true);
$this->setNavHeader('个人中心', SITE_MAIN . '/?go=1');
$data = array(
'myIndexPage' => true,
'showDownloadApp' => true,
'navHome' => true,
'pageFooter' => true,
'cartUrl' => Helpers::url('/cart/index/index', null),
'signinUrl' => Helpers::url('/signin.html', array('refer' => Helpers::url('/home'))),
... ... @@ -848,10 +849,11 @@ class HomeController extends AbstractAction
}
$this->setTitle('订单详情');
$this->setNavHeader('订单详情');
$this->setNavHeader('订单详情', true, false);
$this->_view->display('order-detail', array(
'orderDetailPage' => true,
'navPhone' => 'tel:400-889-9646',
'orderDetail' => $orderDetail,
));
}
... ...
... ... @@ -189,50 +189,7 @@ class CartModel
$product = CartData::cartProductData($uid, $skn);
if (isset($product['code']) && $product['code'] === 200) {
$result['code'] = 200;
$data = array();
$productData = $product['data'];
// 品牌信息
if (isset($productData['brand_info']) && !empty($productData['brand_info'])) {
$data['thumb'] = Helpers::getImageUrl($productData['brand_info']['brand_ico'], 120, 120);
}
$data['name'] = $productData['product_name'];
$data['price'] = $productData['market_price'];
$data['salePrice'] = $productData['sales_price'];
$data['storage'] = $productData['storage_sum'];
$data['num'] = $num;
// 商品选择
if (isset($productData['goods_list'])) {
$goodsList = $productData['goods_list'];
$colors = array();
$oneColor = array();
$sizes = array();
$oneSize = array();
foreach ($goodsList as $val) {
// 颜色
$oneColor = array();
$oneColor['id'] = $val['color_id'];
$oneColor['name'] = $val['color_name'];
// 尺码
foreach ($val['size_list'] as $one) {
$oneSize = array();
$oneSize['id'] = $one['size_id'];
$oneSize['name'] = $one['size_name'];
}
$sizes[] = $oneSize;
$oneColor['sizes'] = $sizes;
$colors[] = $oneColor;
}
$data['colors'] = $colors;
}
$result['data'] = $data;
$result['data'] = self::procGoodsDetail($product['data'], $num);
}
return $result;
... ... @@ -252,49 +209,7 @@ class CartModel
$product = CartData::giftProductData($skn, $promotionId);
if (isset($product['code']) && $product['code'] === 200) {
$result['code'] = 200;
$data = array();
$productData = $product['data'];
// 品牌信息
if (isset($productData['brand_info']) && !empty($productData['brand_info'])) {
$data['thumb'] = Helpers::getImageUrl($productData['brand_info']['brand_ico'], 120, 120);
}
$data['name'] = $productData['product_name'];
$data['price'] = $productData['market_price'];
$data['salePrice'] = $productData['sales_price'];
$data['storage'] = $productData['storage_sum'];
// 商品选择
if (isset($productData['goods_list'])) {
$goodsList = $productData['goods_list'];
$colors = array();
$oneColor = array();
$sizes = array();
$oneSize = array();
foreach ($goodsList as $val) {
// 颜色
$oneColor = array();
$oneColor['id'] = $val['color_id'];
$oneColor['name'] = $val['color_name'];
// 尺码
foreach ($val['size_list'] as $one) {
$oneSize = array();
$oneSize['id'] = $one['size_id'];
$oneSize['name'] = $one['size_name'];
}
$sizes[] = $oneSize;
$oneColor['sizes'] = $sizes;
$colors[] = $oneColor;
}
$data['colors'] = $colors;
}
$result['data'] = $data;
$result['data'] = self::procGoodsDetail($product['data']);
}
return $result;
... ... @@ -657,6 +572,65 @@ class CartModel
/**
* 处理购物车商品、加价购商品、赠品详情数据
*
* @param array $productData 要处理的商品数据
* @param int $num 购买数目
* @return array $data 处理之后的数据
*/
private static function procGoodsDetail($productData, $num = null)
{
$data = array();
// 品牌信息
if (isset($productData['brand_info']) && !empty($productData['brand_info'])) {
$data['thumb'] = Helpers::getImageUrl($productData['brand_info']['brand_ico'], 120, 120);
}
$data['name'] = $productData['product_name'];
$data['price'] = $productData['market_price'];
$data['salePrice'] = $productData['sales_price'];
if (isset($productData['storage_sum'])) {
$data['storage'] = $productData['storage_sum'];
}
if ($num !== null) {
$data['num'] = $num;
}
// 商品选择
if (isset($productData['goods_list'])) {
$goodsList = $productData['goods_list'];
$colors = array();
$oneColor = array();
$sizes = array();
$oneSize = array();
foreach ($goodsList as $val) {
// 颜色
$oneColor = array();
$oneColor['id'] = $val['color_id'];
$oneColor['name'] = $val['color_name'];
// 尺码
foreach ($val['size_list'] as $one) {
$oneSize = array();
$oneSize['id'] = $one['size_id'];
$oneSize['name'] = $one['size_name'];
}
$sizes[] = $oneSize;
$oneColor['sizes'] = $sizes;
$colors[] = $oneColor;
}
$data['colors'] = $colors;
}
return $data;
}
/**
* 处理不同类型的购物车数据
*
* @param array $data 不同类型购物车数据
... ...
... ... @@ -385,7 +385,11 @@ class UserModel
// 处理YOHO币数据
if(isset($yohoCoin['data']) && !empty($yohoCoin['data'])){
$coinList = $yohoCoin['data']['coinlist'];
$data['money'] = $yohoCoin['data']['total'];
// 获取有货币总数
$total = self::getYohoCoinData($uid);
$data['money'] = !empty($total) ? $total['yohoCoin']['coinNum'] : 0;
foreach($coinList as $key => $val){
$result[$key]['title'] = $val['message'];
$result[$key]['time'] = $val['date'];
... ...
... ... @@ -167,7 +167,6 @@ class DetailModel
$colorStorageNum = 0;
$totalStorageNum = 0; // 总库存数
foreach ($baseInfo['goodsList'] as $value) {
$sizeList = array();
$colorStorageNum = 0;
$sizeStorageStr = '';
... ...
... ... @@ -191,6 +191,16 @@ class IndexController extends AbstractAction
}
/*
* 获取购物车加价购商品数据模板
*/
public function giftinfoTplAction()
{
if ($this->isAjax()) {
echo file_get_contents($this->_view->getScriptPath() . '/../partials/cart/chose-panel.phtml');
}
}
/*
* 获取购物车加价购商品数据
*/
public function giftinfoAction()
... ... @@ -276,7 +286,7 @@ class IndexController extends AbstractAction
$uid = $this->getUid(true);
$cartGoods = CartModel::getCartData($uid, $shoppingKey);
if (empty($cartGoods) || isset($cartGoods['isEmptyCart'])) {
$this->go(Helpers::url('/shoppingcart'));
$this->go(Helpers::url('/cart/index/index'));
}
$cartType = $this->get('cartType', 'ordinary');
... ...
... ... @@ -113,7 +113,7 @@ class LoginController extends AbstractAction
/* 判断参数是否有效 */
$verifyEmail = Helpers::verifyEmail($profile);
$verifyMobile = ($area === '86') ? Helpers::verifyMobile($profile) : Helpers::verifyAreaMobile($profile);
$verifyMobile = ($area === '86') ? Helpers::verifyMobile($profile) : Helpers::verifyAreaMobile($profile, $area);
if (!$verifyEmail && !$verifyMobile) {
break;
}
... ...