Authored by hf

code review by hf: fixes bug to coupon newuser second times

Showing 32 changed files with 1067 additions and 578 deletions
... ... @@ -23,12 +23,13 @@ class CartData
* @param int $productSku 商品SKU
* @param int $buyNumber 购买数量
* @param int $goodsType 商品类型,0表示普通商品,1表示加价购商品
* @param int int $isEdit 是否是编辑商品SKU,0表示不是编辑
* @param int $isEdit 是否是编辑商品SKU,0表示不是编辑
* @param null|int $promotionId 促销id,默认null(加价购有关)
* @param null|int $uid 用户UID,可以不传
* @param string $shoppingKey 未登录用户唯一识别码,可以不传
* @return array 加入购物车接口返回的数据
*/
public static function addToCart($productSku, $buyNumber, $goodsType, $isEdit = 0, $promotionId = null, $uid = null)
public static function addToCart($productSku, $buyNumber, $goodsType, $isEdit = 0, $promotionId = null, $uid = null, $shoppingKey = null)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.add';
... ... @@ -42,6 +43,9 @@ class CartData
if ($uid !== null) {
$param['uid'] = $uid;
}
if ($shoppingKey !== null) {
$param['shoppingKey'] = $shoppingKey;
}
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
... ...
... ... @@ -42,7 +42,7 @@ class BindData
* @param string $mobile 手机号
*
*/
public static function sendBindMsg($area,$mobile)
public static function sendBindMsg($area, $mobile)
{
$param = Yohobuy::param();
... ... @@ -58,7 +58,7 @@ class BindData
* 验证验证码是否正确
*
*/
public static function checkBindCode($area,$mobile, $code)
public static function checkBindCode($area, $mobile, $code)
{
$param = Yohobuy::param();
... ... @@ -100,4 +100,47 @@ class BindData
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 换绑手机检验
* @param string $mobile 手机号
* @param string $area 国别码
*/
public static function changeCheck($mobile, $area)
{
$param = Yohobuy::param();
$param['method'] = 'app.passport.changeCheck';
$param['mobile'] = $mobile;
$param['area'] = $area;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 换绑手机
* @param string $uid 用户Id
* @param string $code 验证码
* @param string $mobile 手机号
* @param string $area 国别码
*/
public static function changeMobile($uid, $mobile, $area, $code)
{
$param = Yohobuy::param();
$param['method'] = 'app.passport.changeMobile';
$param['mobile'] = $mobile;
$param['uid'] = $uid;
$param['code'] = $code;
$param['area'] = $area;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
... ... @@ -27,13 +27,18 @@ class DetailData
*
* @param int $productId 商品ID
* @param int $uid 用户ID
* @param int $productSkn SKN
* @return array
*/
public static function baseInfo($productId, $uid)
public static function baseInfo($productId, $uid, $productSkn = null)
{
$param = Yohobuy::param();
$param['method'] = 'h5.product.data';
$param['productId'] = $productId;
if ($productId !== null) {
$param['productId'] = $productId;
} elseif ($productSkn !== null) {
$param['product_skn'] = $productSkn;
}
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
... ...
... ... @@ -546,8 +546,8 @@ class Helpers
$arr[$key]['appearDate'] = $vo['expect_arrival_time'];
}
// 商品链接
if ($haveLink && isset($vo['product_id'])) {
$arr[$key]['link'] = self::url('/product/pro_' . $vo['product_id'] . '_' . $vo['goods_id'] . '/' . $vo['cn_alphabet'] . '.html');
if ($haveLink && isset($vo['product_skn'])) {
$arr[$key]['link'] = self::url('/product/show_' . $vo['product_skn'] . '.html');
}
// 累计购买数
$count += intval($vo['buy_number']);
... ... @@ -561,9 +561,10 @@ class Helpers
*
* @param array $cartGoods 购物车商品列表
* @param boolean $isValid 是否是可用商品(非失效商品),默认是
* @param bool $isAdvanceCart 是否是预售购物车(和上市期有关)
* @return array 处理之后的购物车商品数据
*/
public static function formatCartGoods($cartGoods, $isValid = true)
public static function formatCartGoods($cartGoods, $isAdvanceCart, $isValid = true)
{
$arr = array();
... ... @@ -592,7 +593,7 @@ class Helpers
$oneGoods['isAdvanceBuy'] = true;
}
// 上市期
if (!empty($value['expect_arrival_time'])) {
if ($isAdvanceCart && !empty($value['expect_arrival_time'])) {
$oneGoods['appearDate'] = $value['expect_arrival_time'];
}
// 商品链接
... ... @@ -628,7 +629,6 @@ class Helpers
$oneGoods['id'] = $single['product_skn'];
$oneGoods['name'] = $single['product_name'];
$oneGoods['thumb'] = !empty($single['goods_images']) ? Images::getImageUrl($single['goods_images'], 120, 160) : '';
$oneGoods['appearDate'] = '12月'; // 目前app接口没有返回该数据
$oneGoods['price'] = self::transPrice($single['last_price']);
$oneGoods['marketPrice'] = self::transPrice($single['market_price']);
$oneGoods['count'] = $single['storage_number'];
... ... @@ -639,7 +639,7 @@ class Helpers
$arr[] = $gift;
// 计算加价购商品数目
$count += $value['max_select_number'];
$count += count($value['goods_list']);
}
return $arr;
... ...
... ... @@ -8,7 +8,7 @@
/**
* @ignore
*/
class OAuthException extends Exception {
class OAuthException extends \Exception {
// pass
}
... ...
... ... @@ -8,17 +8,24 @@ var $ = require('jquery'),
lazyLoad = require('yoho.lazyload'),
Hammer = require('yoho.hammer');
var chosePanel = require('./chose-panel');
var chosePanel = require('./chose-panel'),
tip = require('../plugin/tip');
var $cartContent = $('.cart-content');
var navHammer,
cartType = $('#cartType').val();
var hasChecked = $('.cart-goods .icon-cb-checked').length > 0 ? true : false; //是否有选中商品
require('./good');
lazyLoad($('img.lazy'));
if ('advance' === cartType) {
$cartContent.toggleClass('hide');
}
if ($('.cart-nav').length > 0) {
navHammer = new Hammer(document.getElementsByClassName('cart-nav')[0]);
navHammer.on('tap', function(e) {
... ... @@ -46,7 +53,11 @@ if ($('.cart-nav').length > 0) {
}
$('.btn-balance').on('touchend', function() {
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
if (hasChecked) {
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
} else {
tip.show('请先勾选商品');
}
});
$('.chose').on('touchend', function() {
... ... @@ -54,3 +65,6 @@ $('.chose').on('touchend', function() {
//var id = $(this).closest('.gift-advance-good').data('id');
chosePanel.show();
});
//提前触发lazyload
$(window).scrollTop(1).scrollTop(0);
\ No newline at end of file
... ...
... ... @@ -18,13 +18,17 @@ var panelTmpl,
$chosePanel = $('#chose-panel'),
$num,
$chosed,
re = /\d+/,
// re = /\d+/,
leftNum,
$colorList,
$sizeList,
firstColorId,
colorIndex,
confirming;
confirming,
hasChooseColor = false,
hasChooseSize = false,
curColorIndex,
curSizeIndex,
$curSizeRow,
$curSizeBlock = null,
$sizeRowList = $('.size-list ul');
// 读取模板
$.get('/cart/index/giftinfoTpl', function(html) {
... ... @@ -39,45 +43,61 @@ $.get('/cart/index/giftinfoTpl', function(html) {
//初始化购物车面板显示
function init() {
$colorList = $('.chose-panel .color-list ul>li');
$sizeList = $('.chose-panel .size-list ul>li');
firstColorId = $colorList.eq(0).data('id');
$sizeList.each(function() {
colorIndex = $(this).data('colorid');
if (colorIndex === firstColorId) {
$(this).removeClass('hide');
}
});
}
init();
//显示
// function show(data) {
// // var html = tpl(data);
// $('.chose-panel').show();
// // $page.append(html);
// $('.chose-panel')
// $num = $('#good-num');
// }
//$colorList = $('.chose-panel .color-list ul>li');
//$sizeList = $('.chose-panel .size-list ul>li');
//firstColorId = $colorList.eq(0).data('id');
//$sizeList.each(function() {
// colorIndex = $(this).data('colorid');
//
// if (colorIndex === firstColorId) {
// $(this).removeClass('hide');
// }
//});
var $firstRow = $sizeRowList.eq(0);
$firstRow.toggleClass('hide');
$curSizeRow = $firstRow;
}
function checkColorSizeNum() {
if (!hasChooseColor && !hasChooseSize) {
tip.show('请选择颜色和尺码~');
return false;
} else if (!hasChooseColor) {
tip.show('请选择颜色~');
return false;
} else if (!hasChooseSize) {
tip.show('请选择尺码~');
return false;
}
return true;
}
init();
function show(data) {
if (data) {
$chosePanel.html(panelTmpl(data));
init();
}
$('.chose-panel').show();
$('body').css('overflow', 'hidden');
$num = $('#good-num');
}
//移除当前Panel
function remove() {
////显示当前Panel
//function show() {
// $('.chose-panel').show();
//
// $('body').css('overflow', 'hidden');
// $num = $('#good-num');
//}
//隐藏当前Panel
function hide() {
$('.chose-panel').hide();
$('body').css('overflow', 'auto');
}
... ... @@ -90,87 +110,223 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
}
//点击蒙版消失
remove();
}).on('touchstart', '#chose-btn-sure', function() {
hide();
});
var productSku,
buyNumber = $('#good-num').val() - 0,
$('.color-list').on('touchstart', '.block', function(e) {
var $this = $(this),
$that = $(e.target).closest('.chose-items'),
index,
curSelectedSizeBlock,
$sizeChosed,
scindex,
curGoodNum;
promotionId,
isEdit = 0,
numInCart = $('.num-tag').html() - 0;
var $siblingBlock = $this.closest('.block-list').siblings(':first');
// goodsType,
// isEdit;
$this.siblings('.chosed').removeClass('chosed');
index = $this.index();
$chosed = $('.block-list>ul>li.chosed');
$sizeChosed = $siblingBlock.find('.chosed');
scindex = $sizeChosed.index();
$curSizeRow = $sizeRowList.eq(index);
if (2 === $chosed.length && 0 === $chosed.closest('.zero-stock').length) {
productSku = $sizeList.closest('.chosed').data('skuid');
promotionId = $('[data-id="' + productSku + '"]').closest('.advance-block').data('promotion-id');
if (confirming) {
return false;
// 当前颜色已经是选中状态,再点击时
if ($this.hasClass('chosed')) {
//颜色原来已经是勾选时,要清空剩余件数的提示
$that.find('.num .left-num').html('');
$('#left-num').val(0);
hasChooseColor = false;
// 当前颜色不是选中状态,选中时
} else {
hasChooseColor = true;
//根据颜色切换图片
if ($this.closest('.block-list').hasClass('color-list')) {
$('.chose-panel').find('.thumb').addClass('hide').eq(index).removeClass('hide');
}
confirming = true;
loading.showLoadingMask();
$.ajax({
method: 'POST',
url: '/cart/index/add',
data: {
productSku: productSku,
buyNumber: buyNumber,
promotionId: promotionId,
isEdit: isEdit
//把当前选中颜色对应的尺码那一行显示出来
$sizeRowList.addClass('hide');
$curSizeRow.removeClass('hide').addClass('show');
// 之前选中的尺码去掉勾选样式
if ($sizeChosed.length > 0) {
$sizeChosed.removeClass('chosed');
curSelectedSizeBlock = $curSizeRow.children().get(scindex);
}
// 当前选中颜色对应的尺码行,其对应的尺码加上勾选样式 (前提是要判断下这个尺码是否存在)
if (curSelectedSizeBlock) {
curGoodNum = $(curSelectedSizeBlock).data('num');
$(curSelectedSizeBlock).addClass('chosed');
//如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式
if (curGoodNum > 0) {
$that.find('.num .left-num').html('剩余' + curGoodNum + '件');
$('#left-num').val(curGoodNum);
} else {
$(curSelectedSizeBlock).removeClass('zero-stock').addClass('zero-stock');
$that.find('.num .left-num').html('');
$('#left-num').val(0);
}
}).done(function(res) {
loading.hideLoadingMask();
if (res.code === 200) {
$('.num-tag').html(numInCart + buyNumber);
$('.num-tag').removeClass('hide');
remove();
}
}
// 当前颜色块 切换勾选样式
$this.toggleClass('chosed');
curColorIndex = index;
// 设置按钮的样式和文字
$chosed = $('.chose-items').find('.chosed');
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('确定');
}
/**if ($chosed.length === 0) {
$this.closest('ul>li').each(function() {
$(this).removeClass('zero-stock');
if ('0' === $(this).data('num')) {
$(this).addClass('zero-stock');
}
if (res.message) {
tip.show(res.message);
});
$siblingBlock.find('ul>li').each(function() {
$(this).removeClass('zero-stock');
if ('0' === $(this).data('num')) {
$(this).addClass('zero-stock');
}
}).fail(function() {
tip.show('网络出了点问题~');
}).always(function() {
confirming = false;
});
}
} else if ($chosed.length === 1 && $this.hasClass('chosed')) {
$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++) {
if ('0' === numArray[i]) {
$siblingBlock.find('.block').eq(i).addClass('zero-stock');
}
}
} 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')) {
$(this).addClass('zero-stock');
}
});
$that.find('.num .left-num').html('');
} else if ($chosed.length === 2) {
$siblingBlock.find('.block').removeClass('zero-stock');
for (i = 0; i < currentNumArray.length; i++) {
if ('0' === currentNumArray[i]) {
$siblingBlock.find('.block').eq(i).addClass('zero-stock');
}
}
numArray = ($siblingBlock.find('.chosed').data('numstr') + '').split('/');
$that.find('.num .left-num').html('剩余' + numArray[index] + '件');
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', '.block', function(e) {
});
$('.size-list').on('touchstart', '.block', function(e) {
var $this = $(this),
$that = $(e.target).closest('.chose-items'),
numArray,
index,
i;
$colorChosed,
curGoodNum;
var $siblingBlock = $this.closest('.block-list').siblings(':first'),
currentNumArray = ($this.data('numstr') + '').split('/');
var $siblingBlock = $this.closest('.block-list').siblings(':first');
$this.siblings('.chosed').removeClass('chosed');
$this.toggleClass('chosed');
index = $this.index();
$chosed = $('.block-list>ul>li.chosed');
//根据颜色切换图片
if ($this.closest('.block-list').hasClass('color-list')) {
$('.chose-panel').find('.thumb').addClass('hide').eq(index).removeClass('hide');
$colorChosed = $siblingBlock.find('.chosed');
$curSizeRow = $sizeRowList.eq(index);
// 当前尺码已经是选中状态,再点击时
if ($this.hasClass('chosed')) {
//尺码原来已经是勾选时,要清空剩余件数的提示
$that.find('.num .left-num').html('');
$('#left-num').val(0);
hasChooseSize = false;
// 去掉已经选中颜色的 数量为0的样式
if ($colorChosed.length > 0) {
$colorChosed.removeClass('zero-stock').addClass('zero-stock');
}
// 当前尺码不是选中状态,选中时
} else {
hasChooseSize = true;
curGoodNum = $this.data('num');
// 之前选中的尺码去掉勾选样式
if ($curSizeBlock) {
$curSizeBlock.removeClass('chosed');
}
// 如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式, 否则显示剩余件数
if (curGoodNum > 0 && hasChooseColor) {
$that.find('.num .left-num').html('剩余' + curGoodNum + '件');
$('#left-num').val(curGoodNum);
} else {
$colorChosed.removeClass('zero-stock').addClass('zero-stock');
$that.find('.num .left-num').html('');
$('#left-num').val(0);
}
}
$this.toggleClass('chosed');
curSizeIndex = index;
$curSizeBlock = $this;
// 设置按钮的样式和文字
$chosed = $('.chose-items').find('.chosed');
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('确定');
}
if ($chosed.length === 0) {
/**if ($chosed.length === 0) {
$this.closest('ul>li').each(function() {
$(this).removeClass('zero-stock');
if (0 === $(this).data('num') - 0) {
if ('0' === $(this).data('num')) {
$(this).addClass('zero-stock');
}
});
$siblingBlock.find('ul>li').each(function() {
$(this).removeClass('zero-stock');
if (0 === $(this).data('num') - 0) {
if ('0' === $(this).data('num')) {
$(this).addClass('zero-stock');
}
});
... ... @@ -191,7 +347,7 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
numArray = ($chosed.data('numstr') + '').split('/');
$siblingBlock.find('.block').removeClass('zero-stock');
for (i = 0; i < numArray.length; i++) {
if (0 === numArray[i] - 0) {
if ('0' === numArray[i]) {
$siblingBlock.find('.block').eq(i).addClass('zero-stock');
}
}
... ... @@ -201,7 +357,7 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
$siblingBlock.find('ul>li').each(function() {
$(this).removeClass('zero-stock');
if (0 === $(this).data('num') - 0) {
if ('0' === $(this).data('num')) {
$(this).addClass('zero-stock');
}
});
... ... @@ -209,7 +365,7 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
} else if ($chosed.length === 2) {
$siblingBlock.find('.block').removeClass('zero-stock');
for (i = 0; i < currentNumArray.length; i++) {
if (0 === currentNumArray[i] - 0) {
if ('0' === currentNumArray[i]) {
$siblingBlock.find('.block').eq(i).addClass('zero-stock');
}
}
... ... @@ -222,15 +378,16 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
$('#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'),
leftNum = re.exec($('.num .left-num').html());
$('.btn-minus').on('touchstart', function() {
var num = $num.val();
//若颜色和尺码没有被同时选中,则不能点击
if ($chosed.length < 2) {
leftNum = $('#left-num').val();
if (!checkColorSizeNum()) {
return;
}
... ... @@ -239,15 +396,19 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
}
$num.val(num - 1);
}).on('touchstart', '.btn-plus', function() {
var num = +$num.val();
});
$('.btn-plus').on('touchstart', function() {
var num = $num.val();
//若颜色和尺码没有被同时选中,则不能点击
if ($('.block-list>ul>li.chosed').length < 2) {
leftNum = $('#left-num').val();
if (!checkColorSizeNum()) {
return;
}
leftNum = re.exec($('.num .left-num').html());
if (num - 0 === leftNum - 0 || 0 === leftNum - 0) {
if (num - 0 === leftNum || 0 === leftNum) {
return;
}
... ... @@ -255,5 +416,70 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
$num.val(num + 1);
});
$('#chose-btn-sure').on('touchstart', function() {
var productSku,
buyNumber = $('#good-num').val() - 0,
promotionId,
isEdit = 0,
numInCart = $('.num-tag').html() - 0,
num = $num.val();
if (!checkColorSizeNum()) {
return;
}
if ($('#chose-btn-sure').html() === '已售罄') {
return;
}
leftNum = $('#left-num').val();
if (num > leftNum) {
tip.show('您选择的数量超过了最大库存量~');
return;
}
$chosed = $('.block-list>ul>li.chosed');
if (2 === $chosed.length && 0 === $chosed.closest('.zero-stock').length) {
productSku = $curSizeBlock.data('skuid');
promotionId = $('[data-id="' + productSku + '"]').closest('.advance-block').data('promotion-id');
if (confirming) {
return false;
}
confirming = true;
loading.showLoadingMask();
$.ajax({
method: 'POST',
url: '/cart/index/add',
data: {
productSku: productSku,
buyNumber: buyNumber,
promotionId: promotionId,
isEdit: isEdit
}
}).done(function(res) {
loading.hideLoadingMask();
if (res.code === 200) {
$('.num-tag').html(numInCart + buyNumber);
$('.num-tag').removeClass('hide');
confirming = false;
hide();
}
if (res.message) {
tip.show(res.message);
}
}).fail(function() {
tip.show('网络出了点问题~');
}).always(function() {
confirming = false;
});
}
});
exports.init = init;
exports.show = show;
... ...
... ... @@ -12,8 +12,7 @@ var $ = require('jquery'),
var dialog = require('../me/dialog'),
tip = require('../plugin/tip');
var $names,
$selectAllBtn = $('.balance .iconfont'),
var $selectAllBtn = $('.balance .checkbox'),
cartType = $('#cartType').val(),
requesting = false;
... ... @@ -23,11 +22,9 @@ lazyLoad({
try_again_css: 'good-failure'
});
$names = $('.name');
if ($names.length > 0) {
$names[0].mlellipsis(2);
}
$('.shopping-cart-good .name').each(function() {
this.mlellipsis(2);
});
//TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods
$('.cart-goods').on('touchstart', '.checkbox', function() {
... ... @@ -52,7 +49,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
this.selected = properties.selected;
}
goodInfo.goods_type = getCartType();
goodInfo.goods_type = cartType;
goodInfo.selected = isSelected ? 'N' : 'Y';
goodInfo.product_sku = id;
goodInfo.buy_number = $good.find('.count').eq(0).text().trim().replace('×', '');
... ... @@ -73,44 +70,12 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
} else {
$this.removeClass('icon-checkbox').addClass('icon-cb-checked');
}
$.ajax({
type: 'GET',
url: 'getCartData',
data: {
id: id
},
success: function(data) {
if (data) {
if (cartType === 'ordinary') {
$('#good-totalprice').html('¥' + data.commonCart.price);
$('#good-activityPrice').html('¥' + data.commonCart.activityPrice);
$('#good-total').html('总计:¥' + data.commonCart.sumPrice + ' (' + data.commonCart.count + '件)');
if (data.commonCart.isAllSelected) {
$('.balance span').removeClass('icon-checkbox').addClass('icon-cb-checked');
} else {
$('.balance span').removeClass('icon-cb-checked').addClass('icon-checkbox');
}
} else {
$('#good-totalprice').html('¥' + data.preSellCart.price);
$('#good-activityPrice').html('¥' + data.preSellCart.activityPrice);
$('#good-total').html('总计:¥' + data.preSellCart.sumPrice + ' (' + data.preSellCart.count + '件)');
if (data.preSellCart.isAllSelected) {
$('.balance span').removeClass('icon-checkbox').addClass('icon-cb-checked');
} else {
$('.balance span').removeClass('icon-cb-checked').addClass('icon-checkbox');
}
}
}
},
error: function() {
tip.show('网络错误');
}
});
window.history.go(0);
} else if (data.code === 400) {
tip.show('网络错误');
tip.show('网络异常');
}
}).fail(function() {
tip.show('网络错误');
}, function() {
tip.show('网络异常');
});
}).on('touchstart', '.icon-del', function(e) {
var $this = $(this);
... ... @@ -143,10 +108,10 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
});
history.go(0);
}
}).fail(function() {
}, function() {
dialog.showDialog({
autoHide: true,
dialogText: '网络错误~'
dialogText: '网络异常'
});
});
});
... ... @@ -203,6 +168,7 @@ function didUpdateAllGoodsCheckStatus() {
$(checkedBox).removeClass('icon-cb-checked').addClass('icon-checkbox');
});
}
window.history.go(0);
}
function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) {
... ... @@ -251,6 +217,7 @@ function willBeSelected($this) {
//全选按钮点击事件
$selectAllBtn.on('touchend', function() {
var $this = $(this);
bottomCheckBoxHandeler(willBeSelected($this), cartType, didUpdateAllGoodsCheckStatus);
});
... ...
... ... @@ -16,6 +16,7 @@ var dispatchModeHammer,
dispatchTimeHammer,
$invoice = $('.invoice'),
$price = $('.price-cal'),
$couponUse = $('.coupon-use.used'),
payType,
priceTmpl = Handlebars.compile($('#tmpl-price').html()),
queryString = $.queryString(),
... ... @@ -27,6 +28,11 @@ if (window.getUid() !== orderInfo('uid')) {
order.init();
}
if ($couponUse.data('value') !== orderInfo('couponValue')) {
orderInfo('couponCode', null);
orderInfo('couponValue', null);
}
function dispacthTapEvt(e) {
var $cur = $(e.target).closest('li');
... ... @@ -84,21 +90,17 @@ function orderCompute() {
if (!res) {
tip.show('网络出错');
} else {
if (res.order_amount) {
/*if (res.order_amount) {
res.order_amount = (+res.order_amount).toFixed(2);
}
if (res.discount_amount) {
res.discount_amount = (+res.discount_amount).toFixed(2);
}
}*/
if (res.last_order_amount) {
res.last_order_amount = (+res.last_order_amount).toFixed(2);
}
priceHtml = priceTmpl({
sumPrice: res.order_amount,
salePrice: res.discount_amount,
freight: res.promotion_formula_list[1].promotion_amount,
couponPrice: res.coupon_amount,
yohoCoin: res.use_yoho_coin,
cartPayData: res.promotion_formula_list,
price: res.last_order_amount
});
... ... @@ -110,9 +112,24 @@ function orderCompute() {
}
function submitOrder() {
if (orderInfo('invoice') && !orderInfo('invoiceText')) {
tip.show('请输入发票抬头');
return;
var invoiceText = $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'),
msg = $('#msg').find('input').val() || orderInfo('msg');
if (orderInfo('invoice')) {
if (!invoiceText) {
tip.show('请输入发票抬头');
return;
}
if (invoiceText.length > 30) {
tip.show('发票抬头不得超过30个汉字');
return;
}
}
if (msg) {
if (msg.length > 40) {
tip.show('留言不得超过40个汉字');
return;
}
}
loading.showLoadingMask();
$.ajax({
... ... @@ -123,9 +140,9 @@ function submitOrder() {
cartType: queryString.cartType || queryString.carttype || 'ordinary',
deliveryId: orderInfo('deliveryId'),
deliveryTimeId: orderInfo('deliveryTimeId'),
invoiceText: $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'),
invoiceText: invoiceText,
invoiceType: $invoice.find('.invoice-type').val() || orderInfo('invoiceType'),
msg: $('#msg').find('input').val() || orderInfo('msg'),
msg: msg,
paymentTypeId: orderInfo('paymentTypeId'),
paymentType: orderInfo('paymentType'), //支付方式
couponCode: orderInfo('couponCode'),
... ... @@ -198,7 +215,7 @@ $invoice.find('[name="invoice-title"]').on('blur', function() {
orderInfo('invoiceType', $(this).val());
});
$('#msg').find('input').on('blur', function() {
$('#msg').find('textarea').on('blur', function() {
orderInfo('msg', $(this).val());
});
... ...
... ... @@ -16,9 +16,10 @@ var page = 1,
isGetData;
var conponTmpl = Handlebars.compile($('#tmpl-coupon').html()),
conponNotAvaliableTmpl = Handlebars.compile($('#tmpl-coupon-not-avaliable').html()),
$newCoupon = $('#new-coupon');
// conponNotAvaliableTmpl = Handlebars.compile($('#tmpl-coupon-not-avaliable').html()),
ellipsis.init();
$newCoupon.on('submit', function() {
... ... @@ -54,6 +55,12 @@ $('#coupon-list').on('touchend', '.employ-main', function() {
orderInfo('couponValue', $this.data('coupon-value'));
});
$('body').on('touchend', '.not-use', function() {
orderInfo('couponCode', null);
orderInfo('couponValue', null);
});
$newCoupon.find('input').on('input', function() {
if ($(this).val() !== '') {
$newCoupon.find('.submit').css('background', '#444');
... ... @@ -109,15 +116,17 @@ function getCouponHandle(coupons) {
}
});
if (notAvailableCoupons.length) {
$('.not-avaliable-coupon-line').show();
}
$('#coupon-list').append(conponTmpl({
coupons: coupons
}));
$('#coupon-list-not').append(conponNotAvaliableTmpl({
notAvailableCoupons: notAvailableCoupons
}));
// 产品说,暂时不做不可使用的优惠券
// if (notAvailableCoupons.length) {
// $('.not-avaliable-coupon-line').show();
// }
// $('#coupon-list-not').append(conponNotAvaliableTmpl({
// notAvailableCoupons: notAvailableCoupons
// }));
window.rePosFooter();
}
... ...
... ... @@ -124,6 +124,7 @@ $loginBtn.on('touchstart', function() {
});
} else {
showErrTip('账号或密码有错误,请重新输入');
$loginBtn.text('登录').removeClass('disable');
}
});
... ...
... ... @@ -126,6 +126,7 @@ $loginBtn.on('touchstart', function() {
});
} else {
showErrTip('账号或密码有错误,请重新输入');
$loginBtn.text('登录').removeClass('disable');
}
});
... ...
... ... @@ -12,8 +12,14 @@ $.ajax({
type: 'GET',
url: '/cart/index/count',
success: function(data) {
var count;
if (data.code === 200) {
$cart.find('.cart-count').html(data.data.cart_goods_count).removeClass('hide');
count = data.data.cart_goods_count;
if (count > 99) {
count = '99+';
}
$cart.find('.cart-count').html(count).removeClass('hide');
}
}
});
\ No newline at end of file
});
... ...
... ... @@ -63,36 +63,31 @@
}
.deps {
margin-left: 173rem / $pxConvertRem;
padding-bottom: 72rem / $pxConvertRem;
border-bottom: 1px solid #e0e0e0;
width: 380rem / $pxConvertRem;
position: relative;
min-height: 140rem / $pxConvertRem;
width: 380rem / $pxConvertRem;
height: 5.3rem;
margin-left: 4.7rem;
border-bottom: 1px solid #e0e0e0;
padding-top: 0.5rem;
}
.name {
font-size: 28rem / $pxConvertRem;
font-size: 18px;
color: #5a5a5a;
width: 80%;
display: inline-block;
}
.row:nth-child(2) {
font-size: 22rem / $pxConvertRem;
height: 45rem / $pxConvertRem;
line-height: 45rem / $pxConvertRem;
.color-size-row {
margin: 0.2rem 0;
> span {
margin-right: 15rem / $pxConvertRem;
}
}
.row:nth-child(3) {
position: relative;
}
.color, .size {
font-size: 16px;
color: #b6b6b6;
}
... ... @@ -103,7 +98,7 @@
}
.price {
font-size: 24rem / $pxConvertRem;
font-size: 16px;
color: $cartRed;
}
... ...
... ... @@ -116,11 +116,26 @@
color: #8f8f8f;
}
}
.price-compute {
.activity{
padding: 20rem / $pxConvertRem;
border-bottom: 1px solid #e0e0e0;
font-size: 26rem / $pxConvertRem;
h1{
font-size: 32rem / $pxConvertRem;
}
li:before {
content: "";
display: inline-block;
width: 4px;
height: 4px;
background-color: #000;
border-radius: 50%;
margin-right: 8rem / $pxConvertRem;
}
}
.price-compute {
padding: 20rem / $pxConvertRem;
border-top: 1px solid #e0e0e0;
font-size: 28rem / $pxConvertRem;
.title {
display: inline-block;
... ...
... ... @@ -89,6 +89,10 @@
margin-left: 20rem / $pxConvertRem;
}
}
.name {
max-width: pxToRem(400px);
}
}
.sale-invoice {
... ... @@ -162,19 +166,26 @@
}
}
.block input {
box-sizing: border-box;
margin: pxToRem(20px) 0;
padding: 0 pxToRem(12px);
width: 100%;
height: pxToRem(60px);
color: #444;
background: #efefef;
font-size: pxToRem(16px);
line-height: 1;
outline: 0;
border: 0;
@include border-radius(4px);
.block {
input, textarea {
box-sizing: border-box;
margin: pxToRem(20px) 0;
padding: 0 pxToRem(12px);
width: 100%;
height: pxToRem(60px);
color: #444;
background: #efefef;
font-size: pxToRem(16px);
line-height: 1;
outline: 0;
border: 0;
@include border-radius(4px);
}
textarea {
padding: pxToRem(12px);
height: auto;
resize: none;
}
}
#invoice {
... ...
... ... @@ -46,6 +46,17 @@
height: 0;
}
.not-use {
display: block;
width: pxToRem(560px);
margin: pxToRem(30px) auto;
text-align: center;
font-size: pxToRem(32px);
line-height: 2.5;
border: 1px solid #444;
@include border-radius(4px);
}
.not-avaliable-coupon-line {
position: relative;
margin-top: pxToRem(30px);
... ...
... ... @@ -23,13 +23,16 @@
.cart-count {
position: absolute;
width: 18px;
height: 18px;
line-height: 18px;
border-radius: 50%;
background: #f00;
top: 0;
right: 0;
top: -12px;
right: -10px;
width: 36px;
height: 36px;
font-size: 20px;
line-height: 36px;
color: #fff;
background: #f03d35;
text-align: center;
border-radius: 50%;
@include transform(scale(0.5));
}
}
... ...
... ... @@ -25,14 +25,14 @@
{{#if cartNav}}
<ul class="cart-nav clearfix">
<li class="active">
<span>
普通商品({{commonGoodsCount}})
</span>
<span>
普通商品({{commonGoodsCount}})
</span>
</li>
<li>
<span>
预售商品({{presellGoodsCount}})
</span>
<span>
预售商品({{presellGoodsCount}})
</span>
</li>
</ul>
{{/if}}
... ...
... ... @@ -45,14 +45,12 @@
<a href="/cart/index/selectCoupon">
<span class="title">优惠券</span>
{{# coupon}}
{{#if count}}
<span class="coupon-count">
{{count}}张可用
</span>
{{/if}}
<span class="coupon-count">
{{count}}张可用
</span>
{{#if value}}
<span class="used coupon-use">
<span class="used coupon-use" data-value="{{value}}">
{{value}}
<i class="iconfont">&#xe614;</i>
</span>
... ... @@ -79,7 +77,7 @@
<span class="title">发票</span>
<span class="iconfont checkbox {{#if needInvoice}}icon-cb-checked{{else}}icon-checkbox{{/if}}"></span>
<form id="invoice">
<input type="text" name="invoice-title" value="{{invoiceText}}" placeholder="发票抬头">
<input type="text" name="invoice-title" value="{{invoiceText}}" maxlength="30" placeholder="发票抬头">
<label>
发票类型
<select class="invoice-type" name="invoice-type">
... ... @@ -94,34 +92,18 @@
</ul>
<form id="msg" action="" method="post">
<input type="text" name="msg" value="{{msg}}" placeholder="留言">
<textarea name="msg" rows="2" maxlength="40" placeholder="留言">{{msg}}</textarea>
</form>
</section>
<section class="price-cal block">
<ul class="total">
{{#cartPayData}}
<li>
<span>总价</span>
&nbsp;&nbsp;¥{{sumPrice}}
</li>
<li>
<span>活动价</span>
- ¥{{salePrice}}
</li>
<li>
<span>运费</span>
+ {{freight}}
</li>
{{#couponPrice}}
<li>
<span>优惠券</span>
- ¥{{.}}
</li>
{{/couponPrice}}
<li>
<span>YOHO币</span>
- ¥{{yohoCoin}}
<span>{{promotion}}</span>
&nbsp;&nbsp;{{promotion_amount}}
</li>
{{/cartPayData}}
<li class="cost">
应付金额: <em>¥{{price}}</em>
</li>
... ... @@ -146,28 +128,12 @@
</div>
<script id="tmpl-price" type="text/tmpl">
<ul class="total">
\{{#cartPayData}}
<li>
<span>总价</span>
&nbsp;&nbsp;¥\{{sumPrice}}
</li>
<li>
<span>活动价</span>
- ¥\{{salePrice}}
</li>
<li>
<span>运费</span>
+ \{{freight}}
</li>
\{{#couponPrice}}
<li>
<span>优惠券</span>
- ¥\{{.}}
</li>
\{{/couponPrice}}
<li>
<span>YOHO币</span>
- ¥\{{yohoCoin}}
<span>\{{promotion}}</span>
&nbsp;&nbsp;\{{promotion_amount}}
</li>
\{{/cartPayData}}
<li class="cost">
应付金额: <em>¥\{{price}}</em>
</li>
... ...
... ... @@ -20,6 +20,7 @@
</a>
\{{/ notAvailable}}
\{{/coupons}}
<a class="not-use" href="/cart/index/orderEnsure">不使用任何优惠券</a>
</script>
<script id="tmpl-coupon-not-avaliable" type="text/tmpl">
\{{# notAvailableCoupons}}
... ...
... ... @@ -34,17 +34,22 @@
</ul>
{{/if}}
{{# promotionInfo}}
<div class="activity">
<h1>已参与活动</h1>
<ul>
<li>{{name}}</li>
</ul>
</div>
{{/ promotionInfo}}
<div class="price-compute">
<p class="sum-price">
<span class="title">总价</span>
<span id="good-totalprice">¥{{price}}</span>
<p>
<span>总价(¥{{price}})<i>-</i></span>
<span>活动价(¥{{activityPrice}})</span>
</p>
<p class="activity-price">
<span class="title">
活动价
<i class="minus">-</i>
</span>
<span id="good-activityPrice">¥{{activityPrice}}</span>
<p>
<span><i>=</i>商品总计金额 (¥{{sumPrice}})</span>
</p>
</div>
... ...
... ... @@ -15,7 +15,7 @@
<p class="price">
<span class="sale-price{{^price}} no-price{{/price}}">{{salePrice}}</span>
{{#if price}}
<span class="market-price">{{price}}</span>
<span class="market-price">{{price}}</span>
{{/if}}
</p>
</div>
... ... @@ -25,41 +25,46 @@
<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-id="{{id}}" data-numstr="{{sizeNumStr}}" data-skcid="{{skcId}}">
{{name}}
</li>
<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}}
</ul>
</div>
<div class="size-list block-list">
<span>尺码</span>
<span>尺码</span>
{{# sizes}}
<ul class="clearfix" data-type="size" >
{{# sizes}}
<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}}
</ul>
</div>
<div class="num">
<span>数量</span>
<div class="clearfix">
<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="1">
<a class="btn btn-plus" href="javascript:void(0);">
<span class="iconfont">&#xe624;</span>
</a>
</div>
<span class="left-num"></span>
<ul class="size-row clearfix hide">
{{# size}}
<li class="block {{#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>
{{/ size}}
</ul>
{{/ sizes}}
</div>
<p>
<div class="num">
<span>数量</span>
<div class="clearfix">
<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="1">
<a class="btn btn-plus" href="javascript:void(0);">
<span class="iconfont">&#xe624;</span>
</a>
</div>
<span class="left-num"></span>
<input id="left-num" type="hidden" value="0">
</div>
</div>
<div class="btn-wrap">
<button id="chose-btn-sure" class="btn btn-sure">确定</button>
</div>
</div>
<div class="btn-wrap">
<button id="chose-btn-sure" class="btn btn-sure">确定</button>
</div>
</div>
{{/cartInfo}}
\ No newline at end of file
</div>
{{/cartInfo}}
\ No newline at end of file
... ...
... ... @@ -25,7 +25,7 @@
<span class="count">
×{{count}}
</span>
<p class="row">
<p class="row color-size-row">
{{#if color}}
<span class="color">
颜色:{{color}}
... ... @@ -50,23 +50,22 @@
</span>
{{/if}}
<span class="iconfont icon-del" data-count="{{count}}">&#xe621;</span>
</p>
<p class="row">
{{#if lowStocks}}
{{#if lowStocks}}
<p class="row">
<span class="low-stocks">
库存不足
</span>
{{/if}}
</p>
<p class="row">
{{#if appearDate}}
</p>
{{/if}}
{{#if appearDate}}
<p class="row">
<span class="appear-date">
上市期:{{appearDate}}
</span>
{{/if}}
</p>
</p>
{{/if}}
</div>
<div class="calculate-num hide">
<div class="calculate">
... ...
<div class="header">
{{#backUrl}}
<a class="go-back" href="javascript:history.go(-1);"></a>
{{/backUrl}}
<a class="go-back" href="{{#if backUrl}}{{backUrl}}{{^}}javascript:history.go(-1);{{/if}}"></a>
{{#showHeaderImg}}
<div class="img-header"></div>
<div class="img-header"></div>
{{/showHeaderImg}}
{{#headerText}}
<p class="title">{{.}}</p>
<p class="title">{{.}}</p>
{{/headerText}}
</div>
\ No newline at end of file
... ...
... ... @@ -26,13 +26,14 @@ class CartModel
* @param int $isEdit 是否是编辑商品SKU,0表示不是编辑
* @param null|int $promotionId 促销id,默认null(加价购有关)
* @param null|int $uid 用户UID,可以不传
* @param string $shoppingKey 未登录用户唯一识别码,可以不传
* @return array 加入购物车接口返回的数据
*/
public static function addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid)
public static function addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid, $shoppingKey)
{
$result = array('code' => 400, 'message' => '出错啦~~');
$addCart = CartData::addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid);
$addCart = CartData::addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid, $shoppingKey);
if ($addCart && isset($addCart['code'])) {
$result = $addCart;
}
... ... @@ -84,7 +85,7 @@ class CartModel
$result['isEmptyCart'] = true;
break;
}
// 普通购物车空,则显示预售购物车
if ($ordinaryCount === '0') {
$result['cartNav'] = false;
... ... @@ -100,14 +101,14 @@ class CartModel
$result['cartNav'] = true;
$result['cartType'] = 'ordinary';
}
/* 普通购物车 */
$result['commonGoodsCount'] = $ordinaryCount;
$result['commonCart'] = self::procCartData($cart['ordinary_cart_data'], $onlyGift, $onlyAdvanceBuy);
$result['commonCart'] = self::procCartData($cart['ordinary_cart_data'], $onlyGift, $onlyAdvanceBuy, false);
/* 预售购物车 */
$result['presellGoodsCount'] = $advanceCount;
$result['preSellCart'] = self::procCartData($cart['advance_cart_data'], $onlyGift, $onlyAdvanceBuy);
} while(false);
return $result;
... ... @@ -416,7 +417,7 @@ class CartModel
foreach ($payReturn['goods_list'] as $single) {
$oneGoods = array();
$oneGoods['id'] = $single['product_sku']; // TODO 未确定用哪个
$oneGoods['thumb'] = Images::getImageUrl($single['goods_images'], 120, 120);
$oneGoods['thumb'] = Images::getImageUrl($single['goods_images'], 120, 160);
$oneGoods['name'] = $single['product_name'];
$oneGoods['color'] = $single['color_name'];
$oneGoods['size'] = $single['size_name'];
... ... @@ -449,7 +450,11 @@ class CartModel
// 订单数据
if (isset($payReturn['shopping_cart_data']) && !empty($payReturn['shopping_cart_data'])) {
$sumPrice = isset($orderCompute['order_amount']) ? $orderCompute['order_amount'] : $payReturn['shopping_cart_data']['order_amount'];
$result['cartPayData'] = isset($orderCompute['promotion_formula_list']) ? $orderCompute['promotion_formula_list'] : $payReturn['shopping_cart_data']['promotion_formula_list'];
$price = isset($orderCompute['last_order_amount']) ? $orderCompute['last_order_amount'] : $payReturn['shopping_cart_data']['last_order_amount'];
$result['price'] = Helpers::transPrice($price);
/*$sumPrice = isset($orderCompute['order_amount']) ? $orderCompute['order_amount'] : $payReturn['shopping_cart_data']['order_amount'];
$freight = '¥0';
if (isset($orderCompute['promotion_formula_list'][1]['promotion_amount'])) {
... ... @@ -465,7 +470,7 @@ class CartModel
$result['salePrice'] = Helpers::transPrice($salePrice);
$result['price'] = Helpers::transPrice($price);
$result['freight'] = $freight;
$result['couponPrice'] = $couponPrice;
$result['couponPrice'] = $couponPrice;*/
}
// 发票有关数据
... ... @@ -566,17 +571,21 @@ class CartModel
$coupons = CartData::getCouponList($uid);
do {
if ($onlyTotal) {
$result['count'] = count($coupons['data']['couponList']);
break;
}
if (isset($coupons['data']['couponList'])) {
foreach ($coupons['data']['couponList'] as &$val) {
$val['notAvailable'] = $val['isValidity'] === 'N';
foreach ($coupons['data']['couponList'] as $val) {
$notAvailableRes = self::searchCoupon($uid, $val['couponCode']);
// 处理可用的优惠券
if ($val['isValidity'] === 'N' || (isset($notAvailableRes['code']) && $notAvailableRes['code'] !== 200)) {
// $val['notAvailable'] = true;
continue;
}
$result[] = $val;
}
}
$result = $coupons['data']['couponList'];
if ($onlyTotal) {
$count = count($result);
$result = array('count' => $count);
}
}while(0);
... ... @@ -655,6 +664,7 @@ class CartModel
$oneColor = array();
$sizes = array();
$oneSize = array();
$sizeList = array();
$thumbImageList = array();
$colorNum = 0;
$totalStorageNum = 0; // 总库存数
... ... @@ -676,14 +686,16 @@ class CartModel
$colorNum += $one['storage_number'];
$sizeStorageStr .= $one['storage_number'] . '/';
$sizes[] = $oneSize;
$sizeList[$val['color_id']][] = $oneSize;
$colorStorageGroup[$one['size_name']][$val['color_name']] = $one['storage_number'];
}
// 统计尺码对应的各个颜色的库存量
foreach ($sizes as &$sizeArr) {
$sizeArr['colorNumStr'] = implode('/', array_values($colorStorageGroup[ $sizeArr['name'] ]) );
foreach ($sizes as $colorId => $sizeArr) {
foreach ($sizeArr as $key => $value) {
$sizeList[$colorId][$key]['colorNumStr'] = implode('/', array_values($colorStorageGroup[ $sizeArr['name'] ]) );
}
}
// 颜色
... ... @@ -707,6 +719,11 @@ class CartModel
$totalStorageNum += $colorNum;
}
// 格式化尺码对应的各个颜色分组
foreach ($colors as $color) {
$sizes[]['size'] = $sizeList[$color['id']];
}
$data['thumbs'] = $thumbImageList;
$data['colors'] = $colors;
$data['sizes'] = $sizes;
... ... @@ -722,15 +739,16 @@ class CartModel
* @param array $data 不同类型购物车数据
* @param bool $onlyGift 只获取赠品的商品数据
* @param bool $onlyAdvanceBuy 只获取加价购的商品数据
* @param bool $isAdvanceCart 是否是预售购物车,默认是,(和上市期有关)
* @return array $result 处理之后的不同类型购物车数据
*/
private static function procCartData($data, $onlyGift = false, $onlyAdvanceBuy = false)
private static function procCartData($data, $onlyGift = false, $onlyAdvanceBuy = false, $isAdvanceCart = true)
{
$result = array();
do {
// 数据为空时返回空的标志
if (empty($data)) {
if (empty($data['goods_list'])) {
break;
}
... ... @@ -746,13 +764,13 @@ class CartModel
}
// 购买的可用商品列表
$validGoods = Helpers::formatCartGoods($data['goods_list']);
$validGoods = Helpers::formatCartGoods($data['goods_list'], $isAdvanceCart);
if (!empty($validGoods)) {
$result['goods'] = $validGoods;
}
// 失效商品列表
$notValidGoods = Helpers::formatCartGoods($data['sold_out_goods_list'], false);
$notValidGoods = Helpers::formatCartGoods($data['sold_out_goods_list'], $isAdvanceCart, false);
if (!empty($notValidGoods)) {
$result['notValidGoods'] = $notValidGoods;
}
... ... @@ -768,12 +786,25 @@ class CartModel
$result['advanceBuy'] = Helpers::formatAdvanceGoods($data['price_gift'], $result['advanceBuyCount']);
}
// 已参加的活动
if (!empty($data['promotion_info'])) {
$result['promotionInfo'] = array();
$info = array();
foreach ($data['promotion_info'] as $val) {
$info = array();
$info['id'] = $val['promotion_id'];
$info['name'] = $val['promotion_title'];
$result['promotionInfo'][] = $info;
}
}
// 结算数据
$result['price'] = Helpers::transPrice($data['shopping_cart_data']['order_amount']);
$result['activityPrice'] = Helpers::transPrice($data['shopping_cart_data']['discount_amount']);
$result['count'] = $data['shopping_cart_data']['selected_goods_count'];
$result['isAllSelected'] = ($data['shopping_cart_data']['goods_count'] === $data['shopping_cart_data']['selected_goods_count']) && ($data['shopping_cart_data']['selected_goods_count'] >0);
$result['sumPrice'] = Helpers::transPrice($data['shopping_cart_data']['order_amount']);
$result['sumPrice'] = Helpers::transPrice($data['shopping_cart_data']['last_order_amount']);
}while(0);
return $result;
... ...
... ... @@ -20,175 +20,183 @@ class DetailModel
/**
* 商品基本信息
*
* @param int $productId 商品ID
* @param int $productId 商品ID SKN 和 ID 只需要传一个
* @param int $goodsId 某个颜色的商品
* @param int $uid 当前登录用户ID, 未登录为0
* @param int $productSkn SKN 和 ID 只需要传一个
* @return array
*/
public static function getBaseInfo($productId, $goodsId, $uid, $vipLevel)
public static function getBaseInfo($productId, $goodsId, $uid, $vipLevel, $productSkn = null)
{
$result = array();
$baseInfo = array();
// 通过ID获取
if (is_numeric($productId) && is_numeric($goodsId)) {
// 调用服务
$baseInfo = DetailData::baseInfo($productId, $uid);
}
// 通过SKN获取
elseif (is_numeric($productSkn)) {
$baseInfo = DetailData::baseInfo(null, $uid, $productSkn);
}
// 商品名称
if (isset($baseInfo['productName'])) {
$result['goodsName'] = $baseInfo['productName'];
}
// 商品名称
if (empty($baseInfo['productName'])) {
return $result;
}
$result['goodsName'] = $baseInfo['productName'];
// 商品促销短语
if (!empty($baseInfo['salesPhrase'])) {
$result['goodsSubtitle'] = $baseInfo['salesPhrase'];
}
// 商品促销短语
if (!empty($baseInfo['salesPhrase'])) {
$result['goodsSubtitle'] = $baseInfo['salesPhrase'];
}
// 商品标签
if (!empty($baseInfo['productTagBoList'])) {
foreach ($baseInfo['productTagBoList'] as $value) {
switch ($value['tagLabel']) {
case 'is_soon_sold_out': // 即将售磬
$result['tags']['is_soon_sold_out'] = true;
break;
case 'is_new': // 新品NEW
$result['tags']['is_new'] = true;
break;
case 'is_discount': // SALE
$result['tags']['is_discount'] = true;
break;
case 'is_limited': // 限量
$result['tags']['is_limited'] = true;
break;
case 'is_yohood': // YOHOOD
$result['tags']['is_yohood'] = true;
break;
case 'is_advance': // 再到着
$result['tags']['is_advance'] = true;
break;
}
// 商品标签
if (!empty($baseInfo['productTagBoList'])) {
foreach ($baseInfo['productTagBoList'] as $value) {
switch ($value['tagLabel']) {
case 'is_soon_sold_out': // 即将售磬
$result['tags']['is_soon_sold_out'] = true;
break;
case 'is_new': // 新品NEW
$result['tags']['is_new'] = true;
break;
case 'is_discount': // SALE
$result['tags']['is_discount'] = true;
break;
case 'is_limited': // 限量
$result['tags']['is_limited'] = true;
break;
case 'is_yohood': // YOHOOD
$result['tags']['is_yohood'] = true;
break;
case 'is_advance': // 再到着
$result['tags']['is_advance'] = true;
break;
}
}
}
// 商品价格
if (isset($baseInfo['productPriceBo'])) {
$result['goodsPrice'] = array();
$result['goodsPrice']['currentPrice'] = $baseInfo['productPriceBo']['formatSalesPrice'];
if ($baseInfo['productPriceBo']['formatMarketPrice'] !== $baseInfo['productPriceBo']['formatSalesPrice']) {
$result['goodsPrice']['previousPrice'] = $baseInfo['productPriceBo']['formatMarketPrice'];
}
// 商品价格
if (isset($baseInfo['productPriceBo'])) {
$result['goodsPrice'] = array();
$result['goodsPrice']['currentPrice'] = $baseInfo['productPriceBo']['formatSalesPrice'];
if ($baseInfo['productPriceBo']['formatMarketPrice'] !== $baseInfo['productPriceBo']['formatSalesPrice']) {
$result['goodsPrice']['previousPrice'] = $baseInfo['productPriceBo']['formatMarketPrice'];
}
// VIP商品价格
if (isset($baseInfo['productPriceBo']['vipPrices'])) {
$build = array();
foreach ($baseInfo['productPriceBo']['vipPrices'] as $value) {
$build['level'] = $value['vipLevel'];
$build['text'] = $value['vipPrice'];
$build['currentLevel'] = ($value['vipLevel'] == $vipLevel) ? true : false;
$result['vipLevel']['list'][] = $build;
}
}
// VIP商品价格
if (isset($baseInfo['productPriceBo']['vipPrices'])) {
$build = array();
foreach ($baseInfo['productPriceBo']['vipPrices'] as $value) {
$build['level'] = $value['vipLevel'];
$build['text'] = $value['vipPrice'];
$build['currentLevel'] = ($value['vipLevel'] == $vipLevel) ? true : false;
$result['vipLevel']['list'][] = $build;
}
}
// 上市期
if (isset($baseInfo['expectArrivalTime']) && !empty($baseInfo['expectArrivalTime'])) {
$result['periodOfMarket'] = $baseInfo['expectArrivalTime'] . '月';
}
// 上市期
if (isset($baseInfo['expectArrivalTime']) && !empty($baseInfo['expectArrivalTime'])) {
$result['periodOfMarket'] = $baseInfo['expectArrivalTime'] . '月';
}
// 促销信息
if (isset($baseInfo['promotionBoList'])) {
$build = array();
foreach ($baseInfo['promotionBoList'] as $value) {
$build['text'] = '【' . $value['promotionType'] . '】' . $value['promotionTitle'];
$result['goodsDiscount']['list'][] = $build;
}
// 促销信息
if (isset($baseInfo['promotionBoList'])) {
$build = array();
foreach ($baseInfo['promotionBoList'] as $value) {
$build['text'] = '【' . $value['promotionType'] . '】' . $value['promotionTitle'];
$result['goodsDiscount']['list'][] = $build;
}
}
$result['feedbacks'] = array();
// 商品咨询
$result['feedbacks']['consultsNum'] = 0;
if (!empty($baseInfo['consultBoWrapper'])) {
$result['feedbacks']['consultsNum'] = $baseInfo['consultBoWrapper']['consultTotal'];
$result['feedbacks']['consults'] = array();
$build = array();
foreach ($baseInfo['consultBoWrapper']['consultBoList'] as $value) {
$build['question'] = $value['ask'];
$build['time'] = $value['askTime'];
$build['answer'] = $value['answer'];
$result['feedbacks']['consults'][] = $build;
}
$result['feedbacks']['consultsUrl'] = Helpers::url('/product/detail/consults', array('product_id' => $productId, 'total' => $result['feedbacks']['consultsNum']));
}
// 暂无咨询
else {
$result['feedbacks']['consultsUrl'] = Helpers::url('/product/detail/consultform', array('product_id' => $productId));
$result['feedbacks'] = array();
// 商品咨询
$result['feedbacks']['consultsNum'] = 0;
if (!empty($baseInfo['consultBoWrapper'])) {
$result['feedbacks']['consultsNum'] = $baseInfo['consultBoWrapper']['consultTotal'];
$result['feedbacks']['consults'] = array();
$build = array();
foreach ($baseInfo['consultBoWrapper']['consultBoList'] as $value) {
$build['question'] = $value['ask'];
$build['time'] = $value['askTime'];
$build['answer'] = $value['answer'];
$result['feedbacks']['consults'][] = $build;
}
$result['feedbacks']['consultsUrl'] = Helpers::url('/product/detail/consults', array('product_id' => $productId, 'total' => $result['feedbacks']['consultsNum']));
}
// 暂无咨询
else {
$result['feedbacks']['consultsUrl'] = Helpers::url('/product/detail/consultform', array('product_id' => $productId));
}
// 商品评价
$result['feedbacks']['commentsNum'] = 0;
if (!empty($baseInfo['commentBoWrapper'])) {
$result['feedbacks']['commentsNum'] = $baseInfo['commentBoWrapper']['commentTotal'];
$result['feedbacks']['comments'] = array();
$build = array();
foreach ($baseInfo['commentBoWrapper']['commentBoList'] as $value) {
$build['userName'] = $value['nickName'];
$build['desc'] = $value['colorName'] . '/' . $value['sizeName'];
$build['content'] = isset($value['content']) ? $value['content'] : '';
$build['time'] = $value['createTime'];
$result['feedbacks']['comments'][] = $build;
}
$result['feedbacks']['commentsUrl'] = Helpers::url('/product/detail/comments', array('product_id' => $productId, 'total' => $result['feedbacks']['commentsNum']));
// 商品评价
$result['feedbacks']['commentsNum'] = 0;
if (!empty($baseInfo['commentBoWrapper'])) {
$result['feedbacks']['commentsNum'] = $baseInfo['commentBoWrapper']['commentTotal'];
$result['feedbacks']['comments'] = array();
$build = array();
foreach ($baseInfo['commentBoWrapper']['commentBoList'] as $value) {
$build['userName'] = $value['nickName'];
$build['desc'] = $value['colorName'] . '/' . $value['sizeName'];
$build['content'] = isset($value['content']) ? $value['content'] : '';
$build['time'] = $value['createTime'];
$result['feedbacks']['comments'][] = $build;
}
$result['feedbacks']['commentsUrl'] = Helpers::url('/product/detail/comments', array('product_id' => $productId, 'total' => $result['feedbacks']['commentsNum']));
}
// 品牌信息
if (!empty($baseInfo['brand'])) {
$result['enterStore'] = array(
'img' => Helpers::getImageUrl($baseInfo['brand']['brandIco'], 47, 47),
'storeName' => $baseInfo['brand']['brandName'],
'url' => Helpers::url('', array(), $baseInfo['brand']['brandDomain'])
);
// 为你优选的链接
$result['preferenceUrl'] = Helpers::url('/product/detail/preference', array('productSkn' => $baseInfo['erpProductId'], 'brandId' => $baseInfo['brand']['id']), '');
}
// 品牌信息
if (!empty($baseInfo['brand'])) {
$result['enterStore'] = array(
'img' => Helpers::getImageUrl($baseInfo['brand']['brandIco'], 47, 47),
'storeName' => $baseInfo['brand']['brandName'],
'url' => Helpers::url('', array(), $baseInfo['brand']['brandDomain'])
);
// 为你优选的链接
$result['preferenceUrl'] = Helpers::url('/product/detail/preference', array('productSkn' => $baseInfo['erpProductId'], 'brandId' => $baseInfo['brand']['id']), '');
}
// 商品信息
if (!empty($baseInfo['goodsList'])) {
$colorGroup = array();
$sizeList = array();
$goodsGroup = array();
$thumbImageList = array();
$colorStorageGroup = array(); // 颜色分组的库存总数集合, 多个之间用/分隔
$sizeStorageStr = ''; // 尺码库存总数集合, 多个之间用/分隔
$colorStorageNum = 0;
$totalStorageNum = 0; // 总库存数
foreach ($baseInfo['goodsList'] as $value) {
$colorStorageNum = 0;
$sizeStorageStr = '';
// 商品分组
if (isset($value['goodsImagesList'])) {
foreach ($value['goodsImagesList'] as $goods) {
$goodsGroup[] = array(
'goodsId' => $goods['goodsId'],
'img' => $goods['imageUrl'],
);
}
// 商品信息
if (!empty($baseInfo['goodsList'])) {
$colorGroup = array();
$sizeGroup = array();
$goodsGroup = array();
$sizeList = array();
$thumbImageList = array();
$colorStorageGroup = array(); // 颜色分组的库存总数集合, 多个之间用/分隔
$sizeStorageStr = ''; // 尺码库存总数集合, 多个之间用/分隔
$colorStorageNum = 0;
$totalStorageNum = 0; // 总库存数
foreach ($baseInfo['goodsList'] as $value) {
$colorStorageNum = 0;
$sizeStorageStr = '';
// 商品分组
if (isset($value['goodsImagesList'])) {
foreach ($value['goodsImagesList'] as $goods) {
$goodsGroup[] = array(
'goodsId' => $goods['goodsId'],
'img' => $goods['imageUrl'],
);
}
}
// 商品的尺码列表
if (isset($value['goodsSizeBoList'])) {
foreach ($value['goodsSizeBoList'] as $size) {
$sizeList[] = array(
'id' => $size['id'],
'skuId' => $size['goodsSizeSkuId'],
'goodsId' => $size['goodsId'],
'colorId' => $value['colorId'],
'name' => $size['sizeName'],
'sizeNum' => $size['goodsSizeStorageNum'],
);
$colorStorageNum += intval($size['goodsSizeStorageNum']);
$sizeStorageStr .= $size['goodsSizeStorageNum'] . '/';
$colorStorageGroup[ $size['sizeName'] ][ $value['colorName'] ] = $size['goodsSizeStorageNum'];
}
// 商品的尺码列表
if (isset($value['goodsSizeBoList'])) {
foreach ($value['goodsSizeBoList'] as $size) {
$sizeList[$value['colorId']][] = array(
'id' => $size['id'],
'skuId' => $size['goodsSizeSkuId'],
'goodsId' => $size['goodsId'],
'colorId' => $value['colorId'],
'name' => $size['sizeName'],
'sizeNum' => $size['goodsSizeStorageNum'],
);
$colorStorageNum += intval($size['goodsSizeStorageNum']);
$sizeStorageStr .= $size['goodsSizeStorageNum'] . '/';
$colorStorageGroup[$size['sizeName']][$value['colorId']] = $size['goodsSizeStorageNum'];
}
// 颜色分组
... ... @@ -200,75 +208,82 @@ class DetailModel
'colorNum' => $colorStorageNum,
'sizeNumStr' => rtrim($sizeStorageStr, '/'),
);
// 缩略图
$thumbImageList[] = array('img' => Helpers::getImageUrl($value['colorImage'], 60, 60) );
// 统计尺码对应的各个颜色的库存量
foreach ($sizeList as &$sizeArr) {
$sizeArr['colorNumStr'] = implode('/', array_values($colorStorageGroup[ $sizeArr['name'] ]) );
}
// 商品库存总数
$totalStorageNum += $colorStorageNum;
}
// 商品图: 多个
if (isset($goodsGroup[1])) {
foreach ($goodsGroup as $value) {
$result['bannerTop']['list'][] = array(
'img' => Helpers::getImageUrl($value['img'], 450, 600)
);
// 缩略图
$thumbImageList[] = array('img' => Helpers::getImageUrl($value['colorImage'], 60, 60));
// 添加尺码对应的各个颜色的库存量
foreach ($sizeList as $colorId => $sizeArr) {
foreach ($sizeArr as $key => $value) {
$sizeList[$colorId][$key]['colorNumStr'] = implode('/', array_values($colorStorageGroup[$value['name']]));
}
}
// 商品图: 单个
elseif (isset($goodsGroup[0])) {
$result['bannerTop'] = array(
'img' => Helpers::getImageUrl($goodsGroup[0]['img'], 450, 600)
);
}
// 商品库存总数
$totalStorageNum += $colorStorageNum;
}
// 悬浮的购物车信息
$result['cartInfo'] = array(
'cartUrl' => Helpers::url('/cart/index/index', null), // 购物车链接
'numInCart' => 0,
'goodsInstore' => $baseInfo['storage'], // 库存量
);
$soldOut = ($baseInfo['storage'] == 0) || ($baseInfo['status'] == 0);
$notForSale = $baseInfo['attribute'] == 2;
// 显示加入购物车链接
if (!$soldOut && !$notForSale) {
$result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html');
$result['cartInfo']['productId'] = $productId;
$result['cartInfo']['thumbs'] = $thumbImageList;
$result['cartInfo']['name'] = isset($result['goodsName']) ? $result['goodsName'] : '';
$result['cartInfo']['price'] = isset($result['goodsPrice']['previousPrice']) ? $result['goodsPrice']['previousPrice'] : '';
$result['cartInfo']['salePrice'] = isset($result['goodsPrice']['currentPrice']) ? $result['goodsPrice']['currentPrice'] : '';
$result['cartInfo']['totalNum'] = $totalStorageNum;
$result['cartInfo']['colors'] = $colorGroup;
$result['cartInfo']['sizes'] = $sizeList;
// 格式化尺码对应的各个颜色分组
foreach ($colorGroup as $value) {
$sizeGroup[]['size'] = $sizeList[ $value['id'] ];
}
// 非卖品
elseif ($notForSale) {
$result['cartInfo']['notForSale'] = true;
// 商品图: 多个
if (isset($goodsGroup[1])) {
foreach ($goodsGroup as $value) {
$result['bannerTop']['list'][] = array(
'img' => Helpers::getImageUrl($value['img'], 450, 600)
);
}
}
// 已售磬
elseif ($soldOut) {
$result['cartInfo']['soldOut'] = true;
// 商品图: 单个
elseif (isset($goodsGroup[0])) {
$result['bannerTop'] = array(
'img' => Helpers::getImageUrl($goodsGroup[0]['img'], 450, 600)
);
}
}
// 是否收藏
$result['isCollect'] = false;
if (isset($baseInfo['isCollect']) && $baseInfo['isCollect'] === 'Y') {
$result['isCollect'] = true;
}
// 悬浮的购物车信息
$result['cartInfo'] = array(
'cartUrl' => Helpers::url('/cart/index/index', null), // 购物车链接
'numInCart' => 0,
'goodsInstore' => $baseInfo['storage'], // 库存量
);
$soldOut = ($baseInfo['storage'] == 0) || ($baseInfo['status'] == 0);
$notForSale = $baseInfo['attribute'] == 2;
// 显示加入购物车链接
if (!$soldOut && !$notForSale) {
$result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html');
$result['cartInfo']['productId'] = $productId;
$result['cartInfo']['thumbs'] = $thumbImageList;
$result['cartInfo']['name'] = isset($result['goodsName']) ? $result['goodsName'] : '';
$result['cartInfo']['price'] = isset($result['goodsPrice']['previousPrice']) ? $result['goodsPrice']['previousPrice'] : '';
$result['cartInfo']['salePrice'] = isset($result['goodsPrice']['currentPrice']) ? $result['goodsPrice']['currentPrice'] : '';
$result['cartInfo']['totalNum'] = $totalStorageNum;
$result['cartInfo']['colors'] = $colorGroup;
$result['cartInfo']['sizes'] = $sizeGroup;
}
// 非卖品
elseif ($notForSale) {
$result['cartInfo']['notForSale'] = true;
}
// 已售磬
elseif ($soldOut) {
$result['cartInfo']['soldOut'] = true;
}
// 底部简介的URL链接
$result['introUrl'] = Helpers::url('/product/intro_' . $baseInfo['erpProductId'] . '/' . $baseInfo['cnAlphabet'] . '.html', null, '');
$result['id'] = $productId;
// 是否收藏
$result['isCollect'] = false;
if (isset($baseInfo['isCollect']) && $baseInfo['isCollect'] === 'Y') {
$result['isCollect'] = true;
}
// 底部简介的URL链接
$result['introUrl'] = Helpers::url('/product/intro_' . $baseInfo['erpProductId'] . '/' . $baseInfo['cnAlphabet'] . '.html', null, '');
$result['id'] = $productId;
return $result;
}
... ... @@ -355,10 +370,9 @@ class DetailModel
foreach ($sizeInfo['sizeInfoBo']['sizeBoList'] as $value) {
$item = array();
$sizeNameList[] = array('param' => $value['sizeName']);
if ($boyReference && ($gender == 1 || $gender == 3) ) {
if ($boyReference && ($gender == 1 || $gender == 3)) {
$referenceList[] = array('param' => empty($value['boyReferSize']['referenceName']) ? ' ' : $value['boyReferSize']['referenceName']);
}
elseif ($girlReference && ($gender == 2 || $gender == 3) ) {
} elseif ($girlReference && ($gender == 2 || $gender == 3)) {
$referenceList[] = array('param' => empty($value['girlReferSize']['referenceName']) ? ' ' : $value['girlReferSize']['referenceName']);
}
foreach ($value['sortAttributes'] as $attr) {
... ... @@ -469,6 +483,7 @@ class DetailModel
'</p>' => '',
'<img src=' => "<img class=\"lazy\" src=\"data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP///93d3f///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw==\" data-original=",
'<img border="0" src=' => "<img border=\"0\" class=\"lazy\" src=\"data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP///93d3f///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw==\" data-original=",
'.jpg' => '.jpg?imageMogr2/thumbnail/750x/quality/90',
)),
);
}
... ...
... ... @@ -446,7 +446,7 @@ class IndexController extends AbstractAction
$result = CartModel::addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid, $shoppingKey);
// 设置加入购物车凭证到客户端浏览器
if (isset($result['data']['shopping_key'])) {
if (!$shoppingKey && isset($result['data']['shopping_key'])) {
$this->setCookie('_spk', $result['data']['shopping_key']);
}
}
... ...
... ... @@ -17,7 +17,8 @@ class BindController extends AbstractAction
public function indexAction()
{
$refer = $this->get('refer');
if (!empty($refer)) {
if (!empty($refer))
{
$this->setCookie('refer', $refer);
}
... ... @@ -105,9 +106,11 @@ class BindController extends AbstractAction
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do {
do
{
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
if (!$this->isAjax())
{
break;
}
... ... @@ -118,21 +121,27 @@ 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 {
}
else
{
$data = array('code' => $res['code'], 'message' => $res['message'], 'data' => isset($res['data']) ? $res['data'] : '');
}
} while (false);
}
while (false);
$this->echoJson($data);
}
... ... @@ -142,24 +151,29 @@ 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) || !$areaCode)
{
break;
}
$data = BindData::sendBindMsg($areaCode, $phoneNum);
if (!isset($data['code'])) {
if (!isset($data['code']))
{
break;
}
} while (false);
}
while (false);
$this->echoJson($data);
}
... ... @@ -169,9 +183,11 @@ class BindController extends AbstractAction
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do {
do
{
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
if (!$this->isAjax())
{
break;
}
... ... @@ -179,15 +195,18 @@ class BindController extends AbstractAction
$code = $this->post('code');
$areaCode = $this->post('areaCode');
if (!is_numeric($phoneNum) || !$code) {
if (!is_numeric($phoneNum) || !$code || !$areaCode)
{
break;
}
$data = BindData::checkBindCode($areaCode, $phoneNum, $code);
if (!isset($data['code'])) {
if (!isset($data['code']))
{
break;
}
} while (false);
}
while (false);
$this->echoJson($data);
}
... ... @@ -197,9 +216,11 @@ class BindController extends AbstractAction
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do {
do
{
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
if (!$this->isAjax())
{
break;
}
... ... @@ -210,33 +231,107 @@ 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);
}
//换绑check
public function changeCheckAction()
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do
{
/* 判断是不是AJAX请求 */
if (!$this->isAjax())
{
break;
}
$phoneNum = $this->post('phoneNum');
$areaCode = $this->post('areaCode');
if (!is_numeric($phoneNum) || !$areaCode)
{
break;
}
$data = BindData::changeCheck($phoneNum, $areaCode);
if (!isset($data['code']))
{
break;
}
}
while (false);
$this->echoJson($data);
}
//换绑mobile
public function changeMobileAction()
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do
{
/* 判断是不是AJAX请求 */
if (!$this->isAjax())
{
break;
}
$uid = $this->getUid(true);
$phoneNum = $this->post('phoneNum');
$areaCode = $this->post('areaCode');
$code = $this->post('code');
if (!is_numeric($phoneNum) || !$areaCode || !$code || !$uid)
{
break;
}
$data = BindData::changeMobile($uid, $phoneNum, $areaCode, $code);
if (!isset($data['code']))
{
break;
}
}
while (false);
$this->echoJson($data);
}
... ...
... ... @@ -44,7 +44,39 @@ class DetailController extends AbstractAction
$this->setTitle($data['goodsName']);
}
$this->setNavHeader('商品详情');
// 渲染模板
$this->_view->display('index', $data);
}
/**
* 商品详情 (SKN)
*
* @param int productSkn
*/
public function showAction()
{
$productSkn = $this->param('productSkn');
if (!is_numeric($productSkn)) {
$this->error();
}
$uid = $this->getUid();
$vipLevel = 0;
if (isset($this->_vip)) {
$vipLevel = Helpers::getVipLevel($this->_vip);
}
$data = \Product\DetailModel::getBaseInfo(null, null, $uid, $vipLevel, $productSkn);
if (array() === $data) {
$this->error();
}
$data['goodsDetailPage'] = true;
$data['pageFooter'] = true;
if (isset($data['goodsName'])) {
$this->setTitle($data['goodsName']);
}
$this->setNavHeader('商品详情');
// 渲染模板
$this->_view->display('index', $data);
}
... ...
... ... @@ -147,6 +147,13 @@ routes.productintro.route.controller = Detail
routes.productintro.route.action = Intro
routes.productintro.map.1 = productSkn
routes.productskn.type = "regex"
routes.productskn.match = "#/product/show_([0-9]+).html#"
routes.productskn.route.module = Product
routes.productskn.route.controller = Detail
routes.productskn.route.action = Show
routes.productskn.map.1 = productSkn
; 订单相关
routes.cart.type = "rewrite"
routes.cart.match = "/home/order/detail$"
... ...
... ... @@ -20,3 +20,10 @@ routes.productintro.route.module = Product
routes.productintro.route.controller = Detail
routes.productintro.route.action = Intro
routes.productintro.map.1 = productSkn
routes.productskn.type = "regex"
routes.productskn.match = "#/product/show_([0-9]+).html#"
routes.productskn.route.module = Product
routes.productskn.route.controller = Detail
routes.productskn.route.action = Show
routes.productskn.map.1 = productSkn
... ...