Authored by 毕凯

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

<?php
namespace LibModels\Wap\Passport;
use Api\Sign;
use Api\Yohobuy;
/**
* 绑定手机号 数据模型
*
* @name BindData
* @package LibModels/Wap/Passport
* @copyright yoho.inc
* @version 1.0 (2015-12-14 10:00:00)
* @author xiaowei
*/
class BindData
{
/**
* 绑定前检查
* @param string $openId 第三方唯一识别码
* @param string $sourceType 登录方式
* @param string $clientType 所属客户端类型
* @return array 登录返回结果
*/
public static function bindCheck($openId, $sourceType)
{
$param = Yohobuy::param();
$param['v'] = '7';
$param['method'] = 'app.passport.check';
$param['open_id'] = $openId;
$param['source_type'] = $sourceType;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 发送、重发送验证码
* @param string $mobile 手机号
*
*/
public static function sendBindMsg($mobile)
{
$param = Yohobuy::param();
$param['v'] = '7';
$param['method'] = 'app.passport.smsbind';
$param['mobile'] = $mobile;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 验证验证码是否正确
*
*/
public static function checkBindCode($mobile, $code)
{
$param = Yohobuy::param();
$param['v'] = '7';
$param['method'] = 'app.register.validRegCode';
$param['mobile'] = $mobile;
$param['code'] = $code;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 第三方绑定手机号
* @param string $nickname 姓名
* @param string $openId 第三方唯一识别码
* @param string $sourceType 登录方式
* @param string $mobile 手机号
* @param string $password 密码
*/
public static function bindMobile($openId, $nickname, $sourceType, $mobile, $password)
{
$param = Yohobuy::param();
$param['v'] = '7';
$param['method'] = 'app.passport.bind';
$param['mobile'] = $mobile;
$param['passport'] = $password;
$param['open_id'] = $openId;
$param['nickname'] = $nickname;
$param['source_type'] = $sourceType;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
... ... @@ -66,7 +66,7 @@ class LoginData
// 构建必传参数
$param = Yohobuy::param();
$param['v'] = '4'; // 只有早期的V4版本才有直接生成UID
$param['v'] = '7'; // 只有早期的V4版本才有直接生成UID
$param['method'] = 'app.passport.signinByOpenID';
$param['openId'] = $openId;
$param['source_type'] = $sourceType;
... ...
... ... @@ -121,11 +121,11 @@ class DetailModel
$build['answer'] = $value['answer'];
$result['feedbacks']['consults'][] = $build;
}
$result['feedbacks']['link'] = Helpers::url('/product/detail/consults', array('product_id' => $productId, 'total' => $result['feedbacks']['consultsNum']));
$result['feedbacks']['consultsUrl'] = Helpers::url('/product/detail/consults', array('product_id' => $productId, 'total' => $result['feedbacks']['consultsNum']));
}
// 暂无咨询
else {
$result['feedbacks']['link'] = Helpers::url('/product/detail/consultform', array('product_id' => $productId));
$result['feedbacks']['consultsUrl'] = Helpers::url('/product/detail/consultform', array('product_id' => $productId));
}
// 商品评价
... ... @@ -141,8 +141,8 @@ class DetailModel
$build['time'] = $value['createTime'];
$result['feedbacks']['comments'][] = $build;
}
//$result['feedbacks']['link'] = Helpers::url('/product/detail/comments', array('product_id' => $productId, 'total' => $result['feedbacks']['commentsNum']));
}
$result['feedbacks']['commentsUrl'] = Helpers::url('/product/detail/comments', array('product_id' => $productId, 'total' => $result['feedbacks']['commentsNum']));
}
// 品牌信息
if (!empty($baseInfo['brand'])) {
... ...
<?php
use Action\AbstractAction;
use LibModels\Wap\Passport\LoginData;
use LibModels\Wap\Passport\RegData;
use Plugin\Helpers;
use Plugin\Partner\Factory;
/**
* 登录的控制器
*/
class BindController extends AbstractAction
{
/**
* 登录到bind页面
*/
public function indexAction()
{
$this->setTitle('绑定手机号');
$data = array(
'loginIndex' => true, // 模板中使用JS的标识
'backUrl' => '/', // 返回的URL链接
'showHeaderImg' => true, // 控制显示头部图片
'isPassportPage' => true, // 模板中模块标识
'registerUrl' => '/reg.html', // 注册的URL链接
'aliLoginUrl' => '/passport/login/alipay', // 支付宝快捷登录的URL链接
'weiboLoginUrl' => '/passport/login/sina', // 微博登录的URL链接
'qqLoginUrl' => '/passport/login/qq', // 腾讯QQ登录的URL链接
'internationalUrl' => '/login.html', // 国际号登录的URL链接
'phoneRetriveUrl' => '/passport/back/mobile', // 通过手机号找回密码的URL链接
'emailRetriveUrl' => '/passport/back/email', // 通过邮箱找回密码的URL链接
);
// 渲染模板
$this->_view->display('index', $data);
}
// /**
// * 支付宝账号登录:回调方法
// */
// public function alipaycallbackAction()
// {
// $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 {
// $refer = rawurldecode($refer);
// }
//
// if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) {
// $token = Helpers::makeToken($result['data']['uid']);
// $this->setCookie('_TOKEN', $token);
// $this->setSession('_TOKEN', $token);
// $this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
// } else {
// $this->go($refer);
// }
// }
}
... ...
... ... @@ -206,27 +206,41 @@ class LoginController extends AbstractAction
public function qqcallbackAction()
{
$qqconnect = Factory::create('qqconnect');
$access = $qqconnect->getAccessToken();
$access = $qqconnect->getAccessToken();
/* 获取QQ腾讯用户的详细信息 */
$partnerInfo = $qqconnect->getUserInfo($access);
$result = array();
if (!empty($partnerInfo) && isset($partnerInfo['nickname'])) {
if (!empty($partnerInfo) && isset($partnerInfo['nickname']))
{
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq');
}
//判定是否需要绑定手机号
$isBind = $result['data']['is_bind'];
if ($isBind == 'N')
{
$this->go(Helpers::url('/passport/bind/index'));
}
$refer = $this->getCookie('refer');
if (empty($refer)) {
if (empty($refer))
{
$refer = SITE_MAIN . '/?go=1';
} else {
}
else
{
$refer = rawurldecode($refer);
}
if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) {
if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid']))
{
$token = Helpers::makeToken($result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->setSession('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
} else {
}
else
{
$this->go($refer);
}
}
... ... @@ -262,5 +276,5 @@ class LoginController extends AbstractAction
$this->go($refer);
}
}
}
... ...