Authored by Rock Zhang

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

Conflicts:
	library/LibModels/Wap/Home/CartData.php
... ... @@ -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,15 +17,15 @@ 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 加入购物车接口返回的数据
*/
... ... @@ -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);
if (!empty($uid)) {
$param['uid'] = $uid;
}
if ($shoppingKey !== null) {
$param['shopping_key'] = $shoppingKey;
}
return Yohobuy::get(Yohobuy::API_URL, $param);
}
$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 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);
$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;
}
return Yohobuy::get(Yohobuy::API_URL, $param);
}
$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 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['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);
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
... ... @@ -56,6 +56,10 @@ if ($('.cart-nav').length > 0) {
}, 3000);
}
$('.advance-buy').on('touchend', function() {
window.location.href = '/cart/index/advanceBuy?cartType=' + cartType;
});
$('.btn-balance').on('touchend', function() {
if (hasChecked) {
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
... ...
... ... @@ -17,9 +17,6 @@ var $chosePanel = $('#chose-panel'),
$num,
$chosed,
$imgsThumb,
// re = /\d+/,
$leftNum,
leftNum,
confirming,
... ... @@ -32,6 +29,7 @@ var $chosePanel = $('#chose-panel'),
$sizeRowList,
cbFn,
$allChoseItems,
queryString,
$yohoPage = $('.yoho-page');
//初始化购物车面板显示
... ... @@ -41,10 +39,11 @@ function init() {
hasChooseColor = false;
hasChooseSize = false;
$curSizeBlock = null;
$imgsThumb = $('.chose-panel').find('.thumb'),
$allChoseItems = $('.chose-items'),
$sizeRowList = $('.size-list ul'),
$leftNum = $('#left-num'),
queryString = $.queryString();
$imgsThumb = $('.chose-panel').find('.thumb');
$allChoseItems = $('.chose-items');
$sizeRowList = $('.size-list ul');
$leftNum = $('#left-num');
$firstRow = $sizeRowList.eq(0);
$firstRow.toggleClass('hide');
$curSizeRow = $firstRow;
... ... @@ -77,7 +76,6 @@ function show(html, cb) {
//隐藏当前Panel
function hide() {
$('.chose-panel').hide();
cbFn = null;
}
//修改加入购物车的文字和背景
... ... @@ -168,11 +166,9 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) {
// 之前选中的尺码去掉勾选样式
if ($preSiblingBlock.length > 0) {
$preSiblingBlock.removeClass('chosed');
curSizeBlock = $curSizeRow.children().get(scindex);
}
curSizeBlock = $curSizeRow.children().get(scindex);
// 当前选中颜色对应的尺码行,其对应的尺码加上勾选样式 (前提是要判断下这个尺码是否存在)
if (curSizeBlock) {
curGoodNum = $(curSizeBlock).data('num');
... ... @@ -314,7 +310,7 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
if (2 === $chosed.length && 0 === $chosed.closest('.zero-stock').length) {
productSku = $curSizeBlock.data('skuid');
promotionId = $('[data-id="' + productSku + '"]').closest('.advance-block').data('promotion-id');
promotionId = $('#promotionId').val();
if (confirming) {
return false;
}
... ... @@ -328,7 +324,8 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
productSku: productSku,
buyNumber: buyNumber,
promotionId: promotionId,
isEdit: isEdit
isEdit: isEdit,
cartType: queryString.cartType
}
}).done(function(res) {
loading.hideLoadingMask();
... ... @@ -338,7 +335,7 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
hide();
if (cbFn) {
cbFn(res.location);
cbFn();
}
}
if (res.message) {
... ...
... ... @@ -10,7 +10,8 @@ var $ = require('jquery'),
loading = require('../plugin/loading'),
chosePanel = require('./chose-panel');
var $page = $('.gift-advance-page');
var $page = $('.gift-advance-page'),
queryString = $.queryString();
lazyLoad($('.lazy'));
... ... @@ -24,7 +25,9 @@ function getProductInfo(skn, promotionId) {
tip.show('网络错误');
return;
}
chosePanel.show(html);
chosePanel.show(html, function() {
window.location.href = '/cart/index/index?cartType=' + queryString.cartType;
});
}, function() {
tip.show('网络错误');
}).always(function() {
... ...
... ... @@ -17,6 +17,7 @@ var dispatchModeHammer,
$invoice = $('.invoice'),
$price = $('.price-cal'),
$couponUse = $('.coupon-use.used'),
$addressWrap = $('.address-wrap'),
payType,
priceTmpl = Handlebars.compile($('#tmpl-price').html()),
queryString = $.queryString(),
... ... @@ -26,6 +27,7 @@ lazyLoad();
if (window.getUid() !== orderInfo('uid')) {
order.init();
window.location.reload();
}
if ($couponUse.data('name') !== orderInfo('couponName')) {
... ... @@ -33,6 +35,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 +82,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 +143,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'), //支付方式
... ... @@ -180,12 +185,21 @@ function submitOrder() {
// 界面点击,状态存 cookie
if (!orderInfo('addressId')) {
orderInfo('addressId', $('.address-wrap').data('id'));
orderInfo('addressId', $addressWrap.data('id'));
}
$('.dispatch-mode').on('touchend', 'li', function() {
orderInfo('deliveryId', $(this).data('id'));
orderCompute();
$('.dispatch-mode').on('touchstart', 'li', function() {
var $defaultMode = $('.dispatch-mode [data-id="1"]');
if (!$addressWrap.data('support') && $(this).data('id') === 2) {
dispacthTapEvt({
target: $defaultMode
});
tip.show('当前地址不支持顺丰快递');
} else {
orderInfo('deliveryId', $(this).data('id'));
orderCompute();
}
});
$('.dispatch-time').on('touchend', 'li', function() {
... ...
... ... @@ -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));
}
... ...
... ... @@ -37,7 +37,7 @@ $newCoupon.on('submit', function() {
if (res.code === 200) {
tip.show('优惠券可用');
orderInfo('couponCode', res.data.coupon_code);
orderInfo('couponName', res.data.coupon_name);
orderInfo('couponName', res.data.coupon_title);
window.location.href = '/cart/index/orderEnsure';
} else {
tip.show(res.message || '网络错误');
... ...
... ... @@ -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
}
... ...
{{> layout/header}}
<div class="order-ensure-page yoho-page">
{{# orderEnsure}}
<a class="address-wrap block" data-id="{{addressId}}" href="/cart/index/selectAddress">
<a class="address-wrap block" data-id="{{addressId}}" data-support="{{isSupport}}" href="/cart/index/selectAddress">
<p class="infos">
收货地址
<span class="per-info">{{name}} {{phoneNum}}</span>
... ... @@ -41,6 +41,7 @@
<section class="block">
<ul class="sale-invoice">
{{#if isOrdinaryCart}}
<li class="coupon">
<a href="/cart/index/selectCoupon">
<span class="title">优惠券</span>
... ... @@ -49,9 +50,9 @@
{{count}}张可用
</span>
{{#if name}}
<span class="used coupon-use" data-name="{{name}}">
{{name}}
{{#if couponName}}
<span class="used coupon-use" data-name="{{couponName}}">
{{couponName}}
<i class="iconfont">&#xe614;</i>
</span>
{{^}}
... ... @@ -63,6 +64,7 @@
{{/coupon}}
</a>
</li>
{{/if}}
<li class="coin" data-yoho-coin="{{yohoCoin}}">
<span class="title">YOHO币</span>
... ...
... ... @@ -25,7 +25,7 @@
<li class="advance-buy">
<span class="iconfont">&#xe61b;</span>
加价购
<a href="/cart/index/advanceBuy">
<a href="">
<span class="count">{{advanceBuyCount}}</span>
<span class="iconfont icon-right-arrow">&#xe614;</span>
</a>
... ...
... ... @@ -37,7 +37,7 @@
<ul class="size-row clearfix hide">
{{# size}}
<li class="block {{#if chosed}}chosed{{/if}} {{#unless sizeNum}}zero-stock{{/unless}}" data-id={{id}} data-colorid="{{colorId}}" data-num="{{sizeNum}}" data-numstr="{{colorNumStr}}" data-skuid="{{skuId}}" data-goodid="{{goodsId}}">
<li class="block {{#if chosed}}chosed{{/if}} {{#unless sizeNum}}zero-stock{{/unless}}" data-id="{{id}}" data-colorid="{{colorId}}" data-num="{{sizeNum}}" data-numstr="{{colorNumStr}}" data-skuid="{{skuId}}" data-goodid="{{goodsId}}">
{{name}}
</li>
{{/ size}}
... ... @@ -67,4 +67,5 @@
</div>
</div>
</div>
{{/cartInfo}}
\ No newline at end of file
{{/cartInfo}}
<input id="promotionId" type="hidden" value="{{promotionId}}">
\ 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);
}
/**
... ... @@ -256,7 +243,6 @@ class CartModel
$product = CartData::giftProductData($skn, $promotionId);
if (isset($product['code']) && $product['code'] === 200) {
$result['code'] = 200;
$result['data'] = self::procGoodsDetail($product['data']);
}
... ... @@ -426,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;
... ... @@ -488,7 +474,7 @@ class CartModel
// 优惠券数据
$coupons = array();
!empty($orderCompute['coupon_amount']) && $coupons['name'] = $orderInfo['couponName'];
!empty($orderCompute['coupon_amount']) && $coupons['couponName'] = $orderInfo['couponName'];
$coupons += self::getCouponList($uid, true);
$result['coupon'] = $coupons;
}
... ...
... ... @@ -216,6 +216,7 @@ class IndexController extends AbstractAction
}
$this->_view->display('gift-info', array(
'promotionId' => $promotionId,
'cartInfo' => $result['data']
));
}
... ... @@ -271,7 +272,7 @@ class IndexController extends AbstractAction
$this->auditJumpLogin();
$this->setTitle('确认订单');
$this->setNavHeader('确认订单', true, false); // 不显示右上角home按钮
$this->setNavHeader('确认订单', Helpers::url('/cart/index/index'), false); // 不显示右上角home按钮
// 购物车商品为空跳转到购物车页面
$shoppingKey = Helpers::getShoppingKeyByCookie();
... ... @@ -286,6 +287,7 @@ class IndexController extends AbstractAction
$uid = $this->getUid(true);
$data = array(
'orderEnsurePage' => true,
'isOrdinaryCart' => ($cartType !== 'advance'),
'orderEnsure' => CartModel::cartPay($uid, $cartType, $cookieData)
);
... ...
... ... @@ -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();
}
... ...