Authored by Rock Zhang

修复未登录选择的商品同步到登陆账户

Code Review By Rock Zhang
@@ -24,15 +24,21 @@ class LoginData @@ -24,15 +24,21 @@ class LoginData
24 * @param string $area 地区编号 24 * @param string $area 地区编号
25 * @param string $profile 邮箱或手机号 25 * @param string $profile 邮箱或手机号
26 * @param string $password 密码 26 * @param string $password 密码
  27 + * @param string $shoppingKey 未登录用户唯一识别码, 默认为空
27 * @return array 28 * @return array
28 */ 29 */
29 - public static function signin($area, $profile, $password) 30 + public static function signin($area, $profile, $password, $shoppingKey = null)
30 { 31 {
31 $param = Yohobuy::param(); 32 $param = Yohobuy::param();
32 $param['method'] = 'app.passport.signin'; 33 $param['method'] = 'app.passport.signin';
33 $param['area'] = $area; 34 $param['area'] = $area;
34 $param['profile'] = $profile; 35 $param['profile'] = $profile;
35 $param['password'] = $password; 36 $param['password'] = $password;
  37 +
  38 + if (!empty($shoppingKey)) {
  39 + $param['shopping_key'] = $shoppingKey;
  40 + }
  41 +
36 $param['client_secret'] = Sign::getSign($param); 42 $param['client_secret'] = Sign::getSign($param);
37 43
38 return Yohobuy::post(Yohobuy::API_URL, $param); 44 return Yohobuy::post(Yohobuy::API_URL, $param);
@@ -124,7 +124,9 @@ class LoginController extends AbstractAction @@ -124,7 +124,9 @@ class LoginController extends AbstractAction
124 } 124 }
125 125
126 /* 调用登录接口进行登录 */ 126 /* 调用登录接口进行登录 */
127 - $data = LoginData::signin($area, $profile, $password); 127 + // 获取未登录时的唯一识别码
  128 + $shoppingKey = Helpers::getShoppingKeyByCookie();
  129 + $data = LoginData::signin($area, $profile, $password, $shoppingKey);
128 if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['uid'])) { 130 if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['uid'])) {
129 break; 131 break;
130 } 132 }