Authored by wangqing

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

... ... @@ -4,6 +4,7 @@ namespace LibModels\Web\Product;
use Api\Yohobuy;
class SearchData extends \LibModels\Wap\Product\SearchData
{
public static $shops_url = 'http://101.200.31.165/yohosearch/shops.json';
/**
* 获取搜索的服务地址
*
... ... @@ -129,6 +130,16 @@ class SearchData extends \LibModels\Wap\Product\SearchData
}
/**
* 搜索品牌店铺信息
* @param array $params 参数
* @return array
*/
public static function getShop(array $params)
{
return Yohobuy::get(self::$shops_url,$params);
}
/**
* 获取最近浏览记录
* @param int $limit
* @return json
... ...
... ... @@ -13,8 +13,7 @@ class HelperSearch
*/
public static $params = array();
private static $from = '';
public static $options = array();
//当前页
public static $page = 1;
... ... @@ -29,19 +28,13 @@ class HelperSearch
*/
public static $listnav = array();
private static function setFrom($from = '')
{
if ($from) {
self::$from = $from;
}
}
//设置导航
private static function setListNav($option = array())
private static function setListNav()
{
$options = self::$options;
$cookieChannel = isset($_COOKIE['_Channel']) ? $_COOKIE['_Channel'] : 'boys';
if (isset($option['brandName']) && !empty($option['brandName'])) {
$initNav = $option['brandName'];
if (isset($options['brandName']) && !empty($options['brandName'])) {
$initNav = $options['brandName'];
}else{
$initNav = '列表';
}
... ... @@ -64,6 +57,7 @@ class HelperSearch
{
$result = array();
self::$params = $_GET;
self::$options = $options;
unset(self::$params['/']);
unset(self::$params['page']);
unset(self::$params['/sale']);
... ... @@ -80,10 +74,8 @@ class HelperSearch
$result['filters']['checkedConditions']['clearUrl'] = self::current();
//频道
$result['filters']['channel'] = self::gender($filter);
//分类
$result['filters']['sort'] = array();
//品牌
$result['filters']['brand'] = self::brand($filter, $options);
$result['filters']['brand'] = self::brand($filter);
//价格
$result['filters']['price'] = self::price($filter);
$result['filters']['customPrice'] = self::customPrice($filter);
... ... @@ -109,8 +101,10 @@ class HelperSearch
$result['opts']['pageCount'] = $data['data']['page_total'];
$result['opts']['nextHref'] = ($next = self::next($data['data']['page_total'],$data['data']['filter'])) ? $next['href'] : '';
$result['hasNextPage'] = self::next($data['data']['page_total']);
//分类
$result['leftContent'][]['allSort'] = isset($filter['group_sort']) ? self::groupSort($filter['group_sort'], $options) : array();
//分类条件
$result['filters']['sort'] = isset($filter['group_sort']) ? self::searchSort($filter['group_sort']) : array();
//左侧分类分类
$result['leftContent'][]['allSort'] = isset($filter['group_sort']) ? self::groupSort($filter['group_sort']) : array();
//一周新品上架
$result['leftContent'][]['newSales'] = isset($filter['recent']) ? self::recentShelve($filter['recent']) : array();
//全部折扣
... ... @@ -121,6 +115,9 @@ class HelperSearch
$result['pager'] = self::pager($result['totalCount'],$options['viewNum']);
//选中条件
$result['filters']['checkedConditions']['conditions'] = self::getSelected();
if (isset($options['controller']) && $options['controller'] == 'Search') {
self::setSearchNav($data['data']['total']);
}
$result['pathNav'] = self::$listnav;
return $result;
}
... ... @@ -193,6 +190,9 @@ class HelperSearch
'name' => $pval['standard_name'],
'href' => self::buildUrl($tmpParams)
);
if (self::checkSearch('parameter_' . $val['standard_id'])) {
return array();
}
}
$sub[] = array(
'name' => $pval['standard_name'],
... ... @@ -232,6 +232,10 @@ class HelperSearch
'href' => self::buildUrl($params)
);
}
if (self::checkSearch('gender')) {
return array();
}
$result = array();
foreach ($filter['gender'] as $key => $val) {
$result[] = array(
... ... @@ -247,14 +251,18 @@ class HelperSearch
/**
* 组织搜索列表页面的左侧分类
* @param array $sort
* @param array $option
* @return array
*/
public static function groupSort($sort, $option = array())
public static function groupSort($sort)
{
$options = self::$options;
if (isset($options['controller']) && $options['controller'] != 'Search') {
return array();
}
//设置导航
self::setListNav($option);
self::setListNav($options);
$params = self::$params;
$result = array(
'all' => array(
... ... @@ -294,16 +302,48 @@ class HelperSearch
}
}
$result['list'] = $sortList;
return $result;
}
public static function searchSort($sort)
{
$result = array();
$options = self::$options;
if (!isset($options['controller']) || $options['controller'] != 'Search') {
return $result;
}
$params = self::$params;
foreach ($sort as $key => $val) {
$result[$key]['id'] = $val['sort_id'];
$result[$key]['name'] = $val['sort_name'];
if (isset($val['sub']) && !empty($val['sub'])) {
foreach ($val['sub'] as $k => $v) {
$result[$key]['sub'][$k]['href'] = self::buildUrl(array('msort' => $val['sort_id'], 'misort' => $v['sort_id']));
$result[$key]['sub'][$k]['name'] = $v['sort_name'];
if (isset($params['misort']) && $params['misort'] == $v['sort_id']) {
unset($params['misort']);
self::$selected['sort'] = array(
'name' => $v['sort_name'],
'href' => self::buildUrl()
);
}
}
}
}
if (self::checkSearch('msrot') || self::checkSearch('misort')) {
return array();
}
return $result;
}
/**
* 品牌,可以多选
* @param array $filter
* @param array $options
* @return array
*/
public static function brand($filter, $options = array()) {
public static function brand($filter) {
$options = self::$options;
//品牌列表返回空
if (isset($options['brandName'])) {
return array();
... ... @@ -311,11 +351,15 @@ class HelperSearch
$result = array(
'default' => array() ,
'brandIndex' => array(
'0~9',
'A~G',
'H~N',
'O~T',
'U~Z') ,
array(
'index' => 'all',
'name' => '全部'
),
array(
'index' => '0-9',
'name' => '0 ~ 9'
)
),
'brandsShow' => array()
);
$params = self::$params;
... ... @@ -341,12 +385,18 @@ class HelperSearch
)));
}
$this_brand = array(
'brand_id' => $v['id'],
'name' => $v['brand_name'],
'alif' => $v['brand_alif'],
'id' => $v['id'],
'href' => $url,
'name' => $v['brand_name'],
'key' => $v['brand_name'],
'active' => in_array($v['id'], $brandIds) ? true : false
);
if (is_numeric($v['brand_alif'])) {
$this_brand['index'] = '0-9';
}
else {
$this_brand['index'] = strtolower($v['brand_alif']);
}
//默认品牌
if (count($result['default']) < 10) {
$result['default'][] = $this_brand;
... ... @@ -367,9 +417,16 @@ class HelperSearch
'href' => self::buildUrl($params)
);
}
//品牌列表排序
ksort($brandList);
//品牌列表排序, 添加品牌索引
$index_key = array();
foreach ($brandList as $key => $val) {
if ($key && !in_array($key, $index_key)) {
$index['index'] = strtolower(($key));
$index['name'] = $key;
$result['brandIndex'][] = $index;
$index_key[] = $index;
}
if (is_array($val)) {
foreach ($val as $v) {
$result['brandsShow'][] = $v;
... ... @@ -378,6 +435,10 @@ class HelperSearch
}
unset($brandList);
}
//搜索页已选中,返回空
if (self::checkSearch('brand')) {
return array();
}
return $result;
}
/**
... ... @@ -402,6 +463,7 @@ class HelperSearch
'href' => self::buildUrl($params)
);
}
$result[] = array(
'name' => $v['size_name'],
'href' => self::buildUrl(array_merge($params, array(
... ... @@ -409,6 +471,9 @@ class HelperSearch
))) ,
);
}
if (self::checkSearch('size')) {
return array();
}
}
return $result;
}
... ... @@ -443,6 +508,9 @@ class HelperSearch
))) ,
);
}
if (self::checkSearch('color')) {
return array();
}
return $result;
}
... ... @@ -474,6 +542,9 @@ class HelperSearch
);
}
}
if (self::checkSearch('price')) {
return array();
}
//返回价格条件
foreach ($filter['price'] as $key => $val) {
$val = trim($val,'¥');
... ... @@ -556,6 +627,10 @@ class HelperSearch
'href' => $url,
);
}
//搜索页已选中,返回空
if (self::checkSearch('style')) {
return array();
}
$data[0] = array(
'attr' => 'style',
'name' => '风格',
... ... @@ -942,7 +1017,13 @@ class HelperSearch
}
return $result;
}
//分页
/**
* 分页
* @param $total
* @param $viewNum
* @return mixed
*/
public static function pager($total,$viewNum){
$Paging = new Paging('Yoho');
return $Paging->setTotal($total)->setSize($viewNum)->view(0);
... ... @@ -968,4 +1049,67 @@ class HelperSearch
return $result;
}
}
/**
* 组织品牌店铺信息
*/
public static function shop($shop)
{
$url = Helpers::url('','',$shop['brand_domain']);
$shopEntry = array();
$sort = array();
foreach ($shop['sort'] as $msort) {
if (!isset($msort['sub']) || empty($msort['sub'])) {
continue;
}
foreach ($msort['sub'] as $mkey=>$misort) {
if (count($sort) >= 10) {
break 2;
}
$sortInfo['href'] = $url.'/?msort=' . $msort['sort_id'] . '&misort=' . $misort['sort_id'];
$sortInfo['name'] = $misort['sort_name'];
$sort[] = $sortInfo;
}
}
$shopEntry['home'] = $url;
$shopEntry['logo'] = Images::getSourceUrl($shop['brand_ico'],'brandLogo');
$shopEntry['shopName'] = $shop['brand_name'];
$shopEntry['sort'] = $sort;
return $shopEntry;
}
public static function checkSearch($param)
{
if (isset(self::$params[$param]) && isset(self::$options['controller']) && self::$options['controller'] == 'Search') {
return true;
}
}
/**
* 设置搜索页导航
* @param $total
*/
public static function setSearchNav($total)
{
self::$listnav[0] = array(
'href' => '/',
'name' => '首页'
);
$param = self::$params;
$options = self::$options;
if (isset($options['controller']) && $options['controller'] == 'Search' && isset($param['query'])) {
self::$listnav[1] = array(
'href' => '',
'name' => "".$param['query']." ".$total."个结果"
);
}else{
self::$listnav[1] = array(
'href' => '',
'name' => '所有商品'
);
}
}
}
... ...
... ... @@ -30,7 +30,7 @@
</span>
</li>
<li class="input-container-li clearfix">
<input type="hidden" name="code" value="159bI6arxsuaPBxG2iV9OE9BrgDnAPiTecUqYh2iUC3ntt6S0eOtxXpVu+jWIlveXx9NRuwS9zdrXzcUyOd+d3ikzYBAo0k">
<input type="hidden" name="code" value="{{code}}">
<input id="reset-pwd-btn" class="btn reset-pwd-btn" type="submit" value="提交" disabled="">
</li>
</ul>
... ...
{{> layout/simple-header}}
<div class="verification-page back-page passport-page yoho-page clearfix">
{{# verification}}
{{> passport/cover}}
<div class="content">
<form id="verification-form" class="verification-form" method="POST" action="/passport/back/backmobile">
<ul>
<li class="head-title">验证身份</li>
<li class="po-re">
<label class="pn-label">手机号码</label>
<span class="country-code">+{{area}}</span>
<span class="phone-num">{{phoneNum}}</span>
</li>
<li class="po-re">
<input id="captcha" class="input va captcha" type="text" name="captcha">
<input id="send-captcha" class="btn send-captcha" type="button" value="发送验证码" disabled="">
<div id="captcha-tip" class="captcha-tips"><i class="iconfont">&#xe61f;</i>验证码已发送至您的手机,请查收</div>
<span id="err-tip" class="err-tip hide">
<i></i>
<em>请输入验证码</em>
</span>
</li>
<li>
<input name="area" id="area" type="hidden" value="{{area}}">
<input name="mobile" id="mobile" type="hidden" value="{{phoneNum}}">
<input name="captchaPic" id="captchaPic" type="hidden" value="g7ce">
<input name="refer" id="refer" type="hidden" value="">
<input id="next-step" class="btn next-step disable" type="submit" value="下一步" disabled="">
</li>
</ul>
</form>
</div>
{{/ verification}}
</div>
{{> layout/simple-header}}
<div class="verification-page back-page passport-page yoho-page clearfix">
{{# verification}}
{{> passport/cover}}
<div class="content">
<form id="verification-form" class="verification-form" method="POST" action="/passport/back/backmobile">
<ul>
<li class="head-title">验证身份</li>
<li class="po-re">
<label class="pn-label">手机号码</label>
<span class="country-code">+{{area}}</span>
<span class="phone-num">{{phoneNum}}</span>
</li>
<li class="po-re">
<input id="captcha" class="input va captcha" type="text" name="captcha">
<input id="send-captcha" class="btn send-captcha" type="button" value="发送验证码" disabled="">
<div id="captcha-tip" class="captcha-tips"><i class="iconfont">&#xe61f;</i>验证码已发送至您的手机,请查收</div>
<span id="err-tip" class="err-tip hide">
<i></i>
<em>请输入验证码</em>
</span>
</li>
<li>
<input name="area" id="area" type="hidden" value="{{area}}">
<input name="mobile" id="mobile" type="hidden" value="{{phoneNum}}">
<input name="captchaPic" id="captchaPic" type="hidden" value="{{captcha}}">
<input name="refer" id="refer" type="hidden" value="">
<input id="next-step" class="btn next-step disable" type="submit" value="下一步" disabled="">
</li>
</ul>
</form>
</div>
{{/ verification}}
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -36,7 +36,7 @@
<span id="login-btn" class="login-btn btn">登录</span>
</li>
<li class="other-opts">
<span class="remeber-me">
<span class="remember-me">
<i class="iconfont">&#xe613;</i>
记住登录状态
</span>
... ...
{{> layout/header}}
<div class="product-search-page product-page yoho-page center-content">
{{# search}}
{{> layout/path-nav}}
{{> layout/path-nav}}
{{> product/standard-content}}
{{> product/shop-entry}}
{{> product/latest-walk}}
{{> product/standard-content}}
{{> product/latest-walk}}
{{/ search}}
</div>
{{> layout/footer}}
\ No newline at end of file
{{> layout/footer}}
... ...
... ... @@ -4,7 +4,7 @@
<li class="clearfix">
<select id="region" class="region" name="region">
{{#each region}}
<option {{#if selected}}selected="selected"{{/if}} value="{{id}}">{{name}}</option>
<option {{#if selected}}selected="selected"{{/if}} value="{{areaCode}}">{{name}}</option>
{{/each}}
</select>
</li>
... ...
... ... @@ -108,7 +108,7 @@ function getShoppingKey() {
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');
})(window, document, 'script', 'http://cdn.yoho.cn/yas-jssdk/1.0.14/yas.js', '_yas');
(function() {
var uid = getUid();
... ... @@ -118,7 +118,7 @@ function getShoppingKey() {
window._ozuid = uid;//暴露ozuid
if (window._yas) {
window._yas(1 * new Date(), '1.0.13.6.3', 'yohobuy_web', uid, '', '');
window._yas(1 * new Date(), '1.0.14', 'yohobuy_web', uid, '', '');
}
}());
... ... @@ -132,4 +132,4 @@ window.getUid = getUid;
window.getShoppingKey = getShoppingKey;
require('./header');
\ No newline at end of file
require('./header');
... ...
... ... @@ -25,6 +25,8 @@ var $emailAutoComplete = $('#email-autocomplete');
var mailPhoneRegx = require('./mail-phone-regx');
var $remember = $('.remember-me');
//checkbox status unicode
var checkbox = {
checked: '&#xe612;',
... ... @@ -232,7 +234,7 @@ $emailAutoComplete.on('click', 'li', function() {
});
//记住登录状态
$('.remeber-me').on('click', function() {
$remember.on('click', function() {
var $this = $(this);
$this.toggleClass('checked');
... ... @@ -266,15 +268,19 @@ $('#login-btn').on('click', function() {
data: {
areaCode: $countryCodeHide.val().replace('+', ''),
account: $.trim($account.val()),
password: $.trim($password.val())
password: $.trim($password.val()),
isRemember: $remember.hasClass('checked') ? true : false
},
success: function(data) {
if (data.code === 400) {
if (data.code === 200) {
if (data.data) {
//防止data.data为undefined时下行语句执行出错而导致脚本不能走到complete去处理authing
location.href = data.data.href;
}
} else {
$passwordTip.removeClass('hide').children('em').text(data.message);
$password.addClass('error');
return;
} else {
location.href = data.data.href;
}
},
complete: function() {
... ...
... ... @@ -136,9 +136,10 @@ function picCaptchaAjaxFn(page, callback) {
type: 'POST',
url: url,
data: {
code: $ca.val(),
mobile: $pn.val(),
area: $region.text().split('+')[1]
code: $ca.val()
//mobile: $pn.val(),
//area: $region.text().split('+')[1]
}
}).then(function(data) {
switch (data.code) {
... ... @@ -530,7 +531,7 @@ exports.init = function(page) {
data: {
area: $region.text().split('+')[1],
mobile: $pn.val(),
captcha: $ca.val(),
verifyCode: $ca.val(),
code: $mc.val(),
password: $pwd.val()
}
... ...
... ... @@ -60,7 +60,7 @@ $third: sprite-map("passport/third/*.png");
}
}
.remeber-me {
.remember-me {
cursor: pointer;
}
... ...
... ... @@ -73,7 +73,7 @@ class Bootstrap extends Bootstrap_Abstract
$action = 'Index';
// 二级域名
if (3 === $level) {
if (2 === $level) {
$subDomain = strval($hostParts[0]);
switch (strtolower($subDomain)) {
case 'www': // 主站
... ... @@ -90,6 +90,10 @@ class Bootstrap extends Bootstrap_Abstract
case 'list': // 商品列表
$module = 'Product';
break;
case 'sale'://促销
$module = 'Product';
$controller = 'sale';
default: // 其它(识别为品牌)
$module = 'Product';
$action = 'Brand';
... ...
... ... @@ -24,6 +24,7 @@ class PassportModel
const BACK_LFFT_BANNER_CODE = '3bbaf502c447a2ddad60879042e286d8';//找回密码左边的banner
const SIGNIN_LEFT_BANNER_CODE ='db350894e01e90eac55cd3a13ad77331';//登录页左边的banner
const AUTOUSERINFO_LEFT_BANNER_CODE ='c62d5da06d843b6ed78d8d27e87fa143';//完善信息页左边的banner
const BACK_FIND_SECRET_KEY = '_+@#$%^';
//简单头部
public static function getSimpleHeader($isLogin, $username = '')
... ... @@ -75,6 +76,11 @@ class PassportModel
$ret['img'] = Images::getImageUrl($val['src'], 252, 190);
$ret['url'] = $val['url'];
}
else
{
$ret['img'] = 'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190';
$ret['url'] = '';
}
return $ret;
}
... ...
... ... @@ -49,12 +49,7 @@ class SearchModel
//用户浏览记录
$result['data']['filter']['review'] = SearchData::getRecentReview();
// 组织模板数据
$list = HelperSearch::getList($result, $options);
$data = array(
//初始化js
'productListPage' => true,
'list' => $list
);
$data = HelperSearch::getList($result, $options);
}
return $data;
}
... ... @@ -67,31 +62,21 @@ class SearchModel
*/
public static function searchData($condition, $options){
$data = self::getSearchData($condition, $options);
//过滤频道
if (isset($condition['gender'])) {
unset($data['list']['filters']['channel']);
}
//过滤品牌
if (isset($condition['brand'])) {
unset($data['list']['filters']['brand']);
}
//过滤价格
if (isset($condition['price'])) {
unset($data['list']['filters']['price']);
unset($data['list']['filters']['customPrice']);
}
//过滤颜色
if (isset($condition['color'])) {
unset($data['list']['filters']['color']);
}
//过滤风格
if (isset($condition['style'])) {
unset($data['list']['filters']['seniorChose']);
}
//过滤尺码
if (isset($condition['size'])) {
unset($data['list']['filters']['size']);
//获取品牌店铺信息
if (isset($condition['query'])) {
$param['keyword'] = $condition['query'];
$result = SearchData::getShop($param);
if (isset($result['code']) && $result['code'] === 200 && isset($result['data']) && !empty($result['data'])) {
//调用品牌分类
$class['brand'] = $result['data']['id'];
$brandSort = SearchData::getClassesData($class);
$shop = $result['data'];
if (isset($brandSort['data']['sort']) && !empty($brandSort['data']['sort']))
$shop['sort'] = $brandSort['data']['sort'];
$shopEntry = HelperSearch::shop($shop);
}
}
$data['shopEntry'] = isset($shopEntry) ? $shopEntry : array();
return $data;
}
... ...
... ... @@ -56,6 +56,7 @@ class BackController extends WebAction
$data = BackData::sendCodeToMobile($mobile);
$this->setSession('phoneNum', $phoneNum);
$this->setSession('area', $area);
$this->setSession('captcha', $captcha);
if($data['code'] == 200) {
$this->redirect('verification');
}
... ... @@ -66,7 +67,7 @@ class BackController extends WebAction
}
/**
* 发送邮件
* 发送邮件页面
*/
public function sendemailAction() {
$phoneNum = $this->getSession('phoneNum');
... ... @@ -96,14 +97,14 @@ class BackController extends WebAction
'sendEmail' => array(
'coverHref' => $banner['url'],
'coverImg' => $banner['img'],
'countrys' => array()
'countrys' => array(),
)
);
$this->_view->display('send-email', $data);
}
/**
* 重置密码
* 重置密码页面
*/
public function backcodeAction() {
$code = $this->get('code');
... ... @@ -118,14 +119,15 @@ class BackController extends WebAction
'resetPwd' => array(
'coverHref' => $banner['url'],
'coverImg' => $banner['img'],
'countrys' => array()
'countrys' => array(),
'code' => $code,
)
);
$this->_view->display('reset-pwd', $data);
}
/**
* 更新密码
* 更新密码接口
*
*/
public function updateAction()
... ... @@ -134,10 +136,22 @@ class BackController extends WebAction
$password = $this->post('pwd');
$info = $this->checkCode($code);
if(Helpers::verifyPassword($password) && !empty($info)) {
$uid = $info['uid'];
//修改密码
if(isset($info['mobile'])) {//手机号修改密码
$mobile = $info['mobile'];
$token = $info['token'];
$area = $info['area'];
$data = BackData::modifyPasswordByMobile($mobile, $token, $password, $area);
if($data['code']) {
$this->redirect('resetSuccess');
}
} else if(isset($info['uid'])) {//其他方式修改密码
$uid = $info['uid'];
$this->redirect('resetSuccess');
}
}
//跳转错误页面
$this->redirect('/error/index');
}
/**
... ... @@ -157,14 +171,15 @@ class BackController extends WebAction
}
/**
* 手机验证
* 手机验证页面
*/
public function verificationAction() {
$phoneNum = $this->getSession('phoneNum');
$area = $this->getSession('area');
// if(empty($phoneNum)) {
// $this->redirect('index');
// }
$captcha = $this->getSession('captcha');
if(empty($phoneNum)) {
$this->redirect('index');
}
$banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
$data = array(
'simpleHeader' => PassportModel::getSimpleHeader(false),
... ... @@ -174,6 +189,7 @@ class BackController extends WebAction
'coverImg' => $banner['img'],
'phoneNum' => $phoneNum,
'area' => $area,
'captcha'=> $captcha,
'countrys' => array()
)
);
... ... @@ -181,6 +197,32 @@ class BackController extends WebAction
}
/**
* 手机找回密码验证
*/
public function backmobileAction()
{
$mobile = $this->post('mobile');//phoneNum
$area = $this->post('area');
//$captcha = $this->post('captcha');
$code = $this->post('captcha');//code
if($this->getSession('phoneNum') == $mobile && $this->getSession('area') == $area)
{
$result = BackData::validateMobileCode($mobile, $code, $area);
if($result['code'] == 200) {
$str = json_encode(array(
'mobile'=> $mobile,
'area' => $area,
'token'=> $result['data']['token'],
'create_time' => time()
));
$code = AuthCode::encode($str, PassportModel::BACK_FIND_SECRET_KEY);
$url = '/passport/back/backcode?code='.base64_encode($code);
$this->redirect(SITE_MAIN.$url);
}
}
}
/**
* 检查code
*
* @param string $code
... ... @@ -188,9 +230,8 @@ class BackController extends WebAction
*/
private function checkCode($code)
{
$key = '_+@#$%^';
$code = base64_decode($code);
$info = json_decode(AuthCode::decode($code, $key), true);
$info = json_decode(AuthCode::decode($code, PassportModel::BACK_FIND_SECRET_KEY), true);
if ($info['create_time'] < 1 || (time() - $info['create_time']) > 86400) {
return array();
}
... ...
<?php
use Action\AbstractAction;
use Action\WebAction;
use LibModels\Web\Passport\RegData;
use LibModels\Web\Passport\LoginData;
use Passport\PassportModel as PassportModel;
use Plugin\Helpers;
class LoginController extends AbstractAction
class LoginController extends WebAction
{
/**
... ... @@ -23,7 +22,7 @@ class LoginController extends AbstractAction
$this->setCookie('_TOKEN', '');
//登录后跳转页面
$refer = empty($_SERVER["HTTP_REFERER"])?'':$_SERVER["HTTP_REFERER"];
$refer = empty($_SERVER["HTTP_REFERER"]) ? '' : $_SERVER["HTTP_REFERER"];
if (!empty($refer)) {
$this->setCookie('refer', $refer);
}
... ... @@ -40,13 +39,21 @@ class LoginController extends AbstractAction
$simpleHeader = PassportModel::getSimpleHeader($isLogin, $username);
//获取登陆页左侧资源
$cover = PassportModel::getLeftBanner(PassportModel::SIGNIN_LEFT_BANNER_CODE);
//是否记住密码
$isRemember = $this->getCookie('isRemember', FALSE);
$account = '';
$password = '';
if ($isRemember) {
$account = $this->decrypt($this->getCookie('account', ''));
$password = $this->decrypt($this->getCookie('userInfo', ''));
}
//整合
$data = array(
'loginPage' => true,
'simpleHeader' => $simpleHeader,
'passport' => array(
'coverHref' => $cover['url'],
'coverImg' => !empty($cover['img'])?$cover['img']:'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190',
'coverImg' => !empty($cover['img']) ? $cover['img'] : '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(),
... ... @@ -58,6 +65,9 @@ class LoginController extends AbstractAction
'alipayLogin' => Helpers::url('/passport/autosign/alipay'),
'doubanLogin' => Helpers::url('/passport/autosign/douban'),
'renrenLogin' => Helpers::url('/passport/autosign/renren'),
'isRemember' => $isRemember,
'password' => $password,
'account' => $account
),
);
... ... @@ -84,15 +94,17 @@ class LoginController extends AbstractAction
/* 判断参数是否传递 */
$area = trim($this->post('areaCode', '86'));
$profile = trim($this->post('account'));
$account = trim($this->post('account'));
$password = trim($this->post('password'));
if (!is_numeric($area) || empty($profile) || empty($password)) {
$isRemember = trim($this->post('isRemember'));
$isRemember = false;
if (!is_numeric($area) || empty($account) || empty($password)) {
break;
}
/* 判断参数是否有效 */
$verifyEmail = Helpers::verifyEmail($profile);
$verifyMobile = ($area === '86') ? Helpers::verifyMobile($profile) : Helpers::verifyAreaMobile($profile, $area);
$verifyEmail = Helpers::verifyEmail($account);
$verifyMobile = ($area === '86') ? Helpers::verifyMobile($account) : Helpers::verifyAreaMobile($account, $area);
if (!$verifyEmail && !$verifyMobile) {
break;
}
... ... @@ -106,10 +118,21 @@ class LoginController extends AbstractAction
/* 调用登录接口进行登录 */
// 获取未登录时的唯一识别码
$shoppingKey = Helpers::getShoppingKeyByCookie();
$data = LoginData::signin($area, $profile, $password, $shoppingKey);
$data = LoginData::signin($area, $account, $password, $shoppingKey);
if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['uid'])) {
break;
}
//登录成功记录账户信息
if ($isRemember) {
$this->setCookie('account', $this->encrypt($account), time() + 3600 * 24 * 7, '/');
$this->setCookie('userInfo', $this->encrypt($password), time() + 3600 * 24 * 7, '/');
$this->setCookie('isRemember', $isRemember, time() + 3600 * 24 * 7);
}
else {
$this->setCookie('account', '', -1, '/');
$this->setCookie('userInfo', '', -1, '/');
$this->setCookie('isRemember', '', -1, '/');
}
$refer = $this->getCookie('refer');
if (empty($refer)) {
... ... @@ -152,4 +175,60 @@ class LoginController extends AbstractAction
$this->go($refer);
}
/*
* 加密算法
*/
private function encrypt($data, $key='yohobuy')
{
$key = md5($key);
$x = 0;
$str='';
$char='';
$len = strlen($data);
$l = strlen($key);
for ($i = 0; $i < $len; $i++) {
if ($x == $l) {
$x = 0;
}
$char .= $key{$x};
$x++;
}
for ($i = 0; $i < $len; $i++) {
$str .= chr(ord($data{$i}) + (ord($char{$i})) % 256);
}
return base64_encode($str);
}
/*
* 解密算法
*/
private function decrypt($data, $key='yohobuy')
{
$key = md5($key);
$x = 0;
$str='';
$char='';
$data = base64_decode($data);
$len = strlen($data);
$l = strlen($key);
for ($i = 0; $i < $len; $i++) {
if ($x == $l) {
$x = 0;
}
$char .= substr($key, $x, 1);
$x++;
}
for ($i = 0; $i < $len; $i++) {
if (ord(substr($data, $i, 1)) < ord(substr($char, $i, 1))) {
$str .= chr((ord(substr($data, $i, 1)) + 256) - ord(substr($char, $i, 1)));
}
else {
$str .= chr(ord(substr($data, $i, 1)) - ord(substr($char, $i, 1)));
}
}
return $str;
}
}
... ...
... ... @@ -90,7 +90,12 @@ class ListController extends WebAction
$params = array_filter($params);
//每页记录数减1,下一页占位
$params['viewNum'] = $params['viewNum'] - 1;
$data = SearchModel::getSearchData($params,$options);
$list = SearchModel::getSearchData($params,$options);
$data = array(
//初始化js
'productListPage' => true,
'list' => $list
);
$cate = array('boys','girls','kids','lifestyle');
$this->setWebNavHeader($cate[$gender-1]);
$this->_view->display('list', $data);
... ...
... ... @@ -30,8 +30,6 @@ class SearchController extends WebAction
foreach($condition as $key => $val){
$condition[$key] = rawurldecode($val);
}
//关键词
$condition['query'] = '鞋';
//性別(频道)
$gender_cookie = !isset($_COOKIE['_Gender']) ? '3' : ($_COOKIE['_Gender']=='2,3' ? 2 : 1);
$gender = $this->get('gender') ? ($this->get('gender') == '2,3' ? 2 : 1) : $gender_cookie ;
... ... @@ -57,7 +55,7 @@ class SearchController extends WebAction
$minImgSize = array(60, 80);
}
//自定义搜索价格
if (isset($condition['price']) || !empty($condition['price'])) {
if (isset($condition['price']) && !empty($condition['price'])) {
$price = explode(',', $condition['price']);
if (!$price[0]) {
$price[0] = 0;
... ... @@ -90,13 +88,15 @@ class SearchController extends WebAction
$params = array_filter($params);
//每页记录数减1,下一页占位
$params['viewNum'] = $params['viewNum'] - 1;
$options['controller'] = $this->_request->controller;
$searchData = SearchModel::searchData($params,$options);
$cate = array('boys','girls','kids','lifestyle');
$this->setWebNavHeader($cate[$gender-1]);
$data = array(
//初始化js
'searchListPage' => true,
'search' => $searchData
);
$data['search'] = $searchData['list'];
$this->_view->display('search', $data);
}
}
\ No newline at end of file
... ...