Authored by biao

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

@@ -212,7 +212,16 @@ class Yohobuy @@ -212,7 +212,16 @@ class Yohobuy
212 unset($data['private_key']); 212 unset($data['private_key']);
213 } 213 }
214 if (!empty($data)) { 214 if (!empty($data)) {
215 - curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 215 + // 新加支持application/x-www-form-urlencoded调用方式
  216 + $str = '';
  217 + foreach ($data as $key => $val) {
  218 + $str .= $key . '=' . $val . '&';
  219 + }
  220 +
  221 + $str = rtrim($str, '&');
  222 +
  223 +// curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  224 + curl_setopt($ch, CURLOPT_POSTFIELDS, $str);
216 } 225 }
217 $result = curl_exec($ch); 226 $result = curl_exec($ch);
218 if (!$returnJson && !empty($result)) { 227 if (!$returnJson && !empty($result)) {
@@ -65,42 +65,28 @@ class LoginData @@ -65,42 +65,28 @@ class LoginData
65 // 构建必传参数 65 // 构建必传参数
66 $param = Yohobuy::param(); 66 $param = Yohobuy::param();
67 67
  68 + $param['v'] = '4'; // 只有早期的V4版本才有直接生成UID
68 $param['method'] = 'app.passport.signinByOpenID'; 69 $param['method'] = 'app.passport.signinByOpenID';
69 $param['openId'] = $openId; 70 $param['openId'] = $openId;
70 $param['source_type'] = $sourceType; 71 $param['source_type'] = $sourceType;
  72 + $param['nickname'] = $nickname;
71 $param['client_secret'] = Sign::getSign($param); 73 $param['client_secret'] = Sign::getSign($param);
72 74
73 return Yohobuy::get(Yohobuy::API_URL, $param); 75 return Yohobuy::get(Yohobuy::API_URL, $param);
74 } 76 }
75 77
76 /** 78 /**
77 - * 写入SESSION会话 79 + * 登出SESSION会话
78 * 80 *
79 * @param int $uid 用户ID 81 * @param int $uid 用户ID
80 * @return array 82 * @return array
81 */ 83 */
82 - public static function signinSession($uid) 84 + public static function signoutSession($token)
83 { 85 {
84 $param = array(); 86 $param = array();
85 - $param['uid'] = $uid;  
86 - $param['token'] = md5($uid . '#@!@#');  
87 -  
88 - return Yohobuy::get(Yohobuy::API_URL_LOGINSESSION . 'Passport/session/index', $param);  
89 - }  
90 -  
91 - /**  
92 - * 写入SESSION会话  
93 - *  
94 - * @param int $uid 用户ID  
95 - * @return array  
96 - */  
97 - public static function checkSession($uid)  
98 - {  
99 - $param = array();  
100 - $param['uid'] = $uid;  
101 - $param['token'] = md5($uid . '#@!@#'); 87 + $param['token'] = $token;
102 88
103 - return Yohobuy::get(Yohobuy::API_URL_LOGINSESSION . 'Passport/session/val', $param); 89 + return Yohobuy::get(Yohobuy::API_URL_LOGINSESSION . 'Passport/session/logout', $param);
104 } 90 }
105 91
106 } 92 }
@@ -165,7 +165,7 @@ class RegData @@ -165,7 +165,7 @@ class RegData
165 $param['password'] = $password; 165 $param['password'] = $password;
166 $param['client_secret'] = Sign::getSign($param); 166 $param['client_secret'] = Sign::getSign($param);
167 167
168 - return Yohobuy::post(Yohobuy::API_URL, $param, true); 168 + return Yohobuy::post(Yohobuy::API_URL, $param);
169 } 169 }
170 170
171 } 171 }
@@ -542,5 +542,21 @@ class Helpers @@ -542,5 +542,21 @@ class Helpers
542 542
543 return $vipLevel; 543 return $vipLevel;
544 } 544 }
  545 +
  546 + /**
  547 + * 同步用户的会话
  548 + *
  549 + * 转向老的PHP服务器上处理, 因购物车相关的操作会依赖SESSION
  550 + *
  551 + * @param int $uid 用户ID
  552 + * @param string $refer 访问来源
  553 + * @param string $callback 回调方法名
  554 + * @return string
  555 + */
  556 + public static function syncUserSession($uid, $refer = '', $callback='call')
  557 + {
  558 + return 'http://m1.yohobuy.com/Passport/session/index?callback=' . $callback
  559 + . '&sign=' . md5($uid . 'Js8Yn0!EwPM45-ws') . '&uid=' . $uid . '&go=' . $refer;
  560 + }
