Authored by wangqing

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

@@ -4,6 +4,7 @@ namespace LibModels\Web\Product; @@ -4,6 +4,7 @@ namespace LibModels\Web\Product;
4 use Api\Yohobuy; 4 use Api\Yohobuy;
5 class SearchData extends \LibModels\Wap\Product\SearchData 5 class SearchData extends \LibModels\Wap\Product\SearchData
6 { 6 {
  7 + public static $shops_url = 'http://101.200.31.165/yohosearch/shops.json';
7 /** 8 /**
8 * 获取搜索的服务地址 9 * 获取搜索的服务地址
9 * 10 *
@@ -129,6 +130,16 @@ class SearchData extends \LibModels\Wap\Product\SearchData @@ -129,6 +130,16 @@ class SearchData extends \LibModels\Wap\Product\SearchData
129 } 130 }
130 131
131 /** 132 /**
  133 + * 搜索品牌店铺信息
  134 + * @param array $params 参数
  135 + * @return array
  136 + */
  137 + public static function getShop(array $params)
  138 + {
  139 + return Yohobuy::get(self::$shops_url,$params);
  140 + }
  141 +
  142 + /**
132 * 获取最近浏览记录 143 * 获取最近浏览记录
133 * @param int $limit 144 * @param int $limit
134 * @return json 145 * @return json
@@ -13,8 +13,7 @@ class HelperSearch @@ -13,8 +13,7 @@ class HelperSearch
13 */ 13 */
14 public static $params = array(); 14 public static $params = array();
15 15
16 - private static $from = '';  
17 - 16 + public static $options = array();
18 //当前页 17 //当前页
19 public static $page = 1; 18 public static $page = 1;
20 19
@@ -29,19 +28,13 @@ class HelperSearch @@ -29,19 +28,13 @@ class HelperSearch
29 */ 28 */
30 public static $listnav = array(); 29 public static $listnav = array();
31 30
32 -  
33 - private static function setFrom($from = '')  
34 - {  
35 - if ($from) {  
36 - self::$from = $from;  
37 - }  
38 - }  
39 //设置导航 31 //设置导航
40 - private static function setListNav($option = array()) 32 + private static function setListNav()
41 { 33 {
  34 + $options = self::$options;
42 $cookieChannel = isset($_COOKIE['_Channel']) ? $_COOKIE['_Channel'] : 'boys'; 35 $cookieChannel = isset($_COOKIE['_Channel']) ? $_COOKIE['_Channel'] : 'boys';
43 - if (isset($option['brandName']) && !empty($option['brandName'])) {  
44 - $initNav = $option['brandName']; 36 + if (isset($options['brandName']) && !empty($options['brandName'])) {
  37 + $initNav = $options['brandName'];
45 }else{ 38 }else{
46 $initNav = '列表'; 39 $initNav = '列表';
47 } 40 }
@@ -64,6 +57,7 @@ class HelperSearch @@ -64,6 +57,7 @@ class HelperSearch
64 { 57 {
65 $result = array(); 58 $result = array();
66 self::$params = $_GET; 59 self::$params = $_GET;
  60 + self::$options = $options;
67 unset(self::$params['/']); 61 unset(self::$params['/']);
68 unset(self::$params['page']); 62 unset(self::$params['page']);
69 unset(self::$params['/sale']); 63 unset(self::$params['/sale']);
@@ -80,10 +74,8 @@ class HelperSearch @@ -80,10 +74,8 @@ class HelperSearch
80 $result['filters']['checkedConditions']['clearUrl'] = self::current(); 74 $result['filters']['checkedConditions']['clearUrl'] = self::current();
81 //频道 75 //频道
82 $result['filters']['channel'] = self::gender($filter); 76 $result['filters']['channel'] = self::gender($filter);
83 - //分类  
84 - $result['filters']['sort'] = array();  
85 //品牌 77 //品牌
86 - $result['filters']['brand'] = self::brand($filter, $options); 78 + $result['filters']['brand'] = self::brand($filter);
87 //价格 79 //价格
88 $result['filters']['price'] = self::price($filter); 80 $result['filters']['price'] = self::price($filter);
89 $result['filters']['customPrice'] = self::customPrice($filter); 81 $result['filters']['customPrice'] = self::customPrice($filter);
@@ -109,8 +101,10 @@ class HelperSearch @@ -109,8 +101,10 @@ class HelperSearch
109 $result['opts']['pageCount'] = $data['data']['page_total']; 101 $result['opts']['pageCount'] = $data['data']['page_total'];
110 $result['opts']['nextHref'] = ($next = self::next($data['data']['page_total'],$data['data']['filter'])) ? $next['href'] : ''; 102 $result['opts']['nextHref'] = ($next = self::next($data['data']['page_total'],$data['data']['filter'])) ? $next['href'] : '';
111 $result['hasNextPage'] = self::next($data['data']['page_total']); 103 $result['hasNextPage'] = self::next($data['data']['page_total']);
112 - //分类  
113 - $result['leftContent'][]['allSort'] = isset($filter['group_sort']) ? self::groupSort($filter['group_sort'], $options) : array(); 104 + //分类条件
  105 + $result['filters']['sort'] = isset($filter['group_sort']) ? self::searchSort($filter['group_sort']) : array();
  106 + //左侧分类分类
  107 + $result['leftContent'][]['allSort'] = isset($filter['group_sort']) ? self::groupSort($filter['group_sort']) : array();
114 //一周新品上架 108 //一周新品上架
115 $result['leftContent'][]['newSales'] = isset($filter['recent']) ? self::recentShelve($filter['recent']) : array(); 109 $result['leftContent'][]['newSales'] = isset($filter['recent']) ? self::recentShelve($filter['recent']) : array();
116 //全部折扣 110 //全部折扣
@@ -121,6 +115,9 @@ class HelperSearch @@ -121,6 +115,9 @@ class HelperSearch
121 $result['pager'] = self::pager($result['totalCount'],$options['viewNum']); 115 $result['pager'] = self::pager($result['totalCount'],$options['viewNum']);
122 //选中条件 116 //选中条件
123 $result['filters']['checkedConditions']['conditions'] = self::getSelected(); 117 $result['filters']['checkedConditions']['conditions'] = self::getSelected();
  118 + if (isset($options['controller']) && $options['controller'] == 'Search') {
  119 + self::setSearchNav($data['data']['total']);
  120 + }
124 $result['pathNav'] = self::$listnav; 121 $result['pathNav'] = self::$listnav;
125 return $result; 122 return $result;
126 } 123 }
@@ -193,6 +190,9 @@ class HelperSearch @@ -193,6 +190,9 @@ class HelperSearch
193 'name' => $pval['standard_name'], 190 'name' => $pval['standard_name'],
194 'href' => self::buildUrl($tmpParams) 191 'href' => self::buildUrl($tmpParams)
195 ); 192 );
  193 + if (self::checkSearch('parameter_' . $val['standard_id'])) {
  194 + return array();
  195 + }
196 } 196 }
197 $sub[] = array( 197 $sub[] = array(
198 'name' => $pval['standard_name'], 198 'name' => $pval['standard_name'],
@@ -232,6 +232,10 @@ class HelperSearch @@ -232,6 +232,10 @@ class HelperSearch
232 'href' => self::buildUrl($params) 232 'href' => self::buildUrl($params)
233 ); 233 );
234 } 234 }
  235 +
  236 + if (self::checkSearch('gender')) {
  237 + return array();
  238 + }
