Authored by biao

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

Showing 44 changed files with 1549 additions and 1333 deletions
... ... @@ -823,19 +823,23 @@
{
id: 1,
chosed: true,
name: '黄色'
},
...
],
sizes: [
{
id: 2,
chosed: true,
name: 'X'
name: '黄色',
colorNum:10,
shortUrl:'',
sizes: [
{
id: 2,
chosed: true,
name: 'X',
sizeNum: 2
},
...
]
},
...
],
num: 2
totalNum: 20
}
### 购物车商品
... ... @@ -1134,7 +1138,8 @@
'feedbacks' : {
'commentsNum' : 0,
'consultsNum' : 1,
'link' : '',
'commentsUrl' : '',
'consultsUrl' : '',
'comments' : [
{
'userName' : 'Lynnic',
... ... @@ -1264,6 +1269,20 @@
'id' : '',
'preferenceUrl' :''
}
### 评价列表页面
{
'comments':{
'list' : [
{
'userName':'',
'desc':'',
'content':'',
'time':''
}
...
]
}
}
### 咨询列表页面
{
'link' : '咨询表单跳转url',
... ... @@ -1318,3 +1337,29 @@
]
}
### 频道选择页
{
'background' : 'http://img11.static.yhbimg.com/yhb-img01/2015/12/14/03/0189f7499bcb98cbeb4d18d61275606716.png?imageView/2/w/640/h/800',
'searchUrl' : 'http://search.dev.yohobuy.com',
'channelList' : [
{
'href' : '/boys',
'title' : '男生',
'entitle' : 'BOYS',
}, {
'href' : '/girls',
'title' : ' 女生',
'entitle' : 'GIRLS',
}, {
'href' : '/kids',
'title' : '潮童',
'entitle' : KIDS'',
}, {
'href' : '/lifestyle',
'title' : '创意生活',
'entitle' : 'LIFESTYLE',
}
],
'showYohood' : true/false
}
... ...
... ... @@ -17,257 +17,294 @@ use Api\Yohobuy;
class CartData
{
/**
* 加入购物车接口
*
* @param int $productSku 商品SKU
* @param int $buyNumber 购买数量
* @param int $goodsType 商品类型,0表示普通商品,1表示加价购商品
* @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, $shoppingKey = '')
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.add';
$param['product_sku'] = $productSku;
$param['buy_number'] = $buyNumber;
$param['goods_type'] = $goodsType;
$param['edit_product_sku'] = $isEdit;
$param['selected'] = 'Y';
$param['promotion_id'] = $promotionId;
$param['shopping_key'] = $shoppingKey;
if (!empty($uid)) {
$param['uid'] = $uid;
}
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 购物车数据
*
* @param int $uid 用户ID
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 购物车接口返回的数据
*/
public static function cartData($uid, $shoppingKey)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.cart';
if (!empty($uid)) {
$param['uid'] = $uid;
}
if (!empty($shoppingKey)) {
$param['shopping_key'] = $shoppingKey;
}
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 移出购物车
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public static function removeFromCart($uid, $sku, $shoppingKey)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.remove';
$param['product_sku_list'] = $sku;
if (!empty($uid)) {
$param['uid'] = $uid;
}
if (!empty($shoppingKey)) {
$param['shopping_key'] = $shoppingKey;
}
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 移入收藏夹
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @return array 接口返回的数据
*/
public static function addToFav($uid, $sku)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.addfavorite';
$param['product_sku_list'] = $sku;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 获取购物车商品数据
*
* @param int $uid 用户ID
* @param int $skn 商品skn
* @return array 接口返回的数据
*/
public static function cartProductData($uid, $skn)
{
$param = Yohobuy::param();
$param['method'] = 'app.product.data';
$param['product_skn'] = $skn;
$param['showcomment'] = 'N';
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 获取加价购商品数据
*
* @param int $skn 商品skn
* @param int $promotionId 加价购商品促销ID
* @return array 接口返回的数据
*/
public static function giftProductData($skn, $promotionId)
{
$param = Yohobuy::param();
$param['method'] = 'app.product.gift';
$param['product_skn'] = $skn;
$param['promotion_id'] = $promotionId;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 修改购物车商品数据
*
* @param int $uid 用户ID
* @param string $swapData 商品数据
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public static function modifyCartProduct($uid, $swapData, $shoppingKey)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.swap';
$param['swap_data'] = $swapData;
if (!empty($uid)) {
$param['uid'] = $uid;
}
if ($shoppingKey !== null) {
$param['shopping_key'] = $shoppingKey;
}
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 购物车结算
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @return array 接口返回的数据
*/
public static function cartPay($uid, $cartType)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.payment';
$param['cart_type'] = $cartType;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 购物车结算--支付方式和配送方式选择
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @param string $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运
* @param string $paymentType 支付方式,1表示在线支付,2表示货到付款
* @param string $yohoCoin 使用的YOHO币数量,默认为null表示不适用
* @return array 接口返回的数据
*/
public static function paymentTypeAndDelivery($uid, $cartType, $deliveryWay, $paymentType, $yohoCoin = null)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.compute';
$param['cart_type'] = $cartType;
$param['delivery_way'] = $deliveryWay;
$param['payment_type'] = $paymentType;
if ($yohoCoin !== null) {
$param['use_yoho_coin'] = $yohoCoin;
}
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 购物车结算--使用优惠券
*
* @param int $uid 用户ID
* @param string $couponCode 优惠券代码
* @return array 接口返回的数据
*/
public static function getCoupon($uid, $couponCode)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.useCoupon';
$param['coupon_code'] = $couponCode;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 购物车结算--提交结算信息
*
* @param int $uid 用户ID
* @param string $couponCode 优惠券代码
* @return array 接口返回的数据
*/
public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.submit';
$param['addressId'] = $addressId;
$param['cart_type'] = $cartType;
$param['delivery_time'] = $deliveryTime;
$param['delivery_way'] = $deliveryWay;
$param['invoices_title'] = $invoiceTitle;
$param['invoices_type_id'] = $invoiceId;
$param['payment_id'] = $paymentId;
$param['payment_type'] = $paymentType;
$param['remark'] = $remark;
$param['use_yoho_coin'] = $yohoCoin;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 加入购物车接口
*
* @param int $productSku 商品SKU
* @param int $buyNumber 购买数量
* @param int $goodsType 商品类型,0表示普通商品,1表示加价购商品
* @param int int $isEdit 是否是编辑商品SKU,0表示不是编辑
* @param null|int $promotionId 促销id,默认null(加价购有关)
* @param null|int $uid 用户UID,可以不传
* @return array 加入购物车接口返回的数据
*/
public static function addToCart($productSku, $buyNumber, $goodsType, $isEdit = 0, $promotionId = null, $uid = null)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.add';
$param['product_sku'] = $productSku;
$param['buy_number'] = $buyNumber;
$param['goods_type'] = $goodsType;
$param['edit_product_sku'] = $isEdit;
$param['selected'] = 'Y';
$param['promotion_id'] = $promotionId;
if ($uid !== null) {
$param['uid'] = $uid;
}
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 购物车数据
*
* @param int $uid 用户ID
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 购物车接口返回的数据
*/
public static function cartData($uid, $shoppingKey)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.cart';
if (!empty($uid)) {
$param['uid'] = $uid;
}
if (!empty($shoppingKey)) {
$param['shopping_key'] = $shoppingKey;
}
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 移出购物车
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public static function removeFromCart($uid, $sku, $shoppingKey)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.remove';
$param['product_sku_list'] = $sku;
if (!empty($uid)) {
$param['uid'] = $uid;
}
if (!empty($shoppingKey)) {
$param['shopping_key'] = $shoppingKey;
}
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 移入收藏夹
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @return array 接口返回的数据
*/
public static function addToFav($uid, $sku)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.addfavorite';
$param['product_sku_list'] = $sku;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 获取购物车商品数据
*
* @param int $uid 用户ID
* @param int $skn 商品skn
* @return array 接口返回的数据
*/
public static function cartProductData($uid, $skn)
{
$param = Yohobuy::param();
$param['method'] = 'app.product.data';
$param['product_skn'] = $skn;
$param['showcomment'] = 'N';
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 获取加价购商品数据
*
* @param int $skn 商品skn
* @param int $promotionId 加价购商品促销ID
* @return array 接口返回的数据
*/
public static function giftProductData($skn, $promotionId)
{
$param = Yohobuy::param();
$param['method'] = 'app.product.gift';
$param['product_skn'] = $skn;
$param['promotion_id'] = $promotionId;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 修改购物车商品数据
*
* @param int $uid 用户ID
* @param string $swapData 商品数据
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public static function modifyCartProduct($uid, $swapData, $shoppingKey)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.swap';
$param['swap_data'] = $swapData;
if (!empty($uid)) {
$param['uid'] = $uid;
}
if ($shoppingKey !== null) {
$param['shopping_key'] = $shoppingKey;
}
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 购物车结算
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @return array 接口返回的数据
*/
public static function cartPay($uid, $cartType)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.payment';
$param['cart_type'] = $cartType;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 购物车结算--支付方式和配送方式选择
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @param int $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运
* @param int $paymentType 支付方式,1表示在线支付,2表示货到付款
* @param string $couponCode 优惠券码
* @param mixed $yohoCoin 使用的YOHO币数量
* @return array 接口返回的数据
*/
public static function orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.compute';
$param['cart_type'] = $cartType;
$param['delivery_way'] = $deliveryWay;
$param['payment_type'] = $paymentType;
if (!empty($couponCode)) {
$param['coupon_code'] = $couponCode;
}
if (!empty($yohoCoin)) {
$param['use_yoho_coin'] = $yohoCoin;
}
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 购物车结算--使用优惠券
*
* @param int $uid 用户ID
* @param string $couponCode 优惠券代码
* @return array 接口返回的数据
*/
public static function searchCoupon($uid, $couponCode)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.useCoupon';
$param['coupon_code'] = $couponCode;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 购物车结算--获取优惠券列表
*
* @param int $uid 用户ID
* @return array 接口返回的数据
*/
public static function getCouponList($uid)
{
$param = Yohobuy::param();
$param['method'] = 'app.coupons.lists';
$param['type'] = 'notuse';
$param['page'] = 1;
$param['limit'] = 1000;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 购物车结算--提交结算信息
*
* @param int $uid 用户ID
* @param int $addressId 地址ID
* @param int $cartType 购物车类型ID
* @param int $deliveryTime 寄送时间ID
* @param int $deliveryWay 寄送方式ID
* @param string $invoiceTitle 发票说明
* @param int $invoiceId 发票类型ID
* @param int $paymentId 支付方式ID
* @param int $paymentType 支付类型ID
* @param string $remark 留言
* @param mixed $yohoCoin 使用的YOHO币数量或为空
* @return array 接口返回的数据
*/
public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.submit';
$param['addressId'] = $addressId;
$param['cart_type'] = $cartType;
$param['delivery_time'] = $deliveryTime;
$param['delivery_way'] = $deliveryWay;
if (!empty($invoiceTitle)) {
$param['invoices_title'] = $invoiceTitle;
}
if (!empty($invoiceId)) {
$param['invoices_type_id'] = $invoiceId;
}
$param['payment_id'] = $paymentId;
$param['payment_type'] = $paymentType;
$param['remark'] = $remark;
if (!empty($yohoCoin)) {
$param['use_yoho_coin'] = $yohoCoin;
}
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
... ... @@ -4,7 +4,7 @@ namespace LibModels\Wap\Home;
use Api\Yohobuy;
use Api\Sign;
/*
/**
* 帮助中心数据模型
*
*/
... ... @@ -12,7 +12,8 @@ class HelpData
{
/*
* 获取帮助中心列表
* 获取帮助列表(分类),缓存1h
* clientType客户端
*/
public static function serviceInfo()
{
... ... @@ -23,21 +24,7 @@ class HelpData
return Yohobuy::post(Yohobuy::API_URL, $param, $param);
}
/*
* 获取帮助中心列表
*/
public static function serviceDetail($code)
{
//构建必传参数
$param = Yohobuy::param();
$param['method'] = 'app.help.detail';
$param['code'] = $code;
$param['return_type'] = 'html';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(Yohobuy::API_URL, $param,$param );
}
}
... ...
... ... @@ -73,7 +73,6 @@ class DetailData
$param['limit'] = $pageSize;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
... ... @@ -94,7 +93,6 @@ class DetailData
$param['limit'] = $pageSize;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
... ...
... ... @@ -158,6 +158,21 @@ function reMarginFooter(fixedElement) {
$footer.removeClass('hide');
}());
(function(w, d, s, j, f) {
var a = d.createElement(s);
var m = d.getElementsByTagName(s)[0];
w.YohoAcquisitionObject = f;
w[f] = function() {
w[f].p = arguments;
};
a.async = 1;
a.src = j;
m.parentNode.insertBefore(a, m);
})(window, document, 'script', 'http://cdn.yoho.cn/yas-jssdk/1.0.13.6.3/yas-debug.js', '_yas');
(function() {
var uid = getUid();
... ... @@ -166,7 +181,7 @@ function reMarginFooter(fixedElement) {
window._ozuid = uid;//暴露ozuid
if (window._yas) {
window._yas(1 * new Date(), '1.0.13.2', 'yohobuy_m', uid, '');
window._yas(1 * new Date(), '1.0.13.6.3', 'yohobuy_m', uid, '', '');
}
}());
... ... @@ -182,8 +197,8 @@ $yohoPage.on('touchstart', '.tap-hightlight', function() {
$(this).addClass('highlight');
}).on('touchend touchcancel', '.tap-hightlight', function() {
$(this).removeClass('highlight');
});
});
$('.nav-home').on('touchstart', function() {
$('.homebuttom').toggleClass('none');
});
... ... @@ -215,8 +230,8 @@ $('.nav-home').on('touchstart', function() {
//为了使setTimteout的尽可能的接近每秒60帧的效果
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function() {
callback(currTime + timeToCall);
}, timeToCall);
callback(currTime + timeToCall);
}, timeToCall);
lastTime = currTime + timeToCall;
return id;
... ... @@ -231,6 +246,23 @@ $('.nav-home').on('touchstart', function() {
window.cancelAnimationFrame = cancelAnimationFrame;
}());
// 给jQuery 扩展 queryString函数
$.extend({
queryString: function() {
var vars = [],
hash,
i;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
});
//暴露公共接口
window.cookie = cookie;
... ...
... ... @@ -20,7 +20,8 @@ var $addressForm = $('.edit-address'),
$area = $('.area'),
isSubmiting,
currentPage = 'edit',
newArea = [];
newArea = [],
queryString = $.queryString();
$($editAddressPage, $addressListPage).css('min-height', function() {
return $(window).height() - $('#yoho-header').height();
... ... @@ -91,7 +92,11 @@ $addressForm.on('submit', function() {
isSubmiting = false;
loading.hideLoadingMask();
} else {
window.location.href = '/home/address';
if (queryString.refer === 'shopping') {
window.location.href = '/shoppingCart/selectAddress';
} else {
window.location.href = '/home/address';
}
}
}).fail(function() {
tip.show('网络出了点问题~');
... ...
... ... @@ -69,4 +69,5 @@ $addAddress.on('touchend', function() {
$action.on('touchend', '.del', function() {
deleteId = $(this).data('id');
$confim.fadeIn();
return false;
});
... ...
... ... @@ -9,10 +9,7 @@ var $ = require('jquery'),
var commentsNum,consultsNum;
var consultFooterEle = $('.consult-content-footer')[0],
consultFooterHammer = consultFooterEle && new Hammer(consultFooterEle),
navtabEle = document.getElementById('nav-tab'),
var navtabEle = document.getElementById('nav-tab'),
navtabHammer = navtabEle && new Hammer(navtabEle),
gotoConsultEle = document.getElementById('goto-consult'),
... ... @@ -66,12 +63,6 @@ if (navtabHammer) {
});
}
if (consultFooterHammer) {
consultFooterHammer.on('tap', function() {
location.href = $(consultFooterEle).data('href');
});
}
if (gotoConsultHammer) {
gotoConsultHammer.on('tap', function() {
location.href = $(gotoConsultEle).data('href');
... ...
... ... @@ -30,6 +30,7 @@ if (likeHammer) {
opt = 'ok';
favorite = 1;
}
$.ajax({
type: 'POST',
url: '/product/opt/favoriteProduct',
... ... @@ -51,19 +52,19 @@ if (likeHammer) {
} else {
tip.show(data.message);
}
// 统计代码:用于统计用户加入或取消商品收藏的动作
if (window._yas) {
window._yas.sendCustomInfo({
pd: productId,
fa: favorite
});
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
// 统计代码:用于统计用户加入或取消商品收藏的动作
if (window._yas) {
window._yas.sendCustomInfo({
pd: productId,
fa: favorite
}, true);
}
});
}
... ... @@ -75,7 +76,7 @@ if (addToCartHammer) {
window._yas.sendCustomInfo({
pd: productId,
by: 1
});
}, false);
}
});
}
... ...
... ... @@ -8,6 +8,7 @@ var $ = require('jquery'),
Hammer = require('yoho.hammer'),
lazyLoad = require('yoho.lazyload');
//品牌页参数
var $brandHeader = $('#brand-header'),
$introBox = $('#intro-box');
... ... @@ -231,6 +232,25 @@ function search(opt) {
loading.hideLoadingMask();
window.rePosFooter();
// 用于统计点击了商品列表的第几个商品,序号从1开始计算。
if (window._yas) {
switch (navType) {
case 'newest':
window._yas(1 * new Date(), '1.0.13.6.3', 'yohobuy_m', window._ozuid,
'', '.new-goods .good-info .good-detail-img .good-thumb');
break;
case 'price':
window._yas(1 * new Date(), '1.0.13.6.3', 'yohobuy_m', window._ozuid,
'', '.new-goods .good-info .good-detail-img .good-thumb');
break;
case 'discount':
window._yas(1 * new Date(), '1.0.13.6.3', 'yohobuy_m', window._ozuid,
'', '.new-goods .good-info .good-detail-img .good-thumb');
break;
}
}
}
});
... ... @@ -455,8 +475,3 @@ $listNav.on('touchstart', 'li', function() {
$listNav.find('li').removeClass('bytouch');
});
// 用于统计点击了商品列表的第几个商品,序号从1开始计算。
if (window._yas) {
window._yas(1 * new Date(), '1.0.13.2', 'yohobuy_m', window._ozuid,
'', '#goods-container >div >div .good-thumb >img');
}
\ No newline at end of file
... ...
... ... @@ -6,4 +6,6 @@
require('./cart');
require('./gift-advance');
require('./order-ensure');
\ No newline at end of file
require('./order-ensure');
require('./select-coupon');
require('./select-address');
... ...
... ... @@ -6,9 +6,12 @@
var $ = require('jquery'),
lazyLoad = require('yoho.lazyload'),
Hammer = require('yoho.hammer');
Hammer = require('yoho.hammer'),
orderInfo = require('./order-info').orderInfo;
var dispatchModeHammer, dispatchTimeHammer;
var dispatchModeHammer,
dispatchTimeHammer,
$invoice = $('.invoice');
lazyLoad();
... ... @@ -51,3 +54,42 @@ $('.invoice').on('touchend', '.checkbox', function() {
$('.invoice').removeClass('focus');
}
});
// 界面点击,状态存 cookie
$('.dispatch-mode').on('touchend', 'li', function() {
orderInfo('deliveryId', $(this).data('id'));
});
$('.dispatch-time').on('touchend', 'li', function() {
orderInfo('deliveryTimeId', $(this).data('id'));
});
$('.coin').on('touchend', function() {
var $this = $(this);
if ($this.find('.checkbox').hasClass('icon-cb-checked')) {
orderInfo('yohoCoin', $this.data('yoho-coin'));
} else {
orderInfo('yohoCoin', 0);
}
});
$invoice.on('touchend', function() {
var $this = $(this);
orderInfo('invoice', $this.find('.checkbox').hasClass('icon-cb-checked'));
});
$invoice.find('[name="invoice-title"]').on('blur', function() {
orderInfo('invoiceText', $(this).val());
}).end().find('.invoice-type').on('change', function() {
orderInfo('invoiceType', $(this).val());
});
$('#msg').find('input').on('blur', function() {
orderInfo('msg', $(this).val());
});
$('.pay-mode').on('click', 'li', function() {
orderInfo('paymentTypeId', $(this).data('pay-id'));
});
... ...
/**
* 订单信息读取
* @author: bikai<kai.bi@yoho.cn>
* @date: 2015/12/14
*/
var info = window.cookie('order-info');
// info 必须是 JSON 字符串
try {
info = JSON.parse(info);
} catch (e) {
info = {};
}
exports.orderInfo = function(key, value) {
if (value === undefined) {
return info[key];
}
info[key] = value;
window.setCookie('order-info', JSON.stringify(info));
};
... ...
/**
* 购物车 地址选择
* @author: bikai<kai.bi@yoho.cn>
* @date: 2015/12/14
*/
var $ = require('jquery'),
orderInfo = require('./order-info').orderInfo;
$('.address-item').on('touchend', function() {
orderInfo('addressId', $(this).data('address-id'));
}).on('touchend', '.edit', function() {
window.location.href = $(this).data('href');
return false;
});
... ...
/**
* 优惠券选择
* @author: bikai<kai.bi@yoho.cn>
* @date: 2015/12/10
*/
var $ = require('jquery'),
Handlebars = require('yoho.handlebars'),
ellipsis = require('mlellipsis'),
loading = require('../plugin/loading'),
tip = require('../plugin/tip');
tip = require('../plugin/tip'),
orderInfo = require('./order-info').orderInfo;
var page = 1,
canGetCoupon = true,
isGetData;
var conponTmpl = Handlebars.compile($('#tmpl-coupon').html()),
conponNotAvaliableTmpl = Handlebars.compile($('#tmpl-coupon-not-avaliable').html());
conponNotAvaliableTmpl = Handlebars.compile($('#tmpl-coupon-not-avaliable').html()),
$newCoupon = $('#new-coupon');
ellipsis.init();
$('#search-coupon').on('submit', function() {
$newCoupon.on('submit', function() {
$.ajax({
method: 'POST',
url: '',
url: '/shoppingCart/couponSearch',
data: $(this).serialize()
}).then(function(res) {
if (res.avaliable) {
$('#coupon-list').html(conponTmpl({
coupons: res.coupons
}));
$('#coupon-list-not').html('');
if (res.code === 200) {
tip.show('优惠券可用');
orderInfo('couponCode', res.data.coupon_code);
window.location.href = '/shoppingCart/orderEnsure?coupon_code=' + res.data.coupon_code;
} else {
tip.show(res.msg);
tip.show(res.message);
}
}).fail(function() {
tip.show('网络错误');
});
return false;
});
$('#coupon-list').on('touchend', '.employ-main', function() {
var $this = $(this);
orderInfo('couponCode', $this.data('coupon-code'));
orderInfo('couponValue', $this.data('coupon-value'));
});
$newCoupon.find('input').on('input', function() {
if ($(this).val() !== '') {
$newCoupon.find('.submit').css('background', '#444');
} else {
$newCoupon.find('.submit').css('background', '#b0b0b0');
}
});
function getCouponHandle(coupons) {
var notAvailableCoupons = [];
// 后端需要返回一个 coupons 列表,如下
// notAvailable 表示不可用的优惠券
coupons = [{
money: '99',
coupon_name: '满XX-减去吴悠右腿有益于有2222',
couponValidity: '20150129-20150430',
coupon_id: '22222'
}, {
money: '99',
coupon_name: '满XX-减去吴悠右腿有益于有2222',
couponValidity: '20150129-20150430',
coupon_id: '2222233'
}, {
money: '99',
coupon_name: 'NONO满XX-减去吴悠右腿有益于有2222',
couponValidity: '20150129-20150430',
coupon_id: '2222233',
notAvailable: 1
}];
// coupons = [{
// money: '99',
// coupon_name: '满XX-减去吴悠右腿有益于有2222',
// couponValidity: '20150129-20150430',
// coupon_id: '22222'
// }, {
// money: '99',
// coupon_name: '满XX-减去吴悠右腿有益于有2222',
// couponValidity: '20150129-20150430',
// coupon_id: '2222233'
// }, {
// money: '99',
// coupon_name: 'NONO满XX-减去吴悠右腿有益于有2222',
// couponValidity: '20150129-20150430',
// coupon_id: '2222233',
// notAvailable: 1
// }];
// coupons 是个列表,如果不是列表,可能是服务器错误,这次翻页加载不算
if (!$.isArray(coupons)) {
... ... @@ -105,10 +129,9 @@ function getCouponDate() {
$.ajax({
type: 'POST',
url: '/home/couponData',
dataType: 'html',
url: '/shoppingCart/couponList',
dataType: 'json',
data: {
statuss: status,
page: page
}
}).then(getCouponHandle).fail(function() {
... ...
... ... @@ -117,7 +117,7 @@
overflow: hidden;
padding: 0 10rem / $pxConvertRem;;
}
.index-channel {
... ... @@ -143,7 +143,7 @@
font-size: 16px;
line-height: 52px;
color: #fff;
background: #000;
background-color: #000;
border: 4px solid #fff;
font-weight: bold;
&:last-child {
... ... @@ -162,11 +162,11 @@
.homestyle {
margin-bottom: 50rem / $pxConvertRem;
width: 287.3rem / $pxConvertRem;
}
}
}
}
}
}
@import "search","footer", "error";
... ...
... ... @@ -168,9 +168,6 @@
&.focus {
color: #000;
}
.comments-num {
display: none;
}
}
.comment-nav {
border-right: 1px solid #ccc;
... ... @@ -286,17 +283,16 @@
.comment-content-footer,
.consult-content-footer {
display: block;
min-height: pxToRem(88px);
text-align: center;
background-color: #fff;
border-bottom: 1px solid $borderC;
line-height: pxToRem(88px);
font-size: pxToRem(28px);
a {
color: #b0b0b0;
.iconfont {
font-size: inherit;
}
color: #b0b0b0;
.iconfont {
font-size: inherit;
}
}
... ...
... ... @@ -250,8 +250,15 @@ $basicBtnC:#eb0313;
padding-right: pxToRem(28px);
border-bottom: 1px solid $borderC;
background-color: $pageBgC;
display: flex;
align-items: center;
@include flexbox((
box-flex: 1.0,
display: box,
box-align: center
), $version: 1);
@include flexbox((
display: flex,
align-items: center
));
span{
// display: table-cell;
display: -webkit-box;
... ...
@import "good", "chose-panel", "gift-advance-good", "order-ensure", "select-coupon";
@import "good", "chose-panel", "gift-advance-good", "order-ensure", "select-coupon", "select-address";
.icon-checkbox:before { content: "\e61c"; }
... ...
... ... @@ -163,6 +163,20 @@
}
}
#msg {
padding-top: pxToRem(20px);
input {
padding: pxToRem(10px);
width: pxToRem(580px);
height: pxToRem(50px);
outline: 0;
border: 0;
border: 1px solid #f7f7f7;
border-radius: pxToRem(4px);
}
}
.total {
font-size: 22rem / $pxConvertRem;
margin-top: 20rem / $pxConvertRem;
... ...
.select-address-page {
padding-bottom: pxToRem(20px);
.add-address {
margin-bottom: 0;
}
}
... ...
... ... @@ -2,7 +2,7 @@
margin-top: pxToRem(30px);
margin-bottom: pxToRem(30px);
#search-coupon {
#new-coupon {
margin-bottom: pxToRem(30px);
padding-left: pxToRem(30px);
padding-right: pxToRem(30px);
... ...
... ... @@ -2,7 +2,7 @@
<div class="iHelp">
<ul>
{{# iHelp}}
<li><a href="/home/helpDetail?code={{ code}}"><span>{{ caption}}</span><i class="iconfont num">&#xe604;</i></a></li>
<li><a href="/home/helpDetail?code={{ code}}"><span>{{ name}}</span><i class="iconfont num">&#xe604;</i></a></li>
{{/ iHelp}}
</ul>
</div>
... ...
... ... @@ -19,12 +19,14 @@
<div class="index-channel">
<img class="img" src="{{background}}">
<div class="index-channel-list">
<a href="/boys" class="list-item">男生 <span class="lighter">BOYS</span> <span class="iconfont right-icon">&#xe614;</span></a>
<a href="/girls" class="list-item">女生 <span class="lighter">GIRLS</span> <span class="iconfont right-icon">&#xe614;</span></a>
<a href="/kids" class="list-item">潮童 <span class="lighter">KIDS</span> <span class="iconfont right-icon">&#xe614;</span></a>
<a href="/lifestyle" class="list-item">创意生活 <span class="lighter">LIFESTYLE</span> <span class="iconfont right-icon">&#xe614;</span></a>
</div>
{{#channelList}}
<a href="{{href}}" class="list-item">{{title}} <span class="lighter">{{entitle}}</span> <span class="iconfont right-icon">&#xe614;</span></a>
{{/channelList}}
{{#showYohood}}
<a href="/yohood" id="yohood" class="list-item"> <span class="iconfont right-icon">&#xe614;</span></a>
{{/showYohood}}
</div>
</div>
</div>
</div>
{{> layout/footer}}
\ No newline at end of file
{{> layout/footer}}
... ...
... ... @@ -5,7 +5,7 @@
<p class="infos">
收货地址
<span class="per-info">{{name}} {{phoneNum}}</span>
<span class="address">{{address}}</span>
<span class="address">{{area}} {{address}}</span>
</p>
<span class="iconfont">&#xe614;</span>
</a>
... ... @@ -15,7 +15,7 @@
<h3 class="title">配送方式</h3>
<ul class="dispatch-mode clearfix">
{{#each dispatchMode}}
<li {{#if @first}}class="chosed"{{/if}} data-id="{{id}}">{{name}}</li>
<li {{#if isSelected}}class="chosed"{{/if}} data-id="{{id}}">{{name}}</li>
{{/each}}
</ul>
</div>
... ... @@ -24,7 +24,7 @@
<h3 class="title">送货时间</h3>
<ul class="dispatch-time clearfix">
{{#each dispatchTime}}
<li {{#if @first}}class="chosed"{{/if}} data-id="{{id}}">{{name}}</li>
<li {{#if isSelected}}class="chosed"{{/if}} data-id="{{id}}">{{name}}</li>
{{/each}}
</ul>
</div>
... ... @@ -52,14 +52,14 @@
</span>
{{/if}}
{{#if notUsed}}
<span class="not-used coupon-use">
未使用
{{#if value}}
<span class="used coupon-use">
{{value}}
<i class="iconfont">&#xe614;</i>
</span>
{{^}}
<span class="used coupon-use">
{{value}}
<span class="not-used coupon-use">
未使用
<i class="iconfont">&#xe614;</i>
</span>
{{/if}}
... ... @@ -68,7 +68,7 @@
{{/ coupon}}
{{# yohoCoin}}
<li class="coin">
<li class="coin" data-yoho-coin="{{.}}">
<span class="title">YOHO币</span>
<span class="desc">可抵用¥{{.}}</span>
<span class="coin-check">
... ... @@ -97,6 +97,12 @@
{{/if}}
</ul>
<form id="msg" action="" method="post">
<input type="text" name="msg" value="" placeholder="留言">
</form>
</section>
<section class="block">
<ul class="total">
<li>
<span>总价</span>
... ...
... ... @@ -2,12 +2,36 @@
<div class="my-address-page select-address-page yoho-page">
<div class="page-wrap">
{{# address}}
<a class="address-item" href="/shoppingCart/orderEnsure?address_id={{address_id}}">
<a class="address-item" data-address-id="{{address_id}}" href="/shoppingCart/orderEnsure">
<span class="name">{{consignee}}</span>
<span class="tel">{{mobile}}</span>
<p class="address-info">{{area}} {{address}}</p>
<div class="action iconfont">
<span class="edit" data-href="/home/addressAct?id={{address_id}}&refer=shopping">&#xe61e;</span>
<span class="del" data-id="{{address_id}}">&#xe621;</span>
</div>
</a>
{{/ address}}
<a class="add-address" data-href="/home/addressAct?refer=shopping">
添加新地址
</a>
<div class="confim-mask hide">
<div class="confim-box">
<div class="content">
您确定要删除地址?
</div>
<div class="action">
<span class="cancel">
取消
</span>
<span class="confim">
确认
</span>
</div>
</div>
</div>
</div>
</div>
{{> layout/footer}}
... ...
{{> layout/header}}
<div class="yoho-page select-coupon-page my-coupon-page">
<form id="search-coupon" method="POST" action="">
<input type="text" name="coupon-code" value="" placeholder="输入优惠券码">
<form id="new-coupon" method="POST" action="">
<input type="text" name="couponCode" value="" placeholder="输入优惠券码">
<button type="submit" class="submit">确定</button>
</form>
<div id="coupon-list" class="coupon-list"></div>
... ... @@ -11,9 +11,9 @@
<script id="tmpl-coupon" type="text/tmpl">
\{{#coupons}}
\{{^ notAvailable}}
<a class="employ-main" href="/shoppingCart/orderEnsure?coupon_id={{ coupon_id}}">
<span>\{{ money}}</span>
<p class="coupon-name">\{{ coupon_name}}</p>
<a class="employ-main" data-coupon-code="\{{ couponCode}}" data-coupon-value="\{{ couponValue}}" href="/shoppingCart/orderEnsure">
<span>\{{ couponValue}}</span>
<p class="coupon-name">\{{ couponDetailInfomation}}</p>
<p>有效期:\{{ couponValidity}}</p>
</a>
\{{/ notAvailable}}
... ... @@ -22,8 +22,8 @@
<script id="tmpl-coupon-not-avaliable" type="text/tmpl">
\{{# notAvailableCoupons}}
<div class="employ-main not-avaliable">
<span>\{{ money}}</span>
<p class="coupon-name">\{{ coupon_name}}</p>
<span>\{{ couponValue}}</span>
<p class="coupon-name">\{{ couponDetailInfomation}}</p>
<p>有效期:\{{ couponValidity}}</p>
</div>
\{{/ notAvailableCoupons}}
... ...
... ... @@ -8,7 +8,7 @@
{{userName}}
</span>
<span class="goods-spec">
{{desc}}
&nbsp;购买了&nbsp;&nbsp;{{desc}}
</span>
<p class="detail-content">
{{content}}
... ...
... ... @@ -13,6 +13,7 @@
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?c6ee7218b8321cb65fb2e98f284d8311";
hm.async = 1;
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
... ... @@ -22,6 +23,7 @@
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?65dd99e0435a55177ffda862198ce841";
hm.async = 1;
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
... ...
... ... @@ -19,18 +19,7 @@
<script src="http://localhost:8000/static/js/sea.js?nowrap"></script>
<script>seajs.config({base: 'http://localhost:8000/'});</script>
{{/if}}
<script type="text/javascript">
(function(w,d,s,j,f){
w['YohoAcquisitionObject']=f;
w[f]=function(){w[f].p=arguments;};
var a=d.createElement(s);
var m=d.getElementsByTagName(s)[0];
a.async=1;
a.src=j;
m.parentNode.insertBefore(a,m);
})(window,document,'script','http://cdn.yoho.cn/yas-jssdk/{{yas_version}}/yas.js','_yas');
</script>
{{> layout/use}}
{{> layout/use}}
{{> layout/analysis}}
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -234,6 +234,12 @@
seajs.use('js/shopping-cart/order-ensure');
</script>
{{/if}}
{{#if selectAddressPage}}
<script>
seajs.use('js/me/address');
seajs.use('js/shopping-cart/select-address');
</script>
{{/if}}
{{#if selectCouponPage}}
<script>
seajs.use('js/shopping-cart/select-coupon');
... ...
<ul id="nav-tab" class="nav-tab clearfix">
<li class="comment-nav tap-hightlight">商品评价<span class="comments-num">{{commentsNum}}</span></li>
<li class="comment-nav tap-hightlight">商品评价(<span class="comments-num">{{commentsNum}}</span>)</li>
<li class="consult-nav tap-hightlight">购买咨询(<span class="consults-num">{{consultsNum}}</span>)</li>
</ul>
<div id="feedback-content" >
... ... @@ -21,6 +21,10 @@
</span>
{{/ comments}}
</div>
<a class="comment-content-footer tap-hightlight" href="{{commentsUrl}}">
查看更多
<span class="iconfont">&#xe604;</span>
</a>
{{^}}
<div class="comment-content-main content-main no-item">
<span class="iconfont">&#xe63d;</span>暂无评论
... ... @@ -46,17 +50,16 @@
</div>
{{/ consults}}
</div>
<div class="consult-content-footer tap-hightlight" data-href="{{link}}">
<a href="javascript:;">
查看更多
<span class="iconfont">&#xe604;</span></a>
</div>
<a class="consult-content-footer tap-hightlight" href="{{consultsUrl}}">
查看更多
<span class="iconfont">&#xe604;</span>
</a>
{{else}}
<div class="consult-content-main content-main no-item">
<span class="iconfont">&#xe63f;</span>暂无咨询
</div>
<div class="consult-content-footer tap-hightlight" data-href="{{link}}">
<div class="consult-content-footer tap-hightlight" data-href="{{commentsLink}}">
<a href="javascript:;">
我要咨询
<span class="iconfont">&#xe604;</span></a>
... ...
... ... @@ -48,7 +48,7 @@ class HomeController extends AbstractAction
'showDownloadApp' => true,
'pageFooter' => true,
'cartUrl' => Helpers::url('/cart/index/index', null),
'signinUrl' => Helpers::url('/signin.html', array('refer' => Helpers::url('/home')) ),
'signinUrl' => Helpers::url('/signin.html', array('refer' => Helpers::url('/home'))),
);
$uid = $this->getUid(false);
if ($uid) {
... ... @@ -832,69 +832,49 @@ class HomeController extends AbstractAction
*/
public function orderDetailAction()
{
$data = array(
'name' => '毛毛莉Lydia',
'phoneNum' => '18600001133',
'address' => '南京市建邺区嘉陵江东街18号国家广告产业园5栋17楼',
'orderStatus' => '订单取消',
'orderNum' => '418358063',
'orderTime' => '2014-03-10 17:25:10',
'orderCancel' => true,
'goods' => array(
array(
'id' => 1,
'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'name' => 'Adidas Originals ZX FLUXM22508',
'color' => '黄',
'size' => '43',
'price' => '699.00',
'count' => '2'
),
array(
'id' => 1,
'thumb' => 'http://img10.static.yhbimg.com/goodsimg/2015/11/04/05/0188f1aca49ac478a565ec029b5d2d4a6c.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'name' => 'B.Duck浴室玩伴mini浮水鸭',
'gift' => true,
'color' => '黄',
'size' => '43',
'price' => '0.00',
'count' => '1'
)
),
'sumPrice' => 799,
'salePrice' => 80,
'freight' => 5,
'coupon' => 0,
'yohoCoin' => 5,
'price' => 719
);
$this->_view->display('order-detail', array('orderDetail' => $data, 'orderDetailPage' => true));
// 审判跳转登录页
$this->auditJumpLogin();
$orderCode = $this->get('order_code');
if (empty($orderCode)) {
$this->error();
}
$this->setTitle('订单详情');
$this->setNavHeader('订单详情');
$this->_view->display('order-detail', array(
'orderDetailPage' => true,
'orderDetail' => OrderModel::orderDetail($orderCode, $this->_uid, $this->_session),
));
}
/**
* 帮助中心列表页
*/
/**
* 帮助列表页
*/
public function helpAction()
{
$service = Home\HelpModel::serviceInfo();
{
$this->setTitle('帮助中心');
$this->setNavHeader('帮助中心');
$data = array(
'iHelp' =>$service,
'iHelp' => Home\HelpModel::serviceInfo(),
);
$this->_view->display('i-help', $data);
}
/**
* 帮助中心列表详细信息
*/
public function helpDetailAction()
{
$code = $this->get('code', 0);
$service = Home\HelpModel::serviceDetail($code);
$data = array(
'iHelp' => $service,
);
$this->_view->display('helpDetail', $data);
}
* 帮助列表页
*/
public function helpDetailAction()
{
$this->setTitle('帮助中心');
$this->setNavHeader('帮助中心');
$data = array(
'iHelp' => array(
array('name' => '新用户注册'),
)
);
$this->_view->display('helpDetail', $data);
}
}
... ...
... ... @@ -31,351 +31,198 @@ class ShoppingCartController extends AbstractAction
$this->_view->display('index', $data);
}
/**
* 加入购物车
*
* @param string productSku 商品的SKU
* @param int buyNumber 购买数量
* @param int promotionId 促销ID, 加价购有关
* @param int goodsType 商品类型,0表示普通商品,1表示加价购商品
* @param int isEdit 是否是编辑商品SKU,0表示不是编辑
* @return json
*/
public function addAction()
{
$result = array();
if ($this->isAjax()) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$productSku = $this->post('productSku');
$buyNumber = $this->post('buyNumber', 1);
$goodsType = $this->post('goodsType', 0);
$promotionId = $this->post('promotionId', 0);
$isEdit = $this->post('isEdit', 0);
$uid = $this->getUid(true);
// 执行加入购物车操作
$result = CartModel::addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid, $shoppingKey);
// 设置加入购物车凭证到客户端浏览器
if (isset($result['data']['shopping_key'])) {
$this->setCookie('_spk', $shoppingKey);
}
}
$this->echoJson($result);
}
/**
* 移出购物车
*/
public function delAction()
{
$result = array();
if ($this->isAjax()) {
$productId = $this->post('id', 0);
$uid = $this->getUid(true);
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = CartModel::removeFromCart($uid, $productId, $shoppingKey);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 移入收藏夹
*/
public function colAction()
{
$result = array();
if ($this->isAjax()) {
$productId = $this->post('id', 0);
$uid = $this->getUid(true);
$result = CartModel::addToFav($uid, $productId);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/*
* 获取购物车商品数据
*/
public function goodinfoAction()
{
$result = array();
if ($this->isAjax()) {
$num = $this->get('buy_num', 1);
$skn = $this->get('id', 1);
$uid = $this->getUid(true);
$result = CartModel::cartProductData($uid, $skn, $num); // 测试skn的ID为51172055
$result['num'] = $num;
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/*
* 获取购物车加价购商品数据
*/
public function giftinfoAction()
{
$result = array();
if ($this->isAjax()) {
$skn = $this->get('skn', null);
$promotionId = $this->get('promotionId', null);
$result = CartModel::giftProductData($skn, $promotionId);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 修改购物车商品数据
*/
public function modifyAction()
{
$result = array();
if ($this->isAjax()) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$uid = $this->getUid(true);
$params = array();
$params['old_product_sku'] = $this->post('old_product_sku', 0);
$params['new_product_sku'] = $this->post('new_product_sku', 0);
$params['buy_number'] = $this->post('buy_number', 0);
$params['selected'] = $this->post('selected', null);
$result = CartModel::modifyCartProduct($uid, $params, $shoppingKey);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 购物车结算请求
*/
public function payAction()
{
$this->setTitle('购物车');
$this->setNavHeader('购物车');
$cartType = $this->post('cartType', 'ordinary');
$uid = $this->getUid(true);
$data = array(
'orderEnsurePage' => true,
'orderEnsure' => CartModel::cartPay($uid, $cartType)
);
$this->_view->display('order-ensure', $data);
}
/**
* 购物车选择支付方式和配送方式接口
*/
public function payAndDeliveryAction()
{
$result = array();
if ($this->isAjax()) {
$cartType = $this->post('cartType', 'ordinary');
$deliveryWay = $this->post('deliveryWay', 1);
$paymentType = $this->post('paymentType', 1);
$uid = $this->getUid(true);
$result = CartModel::paymentTypeAndDelivery($uid, $cartType, $deliveryWay, $paymentType);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 购物车输入优惠券码使用优惠券
*/
public function couponAction()
{
$result = array();
if ($this->isAjax()) {
$couponCode = $this->post('couponCode', '');
$uid = $this->getUid(true);
$result = CartModel::getCoupon($uid, $couponCode);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 购物车使用YOHO币
*/
public function yohoCoinAction()
{
$result = array();
if ($this->isAjax()) {
$cartType = $this->post('cartType', 'ordinary');
$deliveryWay = $this->post('deliveryWay', 1);
$paymentType = $this->post('paymentType', 1);
$yohoCoin = $this->post('yohoCoin', 1);
$result = CartModel::paymentTypeAndDelivery($this->_uid, $cartType, $deliveryWay, $paymentType, $yohoCoin);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
public function giftAdvanceAction()
{
$data = array(
'advance' => array(
array(
'title' => '【izzue】加¥19购袜子',
'goods' => array(
'id' => 1,
'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/09/17/03/014cacfa5c458b9732c68adf1af15d7a45.jpg?imageMogr2/thumbnail/120x120/extent/120x120/background/d2hpdGU=/position/center/quality/90',
'name' => 'Life.After.Life纯棉短袜',
'salePrice' => 19,
'price' => 99,
'count' => 1
)
),
array(
'title' => '【银鳞堂】加¥9购手绳',
'goods' => array(
'id' => 1,
'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/10/03/10/01bc1878f9154e77ac4f7a6003c954f1b8.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'name' => '银鳞堂民族风牛皮手绳',
'salePrice' => 9,
'price' => 19,
'count' => 1
)
)
)
);
$data = array(
'gift' => array(
'id' => 1,
'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/09/17/03/014cacfa5c458b9732c68adf1af15d7a45.jpg?imageMogr2/thumbnail/120x120/extent/120x120/background/d2hpdGU=/position/center/quality/90',
'name' => 'Life.After.Life纯棉短袜',
'color' => '黄色',
'size' => 'L',
'price' => 0,
'count' => 1
)
);
$this->_view->display('gift-advance', array('giftAdvancePage' => true, 'pageHeader' => array(
'navBack' => true, 'navTitle' => '加价购'), 'shoppingCart' => $data));
}
/*
* 确认订单
*/
public function orderEnsureAction()
{
$data = array(
'orderEnsurePage' => true,
'orderEnsure' => array(
'name' => '申建军',
'phoneNum' => '12345678',
'address' => '江苏省南京市建邺区',
'dispatchMode' => array(
array(
'id' => 1,
'name' => '普通快递¥10'
),
array(
'id' => 2,
'name' => '顺丰速运¥15(仅支持顺丰克配送的地区)'
)
),
'dispatchTime' => array(
array(
'id' => 1,
'name' => '工作日、双休日、节假日均可送货'
),
array(
'id' => 2,
'name' => '只工作日送货'
),
array(
'id' => 3,
'name' => '只双休日、节假日送货'
)
),
'goods' => array(
array(
'id' => 1,
'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'name' => 'Adidas Originals ZX FLUXM22508',
'color' => '黄',
'size' => '43',
'price' => '699.00',
'count' => '2'
),
array(
'id' => 1,
'thumb' => 'http://img10.static.yhbimg.com/goodsimg/2015/11/04/05/0188f1aca49ac478a565ec029b5d2d4a6c.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'name' => 'B.Duck浴室玩伴mini浮水鸭',
'gift' => true,
'color' => '黄',
'size' => '43',
'price' => '0.00',
'count' => '1'
)
),
'coupon' => array(
'count' => 1,
'notUsed' => true
),
'yohoCoin' => '0',
'invoice' => true,
'sumPrice' => 900,
'salePrice' => 90,
'freight' => 0,
'price' => 810
)
);
$this->_view->display('order-ensure', $data);
}
/**
* 移出购物车
*/
public function delAction()
{
$result = array();
if ($this->isAjax()) {
$productId = $this->post('id', 0);
$uid = $this->getUid(true);
$shoppingKey = $this->getSession('shoppingKey');
$result = CartModel::removeFromCart($uid, $productId, $shoppingKey);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 移入收藏夹
*/
public function colAction()
{
$result = array();
if ($this->isAjax()) {
$productId = $this->post('id', 0);
$uid = $this->getUid(true);
$result = CartModel::addToFav($uid, $productId);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/*
* 获取购物车商品数据
*/
public function goodinfoAction()
{
$result = array();
if ($this->isAjax()) {
$num = $this->get('buy_num', 1);
$skn = $this->get('id', 1);
$uid = $this->getUid(true);
$result = CartModel::cartProductData($uid, $skn, $num); // 测试skn的ID为51172055
$result['num'] = $num;
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/*
* 获取购物车加价购商品数据
*/
public function giftinfoAction()
{
$result = array();
if ($this->isAjax()) {
$skn = $this->get('skn', null);
$promotionId = $this->get('promotionId', null);
$result = CartModel::giftProductData($skn, $promotionId);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 修改购物车商品数据
*/
public function modifyAction()
{
$result = array();
if ($this->isAjax()) {
$shoppingKey = $this->getSession('shoppingKey');
$uid = $this->getUid(true);
$params = array();
$params['old_product_sku']= $this->post('old_product_sku', 0);
$params['new_product_sku']= $this->post('new_product_sku', 0);
$params['buy_number']= $this->post('buy_number', 0);
$params['selected']= $this->post('selected', null);
$result = CartModel::modifyCartProduct($uid, $params, $shoppingKey);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 购物车结算请求
*/
public function orderEnsureAction()
{
$this->setTitle('购物车');
$this->setNavHeader('购物车');
$cartType = $this->post('cartType', 'ordinary');
$cookieData = $this->getCookie('order-info', null);
$uid = $this->getUid(true);
$data = array(
'orderEnsurePage' => true,
'orderEnsure' => CartModel::cartPay($uid, $cartType, $cookieData)
);
$this->_view->display('order-ensure', $data);
}
/**
* 购物车选择改变字段,重新运算订单数据
*/
public function orderComputeAction()
{
$result = array();
if ($this->isAjax()) {
$cartType = $this->post('cartType', 'ordinary');
$deliveryWay = $this->post('deliveryWay', 1);
$paymentType = $this->post('paymentType', 1);
$couponCode = $this->post('paymentType', null);
$yohoCoin = $this->post('paymentType', null);
$uid = $this->getUid(true);
$result = CartModel::orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 购物车输入优惠券码使用优惠券
*/
public function couponSearchAction()
{
$result = array();
if ($this->isAjax()) {
$couponCode = $this->get('couponCode', '');
$uid = $this->getUid(true);
$result = CartModel::searchCoupon($uid, $couponCode);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 购物车结算--获取优惠券列表
*/
public function couponListAction()
{
$result = array();
if ($this->isAjax()) {
$uid = $this->getUid(true);
$page = $this->get('page', 1);
$result = CartModel::getCouponList($uid);
}
if (empty($result)) {
echo ' ';
} else {
$this->echoJson($result);
}
}
/**
* 下单流程 选择地址
... ... @@ -386,7 +233,7 @@ class ShoppingCartController extends AbstractAction
$this->setTitle('选择地址');
$this->setNavHeader('选择地址', Helpers::url('/shoppingCart/orderEnsure'));
$uid = $this->_uid;
$uid = $this->getUid(true);
$address = UserModel::getAddressData($uid);
$this->_view->display('select-address', array(
... ... @@ -404,15 +251,41 @@ class ShoppingCartController extends AbstractAction
// 设置网站标题
$this->setTitle('选择优惠券');
$this->setNavHeader('选择优惠券', Helpers::url('/shoppingCart/orderEnsure'));
$uid = $this->_uid;
$address = UserModel::getAddressData($uid);
$this->_view->display('select-coupon', array(
'selectCouponPage' => true,
'pageFooter' => true,
'address' => $address
'pageFooter' => true
));
}
/**
* 确认结算订单
*/
public function orderSubAction()
{
$result = array();
if ($this->isAjax()) {
$uid = $this->getUid(true);
$addressId = $this->post('addressId', null);
$cartType = $this->post('cartType', 'ordinary'); // 默认普通购物车
$deliveryTime = $this->post('deliveryTime', 1); // 默认只工作日配送
$deliveryWay = $this->post('deliveryWay', 1); // 默认普通快递
$invoiceTitle = $this->post('invoiceTitle', null);
$invoiceId = $this->post('invoiceId', null);
$paymentId = $this->post('paymentId', 15);
$paymentType = $this->post('paymentType', 1); // 默认在线支付
$remark = $this->post('remark', null); // 默认在线支付
$yohoCoin = $this->post('yohoCoin', 1);
$result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin);
}
if (empty($result)) {
echo ' ';
} else {
// 提交成功清除Cookie
$this->setCookie('orderInfo', null);
$this->echoJson($result);
}
}
}
... ...
... ... @@ -5,13 +5,13 @@ namespace Home;
use LibModels\Wap\Home\HelpData;
use Plugin\Helpers;
/*
/**
* 帮助中心相关数据处理
*/
class HelpModel
{
/*
* 获取帮助列表
* 获取帮助中心列表
*/
public static function serviceInfo()
... ... @@ -20,26 +20,16 @@ class HelpModel
$res = json_decode(HelpData::serviceInfo(), TRUE);
$cateInfo = $res['data'];
$iHelp = array();
$list = array();
if ($cateInfo) {
foreach ($cateInfo as $key => $value) {
$iHelp[$key]['caption'] = $value['caption'];
$iHelp[$key]['name'] = $value['caption'];
$iHelp[$key]['code'] = $value['code'];
}
}
return $iHelp;
}
/*
* 获取帮助中心详细内容
*/
public static function serviceDetail($code)
{
$res = HelpData::serviceDetail($code);
return $res;
}
}
... ...
... ... @@ -80,7 +80,7 @@ class OrderModel
$result[$key]['sumCost'] = $vo['amount'];
//类内调用格式化订单商品数据方法
$result[$key]['goods'] = Helpers::formatOrderGoods($vo['order_goods'], $count);
$result[$key]['detailUrl'] = Helpers::url('/home/orders/detail', array('order_code' => $vo['order_code'], 't' => time()));
$result[$key]['detailUrl'] = Helpers::url('/home/orderDetail', array('order_code' => $vo['order_code']));
$result[$key]['count'] = $count;
}
}
... ...
... ... @@ -17,463 +17,557 @@ use Plugin\Images;
class CartModel
{
/**
* 加入购物车
*
* @param int $productSku 商品SKU
* @param int $buyNumber 购买数量
* @param int $goodsType 商品类型,0表示普通商品,1表示加价购商品
* @param int int $isEdit 是否是编辑商品SKU,0表示不是编辑
* @param null|int $promotionId 促销id,默认null(加价购有关)
* @param null|int $uid 用户UID,可以不传
* @return array 加入购物车接口返回的数据
*/
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, $shoppingKey);
if ($addCart && isset($addCart['code'])) {
$result = $addCart;
}
return $result;
}
/**
* @param integer $uid 用户ID
* @param string $shoppingKey 未登录用户唯一识别码
* @return array|mixed 处理之后的购物车数据
*/
public static function getCartData($uid, $shoppingKey)
{
$result = array('cartNav' => true);
// 用户是否登录
if (empty($uid)) {
$result['showLoginInfo'] = true;
}
// 调用接口获取购物车的数据
$cartData = CartData::cartData($uid, $shoppingKey);
// 处理普通购物车和预售购物车的数据
if (isset($cartData['data']) && !empty($cartData['data'])) {
$cart = $cartData['data'];
/* 普通购物车 */
if (isset($cart['ordinary_cart_data'])) {
$result['commonGoodsCount'] = count($cart['ordinary_cart_data']['goods_list']);
$result['commonCart'] = self::procCartData($cart['ordinary_cart_data']);
}
/* 预售购物车 */
if (isset($cart['advance_cart_data'])) {
$result['presellGoodsCount'] = count($cart['advance_cart_data']['goods_list']);
$result['preSellCart'] = self::procCartData($cart['advance_cart_data']);
}
}
return $result;
}
/**
* 移出购物车
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public static function removeFromCart($uid, $sku, $shoppingKey)
{
$result = array('code' => 400, 'message' => '出错啦~');
// 处理sku
$sku_list = json_encode(array($sku => 1));
$remove = CartData::removeFromCart($uid, $sku_list, $shoppingKey);
if ($remove && isset($remove['code'])) {
$result['code'] = $remove['code'];
$result['message'] = $remove['message'];
}
return $result;
}
/**
* 移入收藏夹
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @return array 接口返回的数据
*/
public static function addToFav($uid, $sku)
{
$result = array('code' => 400, 'message' => '出错啦~');
if (empty($uid)) {
$result['code'] = 300;
$reult['message'] = '请先登录';
$result['data'] = '/signin.html';
return $result;
}
// 处理sku
$sku_list = json_encode(array($sku => 1));
$add = CartData::addToFav($uid, $sku_list);
if ($add && isset($add['code'])) {
$result['code'] = $add['code'];
$result['message'] = $add['message'];
}
return $result;
}
/**
* 处理购物车商品数据
*
* @param int $uid 用户ID
* @param int $skn 商品skn
* @param int $num 购买数目
* @return array 接口返回的数据
*/
public static function cartProductData($uid, $skn, $num)
{
$result = array('code' => 400, 'message' => '出错啦~');
$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;
}
return $result;
}
/**
* 处理加价购商品数据
*
* @param int $skn 商品skn
* @param int $promotionId 加价购商品促销ID
* @return array
*/
public static function giftProductData($skn, $promotionId)
{
$result = array();
$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;
}
return $result;
}
/**
* 修改购物车商品数据
*
* @param int $uid 用户ID
* @param string $param 要更改的数据
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public static function modifyCartProduct($uid, $param, $shoppingKey)
{
$result = array('code' => 400, 'message' => '出错啦~');
// 处理要更改的数据
$swapData = json_encode(array($param));
$modify = CartData::modifyCartProduct($uid, $swapData, $shoppingKey);
if ($modify && isset($modify['code'])) {
$result['code'] = $modify['code'];
$result['message'] = $modify['message'];
}
return $result;
}
/**
* 调用购物车结算接口返回的数据处理
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @return array 接口返回的数据
*/
public static function cartPay($uid, $cartType)
{
$result = array();
$pay = CartData::cartPay($uid, $cartType);
if ($pay && isset($pay['code']) && $pay['code'] === 200) {
$payReturn = $pay['data'];
$result = array();
// 收货人有关信息
if (isset($payReturn['delivery_address']) && !empty($payReturn['delivery_address'])) {
$result['name'] = $payReturn['delivery_address']['consignee'];
$result['phoneNum'] = $payReturn['delivery_address']['mobile'] ? : $payReturn['delivery_address']['phone'];
$result['address'] = $payReturn['delivery_address']['address'];
}
// 配送方式
if (isset($payReturn['delivery_way'])) {
$oneDeliv = array();
foreach ($payReturn['delivery_way'] as $val) {
$oneDeliv = array();
$oneDeliv['id'] = $val['delivery_way_id'];
$oneDeliv['name'] = $val['delivery_way_name'];
$oneDeliv['default'] = ($val['default'] === 'Y');
$result['dispatchMode'][] = $oneDeliv;
}
}
// 配送时间
if (isset($payReturn['delivery_time'])) {
$oneDelivTime = array();
foreach ($payReturn['delivery_time'] as $one) {
$oneDelivTime = array();
$oneDelivTime['id'] = $one['delivery_time_id'];
$oneDelivTime['name'] = $one['delivery_time_string'];
$oneDelivTime['default'] = ($one['default'] === 'Y');
$result['dispatchTime'][] = $oneDelivTime;
}
}
// 订单商品
if (isset($payReturn['goods_list'])) {
$oneGoods = array();
foreach ($payReturn['goods_list'] as $single) {
$oneGoods = array();
$oneGoods['id'] = $single['product_sku']; // TODO 未确定用哪个
$oneGoods['thumb'] = Images::getImageUrl($single['goods_images'], 120, 120);
$oneGoods['name'] = $single['product_name'];
$oneGoods['color'] = $single['color_name'];
$oneGoods['size'] = $single['size_name'];
$oneGoods['price'] = Helpers::transPrice($single['real_price']); // last_price有些带.00,有些不带,real_price都不带.00
$oneGoods['count'] = $single['buy_number'];
$result['goods'][] = $oneGoods;
}
}
// 支付方式
if (isset($payReturn['payment_way'])) {
$onePay = array();
foreach ($payReturn['payment_way'] as $pay) {
$onePay = array();
$onePay['id'] = $pay['payment_id'];
$onePay['paymentType'] = $pay['payment_type'];
$onePay['name'] = $pay['payment_type_name'];
$onePay['default'] = ($pay['default'] === 'Y');
$result['paymentWay'][] = $onePay;
}
}
// 有货币
$result['yohoCoin'] = $payReturn['yoho_coin'];
// 订单数据
if (isset($payReturn['shopping_cart_data']) && !empty($payReturn['shopping_cart_data'])) {
$result['sumPrice'] = Helpers::transPrice($payReturn['shopping_cart_data']['order_amount']);
$result['salePrice'] = Helpers::transPrice($payReturn['shopping_cart_data']['discount_amount']);
$result['price'] = Helpers::transPrice($payReturn['shopping_cart_data']['last_order_amount']);
$result['freight'] = Helpers::transPrice($payReturn['shopping_cart_data']['shipping_cost']);
}
// 发票有关数据
if (isset($payReturn['invoices']) && !empty($payReturn['invoices'])) {
$one = array();
foreach ($payReturn['invoices']['invoices_type_list'] as $inv) {
$one = array();
$one['id'] = $inv['invoices_type_id'];
$one['name'] = $inv['invoices_type_name'];
$result['invoice'][] = $one;
}
}
// 优惠券数据
$coupons = array('notUsed' => true);
$coupons += UserModel::getCouponData($uid, 0, 1, true);
$result['coupon'] = $coupons;
}
return $result;
}
/**
* 购物车结算--支付方式和配送方式选择以及是否使用YOHO币接口返回的数据处理
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @param string $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运
* @param string $paymentType 支付方式,1表示在线支付,2表示货到付款
* @return array 接口返回的数据
*/
public static function paymentTypeAndDelivery($uid, $cartType, $deliveryWay, $paymentType)
{
$result = array();
$pay = CartData::paymentTypeAndDelivery($uid, $cartType, $deliveryWay, $paymentType);
if ($pay && isset($pay['code']) && $pay['code'] === 200) {
$result = $pay['data'];
}
return $result;
}
/**
* 购物车结算--输入优惠券代码返回的结果处理
*
* @param int $uid 用户ID
* @param string $couponCode 优惠券代码
* @return array 接口返回的数据
*/
public static function getCoupon($uid, $couponCode)
{
$result = array('code' => 400, 'message' => '出错啦~');
$coupon = CartData::getCoupon($uid, $couponCode);
if ($coupon && isset($coupon['code']) && $coupon['code'] === 200) {
$result['code'] = $coupon['code'];
$result['message'] = $coupon['message'];
}
return $result;
}
/**
* 处理不同类型的购物车数据
*
* @param array $data 不同类型购物车数据
* @return array $result 处理之后的不同类型购物车数据
*/
private static function procCartData($data)
{
$result = array();
$oneGoods = array();
// 购买的商品列表
foreach ($data['goods_list'] as $value) {
$oneGoods['id'] = $value['product_sku'];
$oneGoods['skn'] = $value['product_skn'];
$oneGoods['name'] = $value['product_name'];
$oneGoods['thumb'] = Images::getImageUrl($value['goods_images'], 120, 120);
$oneGoods['color'] = $value['color_name'];
$oneGoods['size'] = $value['size_name'];
$oneGoods['appearDate'] = '12月'; // 目前app接口没有返回该数据
$oneGoods['price'] = $value['real_price'];
$oneGoods['count'] = $value['buy_number'];
$oneGoods['lowStocks'] = true;
$result['goods'][] = $oneGoods;
}
// 赠品
count($data['gift_list']) && $result['freebieOrAdvanceBuy'] = true;
$result['freebie'] = $data['gift_list'];
// 加价购
$result['advanceBuy'] = $data['price_gift'];
// 结算数据
$result['price'] = $data['shopping_cart_data']['order_amount'];
$result['activityPrice'] = $data['shopping_cart_data']['discount_amount'];
$result['count'] = $data['shopping_cart_data']['goods_count'];
$result['sumPrice'] = $data['shopping_cart_data']['order_amount'];
return $result;
}
/**
* 加入购物车
*
* @param int $productSku 商品SKU
* @param int $buyNumber 购买数量
* @param int $goodsType 商品类型,0表示普通商品,1表示加价购商品
* @param int int $isEdit 是否是编辑商品SKU,0表示不是编辑
* @param null|int $promotionId 促销id,默认null(加价购有关)
* @param null|int $uid 用户UID,可以不传
* @return array 加入购物车接口返回的数据
*/
public static function addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid)
{
$result = array('code' => 400, 'message' => '出错啦~~');
$addCart = CartData::addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid);
if ($addCart && isset($addCart['code'])) {
$result = $addCart;
}
return $result;
}
/**
* @param integer $uid 用户ID
* @param string $shoppingKey 未登录用户唯一识别码
* @return array|mixed 处理之后的购物车数据
*/
public static function getCartData($uid, $shoppingKey)
{
$result = array('cartNav' => true);
// 用户是否登录
if (empty($uid)) {
$result['showLoginInfo'] = true;
}
// 调用接口获取购物车的数据
$cartData = CartData::cartData($uid, $shoppingKey);
// 处理普通购物车和预售购物车的数据
if (isset($cartData['data']) && !empty($cartData['data'])) {
$cart = $cartData['data'];
/* 普通购物车 */
if(isset($cart['ordinary_cart_data'])) {
$result['commonGoodsCount'] = count($cart['ordinary_cart_data']['goods_list']);
$result['commonCart'] = self::procCartData($cart['ordinary_cart_data']);
}
/* 预售购物车 */
if(isset($cart['advance_cart_data'])) {
$result['presellGoodsCount'] = count($cart['advance_cart_data']['goods_list']);
$result['preSellCart'] = self::procCartData($cart['advance_cart_data']);
}
}
return $result;
}
/**
* 移出购物车
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public static function removeFromCart($uid, $sku, $shoppingKey)
{
$result = array('code' => 400, 'message' => '出错啦~');
// 处理sku
$sku_list = json_encode(array($sku => 1));
$remove = CartData::removeFromCart($uid, $sku_list, $shoppingKey);
if ($remove && isset($remove['code'])) {
$result['code'] = $remove['code'];
$result['message'] = $remove['message'];
}
return $result;
}
/**
* 移入收藏夹
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @return array 接口返回的数据
*/
public static function addToFav($uid, $sku)
{
$result = array('code' => 400, 'message' => '出错啦~');
if (empty($uid)) {
$result['code'] = 300;
$reult['message'] = '请先登录';
$result['data'] = '/signin.html';
return $result;
}
// 处理sku
$sku_list = json_encode(array($sku => 1));
$add = CartData::addToFav($uid, $sku_list);
if ($add && isset($add['code'])) {
$result['code'] = $add['code'];
$result['message'] = $add['message'];
}
return $result;
}
/**
* 处理购物车商品数据
*
* @param int $uid 用户ID
* @param int $skn 商品skn
* @param int $num 购买数目
* @return array 接口返回的数据
*/
public static function cartProductData($uid, $skn, $num)
{
$result = array('code' => 400, 'message' => '出错啦~');
$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;
}
return $result;
}
/**
* 处理加价购商品数据
*
* @param int $skn 商品skn
* @param int $promotionId 加价购商品促销ID
* @return array
*/
public static function giftProductData($skn, $promotionId)
{
$result = array();
$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;
}
return $result;
}
/**
* 修改购物车商品数据
*
* @param int $uid 用户ID
* @param string $param 要更改的数据
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public static function modifyCartProduct($uid, $param, $shoppingKey)
{
$result = array('code' => 400, 'message' => '出错啦~');
// 处理要更改的数据
$swapData = json_encode(array($param));
$modify = CartData::modifyCartProduct($uid, $swapData, $shoppingKey);
if ($modify && isset($modify['code'])) {
$result['code'] = $modify['code'];
$result['message'] = $modify['message'];
}
return $result;
}
/**
* 调用购物车结算接口返回的数据处理
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @param null|string $cookieData cookie中记录的一些订单有关数据
* @return array 接口返回的数据
*/
public static function cartPay($uid, $cartType, $cookieData)
{
$result = array();
$pay = CartData::cartPay($uid, $cartType);
if ($pay && isset($pay['code']) && $pay['code'] === 200) {
$payReturn = $pay['data'];
$orderInfo = array();
$address = array();
$orderCompute = array();
// cookie保存的数据
if (!empty($cookieData)) {
$orderInfo = json_decode($cookieData, true);
$orderCompute = self::orderCompute($uid, $cartType, $orderInfo['deliveryId'], $orderInfo['paymentTypeId'], $orderInfo['couponCode'], $orderInfo['yohoCoin']);
}
// 根据地址id查询地址信息
if (isset($orderInfo['addressId'])) {
$address = UserModel::getAddressDataById($uid, $orderInfo['addressId']);
}
// 收货人有关信息
if (isset($payReturn['delivery_address']) && !empty($payReturn['delivery_address'])) {
$result['addressId'] = isset($address['address_id']) ? $address['address_id'] : $payReturn['delivery_address']['address_id'];
$result['name'] = isset($address['consignee']) ? $address['consignee'] : $payReturn['delivery_address']['consignee'];
$result['phoneNum'] = isset($address['mobile']) ? $address['mobile'] : $payReturn['delivery_address']['mobile'];
$result['area'] = isset($address['area']) ? $address['area'] : $payReturn['delivery_address']['area'];
$result['address'] = isset($address['address']) ? $address['address'] : $payReturn['delivery_address']['address'];
$result['isSupport'] = ($payReturn['delivery_address']['is_support'] === 'Y');
}
// 配送方式
if (isset($payReturn['delivery_way'])) {
$oneDeliv = array();
foreach ($payReturn['delivery_way'] as $val) {
$oneDeliv = array();
$oneDeliv['id'] = $val['delivery_way_id'];
$oneDeliv['name'] = $val['delivery_way_name'];
isset($orderInfo['deliveryId']) && $orderInfo['deliveryId'] === $oneDeliv['id'] && $oneDeliv['isSelected'] = true;
!isset($oneDeliv['isSelected']) && $oneDeliv['isSelected'] = ($val['default'] === 'Y');
$result['dispatchMode'][] = $oneDeliv;
}
}
// 配送时间
if (isset($payReturn['delivery_time'])) {
$oneDelivTime = array();
foreach ($payReturn['delivery_time'] as $one) {
$oneDelivTime = array();
$oneDelivTime['id'] = $one['delivery_time_id'];
$oneDelivTime['name'] = $one['delivery_time_string'];
$oneDelivTime['default'] = ($one['default'] === 'Y');
isset($orderInfo['deliveryTimeId']) && $orderInfo['deliveryTimeId'] === $oneDelivTime['id'] && $oneDeliv['isSelected'] = true;
$result['dispatchTime'][] = $oneDelivTime;
}
}
// 订单商品
if (isset($payReturn['goods_list'])) {
$oneGoods = array();
foreach ($payReturn['goods_list'] as $single) {
$oneGoods = array();
$oneGoods['id'] = $single['product_sku']; // TODO 未确定用哪个
$oneGoods['thumb'] = Images::getImageUrl($single['goods_images'], 120, 120);
$oneGoods['name'] = $single['product_name'];
$oneGoods['color'] = $single['color_name'];
$oneGoods['size'] = $single['size_name'];
$oneGoods['price'] = Helpers::transPrice($single['real_price']); // last_price有些带.00,有些不带,real_price都不带.00
$oneGoods['count'] = $single['buy_number'];
$result['goods'][] = $oneGoods;
}
}
// 支付方式
if (isset($payReturn['payment_way'])) {
$onePay = array();
foreach ($payReturn['payment_way'] as $pay) {
$onePay = array();
$onePay['id'] = $pay['payment_id'];
$onePay['paymentType'] = $pay['payment_type'];
$onePay['name'] = $pay['payment_type_name'];
$onePay['default'] = ($pay['default'] === 'Y');
$result['paymentWay'][] = $onePay;
}
}
// 有货币
$result['yohoCoin'] = isset($orderCompute['use_yoho_coin']) ? isset($orderCompute['use_yoho_coin']) : $payReturn['yoho_coin'];
// 订单数据
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'];
$salePrice = isset($orderCompute['discount_amount']) ? $orderCompute['discount_amount'] : $payReturn['shopping_cart_data']['discount_amount'];
$price = isset($orderCompute['last_order_amount']) ? $orderCompute['last_order_amount'] : $payReturn['shopping_cart_data']['last_order_amount'];
$freight = isset($orderCompute['promotion_formula_list']['promotion_amount']) ? $orderCompute['promotion_formula_list']['promotion_amount'] : $payReturn['shopping_cart_data']['promotion_formula_list'][1]['promotion_amount'];
$result['sumPrice'] = Helpers::transPrice($sumPrice);
$result['salePrice'] = Helpers::transPrice($salePrice);
$result['price'] = Helpers::transPrice($price);
$result['freight'] = strtr($freight, array('¥'=>'','¥'=>'')) . '.00';
}
// 发票有关数据
if (isset($payReturn['invoices']) && !empty($payReturn['invoices'])) {
$one = array();
foreach ($payReturn['invoices']['invoices_type_list'] as $inv) {
$one = array();
$one['id'] = $inv['invoices_type_id'];
$one['name'] = $inv['invoices_type_name'];
$result['invoice'][] = $one;
}
}
// 优惠券数据
$coupons = array('notUsed' => true);
!empty($orderCompute['coupon_amount']) && $coupons['value'] = $orderInfo['couponValue'];
$coupons += self::getCouponList($uid, 0, 1, true);
$result['coupon'] = $coupons;
}
return $result;
}
/**
* 购物车结算--支付方式和配送方式选择以及是否使用YOHO币接口返回的数据处理
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @param int $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运
* @param int $paymentType 支付方式,1表示在线支付,2表示货到付款
* @param string $couponCode 优惠券码
* @param mixed $yohoCoin 使用的YOHO币数量
* @return array 接口返回的数据
*/
public static function orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin)
{
$result = array();
$compute = CartData::orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin);
if ($compute && isset($compute['code']) && $compute['code'] === 200) {
$result = $compute['data'];
}
return $result;
}
/**
* 购物车结算--输入优惠券代码返回的结果处理
*
* @param int $uid 用户ID
* @param string $couponCode 优惠券代码
* @return array 接口返回的数据
*/
public static function searchCoupon($uid, $couponCode)
{
$result = array('code' => 400, 'message' => '出错啦~');
$coupon = CartData::searchCoupon($uid, $couponCode);
if ($coupon && isset($coupon['code'])) {
$result = $coupon;
}
return $result;
}
/**
* 处理优惠券列表数据
*
* @param int $uid 用户ID
* @param boolean $onlyTotal 只返回总数
* @return array|mixed 处理之后的优惠券数据
*/
public static function getCouponList($uid, $onlyTotal = false)
{
$result = array();
// 调用接口获取优惠券数据
$coupons = CartData::getCouponList($uid);
// 处理优惠券数据
if (isset($coupons['data'])) {
if ($onlyTotal) {
$result['count'] = $coupons['data']['total'];
} else {
$couponArr = array();
isset($coupons['data']['couponList']) && $couponArr = $coupons['data']['couponList'];
foreach ($couponArr as &$val) {
$notAvailableRes = self::searchCoupon($uid, $val['couponCode']);
// 处理可用的优惠券
if (isset($notAvailableRes['code']) && $notAvailableRes['code'] !== 200) {
$val['notAvailable'] = true;
}
}
!empty($couponArr) && $result = $couponArr;
}
}
return $result;
}
/**
* 购物车结算--提交结算信息
*
* @param int $uid 用户ID
* @param int $addressId 地址ID
* @param int $cartType 购物车类型ID
* @param int $deliveryTime 寄送时间ID
* @param int $deliveryWay 寄送方式ID
* @param string $invoiceTitle 发票说明
* @param int $invoiceId 发票类型ID
* @param int $paymentId 支付方式ID
* @param int $paymentType 支付类型ID
* @param string $remark 留言
* @param mixed $yohoCoin 使用的YOHO币数量或为空
* @return array 接口返回的数据
*/
public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin)
{
$result = array();
$orderSubRes = CartData::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin);
if ($orderSubRes && isset($orderSubRes['code']) && $orderSubRes['code'] === 200) {
$result = $orderSubRes;
}
return $result;
}
/**
* 处理不同类型的购物车数据
*
* @param array $data 不同类型购物车数据
* @return array $result 处理之后的不同类型购物车数据
*/
private static function procCartData($data)
{
$result = array();
$oneGoods = array();
// 购买的商品列表
foreach ($data['goods_list'] as $value) {
$oneGoods['id'] = $value['product_sku'];
$oneGoods['skn'] = $value['product_skn'];
$oneGoods['name'] = $value['product_name'];
$oneGoods['thumb'] = Images::getImageUrl($value['goods_images'], 120, 120);
$oneGoods['color'] = $value['color_name'];
$oneGoods['size'] = $value['size_name'];
$oneGoods['appearDate'] = '12月'; // 目前app接口没有返回该数据
$oneGoods['price'] = $value['real_price'];
$oneGoods['count'] = $value['buy_number'];
$oneGoods['lowStocks'] = true;
$result['goods'][] = $oneGoods;
}
// 赠品
count($data['gift_list']) && $result['freebieOrAdvanceBuy'] = true;
$result['freebie'] = $data['gift_list'];
// 加价购
$result['advanceBuy'] = $data['price_gift'];
// 结算数据
$result['price'] = $data['shopping_cart_data']['order_amount'];
$result['activityPrice'] = $data['shopping_cart_data']['discount_amount'];
$result['count'] = $data['shopping_cart_data']['goods_count'];
$result['sumPrice'] = $data['shopping_cart_data']['order_amount'];
return $result;
}
}
... ...
... ... @@ -374,10 +374,9 @@ class UserModel
* @param int $uid 用户ID
* @param int $status 优惠券状态,0表示未使用,1表示已使用
* @param int $page 第几页
* @param boolean $onlyTotal 只返回总数
* @return array|mixed 处理之后的优惠券数据
*/
public static function getCouponData($uid, $status, $page, $onlyTotal = false)
public static function getCouponData($uid, $status, $page)
{
$result = array();
... ... @@ -386,7 +385,6 @@ class UserModel
// 没有获取到优惠券时
if (!$coupons) {
$result['topURL'] = '/product/new';
$result['noRecord'] = true;
return $result;
... ... @@ -395,15 +393,8 @@ class UserModel
// 处理优惠券数据
if (isset($coupons['data'])) {
if ($onlyTotal) {
$result['count'] = $coupons['data']['total'];
return $result;
}
// 不能再查到结果了
if ($page == 1 && $coupons['data']['total'] === 0) {
$result['walkwayUrl'] = '/product/new';
$result['noRecord'] = true;
} else {
$couponArr = array();
... ...
... ... @@ -142,7 +142,7 @@ class DetailModel
$result['feedbacks']['comments'][] = $build;
}
$result['feedbacks']['commentsUrl'] = Helpers::url('/product/detail/comments', array('product_id' => $productId, 'total' => $result['feedbacks']['commentsNum']));
}
}
// 品牌信息
if (!empty($baseInfo['brand'])) {
... ... @@ -157,41 +157,59 @@ class DetailModel
// 商品信息
if (!empty($baseInfo['goodsList'])) {
// $colorGroup = array();
// $sizeGroup = array();
$goodsList = array();
$colorGroup = array();
$sizeList = array();
$goodsGroup = array();
$colorId = 0;
foreach ($baseInfo['goodsList'] as $value) {
$colorId = intval($value['colorId']);
// 商品按颜色进行分类分组
$coverImage = '';
$colorStorageNum = 0; // 颜色的库存总数
$totalStorageNum = 0; // 总库存数
foreach ($baseInfo['goodsList'] as $i => $value) {
$sizeList = array();
$colorStorageNum = 0;
// 获取默认的封面图
if ($i === 0) {
$coverImage = Helpers::getImageUrl($value['colorImage'], 60, 60);
}
// 商品分组
if (isset($value['goodsImagesList'])) {
foreach ($value['goodsImagesList'] as $goods) {
$goodsList[$goods['goodsId']] = $colorId;
$goodsGroup[] = array(
'goodsId' => $goods['goodsId'],
'img' => $goods['imageUrl'],
);
// $colorGroup[$colorId] = array(
// 'colorId' => $colorId,
// 'colorName' => $value['colorName'],
// 'colorImage' => Helpers::getImageUrl($value['colorImage'], 60, 60),
// );
}
}
// // 商品的尺码列表
// if (isset($value['goodsSizeBoList'])) {
// foreach ($value['goodsSizeBoList'] as $size) {
// $sizeGroup[$colorId] = array(
// 'sizeName' => $size['sizeName'],
// 'sizeSku' => $size['goodsSizeSkuId'],
// 'sizeStorage' => $size['goodsSizeStorageNum'],
// );
// }
// }
// 商品的尺码列表
if (isset($value['goodsSizeBoList'])) {
foreach ($value['goodsSizeBoList'] as $size) {
$sizeList[] = array(
'id' => $size['id'],
'skuId' => $size['goodsSizeSkuId'],
'goodsId' => $size['goodsId'],
'name' => $size['sizeName'],
'sizeNum' => $size['goodsSizeStorageNum'],
);
$colorStorageNum += intval($size['goodsSizeStorageNum']);
}
}
// 颜色分组
$colorGroup[] = array(
'id' => $value['colorId'],
'skcId' => $value['productSkc'],
'name' => $value['colorName'],
'goodsName' => $value['goodsName'],
'shortUrl' => Helpers::getImageUrl($value['colorImage'], 60, 60),
'colorNum' => $colorStorageNum,
'sizes' => $sizeList,
);
$totalStorageNum += $colorStorageNum;
}
// 商品图: 多个
if (isset($goodsGroup[1])) {
foreach ($goodsGroup as $value) {
... ... @@ -214,11 +232,18 @@ class DetailModel
'numInCart' => 0,
'goodsInstore' => $baseInfo['storage'], // 库存量
);
$soldOut = $baseInfo['storage'] == 0;
$soldOut = $totalStorageNum === 0;
$notForSale = $baseInfo['attribute'] == 2;
// 显示加入购物车链接
if (!$soldOut && !$notForSale) {
$result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html'); //
$result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html');
$result['cartInfo']['productId'] = $productId;
$result['cartInfo']['thumb'] = $coverImage;
$result['cartInfo']['name'] = isset($result['goodsName']) ? $result['goodsName'] : '';
$result['cartInfo']['price'] = isset($result['goodsPrice']['currentPrice']) ? $result['goodsPrice']['currentPrice'] : '';
$result['cartInfo']['salePrice'] = isset($result['goodsPrice']['previousPrice']) ? $result['goodsPrice']['previousPrice'] : '';
$result['cartInfo']['totalNum'] = $totalStorageNum;
$result['cartInfo']['colors'] = $colorGroup;
}
// 非卖品
elseif ($notForSale) {
... ... @@ -251,11 +276,11 @@ class DetailModel
*/
public static function getSizeInfo($productSkn)
{
$result = array();
$result = array();
if (is_numeric($productSkn)) {
// 调用服务
$sizeInfo = DetailData::sizeInfo($productSkn);
$sizeInfo = DetailData::sizeInfo($productSkn);
// 商品信息
if (isset($sizeInfo['productDescBo']['erpProductId'])) {
... ... @@ -345,7 +370,6 @@ class DetailModel
} else {
$result['sizeInfo']['detail']['list'][0]['params'] = array(0 => array('param' => ''));
}
}
// 测量方式
... ...
... ... @@ -51,8 +51,6 @@ application.assets.path = ROOT_PATH "/assets"
; 应用的版本号
application.version = "1.2.1"
; JS统计代码的版本号
application.yas.version = "1.0.13.2"
; 网站SEO信息
application.seo.title = "Yoho!Buy有货 | 潮流购物逛不停"
... ...
... ... @@ -51,8 +51,6 @@ application.assets.path = ROOT_PATH "/assets"
; 应用的版本号
application.version = "1.2.1"
; JS统计代码的版本号
application.yas.version = "1.0.13.2"
; 网站SEO信息
application.seo.title = "Yoho!Buy有货 | 潮流购物逛不停"
... ...
... ... @@ -51,8 +51,6 @@ application.assets.path = ROOT_PATH "/assets"
; 应用的版本号
application.version = "1.2.1"
; JS统计代码的版本号
application.yas.version = "1.0.13.2"
; 网站SEO信息
application.seo.title = "Yoho!Buy有货 | 潮流购物逛不停"
... ...
... ... @@ -51,8 +51,6 @@ application.assets.path = ROOT_PATH "/assets"
; 应用的版本号
application.version = "1.2.1"
; JS统计代码的版本号
application.yas.version = "1.0.13.2"
; 网站SEO信息
application.seo.title = "Yoho!Buy有货 | 潮流购物逛不停"
... ...