Skip to content

Commit

Permalink
pc端的第三方登录
Browse files Browse the repository at this point in the history
  • Loading branch information
ideal committed Jun 13, 2015
1 parent 33d0cdf commit d0fe210
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 2 deletions.
15 changes: 13 additions & 2 deletions upload/src/applications/u/controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Wind::import('SRV:user.PwUser');
Wind::import('SRV:user.srv.PwLoginService');
Wind::import('APPS:u.service.helper.PwUserHelper');
Wind::import('APPS:u.service.PwThirdLoginService');

/**
* 登录
Expand Down Expand Up @@ -50,15 +51,25 @@ public function run() {
$this->setOutput('用户登录', 'title');
$this->setOutput($this->_filterUrl(false), 'url');
$this->setOutput(PwUserHelper::getLoginMessage(), 'loginWay');
$this->setOutput($this->getInput('invite'), 'invite');
$this->setOutput($this->getInput('invite'), 'invite');
$third = new PwThirdLoginService();
$this->setOutput($third->getPlatforms(), 'thirdlogin');
$this->setTemplate('login');

Wind::import('SRV:seo.bo.PwSeoBo');
$seoBo = PwSeoBo::getInstance();
$lang = Wind::getComponent('i18n');
$seoBo->setCustomSeo($lang->getMessage('SEO:u.login.run.title'), '', '');
Wekit::setV('seo', $seoBo);
}
}

public function thirdLoginAction()
{
$platform = $this->getInput('platform', 'get');
if (!isset(PwThirdLoginService::$supportedPlatforms[$platform])) {
$this->showError('USER:third.platform.error');
}
}

/**
* 快捷登录
Expand Down
39 changes: 39 additions & 0 deletions upload/src/applications/u/service/PwThirdLoginService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/**
* 登录
*
* @author shangyuanchun <[email protected]>
* @copyright ©2003-2015 phpwind.com
* @license http://www.phpwind.com
* @version $Id: PwThirdLoginService.php 24383 2015-06-13 14:10:47Z ideal $
* @package products.u.service
*/
class PwThirdLoginService
{
public static $supportedPlatforms = array(
'qq' => array(
'img' => 'http://qzonestyle.gtimg.cn/qzone/vas/opensns/res/img/bt_blue_76X24.png',
),
'weibo' => array(
'img' => '',
),
);

public function getPlatforms()
{
$platforms = array();

// 网站的第三方appid和移动app的不一样
$thirdPlatforms = Wekit::C('webThirdLogin');
foreach (self::$supportedPlatforms as $p => $c) {
if (!isset($thirdPlatforms[$p.'.status']) || !$thirdPlatforms[$p.'.status']) {
continue;
}
$c['url'] = '/index.php?m=u&c=login&a=thirdLogin&platform='.$p;
$platforms[] = $c;
}

return $platforms;
}
}
2 changes: 2 additions & 0 deletions upload/src/i18n/zh_cn/user/message.lang
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,5 @@ user.forumadmin.add.error = "添加版主操作请到版块管理"
user.syn.error = "用户信息同步错误"
founder.edit = "创始人只能通过后台来修改密码"
empty.error = "带*的不能为空"

third.platform.error = "目前还不支持所您选择的第三方平台登录方式"
7 changes: 7 additions & 0 deletions upload/template/u/login.htm
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ <h2 class="reg_head">{$_errMsg}</h2>
<div class="reg_side_cont">
<p class="mb10">还没有帐号?</p>
<p class="mb20"><a rel="nofollow" href="{@url:u/register/run}<!--#if ($invite) {#-->?invite={$invite}<!--#}#-->" class="btn btn_big">免费注册</a></p>
<!--#
foreach($thirdlogin as $p) {
#-->
<p class="mb20"><a href="{$p['url']}"><img src="{$p['img']}" /></a></p>
<!--#
}
#-->
<hook name="login_sidebar"/>
</div>
</div>
Expand Down

0 comments on commit d0fe210

Please sign in to comment.