Authored by 梁志锋

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

存放生成的HTML文件等
\ No newline at end of file
... ...
... ... @@ -9,11 +9,11 @@
* @version 1.0 (2015-9-15 11:55:25)
* @author fei.hong <fei.hong@yoho.cn>
*/
namespace Action;
use Yaf\Controller_Abstract;
use Yaf\Dispatcher;
use Hood\Cache;
class AbstractAction extends Controller_Abstract
... ... @@ -57,7 +57,7 @@ class AbstractAction extends Controller_Abstract
{
return $this->_request->getPost($key, $default);
}
/**
* 使用Memcache缓存
*
... ... @@ -67,13 +67,16 @@ class AbstractAction extends Controller_Abstract
*/
protected function memcache($node = null, $childNode = 'hosts')
{
// WINDOWS
if (PATH_SEPARATOR === '\\') {
return Cache::memcache($node, $childNode);
} else {
}
// LINUX
else {
return Cache::memcached($node, $childNode);
}
}
/**
* 关闭模板自动渲染
*
... ... @@ -83,7 +86,7 @@ class AbstractAction extends Controller_Abstract
{
Dispatcher::getInstance()->autoRender(false);
}
/**
* 输出JSON数据到浏览器
*
... ... @@ -92,14 +95,14 @@ class AbstractAction extends Controller_Abstract
protected function echoJson($json)
{
headers_sent() || header('Content-Type: application/json; charset=utf-8;');
if(is_array($json))
{
if (is_array($json)) {
$json = json_encode($json);
}
echo $json;
}
/**
* 返回JSON数据
*
... ... @@ -116,7 +119,7 @@ class AbstractAction extends Controller_Abstract
'data' => $data,
));
}
/**
* 判断是不是AJAX请求
*
... ... @@ -126,15 +129,137 @@ class AbstractAction extends Controller_Abstract
{
return $this->_request->isXmlHttpRequest();
}
/**
* 跳转到错误页面
*/
protected function error()
{
headers_sent() || header('Location: /error.html');
exit;
}
/**
* 设置Cookie
*
* @param string $name cookie的名字
* @param string $value cookie的值
* @param integer $expire cookie过期时间
* @param integer $path cookie可用的路径
* @param string $domain cookie可用域名
*/
protected function setCookie($name, $value, $expire = 0, $path = '/',$domain = 'yohobuy.com')
{
setcookie('alipay_redirect', $value, $expire, $path, $domain);
}
/**
* 返回Cookie变量
*
* @param string $name cookie名称
* @param string $default 未获取到返回的默认值
* @return string 获取到的cookie值
*/
protected function getCookie($name, $default = '')
{
return $this->request->getCookie($name, $default);
}
/**
* 返回顶部软件下载有关数据
* @return array 下载有关数据
*/
protected function getHeaderDownload()
{
return array(
'img' => 'http://img11.static.yhbimg.com/adpic/2015/02/28/18/01d83bfad41c8fca8fd1ad334216d7d733.jpg?imageView/2/w/640/h/480',
'url' => 'http://www.baidu.com'
);
}
/*
* 设置网站SEO的标题
*
* @param string $title 标题
* @return void
*/
protected function setTitle($title)
{
$this->_view->assign('title', $title);
}
/**
* 设置网站SEO的关键词
*
* @param string $keywords 关键词,多个之间用","逗号分隔
* @return void
*/
protected function setKeywords($keywords)
{
$this->_view->assign('keywords', $keywords);
}
/**
* 设置网站SEO的描述内容
*
* @param string $description 描述内容
* @return void
*/
protected function setDescription($description)
{
$this->_view->assign('description', $description);
}
/**
* 设置网站导航头部信息
*
* @param string $backUrl 返回的链接
* @param string $title 头部标题
* @param string $homeUrl 返回首页的链接
* @return void
*/
protected function setNavHeader($backUrl, $title, $homeUrl)
{
$header = array();
if (!empty($backUrl)) {
$header['pageHeader']['navBack'] = $backUrl;
}
if (!empty($title)) {
$header['pageHeader']['navTitle'] = $title;
}
if (!empty($homeUrl)) {
$header['pageHeader']['navHome'] = $homeUrl;
}
$this->_view->assign('header', $header);
}
/**
* 设置网站导航底部信息
*
* @return void
*/
protected function setNavFooter()
{
$footer = array();
// 已登录 @todo
if (false) {
$footer['pageFooter']['user'] = array();
$footer['pageFooter']['user']['name'] = 'goodboy'; // 昵称
$footer['pageFooter']['user']['url'] = ''; // 个人中心链接
$footer['pageFooter']['user']['signoutUrl'] = ''; // 登出链接
}
// 未登录
else {
$footer['pageFooter'] = array();
$footer['pageFooter']['loginUrl'] = ''; // 登录链接
$footer['pageFooter']['signupUrl'] = ''; // 注册链接
}
$this->_view->assign('footer', $footer);
}
}
... ...
... ... @@ -3,7 +3,6 @@ namespace LibModels\Wap\Home;
use Api\Yohobuy;
use Api\Sign;
use Plugin\Helpers;
/**
* 首页数据接口操作类
... ...
... ... @@ -19,14 +19,16 @@ class LoginData
/**
* 登录
*
* @param string $area 地区编号
* @param string $profile 邮箱或手机号
* @param string $password 密码
* @return array
*/
public static function signin($profile, $password)
public static function signin($area, $profile, $password)
{
$param = Yohobuy::param();
$param['method'] = 'app.passport.signin';
$param['area'] = $area;
$param['profile'] = $profile;
$param['password'] = $password;
... ...
... ... @@ -33,7 +33,7 @@ class Helpers
if (!isset($productData['product_skn'])) {
return false;
}
// 市场价和售价一样,则不显示市场价
if (intval($productData['market_price']) === intval($productData['sales_price'])) {
$productData['market_price'] = false;
... ... @@ -46,31 +46,168 @@ class Helpers
$result['name'] = $productData['product_name'];
$result['price'] = $productData['market_price'];
$result['salePrice'] = $productData['sales_price'];
$result['isFew'] = ($productData['is_soon_sold_out'] === 'Y') ? true : false;
$result['isFew'] = ($productData['is_soon_sold_out'] === 'Y');
$result['url'] = ''; // @todo
$result['tags'] = array(
'isNew' => false, // 新品
'isSale' => false, // 在售
'isLimit' => false, // 限量
'isNewFestival' => false, // 新品节
'isReNew' => false, // 再到着
'isYohood' => false, // YOHOOD
'midYear' => false, // 年中
'yearEnd' => false, // 年末
);
foreach ($productData['tags'] as $tag) {
if ($tag['is_limited'] === 'Y') {
$result['tags']['isLimit'] = true;
} elseif ($tag['is_yohood'] === 'Y') {
$result['tags']['isYohood'] = true;
} elseif ($tag['is_new'] === 'Y') {
$result['tags']['isNew'] = true;
$result['tags'] = array();
$result['tags']['isNew'] = isset($productData['is_new']) && $productData['is_new'] === 'Y'; // 新品
$result['tags']['isSale'] = isset($productData['is_discount']) && $productData['is_discount'] === 'Y'; // 在售
$result['tags']['isLimit'] = isset($productData['is_limited']) && $productData['is_limited'] === 'Y'; // 限量
$result['tags']['isYohood'] = isset($productData['is_yohood']) && $productData['is_yohood'] === 'Y'; // YOHOOD
$result['tags']['midYear'] = isset($productData['mid-year']) && $productData['mid-year'] === 'Y'; // 年中
$result['tags']['yearEnd'] = isset($productData['year-end']) && $productData['year-end'] === 'Y'; // 年末
$result['tags']['isReNew'] = false; // 再到着
$result['tags']['isNewFestival'] = false; // 新品节
return $result;
}
/**
* 生成公开的TOKEN凭证
*
* @param string $string 字符串
* @return string
*/
public static function makeToken($string)
{
return md5(md5($string . '#@!@#'));
}
/**
* 验证TOKEN凭证
*
* @param string $string 字符串
* @param string $token 公开访问TOKEN
* @return bool
*/
public static function verifyToken($string, $token)
{
if ($token === self::makeToken($string)) {
return true;
}
else {
return false;
}
}
/**
* 验证手机是否合法
*
* @param int $mobile
* @return boolean
*/
public static function verifyMobile($mobile)
{
if (empty($mobile)) {
return false;
}
return (bool) preg_match('/^1[3|4|5|8|7][0-9]{9}$/', trim($mobile));
}
/**
* 验证密码是否合法
*
* @param int $password
* @return boolean
*/
public static function verifyPassword($password)
{
if (empty($password)) {
return false;
}
return (bool) preg_match('/^([a-zA-Z0-9\-\+_!@\#$%\^&\*\(\)\:\;\.=\[\]\\\',\?]){6,20}$/', trim($password));
}
/**
* 验证邮箱是否合法
*
* @param string $email
* @return boolean
*/
public static function verifyEmail($email)
{
if (empty($email)) {
return false;
}
return !!filter_var($email, FILTER_VALIDATE_EMAIL);
}
/**
* 验证国际手机号是否合法
*
* @param string $areaMobile
* @return boolean
*/
public static function verifyAreaMobile($areaMobile)
{
if (empty($areaMobile)) {
return false;
}
if (!strpos($areaMobile, '-')) {
return self::areaMobielVerify($areaMobile);
} else {
$mobileData = explode('-', $areaMobile);
if (count($mobileData) != 2) {
return false;
}
}
return $result;
return self::areaMobielVerify($mobileData[1], $mobileData[0]);
}
}
\ No newline at end of file
/**
* 各国手机号规则
*/
private static function areaMobielVerify($mobile, $area = 86)
{
$verify = array(
86 => array(
'name' => '中国',
'match' => (bool) preg_match('/^1[3|4|5|8|7][0-9]{9}$/', trim($mobile)),
),
852 => array(
'name' => '中国香港',
'match' => (bool) preg_match('/^[9|6|5][0-9]{7}$/', trim($mobile)),
),
853 => array(
'name' => '中国澳门',
'match' => (bool) preg_match('/^[0-9]{8}$/', trim($mobile)),
),
886 => array(
'name' => '中国台湾',
'match' => (bool) preg_match('/^[0-9]{10}$/', trim($mobile)),
),
65 => array(
'name' => '新加坡',
'match' => (bool) preg_match('/^[9|8][0-9]{7}$/', trim($mobile)),
),
60 => array(
'name' => '马来西亚',
'match' => (bool) preg_match('/^1[1|2|3|4|6|7|9][0-9]{8}$/', trim($mobile)),
),
1 => array(
'name' => '加拿大&美国',
'match' => (bool) preg_match('/^[0-9]{10}$/', trim($mobile)),
),
82 => array(
'name' => '韩国',
'match' => (bool) preg_match('/^01[0-9]{9}$/', trim($mobile)),
),
44 => array(
'name' => '英国',
'match' => (bool) preg_match('/^7[7|8|9][0-9]{8}$/', trim($mobile)),
),
81 => array(
'name' => '日本',
'match' => (bool) preg_match('/^0[9|8|7][0-9]{9}$/', trim($mobile)),
),
61 => array(
'name' => '澳大利亚',
'match' => (bool) preg_match('/^[0-9]{11}$/', trim($mobile)),
),
);
if (isset($verify[$area])) {
return $verify[$area]['match'];
}
return false;
}
}
... ...
server
{
listen 80;
server_name wap.yohobuy.com;
#access_log /Data/logs/access.wap.yohobuy.com.log combined;
error_log /Data/logs/error.wap.yohobuy.com.log warn;
root /Data/PE/yohobuy/yohobuy/m.yohobuy.com/public;
location ~* \.html$ {
root /Data/PE/yohobuy/assets;
if (!-f $request_filename){
root /Data/PE/yohobuy/yohobuy/m.yohobuy.com/public;
rewrite ^/(.+)$ /index.php?$1& last;
}
expires 7d;
}
location / {
index index.php;
if (!-f $request_filename){
rewrite ^/(.+)$ /index.php?$1& last;
}
}
location ~* \.(ico|woff)$ {
expires 7d;
}
location = /crossdomain.xml {
expires 7d;
}
location ~ .*\.php?$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
error_page 403 = http://wap.yohobuy.com;
error_page 404 = http://wap.yohobuy.com/error.html;
}
server
{
listen 80;
server_name static.wap.yohobuy.com;
#access_log /Data/logs/access.static.wap.yohobuy.com.log combined;
#error_log /Data/logs/error.static.wap.yohobuy.com.log warn;
root /Data/PE/yohobuy/static;
location / {
log_not_found off;
access_log off;
expires 30d;
}
location ~* \.(svg|eot|ttf|woff|otf)$ {
add_header Access-Control-Allow-Origin *;
expires 30d;
}
}
\ No newline at end of file
... ...
... ... @@ -14,6 +14,8 @@ var tip = require('../../plugin/tip');
var trim = $.trim;
var showErrTip = tip.show;
var $mobile = $('#mobile');
api.bindEyesEvt();
$pwd.bind('input', function() {
... ... @@ -25,19 +27,45 @@ $pwd.bind('input', function() {
});
$btnOk.on('touchstart', function() {
var pwd = trim($pwd.val());
var pwd = trim($pwd.val()),
mobileBack = true,
setting,
url;
if ($btnOk.hasClass('disable')) {
return;
}
setting = {
password: pwd
};
if ($mobile.length === 0) {
mobileBack = false;
}
if (mobileBack) {
$.extend(setting, {
mobile: $mobile.val(),
areaCode: $('#areaCode').val(),
token: $('#token').val()
});
url = '/passport/back/passwordByMobile';
} else {
$.extend(setting, {
code: $('#email-code').val()
});
url = '/passport/back/passwordByEmail';
}
if (api.pwdValidate(pwd)) {
$.ajax({
type: 'POST',
url: '/passport/back/update',
data: {
password: pwd
},
data: setting,
success: function(data) {
if (data.code === 200) {
showErrTip('密码修改成功');
... ...
... ... @@ -7,5 +7,14 @@
</div>
<span id="btn-ok" class="btn btn-ok disable">完成</span>
</div>
{{#if mobile}}
<input id="mobile" type="hidden" value={{mobile}}>
<input id="area" type="hidden" value={{areaCode}}>
<input id="token" type="hidden" value={{token}}>
{{/if}}
{{# code}}
<input id="email-code" type="hidden" value={{.}}>
{{/ code}}
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -15,7 +15,6 @@
var docEl = doc.documentElement;
(function () {
var clientWidth = docEl.clientWidth;
if (!clientWidth) {
return;
}
... ...
... ... @@ -380,13 +380,14 @@ class GirlsController extends AbstractAction
),
// 频道数据
$channelData = Index::getUserChannelData(0, '2,3', '201504091403002');
);
$this->_view->assign('title', '首页');
$this->_view->display('index', $data);
echo '<pre>';
print_r($channelData);
$this->_view->assign('title', 'YOHO!有货');
$this->_view->display('index', $data);
// // 频道数据
// $channelData = Index::getUserChannelData(0, '2,3', '201504091403002');
... ...
... ... @@ -120,7 +120,7 @@ class PlusstarController extends AbstractAction
$data['ps']['name'] = $brandInfo['getBrandInfo']['brand_name'];
$data['ps']['isLike'] = $brandInfo['getUidBrandFav'];
$data['ps']['likeUrl'] = "http://guang.m.yohobuy.com/plustar/brandinfo?id=285&amp;openby:yohobuy={&quot;action&quot;:&quot;go.weblogin&quot;,&quot;params&quot;:{&quot;jumpurl&quot;:{&quot;url&quot;:&quot;http:\/\/guang.m.yohobuy.com\/plustar\/brandinfo&quot;,&quot;param&quot;:{&quot;id&quot;:285}},&quot;requesturl&quot;:{&quot;url&quot;:&quot;\/guang\/api\/v1\/favorite\/togglebrand&quot;,&quot;param&quot;:{&quot;brand_id&quot;:&quot;701&quot;}},&quot;priority&quot;:&quot;Y&quot;}}";
$data['ps']['intro'] = empty($brandInfo['brand_intro']) ? '' : strip_tags($brandInfo['brand_intro']);
$data['ps']['intro'] = empty($brandInfo['getBrandInfo']['brand_intro']) ? '' : strtr(strip_tags($brandInfo['getBrandInfo']['brand_intro']), 'nbsp;', ' ');
$data['ps']['newArrival'] = array();
$data['ps']['newArrival']['moreUrl'] = ''; // @todo
$data['ps']['newArrival']['naList'] = $brandInfo['getNewProduct'];
... ...
... ... @@ -8,18 +8,14 @@ use Hood\Core\Security\AuthCode;
*/
class BackController extends AbstractAction
{
public function indexAction()
{
echo '密码找回';
}
public function emailAction()
{
$data = array(
'backUrl' => 'm.yohobuy.com',
'backUrl' => '/passport/login/index',
'headerText' => '找回密码',
'isPassportPage' => true,
'modulePath' => 'passport/back/email'
'backEmail' => true
);
$this->_view->assign('title', 'YOHO!有货');
... ... @@ -33,11 +29,30 @@ class BackController extends AbstractAction
{
if($this->isAjax())
{
$email = $this->post('email', '');
// 发送邮箱验证码
$result = BackData::sendCodeToEmail($email);
if($result['code'] === 200)
{
$result['data'] = '/passport/back/success?email='.$email;
}
$this->echoJson($result);
}
}
/**
* 重新发送邮箱验证码
*/
public function resendemailAction()
{
if($this->isAjax())
{
$email = $this->get('email', '');
// 发送邮箱验证码
$result = BackData::sendCodeToEmail($email);
$result['data'] = '/passport/back/success';
$this->echoJson($result);
}
... ... @@ -45,13 +60,18 @@ class BackController extends AbstractAction
public function successAction()
{
$email = $this->get('email', '');
// 获取到邮箱域名
$pattern = "/^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)$/i";
$domain_name = 'http://mail.'.preg_replace( $pattern ,"$2", $email );
$data = array(
'backUrl' => 'm.yohobuy.com',
'backUrl' => '/passport/back/email',
'headerText' => '找回密码',
'isPassportPage' => true,
'modulePath' => 'passport/back/email-success',
'goEmail' => '',
'resendUrl' => ''
'backEmailSuccess' => true,
'goEmail' => $domain_name,
'resendUrl' => '/passport/back/resendemail?email='.$email
);
$this->_view->assign('title', 'YOHO!有货');
... ... @@ -67,12 +87,12 @@ class BackController extends AbstractAction
{
if($this->isAjax())
{
$pwd = $this->get('pwd', '');
$code = $this->get('code', '');
$pwd = $this->post('password', '');
$code = $this->post('code', '');
$data = BackData::modifyPasswordByEmail($pwd, $code);
$this->returnJson(200, '成功', '');// 前端不需要判断结果
$this->echoJson($data);// 前端不需要判断结果
}
}
... ... @@ -89,7 +109,7 @@ class BackController extends AbstractAction
// 处理地区信息
foreach ($areas as &$val) {
$val['areaCode'] = $val['area'];
if($val['area'] == 86)
if($val['area'] === '86')
{
$val['selected'] = true;
}
... ... @@ -104,12 +124,12 @@ class BackController extends AbstractAction
return ($a['id'] < $b['id'] ? -1 : 1);
});*/
$data = array(
'backUrl' => 'm.yohobuy.com',
'backUrl' => '/passport/login/index',
'headerText' => '找回密码',
'isPassportPage' => true,
'modulePath' => 'passport/back/mobile',
'backMobile' => true,
'countrys' => $areas,
'countryCode' => '+86'
);
... ... @@ -121,17 +141,17 @@ class BackController extends AbstractAction
/**
* 发送手机验证码
*/
public function mobilecodeSendAction()
public function sendcodeAction()
{
if($this->isAjax())
{
$mobile = $this->get('mobile', '');
$area = $this->get('area', 86);
$mobile = $this->post('mobile', '');
$area = $this->post('area', 86);
// 发送手机验证码
$result = BackData::sendCodeToMobile($mobile, $area);
$this->returnJson($result['code'], $result['message'], $result['data']);
$this->echoJson($result);
}
}
... ... @@ -139,13 +159,13 @@ class BackController extends AbstractAction
{
$mobile = $this->get('mobile', '');
$area = $this->get('area', 86);
$areacode = '+'.$area;
$data = array(
'backUrl' => 'm.yohobuy.com',
'backUrl' => '/passport/back/mobile',
'headerText' => '找回密码',
'isPassportPage' => true,
'modulePath' => 'passport/back/code',
'areaCode' => '+86',
'areaCode' => $areacode,
'phoneNum' => $mobile
);
... ... @@ -158,41 +178,40 @@ class BackController extends AbstractAction
*
* @return array 校验手机验证码的结果(token)
*/
public function mobilecodeValidateAction()
public function verifycodeAction()
{
if($this->isAjax())
{
$mobile = $this->get('mobile', '');
$code = $this->get('code', '');
$area = $this->get('area', 86);
$mobile = $this->post('mobile', '');
$code = $this->post('code', '');
$area = $this->post('area', 86);
// 校验手机验证码
$result = BackData::validateMobileCode($mobile, $code, $area);
$this->returnJson($result['code'], $result['message'], $result['data']);
$this->echoJson($result);
}
}
public function passwordAction()
{
$mobile = $this->get('mobile', '');
// 手机验证令牌
$token = $this->get('token', '');
$area = $this->get('area', 86);
// 邮箱验证码
$code = $this->get('code', '');
$data = array(
'backUrl' => 'm.yohobuy.com',
'backUrl' => '/passport/login/index',
'headerText' => '找回密码',
'isPassportPage' => true,
'modulePath' => 'passport/back/new-password',
'pageHeader' => array(
'navBack' => 'm.yohobuy.com',
'navHome' => 'm.yohobuy.com',
'navTitle' => '上衣'
),
'pageFooter' => array(
'loginUrl' => 'm.yohobuy.com/login.html',
'signupUrl' => 'm.yohobuy.com/signup.html'
)
'backNewPwd' => true,
'mobile' => $mobile,
'token' => $token,
'areaCode' => $area,
'code' => $code
);
$this->_view->assign('title', 'YOHO!有货');
... ... @@ -208,15 +227,15 @@ class BackController extends AbstractAction
{
if($this->isAjax())
{
$mobile = $this->get('mobile', '');
$token = $this->get('token', '');
$newpwd = $this->get('newpwd', 86);
$area = $this->get('area', 86);
$mobile = $this->post('mobile', '');
$token = $this->post('token', '');
$newpwd = $this->post('password', '');
$area = $this->post('area', 86);
// 根据手机验证码修改密码
$result = BackData::modifyPasswordByMobile($mobile, $token, $newpwd, $area);
$this->returnJson($result['code'], $result['message'], $result['data']);
$this->echoJson($result);
}
}
}
\ No newline at end of file
... ...
<?php
use Action\AbstractAction;
use Plugin\Partner\Factory;
use LibModels\Wap\Passport\LoginData;
use LibModels\Wap\Passport\RegData;
use Plugin\Helpers;
use Plugin\Partner\Factory;
/**
* 登录的控制器
*/
class LoginController extends AbstractAction
{
/**
* 登录页
*/
public function indexAction()
{
$this->setTitle('登录');
$data = array(
'backUrl' => 'm.yohobuy.com',
'loginIndex' => true,
'backUrl' => '/',
'showHeaderImg' => true,
'isPassportPage' => true,
'modulePath' => 'passport/login/login'
'registerUrl' => '/reg.html',
'interationalUrl' => '/login.html',
'phoneRetriveUrl' => '',
'emailRetriveUrl' => '',
);
$this->_view->assign('title', '登录');
$this->_view->display('index', $data);
}
/**
* 国际账号登录页
*/
public function interationalAction()
{
$data = array(
'backUrl' => 'm.yohobuy.com',
'headerText' => '登录',
'isPassportPage' => true,
'modulePath' => 'passport/login/interational',
'countrys' => array(
array(
'areaCode' => '+86',
'selected' => true,
'name' => '中国'
),
array(
'areaCode' => '+864',
'name' => '中国香港'
)
),
'countryCode' => '+86'
);
$this->setTitle('国际账号登录');
$data = array();
$data['loginInterational'] = true;
$data['backUrl'] = '/';
$data['headerText'] = '登录';
$data['isPassportPage'] = true;
$data['countryCode'] = '+86';
// 获取地区数据列表
$area = RegData::getAreasData();
// 有数据
if (!empty($area['data'])) {
$build = array();
foreach ($area['data'] as $value) {
$build = array();
$build['areaCode'] = '+' . $value['area'];
$build['selected'] = $value['area'] === '86';
$build['name'] = $value['name'];
$data['countrys'][] = $build;
}
}
// 没数据
else {
$data['countrys'][0] = array();
$data['countrys'][0]['areaCode'] = '+86';
$data['countrys'][0]['selected'] = true;
$data['countrys'][0]['name'] = '中国';
}
$this->_view->assign('title', '国际账号登录');
$this->_view->display('interational', $data);
$data = array();
$area = array();
}
/**
* 登录操作
*
* @param string area 地区编号, 不需要+号
* @param string profile 账号(邮箱或手机号)
* @param string password 密码
* @return json
*/
public function authAction()
{
$data = array('code' => 400, 'message' => '账号或密码不正确', 'data' => '');
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
/* 判断参数是否传递 */
$area = $this->post('area', '86');
$profile = $this->post('profile');
$password = $this->post('password');
if (!is_numeric($area) || empty($profile) || empty($password)) {
break;
}
/* 判断参数是否有效 */
$verifyEmail = Helpers::verifyEmail($profile);
$verifyMobile = ($area === '86') ? Helpers::verifyMobile($profile)
: Helpers::verifyAreaMobile($profile);
if (!$verifyEmail && !$verifyMobile) {
break;
}
/* 调用登录接口进行登录 */
$data = LoginData::signin($area, $profile, $password);
} while (false);
$this->echoJson($data);
}
/**
* 支付宝账号登录:授权页面
*/
public function alipayAction()
{
$redirect = $this->_request->getServer('HTTP_REFERER', '');
if($redirect != '')
{
$this->setCookie('alipay_redirect', $redirect);
}
Factory::create('alipay')->getAuthorizeUrl();
exit();
... ... @@ -61,6 +136,11 @@ class LoginController extends AbstractAction
*/
public function qqAction()
{
$redirect = $this->_request->getServer('HTTP_REFERER', '');
if($redirect != '')
{
$this->setCookie('qq_redirect', $redirect);
}
Factory::create('qqconnect')->getAuthorizeUrl();
exit();
... ... @@ -72,6 +152,11 @@ class LoginController extends AbstractAction
*/
public function sinaAction()
{
$redirect = $this->_request->getServer('HTTP_REFERER', '');
if($redirect != '')
{
$this->setCookie('sina_redirect', $redirect);
}
header('Location:' . Factory::create('sinaweibo')->getAuthorizeUrl());
exit();
... ... @@ -108,8 +193,11 @@ class LoginController extends AbstractAction
if($result['code'] == 200)
{
echo '登陆成功';
$redirect = $this->_request->getCookie('alipay_redirect');
$redirect && $this->redirect($redirect);
}
$this->redirect('/');
}
/**
... ... @@ -121,7 +209,6 @@ class LoginController extends AbstractAction
$access = $qqconnect->getAccessToken();
/* 获取QQ腾讯用户的详细信息 */
$partnerInfo = $qqconnect->getUserInfo($access);
var_dump($access, $partnerInfo);
if ($partnerInfo && is_array($partnerInfo))
{
... ... @@ -129,9 +216,12 @@ class LoginController extends AbstractAction
if($result['code'] == 200)
{
echo '登陆成功';
$redirect = $this->_request->getCookie('qq_redirect');
$redirect && $this->redirect($redirect);
}
}
}
$this->redirect('/');
}
/**
... ... @@ -143,7 +233,6 @@ class LoginController extends AbstractAction
$access = $sina->getAccessToken();
/* 获取QQ腾讯用户的详细信息 */
$partnerInfo = $sina->getUserInfo($access);
var_dump($access, $partnerInfo);
if ($partnerInfo && is_array($partnerInfo))
{
... ... @@ -151,8 +240,11 @@ class LoginController extends AbstractAction
if($result['code'] == 200)
{
echo '登陆成功';
$redirect = $this->_request->getCookie('sina_redirect');
$redirect && $this->redirect($redirect);
}
}
}
$this->redirect('/');
}
}
\ No newline at end of file
... ...
<?php
use Action\AbstractAction;
use LibModels\Wap\Passport\RegData;
use Plugin\Helpers;
/**
* 注册的控制器
*/
class RegController extends AbstractAction
{
/**
* 注册页
*/
public function indexAction()
{
$data = array(
'backUrl' => 'm.yohobuy.com',
'headerText' => '注册',
'isPassportPage' => true,
'modulePath' => 'passport/register/register',
'countrys' => array(
array(
'areaCode' => '+86',
'selected' => true,
'name' => '中国'
),
array(
'areaCode' => '+864',
'name' => '中国香港'
)
),
'countryCode' => '+86'
);
$this->_view->assign('title', '注册');
$this->setTitle('注册');
$data = array();
$data['regIndex'] = true;
$data['backUrl'] = '/';
$data['headerText'] = '注册';
$data['isPassportPage'] = true;
$data['countrys'] = array();
// 获取地区数据列表
$area = RegData::getAreasData();
// 有数据
if (!empty($area['data'])) {
$build = array();
foreach ($area['data'] as $value) {
$build = array();
$build['areaCode'] = '+' . $value['area'];
$build['selected'] = $value['area'] === '86';
$build['name'] = $value['name'];
$data['countrys'][] = $build;
}
}
// 没数据
else {
$data['countrys'][0] = array();
$data['countrys'][0]['areaCode'] = '+86';
$data['countrys'][0]['selected'] = true;
$data['countrys'][0]['name'] = '中国';
}
$this->_view->display('index', $data);
$data = array();
$area = array();
}
/**
* 验证码
*
* @param string area 地区编号
* @param string mobile 手机号
* @param string token 访问TOKEN凭证
*/
public function codeAction()
{
$data = array(
'backUrl' => 'm.yohobuy.com',
'headerText' => '注册',
'isPassportPage' => true,
'modulePath' => 'passport/register/code',
'areaCode' => '+86',
'phoneNum' => '15895869035'
);
$this->_view->assign('title', '注册-验证码');
$token = $this->get('token');
$mobile = $this->get('mobile');
$area = $this->get('area', '86');
// 判断是否允许访问, 不允许则跳转到错误页面
if (!is_string($token) || !is_numeric($mobile) || !Helpers::verifyToken($mobile, $token)) {
$this->error();
}
$this->setTitle('注册-验证码');
$data = array();
$data['regCode'] = true;
$data['backUrl'] = '/';
$data['headerText'] = '注册';
$data['isPassportPage'] = true;
$data['areaCode'] = $area;
$data['phoneNum'] = $mobile;
$data['token'] = $token;
$this->_view->display('code', $data);
}
/**
* 填写密码页面
*
* @param string area 地区编号
* @param string mobile 手机号
* @param string token 访问TOKEN凭证
*/
public function passwordAction()
{
$data = array(
'backUrl' => 'm.yohobuy.com',
'headerText' => '注册',
'isPassportPage' => true,
'modulePath' => 'passport/register/password'
);
$this->_view->assign('title', '注册-密码');
$token = $this->get('token');
$mobile = $this->get('mobile');
$area = $this->get('area', '86');
// 判断是否允许访问, 不允许则跳转到错误页面
if (!is_string($token) || !is_numeric($mobile) || !is_numeric($area)
|| !Helpers::verifyToken($mobile, $token)) {
$this->error();
}
$this->setTitle('注册-设置密码');
$data = array();
$data['regPwd'] = true;
$data['backUrl'] = '/';
$data['headerText'] = '注册';
$data['isPassportPage'] = true;
$data['areaCode'] = $area;
$data['phoneNum'] = $mobile;
$data['token'] = $token;
$this->_view->display('password', $data);
}
/**
* 验证注册的手机号
*
* @param string area 地区编号,注意不需要+号
* @param string mobile 手机号
* @return json
*/
public function verifymobileAction()
{
$data = array('code' => 400, 'message' => '参数不正确!', 'data' => '');
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
$mobile = $this->post('mobile');
$area = $this->post('area', '86');
/* 判断参数是否合法 */
if (!is_numeric($mobile) || !is_numeric($area)) {
break;
}
/* 向手机发送注册验证码 */
$data = RegData::sendCodeToMobile($area, $mobile);
if (!isset($data['code'])) {
break;
}
/* 返回跳转到验证页面的链接*/
if ($data['code'] == 200) {
$token = Helpers::makeToken($mobile);
$data['data'] = '/passport/reg/code?token='.$token.'&mobile='.$mobile.'&area='.$area;
}
} while (false);
$this->echoJson($data);
}
/**
* 验证注册的识别码
*
* @param string area 地区编号,注意不需要+号
* @param string mobile 手机号
* @param string token 访问TOKEN凭证
* @param int code 验证码, 手机上收到的
* @return json
*/
public function verifycodeAction()
{
$data = array('code' => 400, 'message' => '参数不正确!', 'data' => '');
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
$mobile = $this->post('mobile');
$area = $this->post('area');
$code = $this->post('code');
/* 判断参数是否合法 */
if (!is_numeric($mobile) || !is_numeric($area) || !isset($code)) {
break;
}
/* 验证注册的标识码是否有效 */
$data = RegData::validMobileCode($area, $mobile, $code);
if (!isset($data['code'])) {
break;
}
/* 返回跳转到设置密码的链接*/
if ($data['code'] == 200) {
$token = Helpers::makeToken($mobile);
$data['data'] = '/passport/reg/password?token='.$token.'&mobile='.$mobile.'&area='.$area;
}
} while (false);
$this->echoJson($data);
}
/**
* 发送验证码
*
* @param string area 地区编号,注意不需要+号
* @param string mobile 手机号
* @return json
*/
public function sendcodeAction()
{
$data = array('code' => 400, 'message' => '参数不正确!', 'data' => '');
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
$mobile = $this->post('mobile');
$area = $this->post('area', '86');
/* 判断参数是否合法 */
if (!is_numeric($mobile) || !is_numeric($area)) {
break;
}
/* 向手机发送注册验证码 */
$data = RegData::sendCodeToMobile($area, $mobile);
if (!isset($data['code'])) {
break;
}
} while (false);
$this->echoJson($data);
}
/**
* 设置密码
*
* @param string area 地区编号,注意不需要+号
* @param string mobile 手机号
* @param string token 访问TOKEN凭证
* @param string password 用户设置的密码
* @return json
*/
public function setpasswordAction()
{
$data = array('code' => 400, 'message' => '密码格式不正确!', 'data' => '');
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
$token = $this->post('token');
$mobile = $this->post('mobile');
$area = $this->post('area');
$password = $this->post('password');
/* 判断参数是否合法 */
if (!is_string($token) || !is_numeric($mobile) || !is_numeric($area) || !isset($password)) {
break;
}
/* 判断是否允许访问 */
if (!Helpers::verifyToken($mobile, $token)) {
break;
}
/* 验证注册的标识码是否有效 */
$data = RegData::regMobile($area, $mobile, $password);
if (!isset($data['code'])) {
break;
}
/* 返回跳转到来源页面 */
if ($data['code'] == 200) {
$data['data'] = '/passport/reg/password?token='.$token.'&mobile='.$mobile.'&area='.$area;
}
} while (false);
$this->echoJson($data);
}
}
\ No newline at end of file
... ...
; default
; 默认页
routes.index.type = "rewrite"
routes.index.match = "/index.html$"
routes.index.route.module = Index
routes.index.route.controller = Index
routes.index.route.action = Index
; error
routes.notfound.type = "rewrite"
routes.notfound.match = "/error.html$"
routes.notfound.route.module = Index
routes.notfound.route.controller = Error
routes.notfound.route.action = Index
\ No newline at end of file
; 错误页
routes.error.type = "rewrite"
routes.error.match = "/error.html$"
routes.error.route.module = Index
routes.error.route.controller = Error
routes.error.route.action = Index
; 注册页
routes.reg.type = "rewrite"
routes.reg.match = "/reg.html$"
routes.reg.route.module = Passport
routes.reg.route.controller = Reg
routes.reg.route.action = Index
; 登录页
routes.login.type = "rewrite"
routes.login.match = "/signin.html$"
routes.login.route.module = Passport
routes.login.route.controller = Login
routes.login.route.action = Index
; 登录页(国际账号)
routes.interational.type = "rewrite"
routes.interational.match = "/login.html$"
routes.interational.route.module = Passport
routes.interational.route.controller = Login
routes.interational.route.action = Interational
... ...