Authored by 周少峰

Merge branch 'develop' of git.dev.yoho.cn:web/yohobuy into feature/web-list

... ... @@ -43,7 +43,7 @@ class Yohobuy
// const API_OLD = 'http://api2.open.yohobuy.com/';
/* PC重构地址 */
const API_URL = 'http://test2.open.yohobuy.com/';
const API_URL = 'http://test.open.yohobuy.com/';
const SERVICE_URL = 'http://test.service.api.yohobuy.com/';
const YOHOBUY_URL = 'http://www.yohobuy.com/';
const API_OLD = 'http://api2.open.yohobuy.com/';
... ...
... ... @@ -77,7 +77,7 @@ class Process
$val['url'] = Helpers::transUrl($val['url'], $type);
$temp['tplrecommend']['category'][] = array(
'name' => $val['name'],
'url' => $val['url']
'href' => $val['url']
);
}
... ... @@ -149,7 +149,8 @@ class Process
$val['url'] = Helpers::transUrl($val['url'], $type);
$temp['list'][] = array(
'href' => $val['url'],
'img' => $val['src']
'img' => $val['src'],
// 'bgColor'=> $val[]
);
}
... ...
... ... @@ -15,5 +15,5 @@ return array(
// 访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http
'transport' => 'http',
// 页面跳转同步通知页面路径 (需http://格式的完整路径,不允许加?id=123这类自定义参数)
'return_url' => SITE_MAIN . '/passport/login/alipaycallback',
'return_url' => SITE_MAIN . '/passport/autosign/alipaycallback',
);
... ...
<?php
defined('DOMAIN') || define('DOMAIN', $_SERVER['HTTP_HOST']);
defined('SITE_MAIN') || define('SITE_MAIN', $_SERVER['HTTP_HOST']);
return array(
'appId' => '09f4fa0661be14ec1ddeee13253a3ec4',
'appKey' => 'b4204e2055d63102',
'callback' => DOMAIN . '/passport/login/doubanback',
'appId' => '03b4e36bf13dc75a0b1eaa43d3b9560e',
'appKey' => 'f16d5913e8610672',
'callback' => SITE_MAIN . '/passport/autosign/doubanback',
'scope' => 'douban_basic_common',
);
\ No newline at end of file
... ...
... ... @@ -4,7 +4,7 @@ defined('SITE_MAIN') || define('SITE_MAIN', $_SERVER['HTTP_HOST']);
return array(
'appid' => '100229394',
'appkey' => 'c0af9c29e0900813028c2ccb42021792',
'callback' => SITE_MAIN . '/passport/login/qqcallback',
'callback' => SITE_MAIN . '/passport/autosign/qqcallback',
'scope' => 'get_user_info,add_share,upload_pic,get_idollist,get_fanslist',
'errorReport' => true,
);
\ No newline at end of file
... ...
<?php
defined('DOMAIN') || define('DOMAIN', $_SERVER['HTTP_HOST']);
defined('SITE_MAIN') || define('SITE_MAIN', $_SERVER['HTTP_HOST']);
return array(
'appId' => '783130c654c94a77ace97054ae266019',
'appKey' => '05e430de8c1e40d3a1f39ca8d3f8252c',
'callback' => DOMAIN . '/passport/login/renrenback',
'callback' => SITE_MAIN . '/passport/autosign/renrenback',
'scope' => 'publish_feed,photo_upload',
);
\ No newline at end of file
... ...
... ... @@ -4,5 +4,5 @@ defined('SITE_MAIN') || define('SITE_MAIN', $_SERVER['HTTP_HOST']);
return array(
'appId' => '3739328910',
'appKey' => '9d44cded26d048e23089e5e975c93df1',
'appCallbackUrl' => SITE_MAIN . '/passport/login/sinacallback',
'appCallbackUrl' => SITE_MAIN . '/passport/autosign/sinacallback',
);
\ No newline at end of file
... ...
... ... @@ -70,7 +70,7 @@
{{! 广告}}
{{# adbanner}}
<div class="floor-ad">
<a href="{{url}}" target= "_blank"><img class="lazy" data-original="{{img}}"/></a>
<a href="{{href}}" target= "_blank"><img class="lazy" data-original="{{img}}"/></a>
</div>
{{/ adbanner}}
... ...
... ... @@ -8,7 +8,7 @@
<div class="debris-slider clearfix">
<div class="left-col col">
{{# left}}
<a href="{{href}}" target= "_blank">
<a href="{{href}}" target="_blank">
<img class="lazy" data-original="{{img}}">
</a>
{{/ left}}
... ... @@ -17,7 +17,7 @@
<ul class="slide-wrapper">
{{# center}}
<li>
<a href="{{href}}" target= "_blank">
<a href="{{href}}" target="_blank">
<img class="lazy" data-original="{{img}}">
</a>
</li>
... ... @@ -34,7 +34,7 @@
</div>
<div class="right-col col">
{{# right}}
<a href="{{href}}" target= "_blank">
<a href="{{href}}" target="_blank">
<img class="lazy" data-original="{{img}}">
</a>
{{/ right}}
... ...
... ... @@ -70,7 +70,7 @@
{{! 广告}}
{{# adbanner}}
<div class="floor-ad">
<a href="{{url}}" target= "_blank"><img class="lazy" data-original="{{img}}"/></a>
<a href="{{href}}" target= "_blank"><img class="lazy" data-original="{{img}}"/></a>
</div>
{{/ adbanner}}
... ...
... ... @@ -30,7 +30,7 @@
<ul class="clearfix">
{{# pagination}}
<li>
<a href="{{href}}"></a>
<a href="{{href}}" target="_blank"></a>
<img src="{{img}}" alt="">
</li>
{{/ pagination}}
... ...
<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-W958MG" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>
var _hmt = _hmt || [];
(function() {
function async_load(){
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-W958MG');
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?c6ee7218b8321cb65fb2e98f284d8311";
hm.async = 1;
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?65dd99e0435a55177ffda862198ce841";
hm.async = 1;
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
(function() {
var hm = document.createElement("script");
hm.src = "http://static.yohobuy.com/js/analytics/analysis.js";
hm.async = 1;
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
}
window.addEventListener('load', async_load, false);
})();
</script>
<script>
window._py = window._py||[];
window._py.push(['a', 'MC..o8vMMWxEXDCiqYckD81lUX']);
window._py.push(['domain','stats.ipinyou.com']);
window._py.push(['e','']);
if(typeof _goodsData!='undefined'){
window._py.push(['pi',_goodsData]);
}
-function(d){
var f = 'https:' == d.location.protocol;var c = d.createElement('script');c.type='text/javascript';c.async=1;
c.src=(f ? 'https' : 'http') + '://'+(f?'fm.ipinyou.com':'fm.p0y.cn')+'/j/t/adv.js';
var h = d.getElementsByTagName("script")[0];h.parentNode.insertBefore(c, h);
}(document);
</script>
<script src="http://static.yohobuy.com/js/v3/o_code.js?v=20150420" async="async"></script>
\ No newline at end of file
... ...
... ... @@ -20,5 +20,6 @@
</script>
{{/if}}
{{> layout/use}}
{{> layout/analysis}}
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -106,6 +106,34 @@ function getShoppingKey() {
return JSON.parse(c).k;
}
//YAS统计代码
(function(w, d, s, j, f) {
var a = d.createElement(s);
var m = d.getElementsByTagName(s)[0];
w.YohoAcquisitionObject = f;
w[f] = function() {
w[f].p = arguments;
};
a.async = 1;
a.src = j;
m.parentNode.insertBefore(a, m);
})(window, document, 'script', 'http://cdn.yoho.cn/yas-jssdk/1.0.13.6.3/yas.js', '_yas');
(function() {
var uid = getUid();
uid = uid === 0 ? '' : uid;
window._ozuid = uid;//暴露ozuid
if (window._yas) {
window._yas(1 * new Date(), '1.0.13.6.3', 'yohobuy_web', uid, '', '');
}
}());
window.cookie = cookie;
window.setCookie = setCookie;
... ... @@ -2572,7 +2600,7 @@ var $ = require("jquery"),
//插入more的位置,more占的是下一页第一个brand的位置,所以page是i/17
out = out + '<li class="brand-more" data-page="' + Math.floor(i / (showNum + 1)) + '">' +
'<a href="javascript:;">MORE ></a></li>' +
'<a href="javascript:;" target="_blank">MORE ></a></li>' +
'<li data-page="' + Math.floor(i / showNum) + '">' + item + '</li>';
} else {
out = out + '<li data-page="' + Math.floor(i / showNum) + '">' + item + '</li>';
... ... @@ -2581,7 +2609,7 @@ var $ = require("jquery"),
//加上最后一个more, more占的是下一页第一个brand的位置,这里已经循环不到brand,所以加在末尾
return out + '<li class="brand-more" data-page="' + Math.floor(i / (showNum + 1)) + '">' +
'<a href="javascript:;">MORE ></a></li></ul>';
'<a href="javascript:;" target="_blank">MORE ></a></li></ul>';
});
},
... ... @@ -2598,7 +2626,7 @@ var $ = require("jquery"),
that._createHelper();
brandHtml = '\{{#brandList logoBrand}}' +
'<a href="\{{href}}"><img class="lazy" data-original="\{{img}}" alt=""></a>' +
'<a href="\{{href}}" target="_blank"><img class="lazy" data-original="\{{img}}" alt=""></a>' +
'\{{/brandList}}';
brandTpl = Handlebars.compile(brandHtml);
that.$element.html(brandTpl(data));
... ... @@ -3721,6 +3749,7 @@ module.exports = function(data) {
var $load = $('.loading a');
var load = new InfiniteLoad({
index: 1,
isload: false,
offset: {
height: function() {
return parseFloat($container.offset().top) + parseFloat($container.height()) - 200;
... ... @@ -3728,28 +3757,35 @@ module.exports = function(data) {
}
});
var loadAjax;
var url = data.url;
var url = data.url,
count = data.count,
rows = data.rows;
data.pageIndex = 0;
delete data.url;
delete data.count;
delete data.rows;
loadAjax = function(url, data, count) {
var options = {
type: 'POST',
url: url,
data: data,
success: function(data) {
var code = data.code;
success: function(result) {
var code = result.code;
var myTemplate,len,pos;
if (code === 200) {
len = data.goods.length % count;
pos = data.goods.length - len - 1;
len = result.goods.length % count;
pos = result.goods.length - len - 1;
data.goods.splice(pos, len);
result.goods.splice(pos, len);
myTemplate = Handlebars.compile(load.tpl);
$container.append(myTemplate(data.goods));
$container.append(myTemplate(result.goods));
data.pageIndex = data.pageIndex + result.goods.length;
//懒加载插件貌似有点问题,图片先直接展示
lazyload($container.find('img.lazy'));
... ... @@ -3768,17 +3804,14 @@ module.exports = function(data) {
}
};
options.data = data;
$.ajax(options);
};
load.on('after', function(p) {
data = $.extend({}, data, {
pageIndex: p.index
});
data.pageCount = data.count * data.rows[1];
data.pageCount = count * rows[1];
loadAjax(url, data);
});
... ... @@ -3814,7 +3847,7 @@ module.exports = function(data) {
load.tpl += ' {{/ tags}}';
load.tpl += ' </div>';
load.tpl += ' <div class="good-detail-img">';
load.tpl += ' <a class="good-thumb" href="{{url}}">';
load.tpl += ' <a class="good-thumb" href="{{url}}" target= "_blank">';
load.tpl += ' <img class="lazy" data-original="{{thumb}}">';
load.tpl += ' </a>';
load.tpl += ' {{# isFew}}';
... ... @@ -3826,7 +3859,7 @@ module.exports = function(data) {
load.tpl += ' {{/if}}';
load.tpl += ' </div>';
load.tpl += ' <div class="good-detail-text">';
load.tpl += ' <a href="{{url}}">{{name}}</a>';
load.tpl += ' <a href="{{url}}" target= "_blank">{{name}}</a>';
load.tpl += ' <p class="price">';
load.tpl += ' <span class="sale-price{{#unless marketPrice}}prime-cost{{/unless}}">';
load.tpl += ' ¥{{salePrice}}';
... ... @@ -3839,16 +3872,12 @@ module.exports = function(data) {
load.tpl += '</div>';
load.tpl += '{{/each}}';
data = $.extend({}, data, {
pageIndex: p.index
});
data.pageCount = data.count * data.rows[0];
data.pageCount = count * rows[0];
loadAjax(url, data, data.count);
load.emit();
//load.emit();
});
load.init();
... ...
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
... ... @@ -94,6 +94,34 @@ function getShoppingKey() {
return JSON.parse(c).k;
}
//YAS统计代码
(function(w, d, s, j, f) {
var a = d.createElement(s);
var m = d.getElementsByTagName(s)[0];
w.YohoAcquisitionObject = f;
w[f] = function() {
w[f].p = arguments;
};
a.async = 1;
a.src = j;
m.parentNode.insertBefore(a, m);
})(window, document, 'script', 'http://cdn.yoho.cn/yas-jssdk/1.0.13.6.3/yas.js', '_yas');
(function() {
var uid = getUid();
uid = uid === 0 ? '' : uid;
window._ozuid = uid;//暴露ozuid
if (window._yas) {
window._yas(1 * new Date(), '1.0.13.6.3', 'yohobuy_web', uid, '', '');
}
}());
window.cookie = cookie;
window.setCookie = setCookie;
... ...
... ... @@ -55,7 +55,7 @@ var $ = require('yoho.jquery'),
//插入more的位置,more占的是下一页第一个brand的位置,所以page是i/17
out = out + '<li class="brand-more" data-page="' + Math.floor(i / (showNum + 1)) + '">' +
'<a href="javascript:;">MORE ></a></li>' +
'<a href="javascript:;" target="_blank">MORE ></a></li>' +
'<li data-page="' + Math.floor(i / showNum) + '">' + item + '</li>';
} else {
out = out + '<li data-page="' + Math.floor(i / showNum) + '">' + item + '</li>';
... ... @@ -64,7 +64,7 @@ var $ = require('yoho.jquery'),
//加上最后一个more, more占的是下一页第一个brand的位置,这里已经循环不到brand,所以加在末尾
return out + '<li class="brand-more" data-page="' + Math.floor(i / (showNum + 1)) + '">' +
'<a href="javascript:;">MORE ></a></li></ul>';
'<a href="javascript:;" target="_blank">MORE ></a></li></ul>';
});
},
... ... @@ -81,7 +81,7 @@ var $ = require('yoho.jquery'),
that._createHelper();
brandHtml = '\{{#brandList logoBrand}}' +
'<a href="\{{href}}" target= "_blank"><img class="lazy" data-original="\{{img}}" alt=""></a>' +
'<a href="\{{href}}" target="_blank"><img class="lazy" data-original="\{{img}}" alt=""></a>' +
'\{{/brandList}}';
brandTpl = Handlebars.compile(brandHtml);
that.$element.html(brandTpl(data));
... ...
<?php
use Action\AbstractAction;
use LibModels\Web\Passport\RegData;
use LibModels\Web\Passport\LoginData;
use LibModels\Web\Home\IndexData;
use Passport\PassportModel as PassportModel;
use Plugin\Helpers;
use Plugin\Images;
use Plugin\Partner\Factory;
class AutosignController extends AbstractAction
{
/**
* 支付宝登录:授权页面
*/
public function alipayAction()
{
$this->setSession('_TOKEN', '');
Factory::create('alipay')->getAuthorizeUrl();
exit();
}
/**
* QQ账号登录:授权页面
*/
public function qqAction()
{
$this->setSession('_TOKEN', '');
Factory::create('qqconnect')->getAuthorizeUrl();
exit();
}
/**
* 新浪微博账号登录:授权页面
*/
public function sinaAction()
{
$this->setSession('_TOKEN', '');
$this->go(Factory::create('sinaweibo')->getAuthorizeUrl());
}
/**
* 新浪微博账号登录:授权页面
*/
public function renrenAction()
{
$this->setSession('_TOKEN', '');
$this->go(Factory::create('renren')->getAuthorizeUrl());
}
/**
* 豆瓣账号登录:授权页面
*/
public function doubanAction()
{
$this->setSession('_TOKEN', '');
$this->go(Factory::create('douban')->getAuthorizeUrl());
}
/**
* 支付宝账号登录:回调方法
*/
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)) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($realName, $userId, 'alipay', $shoppingKey);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
$this->go(Helpers::url('/passport/bind/index', array('openId' => $userId, 'sourceType' => 'alipay', 'nickname' => $realName)));
}
$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->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
}
else {
$this->go($refer);
}
}
/**
* QQ账号登录:回调方法
*/
public function qqcallbackAction()
{
$qqconnect = Factory::create('qqconnect');
$access = $qqconnect->getAccessToken();
/* 获取QQ腾讯用户的详细信息 */
$partnerInfo = $qqconnect->getUserInfo($access);
$result = array();
if (!empty($partnerInfo) && isset($partnerInfo['nickname'])) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq', $shoppingKey);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
$this->go(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $access['openid'], 'sourceType' => 'qq', 'nickname' => $partnerInfo['nickname'])));
}
$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->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
}
else {
$this->go($refer);
}
}
/**
* 新浪微博账号登录:回调方法
*/
public function sinacallbackAction()
{
$sina = Factory::create('sinaweibo');
$access = $sina->getAccessToken();
/* 获取用户的详细信息 */
$partnerInfo = $sina->getUserInfo($access);
$result = array();
if ($partnerInfo && is_array($partnerInfo)) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($partnerInfo['screen_name'], $access['uid'], 'sina', $shoppingKey);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
// $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['screen_name'])));
}
$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->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
}
else {
$this->go($refer);
}
}
/**
* renren账号登录:回调方法
*/
public function renrenbackAction()
{
$renren = Factory::create('renren');
$access = $renren->getAccessToken();
/* 获取用户的详细信息 */
$partnerInfo = $renren->getUserInfo($access);
$result = array();
if ($partnerInfo && is_array($partnerInfo)) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['uid'], 'renren', $shoppingKey);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
// $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['nick_name'])));
}
$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->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
}
else {
$this->go($refer);
}
}
/**
* douban账号登录:回调方法
*/
public function doubanbackAction()
{
$sina = Factory::create('douban');
$access = $sina->getAccessToken();
/* 获取用户的详细信息 */
$partnerInfo = $sina->getUserInfo($access);
$result = array();
if ($partnerInfo && is_array($partnerInfo)) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['uid'], 'douban', $shoppingKey);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
// $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['screen_name'])));
}
$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->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
}
else {
$this->go($refer);
}
}
}
... ...
<?php
use Action\AbstractAction;
use LibModels\Web\Passport\RegData;
use LibModels\Web\Passport\LoginData;
use LibModels\Web\Home\IndexData;
use Passport\PassportModel as PassportModel;
use Plugin\Helpers;
use Plugin\Images;
use Plugin\Partner\Factory;
class AutouserinfoController extends AbstractAction
{
/**
* 第三方登录完善个人信息:
* 绑定手机号
*/
public function indexAction()
{
$this->setTitle('联合登录补全信息');
$nickname = $this->get('nickname');
$openId = $this->get('openId');
$sourceType = $this->get('sourceType');
//登录后跳转页面
$refer = $this->getCookie('refer');
if (empty($refer)) {
$refer = SITE_MAIN;
}
else {
$refer = rawurldecode($refer);
}
//获取用户
$uid = $this->getUid(true);
if (!$uid) {
$isLogin = false;
$username = '';
}
else {
$isLogin = true;
$username = $this->_uname;
}
$simpleHeader = PassportModel::getSimpleHeader($isLogin, $username);
//整合
$data = array(
'loginPage' => true,
'simpleHeader' => $simpleHeader,
'passport' => array(
'coverHref' => '',
'coverImg' => 'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190',
),
);
$this->_view->display('index', $data);
}
/**
* 完善信息页面
*/
public function userInfoAction()
{
//获取用户
$uid = $this->getUid(true);
$nickname = $this->get('nickname');
$openId = $this->get('openId');
$sourceType = $this->get('sourceType');
if (!$uid) {
$isLogin = false;
$username = '';
}
else {
$isLogin = true;
$username = $this->_uname;
}
$simpleHeader = PassportModel::getSimpleHeader($isLogin, $username);
//整合
$data = array(
'simpleHeader' => $simpleHeader,
'passport' => array(
'coverHref' => '',
'coverImg' => 'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190',
'goShoppingUrl' => SITE_MAIN,
'completeInfoUrl' => Helpers::url('/passport/autouserinfo/index', array('openId' => $openId, 'sourceType' => $sourceType, 'nickname' => $nickname)),
),
);
$this->_view->display('userinfo', $data);
}
/*
* 发送绑定验证吗
*/
/*
* 验证图形验证码
*/
/*
* 验证短信验证码
*/
/*
* 绑定手机号
*/
}
... ...
... ... @@ -26,7 +26,7 @@ class LoginController extends AbstractAction
$this->setCookie('_TOKEN', '');
//登录后跳转页面
$refer = $this->get('refer');
$refer = empty($_SERVER["HTTP_REFERER"])?'':$_SERVER["HTTP_REFERER"];
if (!empty($refer)) {
$this->setCookie('refer', $refer);
}
... ... @@ -55,17 +55,17 @@ class LoginController extends AbstractAction
'simpleHeader' => $simpleHeader,
'passport' => array(
'coverHref' => $coverHref,
'coverImg' => $coverImg,
'coverImg' => !empty($coverImg)?$coverImg:'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190',
'countryCode' => '+86',
'countryName' => '中国',
'countryList' => RegData::getAreasData(),
'forgetPwd' => Helpers::url('/passport/back/index'),
'fastReg' => Helpers::url('/reg.html'),
'qqLogin' => Helpers::url('/passport/login/qq'),
'weiboLogin' => Helpers::url('/passport/login/sina'),
'alipayLogin' => Helpers::url('/passport/login/alipay'),
'doubanLogin' => Helpers::url('/passport/login/douban'),
'renrenLogin' => Helpers::url('/passport/login/renren'),
'qqLogin' => Helpers::url('/passport/autosign/qq'),
'weiboLogin' => Helpers::url('/passport/autosign/sina'),
'alipayLogin' => Helpers::url('/passport/autosign/alipay'),
'doubanLogin' => Helpers::url('/passport/autosign/douban'),
'renrenLogin' => Helpers::url('/passport/autosign/renren'),
),
);
... ... @@ -160,262 +160,4 @@ class LoginController extends AbstractAction
$this->go($refer);
}
//第三方登录
/**
* 支付宝登录:授权页面
*/
public function alipayAction()
{
$this->setSession('_TOKEN', '');
Factory::create('alipay')->getAuthorizeUrl();
exit();
}
/**
* QQ账号登录:授权页面
*/
public function qqAction()
{
$this->setSession('_TOKEN', '');
Factory::create('qqconnect')->getAuthorizeUrl();
exit();
}
/**
* 新浪微博账号登录:授权页面
*/
public function sinaAction()
{
$this->setSession('_TOKEN', '');
$this->go(Factory::create('sinaweibo')->getAuthorizeUrl());
}
/**
* 新浪微博账号登录:授权页面
*/
public function renrenAction()
{
$this->setSession('_TOKEN', '');
$this->go(Factory::create('renren')->getAuthorizeUrl());
}
/**
* 豆瓣账号登录:授权页面
*/
public function doubanAction()
{
$this->setSession('_TOKEN', '');
$this->go(Factory::create('douban')->getAuthorizeUrl());
}
/**
* 支付宝账号登录:回调方法
*/
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)) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($realName, $userId, 'alipay', $shoppingKey);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
$this->go(Helpers::url('/passport/bind/index', array('openId' => $userId, 'sourceType' => 'alipay', 'nickname' => $realName)));
}
$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->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
}
else {
$this->go($refer);
}
}
/**
* QQ账号登录:回调方法
*/
public function qqcallbackAction()
{
$qqconnect = Factory::create('qqconnect');
$access = $qqconnect->getAccessToken();
/* 获取QQ腾讯用户的详细信息 */
$partnerInfo = $qqconnect->getUserInfo($access);
$result = array();
if (!empty($partnerInfo) && isset($partnerInfo['nickname'])) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq', $shoppingKey);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
// $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['openid'], 'sourceType' => 'qq', 'nickname' => $partnerInfo['nickname'])));
}
$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->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
}
else {
$this->go($refer);
}
}
/**
* 新浪微博账号登录:回调方法
*/
public function sinacallbackAction()
{
$sina = Factory::create('sinaweibo');
$access = $sina->getAccessToken();
/* 获取用户的详细信息 */
$partnerInfo = $sina->getUserInfo($access);
$result = array();
if ($partnerInfo && is_array($partnerInfo)) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($partnerInfo['screen_name'], $access['uid'], 'sina', $shoppingKey);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
// $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['screen_name'])));
}
$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->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
}
else {
$this->go($refer);
}
}
/**
* renren账号登录:回调方法
*/
public function renrenbackAction()
{
$renren = Factory::create('renren');
$access = $renren->getAccessToken();
/* 获取用户的详细信息 */
$partnerInfo = $renren->getUserInfo($access);
$result = array();
if ($partnerInfo && is_array($partnerInfo)) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['uid'], 'renren', $shoppingKey);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
// $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['nick_name'])));
}
$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->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
}
else {
$this->go($refer);
}
}
/**
* douban账号登录:回调方法
*/
public function doubanbackAction()
{
$sina = Factory::create('douban');
$access = $sina->getAccessToken();
/* 获取用户的详细信息 */
$partnerInfo = $sina->getUserInfo($access);
$result = array();
if ($partnerInfo && is_array($partnerInfo)) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['uid'], 'douban', $shoppingKey);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
// $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['screen_name'])));
}
$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->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
}
else {
$this->go($refer);
}
}
}
... ...
<?php
use Action\WebAction;
use LibModels\Web\Passport\RegData;
use Passport\RegModel;
use Plugin\Helpers;
use Plugin\Cache;
use Passport\PassportModel;
... ... @@ -14,6 +13,7 @@ class RegisterController extends WebAction
{
$refer = $this->get('refer', SITE_MAIN);
$cover = PassportModel::getLeftBanner(PassportModel::REGISTER_LEFT_BANNER_CODE);
$this->setSession('effective_time', time() + 1800);
$data = array(
'registerPage' => true,
'passport' => array(
... ... @@ -31,8 +31,11 @@ class RegisterController extends WebAction
$this->setCookie('refer', $refer);
$this->_view->display('index', $data);
}
/**
* 检测手机号
*
* @return json
*/
public function checkmobileAction()
{
... ... @@ -41,7 +44,7 @@ class RegisterController extends WebAction
$ip = Helpers::getClientIp();
$data = array('code' => 400, 'message' => '', 'data' => '');
$ip_key = md5('ip_checkmobile_' . $ip);
$ip_times = Cache::increment($ip_key);
$ip_times = Cache::increment($ip_key, 1, 0, 3600);
do{
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
... ... @@ -57,8 +60,8 @@ class RegisterController extends WebAction
break;
}
if(!empty(PassportModel::getUserInfoByMobile($area, $mobile))) {
$data['message'] = '手机号码已经存在';
break;
$data['message'] = '手机号码已经存在';
break;
}
$data['code'] = 200;
} while(false);
... ... @@ -93,7 +96,13 @@ class RegisterController extends WebAction
$data['message'] = '验证码不正确';
break;
}
//发送代码
$send_code_key = md5('send_code_' .$area.'_'.$mobile);
$send_code_times = Cache::increment($send_code_key, 1, 0, 3600);
if($send_code_times > 50) {
$data['message'] = '发送验证码太多';
break;
}
/* 向手机发送注册验证码 */
$data = RegData::sendCodeToMobile($area, $mobile);
if (!isset($data['code'])) {
... ... @@ -149,6 +158,12 @@ class RegisterController extends WebAction
$data['message'] = '验证码错误';
break;
}
$effective_time = $this->getSession('effective_time');
if($effective_time < time() || empty($effective_time))
{
$data['message'] = '注册超时';
break;
}
/*手机注册*/
$data = RegData::regMobile($area, $mobile, $password);
if (!isset($data['code']) || $data['code'] != 200) {
... ... @@ -161,17 +176,15 @@ class RegisterController extends WebAction
} else {
$refer = rawurldecode($refer);
}
// $data['data']['href'] = $refer;
// $data['data']['session'] = Helpers::syncUserSession($data['data']['uid']);
$data['code'] = 200;
$data['data']['href'] = $refer;
$data['data']['session'] = Helpers::syncUserSession($data['data']['uid']);
$token = Helpers::makeToken($data['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $data['data']['uid']);
//$this->setSession('session_key', $data['data']['session_key']);
}while(false);
$this->go($refer);
echo $this->echoJson($data);
}
}
\ No newline at end of file
... ...