Authored by Rock Zhang

Merge branch 'develop' of git.dev.yoho.cn:web/yohobuy into hotfix/apichange-bug

... ... @@ -139,7 +139,7 @@ class Yohobuy
if (!empty($data)) {
$url = self::httpBuildQuery($url, $data);
}
var_dump($url);
/* 开启缓存的情况 */
if ($cache && USE_CACHE) {
// 先尝试获取一级缓存(master), 有数据则直接返回.
... ...
... ... @@ -65,9 +65,11 @@ class LoginData
// 构建必传参数
$param = Yohobuy::param();
$param['v'] = '4'; // 只有早期的V4版本才有直接生成UID
$param['method'] = 'app.passport.signinByOpenID';
$param['openId'] = $openId;
$param['source_type'] = $sourceType;
$param['nickname'] = $nickname;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
... ...
... ... @@ -165,7 +165,7 @@ class RegData
$param['password'] = $password;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(Yohobuy::API_URL, $param, true);
return Yohobuy::post(Yohobuy::API_URL, $param);
}
}
... ...
... ... @@ -542,5 +542,21 @@ class Helpers
return $vipLevel;
}
/**
* 同步用户的会话
*
* 转向老的PHP服务器上处理, 因购物车相关的操作会依赖SESSION
*
* @param int $uid 用户ID
* @param string $refer 访问来源
* @param string $callback 回调方法名
* @return string
*/
public static function syncUserSession($uid, $refer = '', $callback='call')
{
return 'http://m1.yohobuy.com/Passport/session/index?callback=' . $callback
. '&sign=' . md5($uid . 'Js8Yn0!EwPM45-ws') . '&uid=' . $uid . '&go=' . $refer;
}
}
... ...
... ... @@ -49,8 +49,8 @@ abstract class Factory
{
// require dirname(__FILE__) . DS . $apiName . DS . 'Call.class.php';
$apiNameCase = ucfirst($apiName);
$apiClass = "Plugin\Partner\\{$apiNameCase}\\Call";
//$apiNameCase = ucfirst($apiName);
$apiClass = "Plugin\Partner\\{$apiName}\Call";
self::$apiObjs[$apiName] = new $apiClass();
self::$apiObjs[$apiName]->apiName = $apiName;
... ...
... ... @@ -2,7 +2,7 @@
defined('SITE_MAIN') || define('SITE_MAIN', $_SERVER['HTTP_HOST']);
return array(
'appId' => '2707954749',
'appKey' => '431730e25a8a0983964a740731c3cb7d',
'appId' => '3739328910',
'appKey' => '9d44cded26d048e23089e5e975c93df1',
'appCallbackUrl' => SITE_MAIN . '/passport/login/sinacallback',
);
\ No newline at end of file
... ...
... ... @@ -17,3 +17,4 @@ require('./browse-record');
require('./address-act');
require('./logistic');
require('./pay');
require('./personal-details');
... ...
... ... @@ -43,7 +43,8 @@ goodsSwiper = new Swiper('.banner-swiper', {
paginationClickable: true,
pagination: '.banner-top .pagination-inner',
nextButton: '.my-swiper-button-next',
prevButton: '.my-swiper-button-prev'
prevButton: '.my-swiper-button-prev',
spaceBetween: 3
});
... ... @@ -69,4 +70,3 @@ if (goodsDiscountHammer) {
require('./like');
... ...
... ... @@ -9,4 +9,5 @@ require('./newsale/discount');
require('./list');
require('./detail/detail');
require('./detail/loadmore');
require('./detail/consultform');
\ No newline at end of file
require('./detail/consultform');
require('./detail/hot-rank');
\ No newline at end of file
... ...
... ... @@ -13,10 +13,14 @@
.basic-info {
padding-top: 30rem / $pxConvertRem;
padding-bottom: 25rem / $pxConvertRem;
.user-name {
max-width: 240rem / $pxConvertRem;
text-overflow:ellipsis;
white-space:nowrap;
font-size: 25rem / $pxConvertRem;
margin-right: 0.5rem;
display: inline-block;
overflow: hidden;
}
.vip-icon {
... ...
... ... @@ -23,7 +23,7 @@ class OrderModel
{
$result = array();
//调用接口获得数据
$data = OrderData::getOrderData($type, $page, $limit, $gender, $yh_channel, 3444485);
$data = OrderData::getOrderData($type, $page, $limit, $gender, $yh_channel, $uid);
// 判断是否还有数据, 没有数据则返回空
if (isset($data['data']['page_total']) && $page > $data['data']['page_total']) {
return $result;
... ...
... ... @@ -211,9 +211,12 @@ class DetailModel
// 悬浮的购物车信息
$result['cartInfo'] = array(
'cartUrl' => Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html'),
'cartUrl' => Helpers::url('/cart/index/index', null), // 购物车链接
'addToCartUrl' => Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html'), // 加入购物车链接
'numInCart' => 0,
'goodsInstore' => $baseInfo['storage'],
'goodsInstore' => $baseInfo['storage'], // 库存量
'soldOut' => $baseInfo['storage'] == 0, // 已售磬
'notForSale' => $baseInfo['attribute'] == 2, // 非卖品
);
// 是否收藏
... ...
... ... @@ -19,8 +19,10 @@ class LoginController extends AbstractAction
{
$this->setTitle('登录');
$refer = $this->get('refer', SITE_MAIN . '/?go=1');
$this->setCookie('refer', $refer);
$refer = $this->get('refer');
if (!empty($refer)) {
$this->setCookie('refer', $refer);
}
$data = array(
'loginIndex' => true, // 模板中使用JS的标识
... ... @@ -47,8 +49,10 @@ class LoginController extends AbstractAction
{
$this->setTitle('国际账号登录');
$refer = $this->get('refer', SITE_MAIN . '/?go=1');
$this->setCookie('refer', $refer);
$refer = $this->get('refer');
if (!empty($refer)) {
$this->setCookie('refer', $refer);
}
$data = array();
$data['loginInternational'] = true; // 模板中使用JS的标识
... ... @@ -70,7 +74,9 @@ class LoginController extends AbstractAction
{
$this->setCookie('_UID', '');
headers_sent() || header('Location: /');
$refer = $this->server('HTTP_REFERER', SITE_MAIN);
$this->go($refer);
}
/**
... ... @@ -115,12 +121,11 @@ class LoginController extends AbstractAction
$refer = $this->getCookie('refer');
if (empty($refer)) {
$refer = SITE_MAIN . '/?go=1';
} else {
$refer = rawurldecode($refer);
}
$data['data'] = array(
// 为了异步调用老系统的SESSION会话
'session' => 'http://m1.yohobuy.com/Passport/session/index?callback=call&uid=' . $data['data']['uid'] . '&sign=' . md5($data['data']['uid'] . 'Js8Yn0!EwPM45-ws'),
'href' => rawurldecode($refer),
);
$data['data']['session'] = Helpers::syncUserSession($data['data']['uid']);
$data['data']['href'] = $refer;
} while (false);
$this->echoJson($data);
... ... @@ -131,10 +136,6 @@ class LoginController extends AbstractAction
*/
public function alipayAction()
{
$redirect = $this->_request->getServer('HTTP_REFERER', '');
if ($redirect != '') {
$this->setCookie('alipay_redirect', $redirect);
}
Factory::create('alipay')->getAuthorizeUrl();
exit();
... ... @@ -145,10 +146,6 @@ class LoginController extends AbstractAction
*/
public function qqAction()
{
$redirect = $this->_request->getServer('HTTP_REFERER', '');
if ($redirect != '') {
$this->setCookie('qq_redirect', $redirect);
}
Factory::create('qqconnect')->getAuthorizeUrl();
exit();
... ... @@ -159,13 +156,7 @@ class LoginController extends AbstractAction
*/
public function sinaAction()
{
$redirect = $this->_request->getServer('HTTP_REFERER', '');
if ($redirect != '') {
$this->setCookie('sina_redirect', $redirect);
}
header('Location:' . Factory::create('sinaweibo')->getAuthorizeUrl());
exit();
$this->go(Factory::create('sinaweibo')->getAuthorizeUrl());
}
/**
... ... @@ -173,30 +164,27 @@ class LoginController extends AbstractAction
*/
public function alipaycallbackAction()
{
$nickname = '';
$alipay = Factory::create('alipay');
$access = $alipay->getAccessToken();
if (!isset($_GET['real_name'])) {
/* 获取支付宝用户的详细信息 */
$userInfo = $alipay->getUserInfo($access);
if ($userInfo && $userInfo['is_success'] === 'T' && isset($userInfo['response']['user_info']['user_name'])) {
$nickname = $userInfo['response']['user_info']['user_name'];
// $alipayEmail = $userInfo['response']['user_info']['email'];
}
$realName = $this->_request->get('real_name');
$email = $this->_request->get('email');
$userId = $this->_request->get('user_id');
$result = array();
if (isset($realName, $email, $userId)) {
$result = LoginData::signinByOpenID($realName, $userId, 'alipay');
}
$refer = $this->getCookie('refer');
if (empty($refer)) {
$refer = SITE_MAIN . '/?go=1';
} else {
$nickname = $_GET['real_name'];
// $alipayEmail = isset($_GET['email']) ? $_GET['email'] : '';
$refer = rawurldecode($refer);
}
$result = LoginData::signinByOpenID($nickname, $access['user_id'], 'qq');
if ($result['code'] == 200) {
$redirect = $this->_request->getCookie('alipay_redirect');
$redirect && $this->redirect($redirect);
if ($result['code'] == 200 && !empty($result['data']['uid'])) {
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
} else {
$this->go($refer);
}
$this->redirect('/');
}
/**
... ... @@ -209,16 +197,23 @@ class LoginController extends AbstractAction
/* 获取QQ腾讯用户的详细信息 */
$partnerInfo = $qqconnect->getUserInfo($access);
$result = array();
if ($partnerInfo && is_array($partnerInfo)) {
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq');
if ($result['code'] == 200) {
$redirect = $this->_request->getCookie('qq_redirect');
$redirect && $this->redirect($redirect);
}
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq');
}
$this->redirect('/');
$refer = $this->getCookie('refer');
if (empty($refer)) {
$refer = SITE_MAIN . '/?go=1';
} else {
$refer = rawurldecode($refer);
}
if ($result['code'] == 200 && !empty($result['data']['uid'])) {
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
} else {
$this->go($refer);
}
}
/**
... ... @@ -226,21 +221,29 @@ class LoginController extends AbstractAction
*/
public function sinacallbackAction()
{
$sina = Factory::create('sina');
$sina = Factory::create('sinaweibo');
$access = $sina->getAccessToken();
/* 获取QQ腾讯用户的详细信息 */
$partnerInfo = $sina->getUserInfo($access);
$result = array();
if ($partnerInfo && is_array($partnerInfo)) {
$result = LoginData::signinByOpenID($partnerInfo['screen_name'], $access['uid'], 'sina');
if ($result['code'] == 200) {
$redirect = $this->_request->getCookie('sina_redirect');
$redirect && $this->redirect($redirect);
}
}
$this->redirect('/');
$refer = $this->getCookie('refer');
if (empty($refer)) {
$refer = SITE_MAIN . '/?go=1';
} else {
$refer = rawurldecode($refer);
}
if ($result['code'] == 200 && !empty($result['data']['uid'])) {
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
} else {
$this->go($refer);
}
}
}
... ...
... ... @@ -133,7 +133,7 @@ class RegController extends AbstractAction
/* 返回跳转到验证页面的链接 */
if ($data['code'] == 200) {
$token = Helpers::makeToken($mobile);
$data['data'] = '/passport/reg/code?token=' . $token . '&phoneNum=' . $mobile . '&areaCode=' . $area;
$data['data'] = Helpers::url('/passport/reg/code', array('token' => $token, 'phoneNum' => $mobile, 'areaCode' => $area));
}
} while (false);
... ... @@ -176,7 +176,7 @@ class RegController extends AbstractAction
/* 返回跳转到设置密码的链接 */
if ($data['code'] == 200) {
$token = Helpers::makeToken($mobile);
$data['data'] = '/passport/reg/password?token=' . $token . '&phoneNum=' . $mobile . '&areaCode=' . $area;
$data['data'] = Helpers::url('/passport/reg/password', array('token' => $token, 'phoneNum' => $mobile, 'areaCode' => $area));
} else if ($data['code'] == 404) {
$data['message'] = '验证码错误'; //统一验证提示
}
... ... @@ -259,22 +259,20 @@ class RegController extends AbstractAction
/* 验证注册的标识码是否有效 */
$data = RegData::regMobile($area, $mobile, $password);
if (!isset($data['code'])) {
if (!isset($data['code']) || $data['code'] != 200) {
break;
}
/* 返回跳转到来源页面 */
if ($data['code'] == 200) {
$refer = $this->getCookie('refer');
if (empty($refer)) {
$refer = SITE_MAIN . '/?go=1';
}
$data['data'] = array(
// 为了异步调用老系统的SESSION会话
'session' => 'http://m1.yohobuy.com/Passport/session/index?uid=' . $data['data']['uid'] . '&sign=' . md5($data['data']['uid'] . 'Js8Yn0!EwPM45-ws'),
'href' => rawurldecode($refer),
);
$refer = $this->getCookie('refer');
if (empty($refer)) {
$refer = SITE_MAIN . '/?go=1';
} else {
$refer = rawurldecode($refer);
}
$data['data']['session'] = Helpers::syncUserSession($data['data']['uid']);
$data['data']['href'] = $refer;
} while (false);
$this->echoJson($data);
... ...