235 $result = array(); 239 $result = array();
236 foreach ($filter['gender'] as $key => $val) { 240 foreach ($filter['gender'] as $key => $val) {
237 $result[] = array( 241 $result[] = array(
@@ -247,14 +251,18 @@ class HelperSearch @@ -247,14 +251,18 @@ class HelperSearch
247 /** 251 /**
248 * 组织搜索列表页面的左侧分类 252 * 组织搜索列表页面的左侧分类
249 * @param array $sort 253 * @param array $sort
250 - * @param array $option  
251 * @return array 254 * @return array
252 */ 255 */
253 256
254 - public static function groupSort($sort, $option = array()) 257 + public static function groupSort($sort)
255 { 258 {
  259 +
  260 + $options = self::$options;
  261 + if (isset($options['controller']) && $options['controller'] != 'Search') {
  262 + return array();
  263 + }
256 //设置导航 264 //设置导航
257 - self::setListNav($option); 265 + self::setListNav($options);
258 $params = self::$params; 266 $params = self::$params;
259 $result = array( 267 $result = array(
260 'all' => array( 268 'all' => array(
@@ -294,16 +302,48 @@ class HelperSearch @@ -294,16 +302,48 @@ class HelperSearch
294 } 302 }
295 } 303 }
296 $result['list'] = $sortList; 304 $result['list'] = $sortList;
  305 +
297 return $result; 306 return $result;
298 } 307 }
299 308
  309 + public static function searchSort($sort)
  310 + {
  311 + $result = array();
  312 + $options = self::$options;
  313 + if (!isset($options['controller']) || $options['controller'] != 'Search') {
  314 + return $result;
  315 + }
  316 + $params = self::$params;
  317 + foreach ($sort as $key => $val) {
  318 + $result[$key]['id'] = $val['sort_id'];
  319 + $result[$key]['name'] = $val['sort_name'];
  320 + if (isset($val['sub']) && !empty($val['sub'])) {
  321 + foreach ($val['sub'] as $k => $v) {
  322 + $result[$key]['sub'][$k]['href'] = self::buildUrl(array('msort' => $val['sort_id'], 'misort' => $v['sort_id']));
  323 + $result[$key]['sub'][$k]['name'] = $v['sort_name'];
  324 + if (isset($params['misort']) && $params['misort'] == $v['sort_id']) {
  325 + unset($params['misort']);
  326 + self::$selected['sort'] = array(
  327 + 'name' => $v['sort_name'],
  328 + 'href' => self::buildUrl()
  329 + );
  330 + }
  331 +
  332 + }
  333 + }
  334 + }
  335 + if (self::checkSearch('msrot') || self::checkSearch('misort')) {
  336 + return array();
  337 + }
  338 + return $result;
  339 + }
300 /** 340 /**
301 * 品牌,可以多选 341 * 品牌,可以多选
302 * @param array $filter 342 * @param array $filter
303 - * @param array $options  
304 * @return array 343 * @return array
305 */ 344 */
306 - public static function brand($filter, $options = array()) { 345 + public static function brand($filter) {
  346 + $options = self::$options;
307 //品牌列表返回空 347 //品牌列表返回空
308 if (isset($options['brandName'])) { 348 if (isset($options['brandName'])) {
309 return array(); 349 return array();
@@ -311,11 +351,15 @@ class HelperSearch @@ -311,11 +351,15 @@ class HelperSearch
311 $result = array( 351 $result = array(
312 'default' => array() , 352 'default' => array() ,
313 'brandIndex' => array( 353 'brandIndex' => array(
314 - '0~9',  
315 - 'A~G',  
316 - 'H~N',  
317 - 'O~T',  
318 - 'U~Z') , 354 + array(
  355 + 'index' => 'all',
  356 + 'name' => '全部'
  357 + ),
  358 + array(
  359 + 'index' => '0-9',
  360 + 'name' => '0 ~ 9'
  361 + )
  362 + ),
319 'brandsShow' => array() 363 'brandsShow' => array()
320 ); 364 );
321 $params = self::$params; 365 $params = self::$params;
@@ -341,12 +385,18 @@ class HelperSearch @@ -341,12 +385,18 @@ class HelperSearch
341 ))); 385 )));
342 } 386 }
343 $this_brand = array( 387 $this_brand = array(
344 - 'brand_id' => $v['id'],  
345 - 'name' => $v['brand_name'],  
346 - 'alif' => $v['brand_alif'], 388 + 'id' => $v['id'],
347 'href' => $url, 389 'href' => $url,
  390 + 'name' => $v['brand_name'],
  391 + 'key' => $v['brand_name'],
348 'active' => in_array($v['id'], $brandIds) ? true : false 392 'active' => in_array($v['id'], $brandIds) ? true : false
349 ); 393 );
  394 + if (is_numeric($v['brand_alif'])) {
  395 + $this_brand['index'] = '0-9';
  396 + }
  397 + else {
  398 + $this_brand['index'] = strtolower($v['brand_alif']);
  399 + }
350 //默认品牌 400 //默认品牌
351 if (count($result['default']) < 10) { 401 if (count($result['default']) < 10) {
352 $result['default'][] = $this_brand; 402 $result['default'][] = $this_brand;
@@ -367,9 +417,16 @@ class HelperSearch @@ -367,9 +417,16 @@ class HelperSearch
367 'href' => self::buildUrl($params) 417 'href' => self::buildUrl($params)
368 ); 418 );
369 } 419 }
370 - //品牌列表排序  
371 ksort($brandList); 420 ksort($brandList);
  421 + //品牌列表排序, 添加品牌索引
  422 + $index_key = array();
