Authored by Rock Zhang

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

Code Review By Rock Zhang
... ... @@ -24,15 +24,21 @@ 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);
... ...
... ... @@ -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;
}
... ...