Authored by 梁志锋

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

... ... @@ -299,7 +299,7 @@ class AbstractAction extends Controller_Abstract
if (!$this->_useSession) {
$useSession = false;
}
$useSession = false;
//$useSession = false;
if (!$this->_uid) {
$cookie = $this->getCookie('_UID');
... ...
... ... @@ -17,186 +17,186 @@ 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 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 = 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;
}
if ($shoppingKey !== null) {
$param['shoppingKey'] = $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 selectGoods($uid, $sku, $shoppingKey)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.selected';
$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 $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 $sku 商品SKU
* @param int $increaseNum 增加的数目
* @param int $decreaseNum 减少的数目
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public static function modifyProductNum($uid, $sku, $increaseNum, $decreaseNum, $shoppingKey)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.increase';
$param['product_sku'] = $sku;
* @return array 加入购物车接口返回的数据
*/
public static function addToCart($productSku, $buyNumber, $goodsType, $isEdit = 0, $promotionId = null, $uid = null, $shoppingKey = 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;
}
if ($shoppingKey !== null) {
$param['shoppingKey'] = $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 selectGoods($uid, $sku, $shoppingKey)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.selected';
$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 $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 $sku 商品SKU
* @param int $increaseNum 增加的数目
* @param int $decreaseNum 减少的数目
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public static function modifyProductNum($uid, $sku, $increaseNum, $decreaseNum, $shoppingKey)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.increase';
$param['product_sku'] = $sku;
if (!empty($increaseNum)) {
$param['increase_number'] = $increaseNum;
... ... @@ -205,175 +205,199 @@ class CartData
$param['decrease_number'] = $decreaseNum;
}
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 $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 string $couponCode 优惠券码
* @param mixed $yohoCoin 使用的YOHO币数量或为空
* @return array 接口返回的数据
*/
public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.submit';
$param['address_id'] = $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($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);
}
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 $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 string $couponCode 优惠券码
* @param mixed $yohoCoin 使用的YOHO币数量或为空
* @return array 接口返回的数据
*/
public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.submit';
$param['address_id'] = $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($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 $shoppingKey 未登录用户唯一识别码
* @return array 购物车接口返回的数据
*/
public static function cartCount($uid, $shoppingKey)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.count';
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);
}
}
... ...
... ... @@ -129,7 +129,7 @@ class Helpers
*/
public static function getShoppingKeyByCookie()
{
$cookie = isset($_COOKIE['_spk']) ? $_COOKIE['_spk'] : '';
$cookie = isset($_COOKIE['_Spk']) ? $_COOKIE['_Spk'] : '';
return $cookie;
}
... ...
... ... @@ -26,6 +26,7 @@ lazyLoad();
if (window.getUid() !== orderInfo('uid')) {
order.init();
window.location.reload();
}
if ($couponUse.data('name') !== orderInfo('couponName')) {
... ... @@ -33,6 +34,8 @@ if ($couponUse.data('name') !== orderInfo('couponName')) {
orderInfo('couponName', null);
}
orderInfo('cartType', queryString.cartType || queryString.carttype || 'ordinary');
function dispacthTapEvt(e) {
var $cur = $(e.target).closest('li');
... ... @@ -78,7 +81,7 @@ function orderCompute() {
method: 'POST',
url: '/cart/index/orderCompute',
data: {
cartType: queryString.cartType || queryString.carttype || 'ordinary',
cartType: orderInfo('cartType') || 'ordinary',
deliveryId: orderInfo('deliveryId'),
paymentTypeId: orderInfo('paymentTypeId'),
couponCode: orderInfo('couponCode'),
... ... @@ -139,11 +142,12 @@ function submitOrder() {
url: '/cart/index/orderSub',
data: {
addressId: orderInfo('addressId'),
cartType: queryString.cartType || queryString.carttype || 'ordinary',
cartType: orderInfo('cartType') || 'ordinary',
deliveryId: orderInfo('deliveryId'),
deliveryTimeId: orderInfo('deliveryTimeId'),
invoiceText: orderInfo('invoice') ? invoiceText : null,
invoiceType: orderInfo('invoice') ? ($invoice.find('.invoice-type').val() || orderInfo('invoiceType')) : null,
invoiceType: orderInfo('invoice') ? ($invoice.find('.invoice-type').val() ||
orderInfo('invoiceType')) : null,
msg: msg,
paymentTypeId: orderInfo('paymentTypeId'),
paymentType: orderInfo('paymentType'), //支付方式
... ...
... ... @@ -19,7 +19,8 @@ function init() {
invoice: null,
invoiceText: null,
invoiceType: null,
msg: null
msg: null,
cartType: 'ordinary'
};
window.setCookie('order-info', JSON.stringify(info));
}
... ...
... ... @@ -161,11 +161,18 @@
color: #fff;
text-align: center;
font-size: 12px;
&:before {
display: block;
line-height: 1;
@include transform(scale(0.833));
}
}
.gift-tag {
height: 25rem / $pxConvertRem;
background: #a1ce4e;
&:before {
content: '赠品';
}
... ... @@ -174,6 +181,7 @@
.advance-buy-tag {
height: 25rem / $pxConvertRem;
background: #eb76aa;
&:before {
content: '加价购';
}
... ... @@ -228,4 +236,4 @@
.appear-date {
color: #f00;
}
}
\ No newline at end of file
}
... ...
... ... @@ -123,20 +123,7 @@ class CartModel
*/
public static function getCartCount($uid, $shoppingKey)
{
$result = array(
'code' => 200,
'data' => array(
'cart_goods_count' => 0
)
);
$carData = self::getCartData($uid, $shoppingKey);
if (isset($carData['commonGoodsCount'])) {
$result['data']['cart_goods_count'] = $carData['commonGoodsCount'] + $carData['presellGoodsCount'];
}
return $result;
return CartData::cartCount($uid, $shoppingKey);
}
/**
... ... @@ -425,9 +412,9 @@ class CartModel
//gift=>是否赠品,advanceBuy=>是否加价购;
if ($single['goods_type'] == 'gift' && !isset($single['isAdvanceBuy'])) {
$oneGoods['isGift'] = true;
$oneGoods['gift'] = true;
} elseif ($single['goods_type'] == 'price_gift') {
$oneGoods['isAdvanceBuy'] = true;
$oneGoods['advanceBuy'] = true;
}
$result['goods'][] = $oneGoods;
... ...
... ... @@ -79,7 +79,7 @@ class IndexController extends AbstractAction
$result = array();
if ($this->isAjax()) {
$uid = $this->getUid(true);
$uid = $this->getUid(false);
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = CartModel::getCartCount($uid, $shoppingKey);
}
... ...
... ... @@ -11,19 +11,22 @@ use Plugin\Helpers;
class BackController extends AbstractAction
{
/**
* 通过邮箱找回密码
*/
public function emailAction()
{
$this->setTitle('找回密码-通过邮箱');
$data = array(
'backUrl' => '/signin.html',
'backUrl' => Helpers::url('/signin.html'),
'headerText' => '找回密码',
'isPassportPage' => true,
'backEmail' => true
);
// 生成HTML (emailback.html)
$this->_view->html('emailback');
//$this->_view->html('emailback');
$this->_view->display('email', $data);
}
... ... @@ -33,30 +36,26 @@ class BackController extends AbstractAction
public function sendemailAction()
{
$result = array('code' => 400, 'message' => '邮箱格式不正确,请重新输入', 'data' => '');
do
{
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax())
{
if (!$this->isAjax()) {
break;
}
$email = $this->post('email', '');
// 判断邮箱是否有效
if(!Helpers::verifyEmail($email))
{
if (!Helpers::verifyEmail($email)) {
break;
}
// 发送邮箱验证码
$result = BackData::sendCodeToEmail($email);
if($result['code'] === 200)
{
$result['data'] = '/passport/back/success?email='.$email;
if ($result['code'] === 200) {
$result['data'] = Helpers::url('/passport/back/resendemail', array(
'email' => $email,
));
}
}
while (false);
} while (false);
$this->echoJson($result);
}
... ... @@ -67,10 +66,8 @@ class BackController extends AbstractAction
public function resendemailAction()
{
$result = array('code' => 400, 'message' => '重发邮件失败');
do
{
if(!$this->isAjax())
{
do {
if (!$this->isAjax()) {
break;
}
... ... @@ -79,17 +76,17 @@ class BackController extends AbstractAction
// 发送邮箱验证码
$return = BackData::sendCodeToEmail($email);
if(!empty($return))
{
if (!empty($return)) {
$result = $return;
}
}
while(false);
} while (false);
$this->echoJson($result);
}
/**
* 邮箱找回密码-成功
*/
public function successAction()
{
$email = $this->get('email', '');
... ... @@ -97,18 +94,20 @@ class BackController extends AbstractAction
if (!Helpers::verifyEmail($email)) {
$this->error();
}
// 获取到邮箱域名
list($name, $domain) = explode('@', $email);
$domain_name = 'http://' . (($domain == 'gmail.com') ? 'mail.google.com' : 'mail.' . $domain);
$data = array(
'backUrl' => '/emailback.html',
'backUrl' => Helpers::url('/emailback.html'),
'headerText' => '找回密码',
'isPassportPage' => true,
'backEmailSuccess' => true,
'goEmail' => $domain_name,
'resendUrl' => '/passport/back/resendemail?email='.$email
'resendUrl' => Helpers::url('/passport/back/resendemail', array(
'email' => $email,
)),
);
$this->setTitle('找回密码-通过邮箱');
... ... @@ -122,32 +121,28 @@ class BackController extends AbstractAction
*/
public function passwordByEmailAction()
{
if($this->isAjax())
{
if ($this->isAjax()) {
$pwd = $this->post('password', '');
$code = $this->post('code', '');
$data = BackData::modifyPasswordByEmail($pwd, $code);
$result = array('code'=>200, 'data' => '/signin.html');
print_r($data);
if(strpos($data, 'history.back') !== false)
{
$result = array('code' => 200, 'data' => Helpers::url('/signin.html') );
if (strpos($data, 'history.back') !== false) {
$result['code'] = 400;
$result['message'] = '修改失败';
}
$this->echoJson($result);// 前端不需要判断结果
$this->echoJson($result); // 前端不需要判断结果
}
}
public function mobileAction()
{
$this->setTitle('找回密码-通过手机号');
$data = array(
'backUrl' => '/signin.html',
'backUrl' => Helpers::url('/signin.html'),
'headerText' => '找回密码',
'isPassportPage' => true,
'backMobile' => true,
... ... @@ -157,7 +152,7 @@ class BackController extends AbstractAction
// 生成HTML (phoneback.html)
// $this->_view->html('phoneback');
$this->_view->display('mobile', $data);
}
... ... @@ -167,35 +162,31 @@ class BackController extends AbstractAction
public function sendcodeAction()
{
$result = array('code' => 400, 'message' => '密码只能使用数字、字母和半角标点符号,请重新输入', 'data' => '');
do
{
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax())
{
if (!$this->isAjax()) {
break;
}
$phoneNum = $this->post('phoneNum', '');
$areaCode = $this->post('areaCode', 86);
if(!Helpers::verifyMobile($phoneNum))
{
if (!Helpers::verifyMobile($phoneNum)) {
break;
}
// 发送手机验证码
$result = BackData::sendCodeToMobile($phoneNum, $areaCode);
if(empty($result))
{
if (empty($result)) {
break;
}
if($result['code'] === 200)
{
$result['data'] = '/passport/back/mobilecode?phoneNum='.$phoneNum.'&areaCode='.$areaCode;
}
}
while (false);
if ($result['code'] === 200) {
$result['data'] = Helpers::url('/passport/back/mobilecode', array(
'phoneNum' => $phoneNum,
'areaCode' => $areaCode,
));
}
} while (false);
$this->echoJson($result);
}
... ... @@ -207,10 +198,10 @@ class BackController extends AbstractAction
{
$phoneNum = $this->get('phoneNum', '');
$areaCode = $this->get('areaCode', 86);
$areaCode = '+'.$areaCode;
$areaCode = '+' . $areaCode;
$data = array(
'backUrl' => '/phoneback.html',
'backUrl' => Helpers::url('/phoneback.html'),
'headerText' => '找回密码',
'isPassportPage' => true,
'backCode' => true,
... ... @@ -229,23 +220,28 @@ class BackController extends AbstractAction
*/
public function verifycodeAction()
{
if($this->isAjax())
{
if ($this->isAjax()) {
$phoneNum = $this->post('phoneNum', '');
$code = $this->post('code', '');
$areaCode = $this->post('areaCode', 86);
// 校验手机验证码
$result = BackData::validateMobileCode($phoneNum, $code, $areaCode);
if($result['code'] === 200)
{
$result['data'] = '/passport/back/backcode?phoneNum='.$phoneNum.'&token='.$result['data']['token'].'&areaCode='.$areaCode;
if ($result['code'] === 200) {
$result['data'] = Helpers::url('/passport/back/backcode', array(
'phoneNum' => $phoneNum,
'token' => $result['data']['token'],
'areaCode' => $areaCode,
));
}
$this->echoJson($result);
}
}
/**
* 找回密码
*/
public function backcodeAction()
{
$phoneNum = $this->get('phoneNum', '');
... ... @@ -260,9 +256,9 @@ class BackController extends AbstractAction
if ((!$token || !Helpers::verifyMobile($phoneNum)) && !$code) {
$this->error();
}
$data = array(
'backUrl' => '/signin.html',
'backUrl' => Helpers::url('/signin.html'),
'headerText' => '找回密码',
'isPassportPage' => true,
'backNewPwd' => true,
... ... @@ -283,8 +279,7 @@ class BackController extends AbstractAction
*/
public function passwordByMobileAction()
{
if($this->isAjax())
{
if ($this->isAjax()) {
$phoneNum = $this->post('phoneNum', '');
$token = $this->post('token', '');
$newpwd = $this->post('password', '');
... ... @@ -292,12 +287,12 @@ class BackController extends AbstractAction
// 根据手机验证码修改密码
$result = BackData::modifyPasswordByMobile($phoneNum, $token, $newpwd, $areaCode);
if($result['code'] === 200)
{
$result['data'] = '/';
if ($result['code'] === 200) {
$result['data'] = Helpers::url('/signin.html');
}
$this->echoJson($result);
}
}
}
\ No newline at end of file
}
... ...
... ... @@ -17,8 +17,7 @@ class BindController extends AbstractAction
public function indexAction()
{
$refer = $this->get('refer');
if (!empty($refer))
{
if (!empty($refer)) {
$this->setCookie('refer', $refer);
}
... ... @@ -50,6 +49,7 @@ class BindController extends AbstractAction
public function codeAction()
{
$this->setTitle('验证手机');
$openId = $this->get('openId');
$sourceType = $this->get('sourceType');
$nickname = $this->get('nickname');
... ... @@ -101,16 +101,16 @@ class BindController extends AbstractAction
$this->_view->display('password', $data);
}
//绑定前手机号校验
/**
* 绑定前手机号校验
*/
public function bindCheckAction()
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do
{
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax())
{
if (!$this->isAjax()) {
break;
}
... ... @@ -121,73 +121,73 @@ 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)
{
$next = Helpers::url('/passport/bind/code', array('isReg' => $res['data']['is_register'], 'openId' => $openId, 'sourceType' => $sourceType, 'nickname' => $nickname, 'areaCode' => $areaCode, 'phoneNum' => $phoneNum));
if ($res['code'] == 200) {
$next = Helpers::url('/passport/bind/code', array(
'isReg' => $res['data']['is_register'],
'openId' => $openId,
'sourceType' => $sourceType,
'areaCode' => $areaCode,
'phoneNum' => $phoneNum,
'nickname' => $nickname,
));
$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);
}
//发送验证码
/**
* 发送验证码
*/
public function sendBindMsgAction()
{
$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) || !$areaCode)
{
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);
}
//校验短信验证码
/**
* 校验短信验证码
*/
public function checkBindMsgAction()
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do
{
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax())
{
if (!$this->isAjax()) {
break;
}
... ... @@ -195,32 +195,29 @@ class BindController extends AbstractAction
$code = $this->post('code');
$areaCode = $this->post('areaCode');
if (!is_numeric($phoneNum) || !$code || !$areaCode)
{
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);
}
//绑定手机号
/**
* 绑定手机号
*/
public function bindMobileAction()
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do
{
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax())
{
if (!$this->isAjax()) {
break;
}
... ... @@ -231,88 +228,78 @@ 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
/**
* 换绑check
*/
public function changeCheckAction()
{
$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) || !$areaCode)
{
if (!is_numeric($phoneNum) || !$areaCode) {
break;
}
$data = BindData::changeCheck($phoneNum, $areaCode);
if (!isset($data['code']))
{
if (!isset($data['code'])) {
break;
}
}
while (false);
} while (false);
$this->echoJson($data);
}
//换绑mobile
/**
* 换绑mobile
*/
public function changeMobileAction()
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do
{
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax())
{
if (!$this->isAjax()) {
break;
}
$uid = $this->getUid(true);
... ... @@ -320,18 +307,15 @@ class BindController extends AbstractAction
$areaCode = $this->post('areaCode');
$code = $this->post('code');
if (!is_numeric($phoneNum) || !$areaCode || !$code || !$uid)
{
if (!is_numeric($phoneNum) || !$areaCode || !$code || !$uid) {
break;
}
$data = BindData::changeMobile($uid, $phoneNum, $areaCode, $code);
if (!isset($data['code']))
{
if (!isset($data['code'])) {
break;
}
}
while (false);
} while (false);
$this->echoJson($data);
}
... ...
... ... @@ -61,6 +61,7 @@ class LoginController extends AbstractAction
$data['isPassportPage'] = true; // 模板中模块标识
$data['areaCode'] = '+86'; // 默认区号
$data['countrys'] = RegData::getAreasData(); // 地区信息列表
// 渲染模板
$this->_view->display('international', $data);
}
... ... @@ -146,6 +147,8 @@ class LoginController extends AbstractAction
*/
public function alipayAction()
{
$this->setSession('_TOKEN', '');
Factory::create('alipay')->getAuthorizeUrl();
exit();
... ... @@ -156,6 +159,8 @@ class LoginController extends AbstractAction
*/
public function qqAction()
{
$this->setSession('_TOKEN', '');
Factory::create('qqconnect')->getAuthorizeUrl();
exit();
... ... @@ -166,6 +171,8 @@ class LoginController extends AbstractAction
*/
public function sinaAction()
{
$this->setSession('_TOKEN', '');
$this->go(Factory::create('sinaweibo')->getAuthorizeUrl());
}
... ...
... ... @@ -81,7 +81,8 @@ class RegController extends AbstractAction
$area = $this->get('areaCode', '86');
// 判断是否允许访问, 不允许则跳转到错误页面
if (!is_string($token) || !is_numeric($mobile) || !is_numeric($area) || !Helpers::verifyToken($mobile, $token)) {
if (!is_string($token) || !is_numeric($mobile) || !is_numeric($area)
|| !Helpers::verifyToken($mobile, $token)) {
$this->error();
}
... ...