372 foreach ($brandList as $key => $val) { 423 foreach ($brandList as $key => $val) {
  424 + if ($key && !in_array($key, $index_key)) {
  425 + $index['index'] = strtolower(($key));
  426 + $index['name'] = $key;
  427 + $result['brandIndex'][] = $index;
  428 + $index_key[] = $index;
  429 + }
373 if (is_array($val)) { 430 if (is_array($val)) {
374 foreach ($val as $v) { 431 foreach ($val as $v) {
375 $result['brandsShow'][] = $v; 432 $result['brandsShow'][] = $v;
@@ -378,6 +435,10 @@ class HelperSearch @@ -378,6 +435,10 @@ class HelperSearch
378 } 435 }
379 unset($brandList); 436 unset($brandList);
380 } 437 }
  438 + //搜索页已选中,返回空
  439 + if (self::checkSearch('brand')) {
  440 + return array();
  441 + }
381 return $result; 442 return $result;
382 } 443 }
383 /** 444 /**
@@ -402,6 +463,7 @@ class HelperSearch @@ -402,6 +463,7 @@ class HelperSearch
402 'href' => self::buildUrl($params) 463 'href' => self::buildUrl($params)
403 ); 464 );
404 } 465 }
  466 +
405 $result[] = array( 467 $result[] = array(
406 'name' => $v['size_name'], 468 'name' => $v['size_name'],
407 'href' => self::buildUrl(array_merge($params, array( 469 'href' => self::buildUrl(array_merge($params, array(
@@ -409,6 +471,9 @@ class HelperSearch @@ -409,6 +471,9 @@ class HelperSearch
409 ))) , 471 ))) ,
410 ); 472 );
411 } 473 }
  474 + if (self::checkSearch('size')) {
  475 + return array();
  476 + }
412 } 477 }
413 return $result; 478 return $result;
414 } 479 }
@@ -443,6 +508,9 @@ class HelperSearch @@ -443,6 +508,9 @@ class HelperSearch
443 ))) , 508 ))) ,
444 ); 509 );
445 } 510 }
  511 + if (self::checkSearch('color')) {
  512 + return array();
  513 + }
446 return $result; 514 return $result;
447 } 515 }
448 516
@@ -474,6 +542,9 @@ class HelperSearch @@ -474,6 +542,9 @@ class HelperSearch
474 ); 542 );
475 } 543 }
476 } 544 }
  545 + if (self::checkSearch('price')) {
  546 + return array();
  547 + }
477 //返回价格条件 548 //返回价格条件
478 foreach ($filter['price'] as $key => $val) { 549 foreach ($filter['price'] as $key => $val) {
479 $val = trim($val,'¥'); 550 $val = trim($val,'¥');
@@ -556,6 +627,10 @@ class HelperSearch @@ -556,6 +627,10 @@ class HelperSearch
556 'href' => $url, 627 'href' => $url,
557 ); 628 );
558 } 629 }
  630 + //搜索页已选中,返回空
  631 + if (self::checkSearch('style')) {
  632 + return array();
  633 + }
559 $data[0] = array( 634 $data[0] = array(
560 'attr' => 'style', 635 'attr' => 'style',
561 'name' => '风格', 636 'name' => '风格',
@@ -942,7 +1017,13 @@ class HelperSearch @@ -942,7 +1017,13 @@ class HelperSearch
942 } 1017 }
943 return $result; 1018 return $result;
944 } 1019 }
945 - //分页 1020 +
  1021 + /**
  1022 + * 分页
  1023 + * @param $total
  1024 + * @param $viewNum
  1025 + * @return mixed
  1026 + */
946 public static function pager($total,$viewNum){ 1027 public static function pager($total,$viewNum){
947 $Paging = new Paging('Yoho'); 1028 $Paging = new Paging('Yoho');
948 return $Paging->setTotal($total)->setSize($viewNum)->view(0); 1029 return $Paging->setTotal($total)->setSize($viewNum)->view(0);
@@ -968,4 +1049,67 @@ class HelperSearch @@ -968,4 +1049,67 @@ class HelperSearch
968 return $result; 1049 return $result;
969 } 1050 }
970 } 1051 }
  1052 +
  1053 + /**
  1054 + * 组织品牌店铺信息
  1055 + */
  1056 + public static function shop($shop)
  1057 + {
  1058 + $url = Helpers::url('','',$shop['brand_domain']);
  1059 + $shopEntry = array();
  1060 + $sort = array();
  1061 + foreach ($shop['sort'] as $msort) {
  1062 + if (!isset($msort['sub']) || empty($msort['sub'])) {
  1063 + continue;
  1064 + }
  1065 + foreach ($msort['sub'] as $mkey=>$misort) {
  1066 + if (count($sort) >= 10) {
  1067 + break 2;
  1068 + }
  1069 + $sortInfo['href'] = $url.'/?msort=' . $msort['sort_id'] . '&misort=' . $misort['sort_id'];
  1070 + $sortInfo['name'] = $misort['sort_name'];
  1071 + $sort[] = $sortInfo;
  1072 + }
  1073 +
  1074 + }
  1075 + $shopEntry['home'] = $url;
  1076 + $shopEntry['logo'] = Images::getSourceUrl($shop['brand_ico'],'brandLogo');
  1077 + $shopEntry['shopName'] = $shop['brand_name'];
  1078 + $shopEntry['sort'] = $sort;
  1079 + return $shopEntry;
  1080 + }
  1081 +
  1082 + public static function checkSearch($param)
  1083 + {
  1084 + if (isset(self::$params[$param]) && isset(self::$options['controller']) && self::$options['controller'] == 'Search') {
  1085 + return true;
  1086 + }
  1087 +
  1088 + }
  1089 +
  1090 + /**
  1091 + * 设置搜索页导航
  1092 + * @param $total
  1093 + */
  1094 + public static function setSearchNav($total)
  1095 + {
  1096 + self::$listnav[0] = array(
  1097 + 'href' => '/',
  1098 + 'name' => '首页'
  1099 + );
  1100 + $param = self::$params;
  1101 + $options = self::$options;
  1102 + if (isset($options['controller']) && $options['controller'] == 'Search' && isset($param['query'])) {
  1103 + self::$listnav[1] = array(
  1104 + 'href' => '',
  1105 + 'name' => "".$param['query']." ".$total."个结果"
  1106 + );
  1107 + }else{
  1108 + self::$listnav[1] = array(
  1109 + 'href' => '',
  1110 + 'name' => '所有商品'
  1111 + );
  1112 + }
  1113 +
  1114 + }