545 561
546 } 562 }
@@ -49,8 +49,8 @@ abstract class Factory @@ -49,8 +49,8 @@ abstract class Factory
49 { 49 {
50 // require dirname(__FILE__) . DS . $apiName . DS . 'Call.class.php'; 50 // require dirname(__FILE__) . DS . $apiName . DS . 'Call.class.php';
51 51
52 - $apiNameCase = ucfirst($apiName);  
53 - $apiClass = "Plugin\Partner\\{$apiNameCase}\\Call"; 52 + //$apiNameCase = ucfirst($apiName);
  53 + $apiClass = "Plugin\Partner\\{$apiName}\Call";
54 54
55 self::$apiObjs[$apiName] = new $apiClass(); 55 self::$apiObjs[$apiName] = new $apiClass();
56 self::$apiObjs[$apiName]->apiName = $apiName; 56 self::$apiObjs[$apiName]->apiName = $apiName;
@@ -77,7 +77,7 @@ class Call extends Factory @@ -77,7 +77,7 @@ class Call extends Factory
77 77
78 if (is_array($token) && isset($token['uid'])) 78 if (is_array($token) && isset($token['uid']))
79 { 79 {
80 - $this->client = new SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']); 80 + $this->client = new \SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']);
81 81
82 $userInfo = $this->client->show_user_by_id($token['uid']); 82 $userInfo = $this->client->show_user_by_id($token['uid']);
83 83
@@ -108,7 +108,7 @@ class Call extends Factory @@ -108,7 +108,7 @@ class Call extends Factory
108 108
109 if (is_array($token) && isset($token['access_token'])) 109 if (is_array($token) && isset($token['access_token']))
110 { 110 {
111 - $this->client = new SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']); 111 + $this->client = new \SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']);
112 112
113 $result = $this->client->friends_by_id($params['uid'], $params['cursor'], $params['count']); 113 $result = $this->client->friends_by_id($params['uid'], $params['cursor'], $params['count']);
114 114
@@ -133,7 +133,7 @@ class Call extends Factory @@ -133,7 +133,7 @@ class Call extends Factory
133 133
134 if (is_array($token) && isset($token['access_token'])) 134 if (is_array($token) && isset($token['access_token']))
135 { 135 {
136 - $this->client = new SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']); 136 + $this->client = new \SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']);
137 137
138 $result = $this->client->bilateral($params['uid'], $params['page'], $params['count']); 138 $result = $this->client->bilateral($params['uid'], $params['page'], $params['count']);
139 139
@@ -163,7 +163,7 @@ class Call extends Factory @@ -163,7 +163,7 @@ class Call extends Factory
163 { 163 {
164 $content .= $link; 164 $content .= $link;
165 165
166 - $this->client = new SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']); 166 + $this->client = new \SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']);
167 167
168 $response = $this->client->upload($content, $image); 168 $response = $this->client->upload($content, $image);
169 169
@@ -190,7 +190,7 @@ class Call extends Factory @@ -190,7 +190,7 @@ class Call extends Factory
190 190
191 if (is_array($token) && isset($token['access_token'])) 191 if (is_array($token) && isset($token['access_token']))
192 { 192 {
193 - $this->client = new SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']); 193 + $this->client = new \SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']);
194 194
195 if ($uid !== null) 195 if ($uid !== null)
196 { 196 {
@@ -218,7 +218,7 @@ class Call extends Factory @@ -218,7 +218,7 @@ class Call extends Factory
218 218
219 if (is_array($token) && isset($token['access_token']) && is_string($content)) 219 if (is_array($token) && isset($token['access_token']) && is_string($content))
220 { 220 {
221 - $this->client = new SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']); 221 + $this->client = new \SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']);
222 222
223 $this->client->update($content); 223 $this->client->update($content);
224 } 224 }
@@ -238,7 +238,7 @@ class Call extends Factory @@ -238,7 +238,7 @@ class Call extends Factory
238 { 238 {
239 if (is_array($token) && isset($token['access_token']) && isset($uid)) 239 if (is_array($token) && isset($token['access_token']) && isset($uid))
240 { 240 {
241 - $this->client = new SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']); 241 + $this->client = new \SaeTClientV2($this->apiConfig['appId'], $this->apiConfig['appKey'], $token['access_token']);
242 $this->client->send_dm_by_id($uid, $content, $id); 242 $this->client->send_dm_by_id($uid, $content, $id);
243 } 243 }
244 } 244 }
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 defined('SITE_MAIN') || define('SITE_MAIN', $_SERVER['HTTP_HOST']); 2 defined('SITE_MAIN') || define('SITE_MAIN', $_SERVER['HTTP_HOST']);
3 3
4 return array( 4 return array(
5 - 'appId' => '2707954749',  
6 - 'appKey' => '431730e25a8a0983964a740731c3cb7d', 5 + 'appId' => '3739328910',
  6 + 'appKey' => '9d44cded26d048e23089e5e975c93df1',
7 'appCallbackUrl' => SITE_MAIN . '/passport/login/sinacallback', 7 'appCallbackUrl' => SITE_MAIN . '/passport/login/sinacallback',
8 ); 8 );
@@ -17,3 +17,4 @@ require('./browse-record'); @@ -17,3 +17,4 @@ require('./browse-record');
17 require('./address-act'); 17 require('./address-act');
18 require('./logistic'); 18 require('./logistic');
19 require('./pay'); 19 require('./pay');
  20 +require('./personal-details');
@@ -43,7 +43,8 @@ goodsSwiper = new Swiper('.banner-swiper', { @@ -43,7 +43,8 @@ goodsSwiper = new Swiper('.banner-swiper', {
43 paginationClickable: true, 43 paginationClickable: true,
44 pagination: '.banner-top .pagination-inner', 44 pagination: '.banner-top .pagination-inner',
45 nextButton: '.my-swiper-button-next', 45 nextButton: '.my-swiper-button-next',
46 - prevButton: '.my-swiper-button-prev' 46 + prevButton: '.my-swiper-button-prev',
  47 + spaceBetween: 3
47 }); 48 });
48 49
49 50
@@ -69,4 +70,3 @@ if (goodsDiscountHammer) { @@ -69,4 +70,3 @@ if (goodsDiscountHammer) {
69 70
70 71
71 require('./like'); 72 require('./like');
72 -  
@@ -9,4 +9,5 @@ require('./newsale/discount'); @@ -9,4 +9,5 @@ require('./newsale/discount');
9 require('./list'); 9 require('./list');
10 require('./detail/detail'); 10 require('./detail/detail');
11 require('./detail/loadmore'); 11 require('./detail/loadmore');
12 -require('./detail/consultform');  
  12 +require('./detail/consultform');
  13 +require('./newsale/hot-rank');
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 width: pxToRem(126px); 24 width: pxToRem(126px);
25 height: pxToRem(126px); 25 height: pxToRem(126px);
26 border-radius: 50%; 26 border-radius: 50%;
27 - border: pxToRem(6px) solid #a7a8a9; 27 + border: pxToRem(6px) solid #a7a8a9;
28 background-image: image-url("me/index/user-avatar.png"); 28 background-image: image-url("me/index/user-avatar.png");
29 background-size: 100%; 29 background-size: 100%;
30 } 30 }
@@ -46,7 +46,7 @@ @@ -46,7 +46,7 @@
46 } 46 }
47 47
48 .vip-3 { 48 .vip-3 {
49 - @include rem-sprite($vip, vip-3); 49 + @include rem-sprite($vip, vip-3);
50 } 50 }
51 51
52 .vip-2 { 52 .vip-2 {
@@ -91,7 +91,7 @@ @@ -91,7 +91,7 @@
91 font-size: pxToRem(22px); 91 font-size: pxToRem(22px);
92 line-height: pxToRem(38px); 92 line-height: pxToRem(38px);
93 width: pxToRem(213px); 93 width: pxToRem(213px);
94 - 94 +
95 &:after { 95 &:after {
96 content: ''; 96 content: '';
97 position: absolute; 97 position: absolute;
@@ -153,16 +153,17 @@ @@ -153,16 +153,17 @@
153 153
154 .num { 154 .num {
155 position: absolute; 155 position: absolute;
156 - padding: 0 pxToRem(8px);  
157 - top: 0;  
158 - right: pxToRem(40px);  
159 - min-width: pxToRem(16px);  
160 - font-size: pxToRem(24px);  
161 - line-height: pxToRem(32px); 156 + top: pxToRem(-24px);
  157 + right: pxToRem(36px);
  158 + width: pxToRem(72px);
  159 + height: pxToRem(72px);
  160 + font-size: pxToRem(40px);
  161 + line-height: pxToRem(72px);
162 color: #fff; 162 color: #fff;
163 - background: #F03D35; 163 + background: #f03d35;
164 text-align: center; 164 text-align: center;
165 - border-radius: pxToRem(20px); 165 + border-radius: 50%;
  166 + @include transform(scale(0.5));
166 } 167 }
167 } 168 }
168 169
@@ -184,7 +185,7 @@ @@ -184,7 +185,7 @@
184 padding: 0 pxToRem(30px); 185 padding: 0 pxToRem(30px);
185 font-size: pxToRem(32px); 186 font-size: pxToRem(32px);
186 line-height: pxToRem(88px); 187 line-height: pxToRem(88px);
187 - 188 +
188 &.highlight { 189 &.highlight {
189 background: #eee; 190 background: #eee;
190 } 191 }
@@ -214,4 +215,4 @@ @@ -214,4 +215,4 @@
214 float: right; 215 float: right;
215 } 216 }
216 } 217 }
217 -}  
  218 +}
