Authored by hf

modify side nav to call h5 api

@@ -353,6 +353,8 @@ class AbstractAction extends Controller_Abstract @@ -353,6 +353,8 @@ class AbstractAction extends Controller_Abstract
353 */ 353 */
354 protected function setNavSide($guangChoosed = 'all') 354 protected function setNavSide($guangChoosed = 'all')
355 { 355 {
  356 + $this->_view->assign('sideNav', \Index\SideModel::getLeftNav($guangChoosed));
  357 + /*
356 $this->_view->assign('sideNav', array( 358 $this->_view->assign('sideNav', array(
357 0 => array( 359 0 => array(
358 'textCn' => '男生', 360 'textCn' => '男生',
@@ -415,6 +417,7 @@ class AbstractAction extends Controller_Abstract @@ -415,6 +417,7 @@ class AbstractAction extends Controller_Abstract
415 ) 417 )
416 ), 418 ),
417 )); 419 ));
  420 + */
418 } 421 }
419 422
420 /** 423 /**
@@ -14,5 +14,7 @@ class CacheConfig @@ -14,5 +14,7 @@ class CacheConfig
14 const KEY_ACTION_GIRLS_INDEX = 'key_action_girls_index'; // 女生首页 14 const KEY_ACTION_GIRLS_INDEX = 'key_action_girls_index'; // 女生首页
15 const KEY_ACTION_KIDS_INDEX = 'key_action_kids_index'; // 潮童首页 15 const KEY_ACTION_KIDS_INDEX = 'key_action_kids_index'; // 潮童首页
16 const KEY_ACTION_LIFESTYLE_INDEX = 'key_action_lifestyle_index'; // 创意生活首页 16 const KEY_ACTION_LIFESTYLE_INDEX = 'key_action_lifestyle_index'; // 创意生活首页
  17 +
  18 + const KEY_COMMON_SIDE_NAV = 'key_common_side_nav'; // 公共的侧边栏
17 19
18 } 20 }
@@ -22,27 +22,26 @@ class SideData @@ -22,27 +22,26 @@ class SideData
22 /** 22 /**
23 * 左侧边栏的分类和图标数据 23 * 左侧边栏的分类和图标数据
24 * 24 *
25 - * 备注:暂不使用,因很少变,获取后还需要再封装  
26 - *  
27 * @return array 25 * @return array
28 */ 26 */
29 public static function leftNav() 27 public static function leftNav()
30 { 28 {
31 - $param = Yohobuy::param();  
32 - $param['client_type'] = 'iphone'; // 因安卓不返回icon的地址  
33 - $param['client_secret'] = Sign::getSign($param);  
34 - $query = Yohobuy::httpBuildQuery('', $param);  
35 -  
36 - $urlList = array();  
37 - $urlList['getEntrance'] = Yohobuy::SERVICE_URL . self::URI_LEFTNAV_ENTRANCE . $query;  
38 - $urlList['getCategory'] = Yohobuy::SERVICE_URL . self::URI_LEFTNAV_CATEGORY . $query;  
39 -  
40 - return Yohobuy::getMulti($urlList);  
41 -  
42 // $param = Yohobuy::param(); 29 // $param = Yohobuy::param();
  30 +// $param['client_type'] = 'h5'; // 因安卓不返回icon的地址
43 // $param['client_secret'] = Sign::getSign($param); 31 // $param['client_secret'] = Sign::getSign($param);
  32 +// $query = Yohobuy::httpBuildQuery('', $param);
44 // 33 //
45 -// return Yohobuy::get(Yohobuy::SERVICE_URL . self::URI_LEFTNAV_CATEGORY, $param); 34 +// $urlList = array();
  35 +// $urlList['getEntrance'] = Yohobuy::SERVICE_URL . self::URI_LEFTNAV_ENTRANCE . $query;
  36 +// $urlList['getCategory'] = Yohobuy::SERVICE_URL . self::URI_LEFTNAV_CATEGORY . $query;
  37 +//
  38 +// return Yohobuy::getMulti($urlList);
  39 +
  40 + $param = Yohobuy::param();
  41 + $param['client_type'] = 'h5'; // 调用H5手机网站的
  42 + $param['client_secret'] = Sign::getSign($param);
  43 +
  44 + return Yohobuy::get(Yohobuy::SERVICE_URL . self::URI_LEFTNAV_CATEGORY, $param);
46 } 45 }
47 46
48 } 47 }
@@ -150,8 +150,6 @@ class FloorProcess @@ -150,8 +150,6 @@ class FloorProcess
150 $build['textCn'] = $one['title']; 150 $build['textCn'] = $one['title'];
151 $result['hotCategory']['list'][] = $build; 151 $result['hotCategory']['list'][] = $build;
152 } 152 }
153 -  
154 -  
155 153
156 return $result; 154 return $result;
157 } 155 }
1 server 1 server
2 { 2 {
3 listen 80; 3 listen 80;
4 - server_name wap.yohobuy.com; 4 + server_name yhb.test.yoho.cn *.yhb.test.yoho.cn;
5 5
6 - #access_log /Data/logs/access.wap.yohobuy.com.log combined;  
7 - error_log /Data/logs/error.wap.yohobuy.com.log warn; 6 + #access_log /Data/logs/access.buy.test.yoho.cn.log combined;
  7 + error_log /Data/logs/error.buy.test.yoho.cn.log warn;
8 8
9 root /Data/code/git/yohobuy/yohobuy/m.yohobuy.com/public; 9 root /Data/code/git/yohobuy/yohobuy/m.yohobuy.com/public;
10 10
  11 + set $sub '';
  12 + if ($host ~* ([^\.]+)\.yhb.test.yoho.cn$) {
  13 + set $sub $1;
  14 + }
  15 +
11 location ~* \.html$ { 16 location ~* \.html$ {
12 - root /Data/PE/yohobuy/assets; 17 + root /Data/code/git/yohobuy/assets;
13 if (!-f $request_filename){ 18 if (!-f $request_filename){
14 - root /Data/PE/yohobuy/yohobuy/m.yohobuy.com/public; 19 + root /Data/code/git/yohobuy/yohobuy/m.yohobuy.com/public;
15 rewrite ^/(.+)$ /index.php?$1& last; 20 rewrite ^/(.+)$ /index.php?$1& last;
16 } 21 }
17 expires 7d; 22 expires 7d;
@@ -40,19 +45,19 @@ server @@ -40,19 +45,19 @@ server
40 include fastcgi_params; 45 include fastcgi_params;
41 } 46 }
42 47
43 - error_page 403 = http://wap.yohobuy.com;  
44 - error_page 404 = http://wap.yohobuy.com/error.html; 48 + error_page 403 = http://buy.test.yoho.cn;
  49 + error_page 404 = http://buy.test.yoho.cn/error.html;
45 } 50 }
46 51
47 server 52 server
48 { 53 {
49 listen 80; 54 listen 80;
50 - server_name static.wap.yohobuy.com; 55 + server_name staticyhb.test.yoho.cn;
51 56
52 - #access_log /Data/logs/access.static.wap.yohobuy.com.log combined;  
53 - #error_log /Data/logs/error.static.wap.yohobuy.com.log warn; 57 + #access_log /Data/logs/access.static.buy.test.yoho.cn.log combined;
  58 + #error_log /Data/logs/error.static.buy.test.yoho.cn.log warn;
54 59
55 - root /Data/PE/yohobuy/static; 60 + root /Data/code/git/yohobuy/static;
56 61
57 location / { 62 location / {
58 log_not_found off; 63 log_not_found off;
  1 +<?php
  2 +
  3 +namespace Index;
  4 +
  5 +use LibModels\Wap\Home\SideData;
  6 +use Configs\CacheConfig;
  7 +use Plugin\Helpers;
  8 +
  9 +/**
  10 + *
  11 + * @name SideModel
  12 + * @package models/Index
  13 + * @copyright yoho.inc
  14 + * @version 1.0 (2015-10-21 21:21:09)
  15 + * @author fei.hong <fei.hong@yoho.cn>
  16 + */
  17 +class SideModel
  18 +{
  19 +
  20 + /**
  21 + * 获取左侧边栏数据
  22 + *
  23 + * @param string $guangChoosed 逛默认选中项 "all"表示全部,"boys":只看男生,"girls":只看女生
  24 + */
  25 + public static function getLeftNav($guangChoosed = 'all')
  26 + {
  27 + $result = array();
  28 +
  29 + if (USE_CACHE) {
  30 + // 先尝试获取一级缓存(master), 有数据则直接返回.
  31 + $result = Cache::get(CacheConfig::KEY_COMMON_SIDE_NAV, 'master');
  32 + if (!empty($result)) {
  33 + $result[] = self::genLeftNavGuang($guangChoosed);
  34 + return $result;
  35 + }
  36 + }
  37 +
  38 + // 调用接口获取后台配置的侧边栏数据
  39 + $side = SideData::leftNav();
  40 + if (!empty($side['data'])) {
  41 + foreach ($side['data'] as $key => $value) {
  42 + // 逛的按照原来的做法,使用配置
  43 + if ($value['sort_name_en'] === 'TRENDFINDER') {
  44 + continue;
  45 + }
  46 + $result[$key]['textCn'] = $value['sort_name'];
  47 + $result[$key]['textEn'] = $value['sort_name_en'];
  48 + $result[$key]['styleClass'] = strtolower($value['sort_name_en']);
  49 + $result[$key]['url'] = $value['sort_url'];
  50 + $result[$key]['img'] = Helpers::getImageUrl($value['sort_ico'], 60, 60);
  51 + }
  52 + }
  53 +
  54 + if (USE_CACHE) {
  55 + // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
  56 + if (empty($result)) {
  57 + $result = Cache::get(CacheConfig::KEY_COMMON_SIDE_NAV, 'slave');
  58 + }
  59 + // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
  60 + else {
  61 + Cache::set(CacheConfig::KEY_COMMON_SIDE_NAV, $result);
  62 + }
  63 + }
  64 +
  65 + // 追加逛的子分类数据
  66 + $result[] = self::genLeftNavGuang($guangChoosed);
  67 +
  68 + return $result;
  69 + }
  70 +
  71 + /**
  72 + * 获取并生成左侧边栏中逛的数据
  73 + *
  74 + * @param string $guangChoosed 逛默认选中项 "all"表示全部,"boys":只看男生,"girls":只看女生
  75 + * @return array
  76 + */
  77 + private static function genLeftNavGuang($guangChoosed = 'all')
  78 + {
  79 + return array(
  80 + 'textCn' => '逛',
  81 + 'textEn' => 'TRENDFINDER',
  82 + 'styleClass' => 'guang',
  83 + 'subNav' => array(
  84 + 'list' => array(
  85 + 0 => array(
  86 + 'textCn' => '逛',
  87 + 'textEn' => 'TrendFinder',
  88 + 'back' => true,
  89 + 'isSelect' => false,
  90 + 'bgColor' => ($guangChoosed === 'girls') ? '#FF88AE' : false,
  91 + ),
  92 + 1 => array(
  93 + 'textCn' => '查看全部',
  94 + 'textEn' => '',
  95 + 'back' => false,
  96 + 'isSelect' => ($guangChoosed === 'all') ? true : false,
  97 + 'url' => '/guang/list/index?gender=1,2,3'
  98 + ),
  99 + 2 => array(
  100 + 'textCn' => '只看男生',
  101 + 'textEn' => 'Boys',
  102 + 'back' => false,
  103 + 'isSelect' => ($guangChoosed === 'boys') ? true : false,
  104 + 'url' => '/guang/list/index?gender=1,3'
  105 + ),
  106 + 3 => array(
  107 + 'textCn' => '只看女生',
  108 + 'textEn' => 'Girls',
  109 + 'back' => false,
  110 + 'isSelect' => ($guangChoosed === 'girls') ? true : false,
  111 + 'url' => '/guang/list/index?gender=2,3',
  112 + ),
  113 + )
  114 + )
  115 + );
  116 + }
  117 +
  118 +}