971 } 1115 }
@@ -30,7 +30,7 @@ @@ -30,7 +30,7 @@
30 </span> 30 </span>
31 </li> 31 </li>
32 <li class="input-container-li clearfix"> 32 <li class="input-container-li clearfix">
33 - <input type="hidden" name="code" value="159bI6arxsuaPBxG2iV9OE9BrgDnAPiTecUqYh2iUC3ntt6S0eOtxXpVu+jWIlveXx9NRuwS9zdrXzcUyOd+d3ikzYBAo0k"> 33 + <input type="hidden" name="code" value="{{code}}">
34 <input id="reset-pwd-btn" class="btn reset-pwd-btn" type="submit" value="提交" disabled=""> 34 <input id="reset-pwd-btn" class="btn reset-pwd-btn" type="submit" value="提交" disabled="">
35 </li> 35 </li>
36 </ul> 36 </ul>
1 -{{> layout/simple-header}}  
2 -<div class="verification-page back-page passport-page yoho-page clearfix">  
3 -{{# verification}}  
4 - {{> passport/cover}}  
5 - <div class="content">  
6 - <form id="verification-form" class="verification-form" method="POST" action="/passport/back/backmobile">  
7 - <ul>  
8 - <li class="head-title">验证身份</li>  
9 - <li class="po-re">  
10 - <label class="pn-label">手机号码</label>  
11 - <span class="country-code">+{{area}}</span>  
12 - <span class="phone-num">{{phoneNum}}</span>  
13 - </li>  
14 - <li class="po-re">  
15 - <input id="captcha" class="input va captcha" type="text" name="captcha">  
16 - <input id="send-captcha" class="btn send-captcha" type="button" value="发送验证码" disabled="">  
17 - <div id="captcha-tip" class="captcha-tips"><i class="iconfont">&#xe61f;</i>验证码已发送至您的手机,请查收</div>  
18 - <span id="err-tip" class="err-tip hide">  
19 - <i></i>  
20 - <em>请输入验证码</em>  
21 - </span>  
22 - </li>  
23 - <li>  
24 - <input name="area" id="area" type="hidden" value="{{area}}">  
25 - <input name="mobile" id="mobile" type="hidden" value="{{phoneNum}}">  
26 - <input name="captchaPic" id="captchaPic" type="hidden" value="g7ce">  
27 - <input name="refer" id="refer" type="hidden" value="">  
28 - <input id="next-step" class="btn next-step disable" type="submit" value="下一步" disabled="">  
29 - </li>  
30 - </ul>  
31 - </form>  
32 - </div>  
33 -{{/ verification}}  
34 -</div> 1 +{{> layout/simple-header}}
  2 +<div class="verification-page back-page passport-page yoho-page clearfix">
  3 +{{# verification}}
  4 + {{> passport/cover}}
  5 + <div class="content">
  6 + <form id="verification-form" class="verification-form" method="POST" action="/passport/back/backmobile">
  7 + <ul>
  8 + <li class="head-title">验证身份</li>
  9 + <li class="po-re">
  10 + <label class="pn-label">手机号码</label>
  11 + <span class="country-code">+{{area}}</span>
  12 + <span class="phone-num">{{phoneNum}}</span>
  13 + </li>
  14 + <li class="po-re">
  15 + <input id="captcha" class="input va captcha" type="text" name="captcha">
  16 + <input id="send-captcha" class="btn send-captcha" type="button" value="发送验证码" disabled="">
  17 + <div id="captcha-tip" class="captcha-tips"><i class="iconfont">&#xe61f;</i>验证码已发送至您的手机,请查收</div>
  18 + <span id="err-tip" class="err-tip hide">
  19 + <i></i>
  20 + <em>请输入验证码</em>
  21 + </span>
  22 + </li>
  23 + <li>
  24 + <input name="area" id="area" type="hidden" value="{{area}}">
  25 + <input name="mobile" id="mobile" type="hidden" value="{{phoneNum}}">
  26 + <input name="captchaPic" id="captchaPic" type="hidden" value="{{captcha}}">
  27 + <input name="refer" id="refer" type="hidden" value="">
  28 + <input id="next-step" class="btn next-step disable" type="submit" value="下一步" disabled="">
  29 + </li>
  30 + </ul>
  31 + </form>
  32 + </div>
  33 +{{/ verification}}
  34 +</div>
35 {{> layout/footer}} 35 {{> layout/footer}}
@@ -36,7 +36,7 @@ @@ -36,7 +36,7 @@
36 <span id="login-btn" class="login-btn btn">登录</span> 36 <span id="login-btn" class="login-btn btn">登录</span>
37 </li> 37 </li>
38 <li class="other-opts"> 38 <li class="other-opts">
39 - <span class="remeber-me"> 39 + <span class="remember-me">
40 <i class="iconfont">&#xe613;</i> 40 <i class="iconfont">&#xe613;</i>
41 记住登录状态 41 记住登录状态
42 </span> 42 </span>
1 {{> layout/header}} 1 {{> layout/header}}
2 <div class="product-search-page product-page yoho-page center-content"> 2 <div class="product-search-page product-page yoho-page center-content">
3 {{# search}} 3 {{# search}}
4 - {{> layout/path-nav}} 4 + {{> layout/path-nav}}
5 5
6 - {{> product/standard-content}} 6 + {{> product/shop-entry}}
7 7
8 - {{> product/latest-walk}} 8 + {{> product/standard-content}}
  9 +
  10 + {{> product/latest-walk}}
9 {{/ search}} 11 {{/ search}}
10 </div> 12 </div>
11 -{{> layout/footer}}  
  13 +{{> layout/footer}}
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 <li class="clearfix"> 4 <li class="clearfix">
5 <select id="region" class="region" name="region"> 5 <select id="region" class="region" name="region">
6 {{#each region}} 6 {{#each region}}
7 - <option {{#if selected}}selected="selected"{{/if}} value="{{id}}">{{name}}</option> 7 + <option {{#if selected}}selected="selected"{{/if}} value="{{areaCode}}">{{name}}</option>
8 {{/each}} 8 {{/each}}
9 </select> 9 </select>
10 </li> 10 </li>
@@ -108,7 +108,7 @@ function getShoppingKey() { @@ -108,7 +108,7 @@ function getShoppingKey() {
108 a.async = 1; 108 a.async = 1;
109 a.src = j; 109 a.src = j;
110 m.parentNode.insertBefore(a, m); 110 m.parentNode.insertBefore(a, m);
111 -})(window, document, 'script', 'http://cdn.yoho.cn/yas-jssdk/1.0.13.6.3/yas.js', '_yas'); 111 +})(window, document, 'script', 'http://cdn.yoho.cn/yas-jssdk/1.0.14/yas.js', '_yas');
112 112
113 (function() { 113 (function() {
114 var uid = getUid(); 114 var uid = getUid();
@@ -118,7 +118,7 @@ function getShoppingKey() { @@ -118,7 +118,7 @@ function getShoppingKey() {
118 window._ozuid = uid;//暴露ozuid 118 window._ozuid = uid;//暴露ozuid
119 119
120 if (window._yas) { 120 if (window._yas) {
121 - window._yas(1 * new Date(), '1.0.13.6.3', 'yohobuy_web', uid, '', ''); 121 + window._yas(1 * new Date(), '1.0.14', 'yohobuy_web', uid, '', '');
122 } 122 }
123 }()); 123 }());
124 124
@@ -132,4 +132,4 @@ window.getUid = getUid; @@ -132,4 +132,4 @@ window.getUid = getUid;
132 132
133 window.getShoppingKey = getShoppingKey; 133 window.getShoppingKey = getShoppingKey;
134 134
135 -require('./header');  
  135 +require('./header');
@@ -25,6 +25,8 @@ var $emailAutoComplete = $('#email-autocomplete'); @@ -25,6 +25,8 @@ var $emailAutoComplete = $('#email-autocomplete');
25 25
26 var mailPhoneRegx = require('./mail-phone-regx'); 26 var mailPhoneRegx = require('./mail-phone-regx');
27 27
  28 +var $remember = $('.remember-me');
  29 +
28 //checkbox status unicode 30 //checkbox status unicode
29 var checkbox = { 31 var checkbox = {
30 checked: '&#xe612;', 32 checked: '&#xe612;',
@@ -232,7 +234,7 @@ $emailAutoComplete.on('click', 'li', function() { @@ -232,7 +234,7 @@ $emailAutoComplete.on('click', 'li', function() {
232 }); 234 });
233 235
234 //记住登录状态 236 //记住登录状态
235 -$('.remeber-me').on('click', function() { 237 +$remember.on('click', function() {
236 var $this = $(this); 238 var $this = $(this);
237 239
238 $this.toggleClass('checked'); 240 $this.toggleClass('checked');
@@ -266,15 +268,19 @@ $('#login-btn').on('click', function() { @@ -266,15 +268,19 @@ $('#login-btn').on('click', function() {
266 data: { 268 data: {
267 areaCode: $countryCodeHide.val().replace('+', ''), 269 areaCode: $countryCodeHide.val().replace('+', ''),
268 account: $.trim($account.val()), 270 account: $.trim($account.val()),
269 - password: $.trim($password.val()) 271 + password: $.trim($password.val()),
  272 + isRemember: $remember.hasClass('checked') ? true : false
270 }, 273 },
271 success: function(data) { 274 success: function(data) {
272 - if (data.code === 400) { 275 + if (data.code === 200) {
  276 + if (data.data) {
  277 +
  278 + //防止data.data为undefined时下行语句执行出错而导致脚本不能走到complete去处理authing
  279 + location.href = data.data.href;
  280 + }
  281 + } else {
273 $passwordTip.removeClass('hide').children('em').text(data.message); 282 $passwordTip.removeClass('hide').children('em').text(data.message);
274 $password.addClass('error'); 283 $password.addClass('error');
275 - return;  
276 - } else {  
277 - location.href = data.data.href;  
278 } 284 }
279 }, 285 },
280 complete: function() { 286 complete: function() {
@@ -136,9 +136,10 @@ function picCaptchaAjaxFn(page, callback) { @@ -136,9 +136,10 @@ function picCaptchaAjaxFn(page, callback) {
136 type: 'POST', 136 type: 'POST',
137 url: url, 137 url: url,
138 data: { 138 data: {
139 - code: $ca.val(),  
140 - mobile: $pn.val(),  
141 - area: $region.text().split('+')[1] 139 + code: $ca.val()
  140 +
  141 + //mobile: $pn.val(),
  142 + //area: $region.text().split('+')[1]
142 } 143 }
143 }).then(function(data) { 144 }).then(function(data) {
144 switch (data.code) { 145 switch (data.code) {
@@ -530,7 +531,7 @@ exports.init = function(page) { @@ -530,7 +531,7 @@ exports.init = function(page) {
530 data: { 531 data: {
531 area: $region.text().split('+')[1], 532 area: $region.text().split('+')[1],
532 mobile: $pn.val(), 533 mobile: $pn.val(),
533 - captcha: $ca.val(), 534 + verifyCode: $ca.val(),
534 code: $mc.val(), 535 code: $mc.val(),
535 password: $pwd.val() 536 password: $pwd.val()
536 } 537 }
@@ -60,7 +60,7 @@ $third: sprite-map("passport/third/*.png"); @@ -60,7 +60,7 @@ $third: sprite-map("passport/third/*.png");
60 } 60 }
61 } 61 }
62 62
63 - .remeber-me { 63 + .remember-me {
64 cursor: pointer; 64 cursor: pointer;
65 } 65 }
66 66
@@ -73,7 +73,7 @@ class Bootstrap extends Bootstrap_Abstract @@ -73,7 +73,7 @@ class Bootstrap extends Bootstrap_Abstract
73 $action = 'Index'; 73 $action = 'Index';
74 74
75 // 二级域名 75 // 二级域名
76 - if (3 === $level) { 76 + if (2 === $level) {
77 $subDomain = strval($hostParts[0]); 77 $subDomain = strval($hostParts[0]);
78 switch (strtolower($subDomain)) { 78 switch (strtolower($subDomain)) {
79 case 'www': // 主站 79 case 'www': // 主站
@@ -90,6 +90,10 @@ class Bootstrap extends Bootstrap_Abstract @@ -90,6 +90,10 @@ class Bootstrap extends Bootstrap_Abstract
90 case 'list': // 商品列表 90 case 'list': // 商品列表
91 $module = 'Product'; 91 $module = 'Product';
92 break; 92 break;
  93 + case 'sale'://促销
  94 + $module = 'Product';
  95 + $controller = 'sale';
  96 +
93 default: // 其它(识别为品牌) 97 default: // 其它(识别为品牌)
94 $module = 'Product'; 98 $module = 'Product';
95 $action = 'Brand'; 99 $action = 'Brand';
@@ -24,6 +24,7 @@ class PassportModel @@ -24,6 +24,7 @@ class PassportModel
24 const BACK_LFFT_BANNER_CODE = '3bbaf502c447a2ddad60879042e286d8';//找回密码左边的banner 24 const BACK_LFFT_BANNER_CODE = '3bbaf502c447a2ddad60879042e286d8';//找回密码左边的banner
25 const SIGNIN_LEFT_BANNER_CODE ='db350894e01e90eac55cd3a13ad77331';//登录页左边的banner 25 const SIGNIN_LEFT_BANNER_CODE ='db350894e01e90eac55cd3a13ad77331';//登录页左边的banner
26 const AUTOUSERINFO_LEFT_BANNER_CODE ='c62d5da06d843b6ed78d8d27e87fa143';//完善信息页左边的banner 26 const AUTOUSERINFO_LEFT_BANNER_CODE ='c62d5da06d843b6ed78d8d27e87fa143';//完善信息页左边的banner
  27 + const BACK_FIND_SECRET_KEY = '_+@#$%^';
27 28
28 //简单头部 29 //简单头部
29 public static function getSimpleHeader($isLogin, $username = '') 30 public static function getSimpleHeader($isLogin, $username = '')
@@ -75,6 +76,11 @@ class PassportModel @@ -75,6 +76,11 @@ class PassportModel
75 $ret['img'] = Images::getImageUrl($val['src'], 252, 190); 76 $ret['img'] = Images::getImageUrl($val['src'], 252, 190);
76 $ret['url'] = $val['url']; 77 $ret['url'] = $val['url'];
77 } 78 }
  79 + else
  80 + {
  81 + $ret['img'] = 'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190';
  82 + $ret['url'] = '';
  83 + }
78 return $ret; 84 return $ret;
79 } 85 }
80 86
@@ -49,12 +49,7 @@ class SearchModel @@ -49,12 +49,7 @@ class SearchModel
49 //用户浏览记录 49 //用户浏览记录
50 $result['data']['filter']['review'] = SearchData::getRecentReview(); 50 $result['data']['filter']['review'] = SearchData::getRecentReview();
51 // 组织模板数据 51 // 组织模板数据
52 - $list = HelperSearch::getList($result, $options);  
53 - $data = array(  
54 - //初始化js  
55 - 'productListPage' => true,  
56 - 'list' => $list  
57 - ); 52 + $data = HelperSearch::getList($result, $options);
58 } 53 }
59 return $data; 54 return $data;
60 } 55 }
@@ -67,31 +62,21 @@ class SearchModel @@ -67,31 +62,21 @@ class SearchModel
67 */ 62 */
68 public static function searchData($condition, $options){ 63 public static function searchData($condition, $options){
69 $data = self::getSearchData($condition, $options); 64 $data = self::getSearchData($condition, $options);
70 - //过滤频道  
71 - if (isset($condition['gender'])) {  
72 - unset($data['list']['filters']['channel']);  
73 - }  
74 - //过滤品牌  
75 - if (isset($condition['brand'])) {  
76 - unset($data['list']['filters']['brand']);  
77 - }  
78 - //过滤价格  
79 - if (isset($condition['price'])) {  
80 - unset($data['list']['filters']['price']);  
81 - unset($data['list']['filters']['customPrice']);  
82 - }  
83 - //过滤颜色  
84 - if (isset($condition['color'])) {  
85 - unset($data['list']['filters']['color']);  
86 - }  
87 - //过滤风格  
88 - if (isset($condition['style'])) {  
89 - unset($data['list']['filters']['seniorChose']);  
90 - }  
91 - //过滤尺码  
92 - if (isset($condition['size'])) {  
93 - unset($data['list']['filters']['size']); 65 + //获取品牌店铺信息
  66 + if (isset($condition['query'])) {
  67 + $param['keyword'] = $condition['query'];
  68 + $result = SearchData::getShop($param);
  69 + if (isset($result['code']) && $result['code'] === 200 && isset($result['data']) && !empty($result['data'])) {
  70 + //调用品牌分类
  71 + $class['brand'] = $result['data']['id'];
  72 + $brandSort = SearchData::getClassesData($class);
  73 + $shop = $result['data'];
  74 + if (isset($brandSort['data']['sort']) && !empty($brandSort['data']['sort']))
  75 + $shop['sort'] = $brandSort['data']['sort'];
  76 + $shopEntry = HelperSearch::shop($shop);
  77 + }
94 } 78 }
  79 + $data['shopEntry'] = isset($shopEntry) ? $shopEntry : array();
95 return $data; 80 return $data;
96 81
97 } 82 }
@@ -56,6 +56,7 @@ class BackController extends WebAction @@ -56,6 +56,7 @@ class BackController extends WebAction
56 $data = BackData::sendCodeToMobile($mobile); 56 $data = BackData::sendCodeToMobile($mobile);
57 $this->setSession('phoneNum', $phoneNum); 57 $this->setSession('phoneNum', $phoneNum);
58 $this->setSession('area', $area); 58 $this->setSession('area', $area);
  59 + $this->setSession('captcha', $captcha);
59 if($data['code'] == 200) { 60 if($data['code'] == 200) {
60 $this->redirect('verification'); 61 $this->redirect('verification');
61 } 62 }
@@ -66,7 +67,7 @@ class BackController extends WebAction @@ -66,7 +67,7 @@ class BackController extends WebAction
66 } 67 }
67 68
68 /** 69 /**
69 - * 发送邮件 70 + * 发送邮件页面
70 */ 71 */
71 public function sendemailAction() { 72 public function sendemailAction() {
72 $phoneNum = $this->getSession('phoneNum'); 73 $phoneNum = $this->getSession('phoneNum');
@@ -96,14 +97,14 @@ class BackController extends WebAction @@ -96,14 +97,14 @@ class BackController extends WebAction
96 'sendEmail' => array( 97 'sendEmail' => array(
97 'coverHref' => $banner['url'], 98 'coverHref' => $banner['url'],
98 'coverImg' => $banner['img'], 99 'coverImg' => $banner['img'],
99 - 'countrys' => array() 100 + 'countrys' => array(),
100 ) 101 )
101 ); 102 );
102 $this->_view->display('send-email', $data); 103 $this->_view->display('send-email', $data);
103 } 104 }
104 105
105 /** 106 /**
106 - * 重置密码 107 + * 重置密码页面
107 */ 108 */
108 public function backcodeAction() { 109 public function backcodeAction() {
109 $code = $this->get('code'); 110 $code = $this->get('code');
@@ -118,14 +119,15 @@ class BackController extends WebAction @@ -118,14 +119,15 @@ class BackController extends WebAction
118 'resetPwd' => array( 119 'resetPwd' => array(
119 'coverHref' => $banner['url'], 120 'coverHref' => $banner['url'],
120 'coverImg' => $banner['img'], 121 'coverImg' => $banner['img'],
121 - 'countrys' => array() 122 + 'countrys' => array(),
  123 + 'code' => $code,
122 ) 124 )
123 ); 125 );
124 $this->_view->display('reset-pwd', $data); 126 $this->_view->display('reset-pwd', $data);
125 } 127 }
126 128
127 /** 129 /**
128 - * 更新密码 130 + * 更新密码接口
129 * 131 *
130 */ 132 */
131 public function updateAction() 133 public function updateAction()
@@ -134,10 +136,22 @@ class BackController extends WebAction @@ -134,10 +136,22 @@ class BackController extends WebAction
134 $password = $this->post('pwd'); 136 $password = $this->post('pwd');
135 $info = $this->checkCode($code); 137 $info = $this->checkCode($code);
136 if(Helpers::verifyPassword($password) && !empty($info)) { 138 if(Helpers::verifyPassword($password) && !empty($info)) {
137 - $uid = $info['uid'];  
138 //修改密码 139 //修改密码
  140 + if(isset($info['mobile'])) {//手机号修改密码
  141 + $mobile = $info['mobile'];
  142 + $token = $info['token'];
  143 + $area = $info['area'];
  144 + $data = BackData::modifyPasswordByMobile($mobile, $token, $password, $area);
  145 + if($data['code']) {
  146 + $this->redirect('resetSuccess');
  147 + }
  148 + } else if(isset($info['uid'])) {//其他方式修改密码
  149 + $uid = $info['uid'];
  150 + $this->redirect('resetSuccess');
  151 + }
139 } 152 }
140 - 153 + //跳转错误页面
  154 + $this->redirect('/error/index');
141 } 155 }
142 156
143 /** 157 /**
@@ -157,14 +171,15 @@ class BackController extends WebAction @@ -157,14 +171,15 @@ class BackController extends WebAction
157 } 171 }
158 172
159 /** 173 /**
160 - * 手机验证 174 + * 手机验证页面
161 */ 175 */
162 public function verificationAction() { 176 public function verificationAction() {
163 $phoneNum = $this->getSession('phoneNum'); 177 $phoneNum = $this->getSession('phoneNum');
164 $area = $this->getSession('area'); 178 $area = $this->getSession('area');
165 -// if(empty($phoneNum)) {  
166 -// $this->redirect('index');  
167 -// } 179 + $captcha = $this->getSession('captcha');
  180 + if(empty($phoneNum)) {
  181 + $this->redirect('index');
  182 + }
168 $banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE); 183 $banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
169 $data = array( 184 $data = array(
170 'simpleHeader' => PassportModel::getSimpleHeader(false), 185 'simpleHeader' => PassportModel::getSimpleHeader(false),
@@ -174,6 +189,7 @@ class BackController extends WebAction @@ -174,6 +189,7 @@ class BackController extends WebAction
174 'coverImg' => $banner['img'], 189 'coverImg' => $banner['img'],
175 'phoneNum' => $phoneNum, 190 'phoneNum' => $phoneNum,
176 'area' => $area, 191 'area' => $area,
  192 + 'captcha'=> $captcha,
177 'countrys' => array() 193 'countrys' => array()
178 ) 194 )
179 ); 195 );
@@ -181,6 +197,32 @@ class BackController extends WebAction @@ -181,6 +197,32 @@ class BackController extends WebAction
181 } 197 }
182 198
183 /** 199 /**
  200 + * 手机找回密码验证
  201 + */
  202 + public function backmobileAction()
  203 + {
  204 + $mobile = $this->post('mobile');//phoneNum
  205 + $area = $this->post('area');
  206 + //$captcha = $this->post('captcha');
  207 + $code = $this->post('captcha');//code
  208 + if($this->getSession('phoneNum') == $mobile && $this->getSession('area') == $area)
  209 + {
  210 + $result = BackData::validateMobileCode($mobile, $code, $area);
  211 + if($result['code'] == 200) {
  212 + $str = json_encode(array(
  213 + 'mobile'=> $mobile,
  214 + 'area' => $area,
  215 + 'token'=> $result['data']['token'],
  216 + 'create_time' => time()
  217 + ));
  218 + $code = AuthCode::encode($str, PassportModel::BACK_FIND_SECRET_KEY);
  219 + $url = '/passport/back/backcode?code='.base64_encode($code);
  220 + $this->redirect(SITE_MAIN.$url);
  221 + }
  222 + }
  223 + }
  224 +
  225 + /**
184 * 检查code 226 * 检查code
185 * 227 *
186 * @param string $code 228 * @param string $code
@@ -188,9 +230,8 @@ class BackController extends WebAction @@ -188,9 +230,8 @@ class BackController extends WebAction
188 */ 230 */
189 private function checkCode($code) 231 private function checkCode($code)
190 { 232 {
191 - $key = '_+@#$%^';  
192 $code = base64_decode($code); 233 $code = base64_decode($code);
193 - $info = json_decode(AuthCode::decode($code, $key), true); 234 + $info = json_decode(AuthCode::decode($code, PassportModel::BACK_FIND_SECRET_KEY), true);
194 if ($info['create_time'] < 1 || (time() - $info['create_time']) > 86400) { 235 if ($info['create_time'] < 1 || (time() - $info['create_time']) > 86400) {
195 return array(); 236 return array();
196 } 237 }
1 <?php 1 <?php
2 2
3 -use Action\AbstractAction; 3 +use Action\WebAction;
4 use LibModels\Web\Passport\RegData; 4 use LibModels\Web\Passport\RegData;
5 use LibModels\Web\Passport\LoginData; 5 use LibModels\Web\Passport\LoginData;
6 use Passport\PassportModel as PassportModel; 6 use Passport\PassportModel as PassportModel;
7 use Plugin\Helpers; 7 use Plugin\Helpers;
8 -  
9 -class LoginController extends AbstractAction 8 +class LoginController extends WebAction
10 { 9 {
11 10
12 /** 11 /**
@@ -23,7 +22,7 @@ class LoginController extends AbstractAction @@ -23,7 +22,7 @@ class LoginController extends AbstractAction
23 $this->setCookie('_TOKEN', ''); 22 $this->setCookie('_TOKEN', '');
24 23
25 //登录后跳转页面 24 //登录后跳转页面
26 - $refer = empty($_SERVER["HTTP_REFERER"])?'':$_SERVER["HTTP_REFERER"]; 25 + $refer = empty($_SERVER["HTTP_REFERER"]) ? '' : $_SERVER["HTTP_REFERER"];
27 if (!empty($refer)) { 26 if (!empty($refer)) {
28 $this->setCookie('refer', $refer); 27 $this->setCookie('refer', $refer);
29 } 28 }
@@ -40,13 +39,21 @@ class LoginController extends AbstractAction @@ -40,13 +39,21 @@ class LoginController extends AbstractAction
40 $simpleHeader = PassportModel::getSimpleHeader($isLogin, $username); 39 $simpleHeader = PassportModel::getSimpleHeader($isLogin, $username);
41 //获取登陆页左侧资源 40 //获取登陆页左侧资源
42 $cover = PassportModel::getLeftBanner(PassportModel::SIGNIN_LEFT_BANNER_CODE); 41 $cover = PassportModel::getLeftBanner(PassportModel::SIGNIN_LEFT_BANNER_CODE);
  42 + //是否记住密码
  43 + $isRemember = $this->getCookie('isRemember', FALSE);
  44 + $account = '';
  45 + $password = '';
  46 + if ($isRemember) {
  47 + $account = $this->decrypt($this->getCookie('account', ''));
  48 + $password = $this->decrypt($this->getCookie('userInfo', ''));
  49 + }
43 //整合 50 //整合
44 $data = array( 51 $data = array(
45 'loginPage' => true, 52 'loginPage' => true,
46 'simpleHeader' => $simpleHeader, 53 'simpleHeader' => $simpleHeader,
47 'passport' => array( 54 'passport' => array(
48 'coverHref' => $cover['url'], 55 'coverHref' => $cover['url'],
49 - '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', 56 + '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',
50 'countryCode' => '+86', 57 'countryCode' => '+86',
51 'countryName' => '中国', 58 'countryName' => '中国',
52 'countryList' => RegData::getAreasData(), 59 'countryList' => RegData::getAreasData(),
@@ -58,6 +65,9 @@ class LoginController extends AbstractAction @@ -58,6 +65,9 @@ class LoginController extends AbstractAction
58 'alipayLogin' => Helpers::url('/passport/autosign/alipay'), 65 'alipayLogin' => Helpers::url('/passport/autosign/alipay'),
59 'doubanLogin' => Helpers::url('/passport/autosign/douban'), 66 'doubanLogin' => Helpers::url('/passport/autosign/douban'),
60 'renrenLogin' => Helpers::url('/passport/autosign/renren'), 67 'renrenLogin' => Helpers::url('/passport/autosign/renren'),
  68 + 'isRemember' => $isRemember,
  69 + 'password' => $password,
  70 + 'account' => $account
61 ), 71 ),
62 ); 72 );
63 73
@@ -84,15 +94,17 @@ class LoginController extends AbstractAction @@ -84,15 +94,17 @@ class LoginController extends AbstractAction
84 94
85 /* 判断参数是否传递 */ 95 /* 判断参数是否传递 */
86 $area = trim($this->post('areaCode', '86')); 96 $area = trim($this->post('areaCode', '86'));
87 - $profile = trim($this->post('account')); 97 + $account = trim($this->post('account'));
88 $password = trim($this->post('password')); 98 $password = trim($this->post('password'));
89 - if (!is_numeric($area) || empty($profile) || empty($password)) { 99 + $isRemember = trim($this->post('isRemember'));
  100 + $isRemember = false;
  101 + if (!is_numeric($area) || empty($account) || empty($password)) {
90 break; 102 break;
91 } 103 }
92 104
93 /* 判断参数是否有效 */ 105 /* 判断参数是否有效 */
94 - $verifyEmail = Helpers::verifyEmail($profile);  
95 - $verifyMobile = ($area === '86') ? Helpers::verifyMobile($profile) : Helpers::verifyAreaMobile($profile, $area); 106 + $verifyEmail = Helpers::verifyEmail($account);
  107 + $verifyMobile = ($area === '86') ? Helpers::verifyMobile($account) : Helpers::verifyAreaMobile($account, $area);
96 if (!$verifyEmail && !$verifyMobile) { 108 if (!$verifyEmail && !$verifyMobile) {
97 break; 109 break;
98 } 110 }
@@ -106,10 +118,21 @@ class LoginController extends AbstractAction @@ -106,10 +118,21 @@ class LoginController extends AbstractAction
106 /* 调用登录接口进行登录 */ 118 /* 调用登录接口进行登录 */
107 // 获取未登录时的唯一识别码 119 // 获取未登录时的唯一识别码
108 $shoppingKey = Helpers::getShoppingKeyByCookie(); 120 $shoppingKey = Helpers::getShoppingKeyByCookie();
109 - $data = LoginData::signin($area, $profile, $password, $shoppingKey); 121 + $data = LoginData::signin($area, $account, $password, $shoppingKey);
110 if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['uid'])) { 122 if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['uid'])) {
111 break; 123 break;
112 } 124 }
  125 + //登录成功记录账户信息
  126 + if ($isRemember) {
  127 + $this->setCookie('account', $this->encrypt($account), time() + 3600 * 24 * 7, '/');
  128 + $this->setCookie('userInfo', $this->encrypt($password), time() + 3600 * 24 * 7, '/');
  129 + $this->setCookie('isRemember', $isRemember, time() + 3600 * 24 * 7);
  130 + }
  131 + else {
  132 + $this->setCookie('account', '', -1, '/');
  133 + $this->setCookie('userInfo', '', -1, '/');
  134 + $this->setCookie('isRemember', '', -1, '/');
  135 + }
113 136
114 $refer = $this->getCookie('refer'); 137 $refer = $this->getCookie('refer');
115 if (empty($refer)) { 138 if (empty($refer)) {
@@ -152,4 +175,60 @@ class LoginController extends AbstractAction @@ -152,4 +175,60 @@ class LoginController extends AbstractAction
152 $this->go($refer); 175 $this->go($refer);
153 } 176 }
154 177
  178 + /*
  179 + * 加密算法
  180 + */
  181 +
  182 + private function encrypt($data, $key='yohobuy')
  183 + {
  184 + $key = md5($key);
  185 + $x = 0;
  186 + $str='';
  187 + $char='';
  188 + $len = strlen($data);
  189 + $l = strlen($key);
  190 + for ($i = 0; $i < $len; $i++) {
  191 + if ($x == $l) {
  192 + $x = 0;
  193 + }
  194 + $char .= $key{$x};
  195 + $x++;
  196 + }
  197 + for ($i = 0; $i < $len; $i++) {
  198 + $str .= chr(ord($data{$i}) + (ord($char{$i})) % 256);
  199 + }
  200 + return base64_encode($str);
  201 + }
  202 +
  203 + /*
  204 + * 解密算法
  205 + */
  206 +
  207 + private function decrypt($data, $key='yohobuy')
  208 + {
  209 + $key = md5($key);
  210 + $x = 0;
  211 + $str='';
  212 + $char='';
  213 + $data = base64_decode($data);
  214 + $len = strlen($data);
  215 + $l = strlen($key);
  216 + for ($i = 0; $i < $len; $i++) {
  217 + if ($x == $l) {
  218 + $x = 0;
  219 + }
  220 + $char .= substr($key, $x, 1);
  221 + $x++;
  222 + }
  223 + for ($i = 0; $i < $len; $i++) {
  224 + if (ord(substr($data, $i, 1)) < ord(substr($char, $i, 1))) {
  225 + $str .= chr((ord(substr($data, $i, 1)) + 256) - ord(substr($char, $i, 1)));
  226 + }
  227 + else {
  228 + $str .= chr(ord(substr($data, $i, 1)) - ord(substr($char, $i, 1)));
  229 + }
  230 + }
  231 + return $str;
  232 + }
  233 +
155 } 234 }
@@ -90,7 +90,12 @@ class ListController extends WebAction @@ -90,7 +90,12 @@ class ListController extends WebAction
90 $params = array_filter($params); 90 $params = array_filter($params);
91 //每页记录数减1,下一页占位 91 //每页记录数减1,下一页占位
92 $params['viewNum'] = $params['viewNum'] - 1; 92 $params['viewNum'] = $params['viewNum'] - 1;
93 - $data = SearchModel::getSearchData($params,$options); 93 + $list = SearchModel::getSearchData($params,$options);
  94 + $data = array(
  95 + //初始化js
  96 + 'productListPage' => true,
  97 + 'list' => $list
  98 + );
94 $cate = array('boys','girls','kids','lifestyle'); 99 $cate = array('boys','girls','kids','lifestyle');
95 $this->setWebNavHeader($cate[$gender-1]); 100 $this->setWebNavHeader($cate[$gender-1]);
96 $this->_view->display('list', $data); 101 $this->_view->display('list', $data);
@@ -30,8 +30,6 @@ class SearchController extends WebAction @@ -30,8 +30,6 @@ class SearchController extends WebAction
30 foreach($condition as $key => $val){ 30 foreach($condition as $key => $val){
31 $condition[$key] = rawurldecode($val); 31 $condition[$key] = rawurldecode($val);
32 } 32 }
33 - //关键词  
34 - $condition['query'] = '鞋';  
35 //性別(频道) 33 //性別(频道)
36 $gender_cookie = !isset($_COOKIE['_Gender']) ? '3' : ($_COOKIE['_Gender']=='2,3' ? 2 : 1); 34 $gender_cookie = !isset($_COOKIE['_Gender']) ? '3' : ($_COOKIE['_Gender']=='2,3' ? 2 : 1);
37 $gender = $this->get('gender') ? ($this->get('gender') == '2,3' ? 2 : 1) : $gender_cookie ; 35 $gender = $this->get('gender') ? ($this->get('gender') == '2,3' ? 2 : 1) : $gender_cookie ;
@@ -57,7 +55,7 @@ class SearchController extends WebAction @@ -57,7 +55,7 @@ class SearchController extends WebAction
57 $minImgSize = array(60, 80); 55 $minImgSize = array(60, 80);
58 } 56 }
59 //自定义搜索价格 57 //自定义搜索价格
60 - if (isset($condition['price']) || !empty($condition['price'])) { 58 + if (isset($condition['price']) && !empty($condition['price'])) {
61 $price = explode(',', $condition['price']); 59 $price = explode(',', $condition['price']);
62 if (!$price[0]) { 60 if (!$price[0]) {
63 $price[0] = 0; 61 $price[0] = 0;
@@ -90,13 +88,15 @@ class SearchController extends WebAction @@ -90,13 +88,15 @@ class SearchController extends WebAction
90 $params = array_filter($params); 88 $params = array_filter($params);
91 //每页记录数减1,下一页占位 89 //每页记录数减1,下一页占位
92 $params['viewNum'] = $params['viewNum'] - 1; 90 $params['viewNum'] = $params['viewNum'] - 1;
  91 + $options['controller'] = $this->_request->controller;
93 $searchData = SearchModel::searchData($params,$options); 92 $searchData = SearchModel::searchData($params,$options);
94 $cate = array('boys','girls','kids','lifestyle'); 93 $cate = array('boys','girls','kids','lifestyle');
95 $this->setWebNavHeader($cate[$gender-1]); 94 $this->setWebNavHeader($cate[$gender-1]);
96 $data = array( 95 $data = array(
  96 + //初始化js
97 'searchListPage' => true, 97 'searchListPage' => true,
  98 + 'search' => $searchData
98 ); 99 );
99 - $data['search'] = $searchData['list'];  
100 $this->_view->display('search', $data); 100 $this->_view->display('search', $data);
101 } 101 }
102 } 102 }