Authored by uedxwg

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

... ... @@ -23,18 +23,17 @@ class Yohobuy
// const SERVICE_URL = 'http://service.api.yohobuy.com/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
// const API_URL = 'http://apih5.yoho.cn/';
// const API_URL2 = 'http://apih5.yoho.cn/';
// const SERVICE_URL = 'http://serviceh5.yoho.cn/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
// const API_OLD = 'http://api2.open.yohobuy.com/';
/* 测试环境 */
const API_URL = 'http://testapi.yoho.cn:28078/';
const SERVICE_URL = 'http://testservice.yoho.cn:28077/';
const API_URL = 'http://apih5.yoho.cn/';
const API_URL2 = 'http://apih5.yoho.cn/';
const SERVICE_URL = 'http://serviceh5.yoho.cn/';
const YOHOBUY_URL = 'http://www.yohobuy.com/';
const API_OLD = 'http://test2.open.yohobuy.com/';
const API_OLD = 'http://api2.open.yohobuy.com/';
// /* 测试环境 */
// const API_URL = 'http://testapi.yoho.cn:28078/';
// const SERVICE_URL = 'http://testservice.yoho.cn:28077/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
// const API_OLD = 'http://test2.open.yohobuy.com/';
/**
* 私钥列表
... ...
... ... @@ -24,15 +24,20 @@ class LoginData
* @param string $area 地区编号
* @param string $profile 邮箱或手机号
* @param string $password 密码
* @param string $shoppingKey 未登录用户唯一识别码, 默认为空
* @return array
*/
public static function signin($area, $profile, $password)
public static function signin($area, $profile, $password, $shoppingKey = null)
{
$param = Yohobuy::param();
$param['method'] = 'app.passport.signin';
$param['area'] = $area;
$param['profile'] = $profile;
$param['password'] = $password;
if (!empty($shoppingKey)) {
$param['shopping_key'] = $shoppingKey;
}
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(Yohobuy::API_URL, $param);
... ... @@ -59,9 +64,10 @@ class LoginData
* @param string $nickname 姓名
* @param string $openId 第三方唯一识别码
* @param string $sourceType 登录方式
* @param string $shoppingKey 未登录用户唯一识别码, 默认为空
* @return array 登录返回结果
*/
public static function signinByOpenID($nickname, $openId, $sourceType)
public static function signinByOpenID($nickname, $openId, $sourceType, $shoppingKey = null)
{
// 构建必传参数
$param = Yohobuy::param();
... ... @@ -71,6 +77,9 @@ class LoginData
$param['source_type'] = $sourceType;
$param['nickname'] = $nickname;
$param['client_secret'] = Sign::getSign($param);
if (!empty($shoppingKey)) {
$param['shopping_key'] = $shoppingKey;
}
return Yohobuy::get(Yohobuy::API_URL, $param);
}
... ...
... ... @@ -191,7 +191,7 @@ class Helpers
*/
public static function transPrice($price)
{
return (!empty($price) && !is_float($price)) ? $price . '.00' : number_format($price, 2, '.', '');
return number_format($price, 2, '.', '');
}
/**
... ...
... ... @@ -5,7 +5,6 @@
*/
var $ = require('jquery'),
lazyLoad = require('yoho.lazyload'),
Hammer = require('yoho.hammer');
var chosePanel = require('./chose-panel'),
... ... @@ -16,14 +15,21 @@ var $cartContent = $('.cart-content'),
cartType = $('#cartType').val(),
hasShowCartPresellTip = false;
var $cartContentShow = $cartContent.not('.hide');
var navHammer,
advanceBuyHammer,
freebieHammer;
freebieHammer,
switchChose = false;
require('../product/recommend-for-you');
var hasChecked = $('.cart-content:not(.hide) .icon-cb-checked').length > 0 ? true : false; //是否有选中商品
function hasChecked() {
return $cartContentShow.find('.icon-cb-checked').length > 0 ? true : false;
}
function shouldSelectGift() {
var $freebie = $('.freebie');
var $freebie = $cartContentShow.find('.freebie');
if ($freebie.length <= 0) {
return false;
... ... @@ -33,9 +39,15 @@ function shouldSelectGift() {
}
function shouldLowStocks() {
var $lowStocks = $('.low-stocks'),
var $lowStocks,
result = false;
if ('ordinary' === cartType) {
$lowStocks = $('.common .low-stocks');
} else if ('advance' === cartType) {
$lowStocks = $('.presell .low-stocks');
}
if ($lowStocks.length <= 0) {
return result;
}
... ... @@ -58,7 +70,7 @@ function showChooseGifDialog() {
rightBtnText: '去选择'
}
}, function() {
window.location.href = $('.freebie').find('a').attr('href');
window.location.href = $cartContentShow.find('.freebie > a').attr('href');
}, function() {
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
});
... ... @@ -66,7 +78,7 @@ function showChooseGifDialog() {
require('./good');
lazyLoad($('img.lazy'));
//lazyLoad($('img.lazy'));
if (typeof window.cookie === 'function' && 'y' === window.cookie('_hasShowCartPresellTip')) {
$('#presell-tip').removeClass('show').addClass('hide');
... ... @@ -77,8 +89,11 @@ if (typeof window.cookie === 'function' && 'y' === window.cookie('_hasShowCartPr
if ('advance' === cartType) {
$cartContent.toggleClass('hide');
$('presell-cart-nav').addClass('active');
$('common-cart-nav').removeClass('active');
$('#common-cart-nav').removeClass('active');
$('#presell-cart-nav').addClass('active');
$('.shopping-cart-good .name').each(function() {
this.mlellipsis(2);
});
}
if ($('.cart-nav').length > 0) {
... ... @@ -104,7 +119,14 @@ if ($('.cart-nav').length > 0) {
//切换普通商品和预售商品购物车显示
$cartContent.toggleClass('hide');
hasChecked = $('.cart-content:not(.hide) .icon-cb-checked').length > 0 ? true : false;
$cartContentShow = $cartContent.not('.hide');
if (switchChose === false) {
$cartContentShow.find('.shopping-cart-good .name').each(function() {
this.mlellipsis(2);
});
switchChose = true;
}
//trigger lazyload
$(window).trigger('scroll');
... ... @@ -133,16 +155,17 @@ if ($('.freebie').length > 0) {
}
$('.btn-balance').on('touchend', function() {
if (shouldSelectGift()) {
showChooseGifDialog();
if (shouldLowStocks()) {
tip.show('所选商品中含有库存不足的商品');
return false;
}
if (shouldLowStocks()) {
tip.show('库存不足无法结算');
if (shouldSelectGift()) {
showChooseGifDialog();
return false;
}
if (hasChecked) {
if (hasChecked()) {
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
} else {
tip.show('请先勾选商品');
... ... @@ -153,10 +176,6 @@ $('.chose').on('touchend', function() {
chosePanel.show();
});
if ($('.shopping-cart-good').length <= 0) {
require('../product/recommend-for-you');
}
function notAllowScroll() {
var docH = $(document).height(),
winH = $(window).height();
... ...
... ... @@ -22,9 +22,11 @@ lazyLoad({
try_again_css: 'good-failure'
});
$('.shopping-cart-good .name').each(function() {
setTimeout(function() {
$('.shopping-cart-good .name').each(function() {
this.mlellipsis(2);
});
});
}, 0);
function GoodInfo(properties) {
this.goods_type = properties.goods_type;
... ... @@ -104,7 +106,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
});
orderInfo('couponCode', null);
orderInfo('couponName', null);
history.go(0);
window.location.href = '/cart/index/index?cartType=' + $('#cartType').val();
} else {
tip.show(data.message);
}
... ... @@ -164,7 +166,7 @@ function didUpdateAllGoodsCheckStatus() {
$(checkedBox).removeClass('icon-cb-checked').addClass('icon-checkbox');
});
}
window.history.go(0);
window.location.href = '/cart/index/index?cartType=' + $('#cartType').val();
}
function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) {
... ... @@ -190,7 +192,22 @@ function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) {
//全选按钮点击事件
$selectAllBtn.on('touchend', function() {
bottomCheckBoxHandeler($(this).hasClass('icon-cb-checked'), $('#cartType').val(), didUpdateAllGoodsCheckStatus);
var cartType = $('#cartType').val(),
isSelect = $(this).hasClass('icon-cb-checked');
if ('ordinary' === cartType) {
if (!isSelect && $('.common .low-stocks').length > 0) {
tip.show('所选商品中含有库存不足的商品');
return false;
}
} else if ('advance' === cartType) {
if (!isSelect && $('.presell .low-stocks').length > 0) {
tip.show('所选商品中含有库存不足的商品');
return false;
}
}
bottomCheckBoxHandeler(isSelect, cartType, didUpdateAllGoodsCheckStatus);
});
$('.down').on('touchend', function() {
... ...
... ... @@ -3,7 +3,6 @@
* @author: chenglong<chenglong.wang@yoho.cn>
* @date: 2015/11/12
*/
var $ = require('jquery'),
Hammer = require('yoho.hammer'),
Swiper = require('yoho.iswiper');
... ...
... ... @@ -41,7 +41,7 @@ optHammer.on('tap', function(e) {
}
}).then(function(res) {
$('#dialog-wrapper').hide();
if (!res) {
if ($.type(res) !== 'object') {
return;
}
if (res.message) {
... ... @@ -70,7 +70,7 @@ optHammer.on('tap', function(e) {
}
}).then(function(res) {
$('#dialog-wrapper').hide();
if (!res) {
if ($.type(res) !== 'object') {
return;
}
if (res.message) {
... ...
... ... @@ -58,6 +58,7 @@
}
.sale-price {
color: #e10;
margin-right: pxToRem(15px);
&.no-price {
color: #000;
... ...
... ... @@ -27,7 +27,7 @@
}
}
.few-tag{
.few-tag {
width: 148rem / $pxConvertRem;
position: absolute;
left: 92rem / $pxConvertRem;
... ... @@ -90,6 +90,7 @@
width: 80%;
color: #5a5a5a;
font-size: 0.6rem;
line-height: 0.7rem;
}
.color-size-row > span {
... ...
... ... @@ -138,6 +138,13 @@
}
}
.checkbox {
display: inline-block;
width: 80rem / $pxConvertRem;
text-align: center;
margin-right: -20rem / $pxConvertRem;
}
.coin-check {
float: right;
color: #999;
... ...
... ... @@ -78,6 +78,7 @@
}
.not-avaliable {
-webkit-filter: grayscale(100%);
// -webkit-filter: grayscale(100%);
@include filter(grayscale(100%));
}
}
... ...
... ... @@ -101,7 +101,7 @@ a {
color: #fff;
font-size: 18px;
border: none;
z-index:2;
z-index:4;
@include border-radius(10px);
}
... ...
... ... @@ -9,6 +9,10 @@ $basicBtnC:#eb0313;
overflow: hidden;
background-color: #f0f0f0;
.yoho-tip {
z-index: 4;
}
.page-block {
background-color: #fff;
box-sizing: border-box;
... ...
... ... @@ -19,13 +19,13 @@
{{^}}
{{#if cartNav}}
<ul class="cart-nav clearfix">
<li class="active">
<span id="common-cart-nav">
<li class="active" id="common-cart-nav">
<span >
普通商品({{commonGoodsCount}})
</span>
</li>
<li>
<span id="presell-cart-nav">
<li id="presell-cart-nav">
<span >
预售商品({{presellGoodsCount}})
</span>
<div id="presell-tip" class="presell-tip hide">
... ...
... ... @@ -14,7 +14,7 @@
{{#if freebieOrAdvanceBuy}}
<ul class="freebie-and-advance-buy">
{{# freebie}}
{{#if freebie}}
<li class="freebie">
<a href="/cart/index/gift?cartType={{cartType}}">
<span class="iconfont">&#xe620;</span>
... ... @@ -23,7 +23,7 @@
<span class="count">{{giftCount}}</span>
</a>
</li>
{{/ freebie}}
{{/if}}
{{#if advanceBuy}}
<li class="advance-buy">
<a href="/cart/index/advanceBuy?cartType={{cartType}}">
... ...
... ... @@ -782,7 +782,7 @@ class HomeController extends AbstractAction
$this->auditJumpLogin();
$this->setTitle('支付中心');
$this->setNavHeader('支付中心', Helpers::url('/cart/index/index'));
$this->setNavHeader('支付中心', Helpers::url('/home/orders'), '');
$orderCode = $this->get('order_code');
if (empty($orderCode)) {
... ...
... ... @@ -313,10 +313,10 @@ class CartModel
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @param null|string $cookieData cookie中记录的一些订单有关数据
* @param array $orderInfo cookie中记录的一些订单有关数据
* @return array 接口返回的数据
*/
public static function cartPay($uid, $cartType, $cookieData)
public static function cartPay($uid, $cartType, $orderInfo)
{
$result = array();
... ... @@ -324,13 +324,11 @@ class CartModel
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);
if (!empty($orderInfo)) {
$orderCompute = self::orderCompute($uid, $cartType, $orderInfo['deliveryId'], $orderInfo['paymentTypeId'], $orderInfo['couponCode'], $orderInfo['yohoCoin']);
}
... ... @@ -408,7 +406,7 @@ class CartModel
$oneGoods['name'] = $single['product_name'];
$oneGoods['color'] = $single['color_name'];
$oneGoods['size'] = $single['size_name'];
$oneGoods['price'] = Helpers::transPrice($single['sales_price']);
$oneGoods['price'] = Helpers::transPrice($single['last_price']);
$oneGoods['count'] = $single['buy_number'];
//gift=>是否赠品,advanceBuy=>是否加价购;
... ...
... ... @@ -277,6 +277,12 @@ class IndexController extends AbstractAction
// 购物车商品为空跳转到购物车页面
$cartType = $this->get('cartType', 'ordinary');
$cookieData = $this->getCookie('order-info', null);
$orderInfo = array();
if (!empty($cookieData)) {
$orderInfo = json_decode($cookieData, true);
$cartType = $orderInfo['cartType'];
}
$cartKey = 'commonCart';
if ($cartType === 'advance') {
$cartKey = 'preSellCart';
... ... @@ -289,12 +295,10 @@ class IndexController extends AbstractAction
$this->go(Helpers::url('/cart/index/index'));
}
$cookieData = $this->getCookie('order-info', null);
$uid = $this->getUid(true);
$data = array(
'orderEnsurePage' => true,
'isOrdinaryCart' => ($cartType !== 'advance'),
'orderEnsure' => CartModel::cartPay($uid, $cartType, $cookieData)
'orderEnsure' => CartModel::cartPay($uid, $cartType, $orderInfo)
);
$this->_view->display('order-ensure', $data);
... ...
... ... @@ -124,7 +124,9 @@ class LoginController extends AbstractAction
}
/* 调用登录接口进行登录 */
$data = LoginData::signin($area, $profile, $password);
// 获取未登录时的唯一识别码
$shoppingKey = Helpers::getShoppingKeyByCookie();
$data = LoginData::signin($area, $profile, $password, $shoppingKey);
if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['uid'])) {
break;
}
... ... @@ -191,7 +193,8 @@ class LoginController extends AbstractAction
$result = array();
if (isset($realName, $email, $userId)) {
$result = LoginData::signinByOpenID($realName, $userId, 'alipay');
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($realName, $userId, 'alipay', $shoppingKey);
}
//判定是否需要绑定手机号
... ... @@ -227,7 +230,8 @@ class LoginController extends AbstractAction
$partnerInfo = $qqconnect->getUserInfo($access);
$result = array();
if (!empty($partnerInfo) && isset($partnerInfo['nickname'])) {
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq');
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq', $shoppingKey);
}
//判定是否需要绑定手机号
... ... @@ -264,7 +268,8 @@ class LoginController extends AbstractAction
$result = array();
if ($partnerInfo && is_array($partnerInfo)) {
$result = LoginData::signinByOpenID($partnerInfo['screen_name'], $access['uid'], 'sina');
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($partnerInfo['screen_name'], $access['uid'], 'sina', $shoppingKey);
}
//判定是否需要绑定手机号
if (isset($result['data']['is_bind']) && $result['data']['is_bind'] == 'N') {
... ...