@@ -13,10 +13,14 @@ @@ -13,10 +13,14 @@
13 .basic-info { 13 .basic-info {
14 padding-top: 30rem / $pxConvertRem; 14 padding-top: 30rem / $pxConvertRem;
15 padding-bottom: 25rem / $pxConvertRem; 15 padding-bottom: 25rem / $pxConvertRem;
16 -  
17 .user-name { 16 .user-name {
  17 + max-width: 240rem / $pxConvertRem;
  18 + text-overflow:ellipsis;
  19 + white-space:nowrap;
18 font-size: 25rem / $pxConvertRem; 20 font-size: 25rem / $pxConvertRem;
19 margin-right: 0.5rem; 21 margin-right: 0.5rem;
  22 + display: inline-block;
  23 + overflow: hidden;
20 } 24 }
21 25
22 .vip-icon { 26 .vip-icon {
@@ -44,22 +44,22 @@ @@ -44,22 +44,22 @@
44 <a class="type-item" href="/home/order?type=2"> 44 <a class="type-item" href="/home/order?type=2">
45 <span class="iconfont">&#xe634;</span> 45 <span class="iconfont">&#xe634;</span>
46 <br>待付款 46 <br>待付款
47 - {{#if pendingPaymentCount}}  
48 - <span class="num">{{pendingPaymentCount}}</span> 47 + {{#if wait_pay_num}}
  48 + <span class="num">{{wait_pay_num}}</span>
49 {{/if}} 49 {{/if}}
50 </a> 50 </a>
51 <a class="type-item" href="/home/order?type=3"> 51 <a class="type-item" href="/home/order?type=3">
52 <span class="iconfont">&#xe63b;</span> 52 <span class="iconfont">&#xe63b;</span>
53 <br>待发货 53 <br>待发货
54 - {{#if dueOutGoodsCount}}  
55 - <span class="num">{{dueOutGoodsCount}}</span> 54 + {{#if wait_cargo_num}}
  55 + <span class="num">{{wait_cargo_num}}</span>
56 {{/if}} 56 {{/if}}
57 </a> 57 </a>
58 <a class="type-item" href="/home/order?type=4"> 58 <a class="type-item" href="/home/order?type=4">
59 <span class="iconfont">&#xe633;</span> 59 <span class="iconfont">&#xe633;</span>
60 <br>待收货 60 <br>待收货
61 - {{#if dueInGoodsCount}}  
62 - <span class="num">{{dueInGoodsCount}}</span> 61 + {{#if send_cargo_num}}
  62 + <span class="num">{{send_cargo_num}}</span>
63 {{/if}} 63 {{/if}}
64 </a> 64 </a>
65 </div> 65 </div>
@@ -471,6 +471,7 @@ class HomeController extends AbstractAction @@ -471,6 +471,7 @@ class HomeController extends AbstractAction
471 471
472 $service = array( 472 $service = array(
473 'header' => array('title' => '在线客服'), 473 'header' => array('title' => '在线客服'),
  474 + 'pageFooter' => true,
474 'service' => $service 475 'service' => $service
475 ); 476 );
476 477
@@ -23,7 +23,7 @@ class OrderModel @@ -23,7 +23,7 @@ class OrderModel
23 { 23 {
24 $result = array(); 24 $result = array();
25 //调用接口获得数据 25 //调用接口获得数据
26 - $data = OrderData::getOrderData($type, $page, $limit, $gender, $yh_channel, 3444485); 26 + $data = OrderData::getOrderData($type, $page, $limit, $gender, $yh_channel, $uid);
27 // 判断是否还有数据, 没有数据则返回空 27 // 判断是否还有数据, 没有数据则返回空
28 if (isset($data['data']['page_total']) && $page > $data['data']['page_total']) { 28 if (isset($data['data']['page_total']) && $page > $data['data']['page_total']) {
29 return $result; 29 return $result;
@@ -62,10 +62,9 @@ class UserModel @@ -62,10 +62,9 @@ class UserModel
62 'brand_favorite_total', 62 'brand_favorite_total',
63 'product_favorite_total', 63 'product_favorite_total',
64 'product_browse', 64 'product_browse',
65 - 'dueInGoodsCount',  
66 - 'dueOutGoodsCount',  
67 - 'pendingPaymentCount',  
68 - 'refundGoodsCount' 65 + 'send_cargo_num',
  66 + 'wait_cargo_num',
  67 + 'wait_pay_num',
69 ); 68 );
70 foreach ($infoNumData['data'] as $key => &$val) { 69 foreach ($infoNumData['data'] as $key => &$val) {
71 70
@@ -211,9 +211,12 @@ class DetailModel @@ -211,9 +211,12 @@ class DetailModel
211 211
212 // 悬浮的购物车信息 212 // 悬浮的购物车信息
213 $result['cartInfo'] = array( 213 $result['cartInfo'] = array(
214 - 'cartUrl' => Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html'), 214 + 'cartUrl' => Helpers::url('/cart/index/index', null), // 购物车链接
  215 + 'addToCartUrl' => Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html'), // 加入购物车链接
215 'numInCart' => 0, 216 'numInCart' => 0,
216 - 'goodsInstore' => $baseInfo['storage'], 217 + 'goodsInstore' => $baseInfo['storage'], // 库存量
  218 + 'soldOut' => $baseInfo['storage'] == 0, // 已售磬
  219 + 'notForSale' => $baseInfo['attribute'] == 2, // 非卖品
217 ); 220 );
218 221
219 // 是否收藏 222 // 是否收藏
@@ -16,11 +16,13 @@ class LoginController extends AbstractAction @@ -16,11 +16,13 @@ class LoginController extends AbstractAction
16 * 登录页 16 * 登录页
17 */ 17 */
18 public function indexAction() 18 public function indexAction()
19 - { 19 + {
20 $this->setTitle('登录'); 20 $this->setTitle('登录');
21 21
22 - $refer = $this->get('refer', SITE_MAIN . '/?go=1');  
23 - $this->setCookie('refer', $refer); 22 + $refer = $this->get('refer');
  23 + if (!empty($refer)) {
  24 + $this->setCookie('refer', $refer);
  25 + }
24 26
25 $data = array( 27 $data = array(
26 'loginIndex' => true, // 模板中使用JS的标识 28 'loginIndex' => true, // 模板中使用JS的标识
@@ -47,8 +49,10 @@ class LoginController extends AbstractAction @@ -47,8 +49,10 @@ class LoginController extends AbstractAction
47 { 49 {
48 $this->setTitle('国际账号登录'); 50 $this->setTitle('国际账号登录');
49 51
50 - $refer = $this->get('refer', SITE_MAIN . '/?go=1');  
51 - $this->setCookie('refer', $refer); 52 + $refer = $this->get('refer');
  53 + if (!empty($refer)) {
  54 + $this->setCookie('refer', $refer);
  55 + }
52 56
53 $data = array(); 57 $data = array();
54 $data['loginInternational'] = true; // 模板中使用JS的标识 58 $data['loginInternational'] = true; // 模板中使用JS的标识
@@ -63,14 +67,17 @@ class LoginController extends AbstractAction @@ -63,14 +67,17 @@ class LoginController extends AbstractAction
63 67
64 /** 68 /**
65 * 退出 69 * 退出
66 - *  
67 - * @todo  
68 */ 70 */
69 public function outAction() 71 public function outAction()
70 { 72 {
71 $this->setCookie('_UID', ''); 73 $this->setCookie('_UID', '');
72 74
73 - headers_sent() || header('Location: /'); 75 + $refer = $this->server('HTTP_REFERER', SITE_MAIN);
  76 + $token = $this->get('token');
  77 +
  78 + LoginData::signoutSession($token);
  79 +
  80 + $this->go($refer);
74 } 81 }
75 82
76 /** 83 /**
@@ -115,12 +122,12 @@ class LoginController extends AbstractAction @@ -115,12 +122,12 @@ class LoginController extends AbstractAction
115 $refer = $this->getCookie('refer'); 122 $refer = $this->getCookie('refer');
116 if (empty($refer)) { 123 if (empty($refer)) {
117 $refer = SITE_MAIN . '/?go=1'; 124 $refer = SITE_MAIN . '/?go=1';
  125 + } else {
  126 + $refer = rawurldecode($refer);
118 } 127 }
119 - $data['data'] = array(  
120 - // 为了异步调用老系统的SESSION会话  
121 - 'session' => 'http://m1.yohobuy.com/Passport/session/index?callback=call&uid=' . $data['data']['uid'] . '&sign=' . md5($data['data']['uid'] . 'Js8Yn0!EwPM45-ws'),  
122 - 'href' => rawurldecode($refer),  
123 - ); 128 + $data['data']['session'] = Helpers::syncUserSession($data['data']['uid']);
  129 + $data['data']['href'] = $refer;
  130 +
124 } while (false); 131 } while (false);
125 132
126 $this->echoJson($data); 133 $this->echoJson($data);
@@ -131,10 +138,6 @@ class LoginController extends AbstractAction @@ -131,10 +138,6 @@ class LoginController extends AbstractAction
131 */ 138 */
132 public function alipayAction() 139 public function alipayAction()
133 { 140 {
134 - $redirect = $this->_request->getServer('HTTP_REFERER', '');  
135 - if ($redirect != '') {  
136 - $this->setCookie('alipay_redirect', $redirect);  
137 - }  
138 Factory::create('alipay')->getAuthorizeUrl(); 141 Factory::create('alipay')->getAuthorizeUrl();
139 142
140 exit(); 143 exit();
@@ -145,10 +148,6 @@ class LoginController extends AbstractAction @@ -145,10 +148,6 @@ class LoginController extends AbstractAction
145 */ 148 */
146 public function qqAction() 149 public function qqAction()
147 { 150 {
148 - $redirect = $this->_request->getServer('HTTP_REFERER', '');  
149 - if ($redirect != '') {  
150 - $this->setCookie('qq_redirect', $redirect);  
151 - }  
152 Factory::create('qqconnect')->getAuthorizeUrl(); 151 Factory::create('qqconnect')->getAuthorizeUrl();
153 152
154 exit(); 153 exit();
@@ -159,13 +158,7 @@ class LoginController extends AbstractAction @@ -159,13 +158,7 @@ class LoginController extends AbstractAction
159 */ 158 */
160 public function sinaAction() 159 public function sinaAction()
161 { 160 {
162 - $redirect = $this->_request->getServer('HTTP_REFERER', '');  
163 - if ($redirect != '') {  
164 - $this->setCookie('sina_redirect', $redirect);  
165 - }  
166 - header('Location:' . Factory::create('sinaweibo')->getAuthorizeUrl());  
167 -  
168 - exit(); 161 + $this->go(Factory::create('sinaweibo')->getAuthorizeUrl());
169 } 162 }
170 163
171 /** 164 /**
@@ -173,30 +166,27 @@ class LoginController extends AbstractAction @@ -173,30 +166,27 @@ class LoginController extends AbstractAction
173 */ 166 */
174 public function alipaycallbackAction() 167 public function alipaycallbackAction()
175 { 168 {
176 - $nickname = '';  
177 - $alipay = Factory::create('alipay');  
178 - $access = $alipay->getAccessToken();  
179 -  
180 - if (!isset($_GET['real_name'])) {  
181 - /* 获取支付宝用户的详细信息 */  
182 - $userInfo = $alipay->getUserInfo($access);  
183 - if ($userInfo && $userInfo['is_success'] === 'T' && isset($userInfo['response']['user_info']['user_name'])) {  
184 - $nickname = $userInfo['response']['user_info']['user_name'];  
185 - // $alipayEmail = $userInfo['response']['user_info']['email'];  
186 - } 169 + $realName = $this->_request->get('real_name');
  170 + $email = $this->_request->get('email');
  171 + $userId = $this->_request->get('user_id');
  172 +
  173 + $result = array();
  174 + if (isset($realName, $email, $userId)) {
  175 + $result = LoginData::signinByOpenID($realName, $userId, 'alipay');
  176 + }
  177 +
  178 + $refer = $this->getCookie('refer');
  179 + if (empty($refer)) {
  180 + $refer = SITE_MAIN . '/?go=1';
187 } else { 181 } else {
188 - $nickname = $_GET['real_name'];  
189 - // $alipayEmail = isset($_GET['email']) ? $_GET['email'] : ''; 182 + $refer = rawurldecode($refer);
190 } 183 }
191 -  
192 - $result = LoginData::signinByOpenID($nickname, $access['user_id'], 'qq');  
193 -  
194 - if ($result['code'] == 200) {  
195 - $redirect = $this->_request->getCookie('alipay_redirect');  
196 - $redirect && $this->redirect($redirect); 184 +
  185 + if ($result['code'] == 200 && !empty($result['data']['uid'])) {
  186 + $this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
  187 + } else {
  188 + $this->go($refer);
197 } 189 }
198 -  
199 - $this->redirect('/');  
200 } 190 }
201 191
202 /** 192 /**
@@ -209,16 +199,23 @@ class LoginController extends AbstractAction @@ -209,16 +199,23 @@ class LoginController extends AbstractAction
209 /* 获取QQ腾讯用户的详细信息 */ 199 /* 获取QQ腾讯用户的详细信息 */
210 $partnerInfo = $qqconnect->getUserInfo($access); 200 $partnerInfo = $qqconnect->getUserInfo($access);
211 201
  202 + $result = array();
212 if ($partnerInfo && is_array($partnerInfo)) { 203 if ($partnerInfo && is_array($partnerInfo)) {
213 - $result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq');  
214 -  
215 - if ($result['code'] == 200) {  
216 - $redirect = $this->_request->getCookie('qq_redirect');  
217 - $redirect && $this->redirect($redirect);  
218 - } 204 + $result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq');
219 } 205 }
220 206
221 - $this->redirect('/'); 207 + $refer = $this->getCookie('refer');
  208 + if (empty($refer)) {
  209 + $refer = SITE_MAIN . '/?go=1';
  210 + } else {
  211 + $refer = rawurldecode($refer);
  212 + }
  213 +
  214 + if ($result['code'] == 200 && !empty($result['data']['uid'])) {
  215 + $this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
  216 + } else {
  217 + $this->go($refer);
  218 + }
222 } 219 }
223 220
224 /** 221 /**
@@ -226,21 +223,29 @@ class LoginController extends AbstractAction @@ -226,21 +223,29 @@ class LoginController extends AbstractAction
226 */ 223 */
227 public function sinacallbackAction() 224 public function sinacallbackAction()
228 { 225 {
229 - $sina = Factory::create('sina'); 226 + $sina = Factory::create('sinaweibo');
230 $access = $sina->getAccessToken(); 227 $access = $sina->getAccessToken();
231 /* 获取QQ腾讯用户的详细信息 */ 228 /* 获取QQ腾讯用户的详细信息 */
232 $partnerInfo = $sina->getUserInfo($access); 229 $partnerInfo = $sina->getUserInfo($access);
233 230
  231 + $result = array();
  232 +
234 if ($partnerInfo && is_array($partnerInfo)) { 233 if ($partnerInfo && is_array($partnerInfo)) {
235 $result = LoginData::signinByOpenID($partnerInfo['screen_name'], $access['uid'], 'sina'); 234 $result = LoginData::signinByOpenID($partnerInfo['screen_name'], $access['uid'], 'sina');
236 -  
237 - if ($result['code'] == 200) {  
238 - $redirect = $this->_request->getCookie('sina_redirect');  
239 - $redirect && $this->redirect($redirect);  
240 - }  
241 } 235 }
242 236
243 - $this->redirect('/'); 237 + $refer = $this->getCookie('refer');
  238 + if (empty($refer)) {
  239 + $refer = SITE_MAIN . '/?go=1';
  240 + } else {
  241 + $refer = rawurldecode($refer);
  242 + }
  243 +
  244 + if ($result['code'] == 200 && !empty($result['data']['uid'])) {
  245 + $this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
  246 + } else {
  247 + $this->go($refer);
  248 + }
244 } 249 }
245 250
246 } 251 }
@@ -133,7 +133,7 @@ class RegController extends AbstractAction @@ -133,7 +133,7 @@ class RegController extends AbstractAction
133 /* 返回跳转到验证页面的链接 */ 133 /* 返回跳转到验证页面的链接 */
134 if ($data['code'] == 200) { 134 if ($data['code'] == 200) {
135 $token = Helpers::makeToken($mobile); 135 $token = Helpers::makeToken($mobile);
136 - $data['data'] = '/passport/reg/code?token=' . $token . '&phoneNum=' . $mobile . '&areaCode=' . $area; 136 + $data['data'] = Helpers::url('/passport/reg/code', array('token' => $token, 'phoneNum' => $mobile, 'areaCode' => $area));
137 } 137 }
138 } while (false); 138 } while (false);
139 139
@@ -176,7 +176,7 @@ class RegController extends AbstractAction @@ -176,7 +176,7 @@ class RegController extends AbstractAction
176 /* 返回跳转到设置密码的链接 */ 176 /* 返回跳转到设置密码的链接 */
177 if ($data['code'] == 200) { 177 if ($data['code'] == 200) {
178 $token = Helpers::makeToken($mobile); 178 $token = Helpers::makeToken($mobile);
179 - $data['data'] = '/passport/reg/password?token=' . $token . '&phoneNum=' . $mobile . '&areaCode=' . $area; 179 + $data['data'] = Helpers::url('/passport/reg/password', array('token' => $token, 'phoneNum' => $mobile, 'areaCode' => $area));
180 } else if ($data['code'] == 404) { 180 } else if ($data['code'] == 404) {
181 $data['message'] = '验证码错误'; //统一验证提示 181 $data['message'] = '验证码错误'; //统一验证提示
182 } 182 }
@@ -259,22 +259,20 @@ class RegController extends AbstractAction @@ -259,22 +259,20 @@ class RegController extends AbstractAction
259 259
260 /* 验证注册的标识码是否有效 */ 260 /* 验证注册的标识码是否有效 */
261 $data = RegData::regMobile($area, $mobile, $password); 261 $data = RegData::regMobile($area, $mobile, $password);
262 - if (!isset($data['code'])) { 262 + if (!isset($data['code']) || $data['code'] != 200) {
263 break; 263 break;
264 } 264 }
265 265
266 /* 返回跳转到来源页面 */ 266 /* 返回跳转到来源页面 */
267 - if ($data['code'] == 200) {  
268 - $refer = $this->getCookie('refer');  
269 - if (empty($refer)) {  
270 - $refer = SITE_MAIN . '/?go=1';  
271 - }  
272 - $data['data'] = array(  
273 - // 为了异步调用老系统的SESSION会话  
274 - 'session' => 'http://m1.yohobuy.com/Passport/session/index?uid=' . $data['data']['uid'] . '&sign=' . md5($data['data']['uid'] . 'Js8Yn0!EwPM45-ws'),  
275 - 'href' => rawurldecode($refer),  
276 - ); 267 + $refer = $this->getCookie('refer');
  268 + if (empty($refer)) {
  269 + $refer = SITE_MAIN . '/?go=1';
  270 + } else {
  271 + $refer = rawurldecode($refer);
277 } 272 }
  273 + $data['data']['session'] = Helpers::syncUserSession($data['data']['uid']);
  274 + $data['data']['href'] = $refer;
  275 +
278 } while (false); 276 } while (false);
279 277
280 $this->echoJson($data); 278 $this->echoJson($data);
@@ -40,6 +40,13 @@ routes.interational.route.module = Passport @@ -40,6 +40,13 @@ routes.interational.route.module = Passport
40 routes.interational.route.controller = Login 40 routes.interational.route.controller = Login
41 routes.interational.route.action = International 41 routes.interational.route.action = International
42 42
  43 +; 登录页
  44 +routes.logout.type = "rewrite"
  45 +routes.logout.match = "/passport/signout/index"
  46 +routes.logout.route.module = Passport
  47 +routes.logout.route.controller = Login
  48 +routes.logout.route.action = out
  49 +
43 ; 找回密码(手机号) 50 ; 找回密码(手机号)
44 routes.phoneback.type = "rewrite" 51 routes.phoneback.type = "rewrite"
45 routes.phoneback.match = "/phoneback.html" 52 routes.phoneback.match = "/phoneback.html"