Authored by hf

do plustar template

@@ -15,8 +15,8 @@ use Api\Yohobuy; @@ -15,8 +15,8 @@ use Api\Yohobuy;
15 */ 15 */
16 class DetailData 16 class DetailData
17 { 17 {
18 - const API_URI_ARTICLE = 'guang/service/v2/article/';  
19 - const API_URI_AUTHOR = 'guang/service/v1/author/'; 18 + const URI_PACKAGE_ARTICLE = 'guang/service/v2/article/';
  19 + const URI_PACKAGE_AUTHOR = 'guang/service/v1/author/';
20 20
21 /** 21 /**
22 * 逛资讯详情页数据封装 22 * 逛资讯详情页数据封装
@@ -31,7 +31,7 @@ class DetailData @@ -31,7 +31,7 @@ class DetailData
31 $result['getOtherArticle'] = array(); 31 $result['getOtherArticle'] = array();
32 32
33 // 获取资讯 33 // 获取资讯
34 - $article = Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::API_URI_ARTICLE, 'getArticle', array($id)); 34 + $article = Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getArticle', array($id));
35 if (!isset($article['tag'])) { 35 if (!isset($article['tag'])) {
36 return $result; 36 return $result;
37 } else { 37 } else {
@@ -39,7 +39,7 @@ class DetailData @@ -39,7 +39,7 @@ class DetailData
39 } 39 }
40 40
41 // 获取作者信息 41 // 获取作者信息
42 - Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::API_URI_AUTHOR, 'getAuthor', array($id), function ($retval) use (&$result) { 42 + Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_PACKAGE_AUTHOR, 'getAuthor', array($id), function ($retval) use (&$result) {
43 $result['getAuthor'] = empty($retval) ? array() : $retval; 43 $result['getAuthor'] = empty($retval) ? array() : $retval;
44 }); 44 });
45 45
@@ -4,7 +4,6 @@ namespace LibModels\Wap\Guang; @@ -4,7 +4,6 @@ namespace LibModels\Wap\Guang;
4 4
5 use Api\Sign; 5 use Api\Sign;
6 use Api\Yohobuy; 6 use Api\Yohobuy;
7 -use Hood\Cache;  
8 7
9 /** 8 /**
10 * 逛首页列表相关的数据模型 9 * 逛首页列表相关的数据模型
@@ -17,6 +17,11 @@ use Api\Yohobuy; @@ -17,6 +17,11 @@ use Api\Yohobuy;
17 class PlusstarData 17 class PlusstarData
18 { 18 {
19 19
  20 + const URI_BRANDLIST = 'guang/api/v1/plustar/getlist';
  21 + const URI_BRANDINFO_PLUSSTAR = 'guang/service/v1/plustar/';
  22 + const URI_BRANDINFO_FAVORITE = 'shops/service/v1/favorite/';
  23 + const URI_BRANDINFO_ARTICLE = 'guang/service/v1/article/';
  24 +
20 /** 25 /**
21 * 品牌列表 26 * 品牌列表
22 * 27 *
@@ -32,7 +37,7 @@ class PlusstarData @@ -32,7 +37,7 @@ class PlusstarData
32 // 存放接口列表 37 // 存放接口列表
33 $urlList = array(); 38 $urlList = array();
34 // 接口调用的URL 39 // 接口调用的URL
35 - $url = Yohobuy::SERVICE_URL . 'guang/api/v1/plustar/getlist'; 40 + $url = Yohobuy::SERVICE_URL . self::URI_BRANDLIST;
36 41
37 // 公共的参数 42 // 公共的参数
38 $param = Yohobuy::param(); 43 $param = Yohobuy::param();
@@ -80,7 +85,7 @@ class PlusstarData @@ -80,7 +85,7 @@ class PlusstarData
80 $result['getArticleByBrand'] = array(); 85 $result['getArticleByBrand'] = array();
81 86
82 // 品牌详情信息 87 // 品牌详情信息
83 - $brandInfo = Yohobuy::yarClient(Yohobuy::SERVICE_URL . 'guang/service/v1/plustar/', 'getBrandInfo', array(array('id' => $id)) ); 88 + $brandInfo = Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_BRANDINFO_PLUSSTAR, 'getBrandInfo', array(array('id' => $id)) );
84 if (!isset($brandInfo['brand_id'])) { 89 if (!isset($brandInfo['brand_id'])) {
85 return $result; 90 return $result;
86 } else { 91 } else {
@@ -90,14 +95,14 @@ class PlusstarData @@ -90,14 +95,14 @@ class PlusstarData
90 // 是否收藏店铺 95 // 是否收藏店铺
91 $isUidOk = $uid && is_numeric($uid); 96 $isUidOk = $uid && is_numeric($uid);
92 if ($isUidOk) { 97 if ($isUidOk) {
93 - Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . 'shops/service/v1/favorite/', 'getUidBrandFav', array($uid, $id), function($retval) use(&$result) { 98 + Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_BRANDINFO_FAVORITE, 'getUidBrandFav', array($uid, $id), function($retval) use(&$result) {
94 $result['getUidBrandFav'] = empty($retval['data']) ? false : $retval['data']; 99 $result['getUidBrandFav'] = empty($retval['data']) ? false : $retval['data'];
95 }); 100 });
96 } 101 }
97 102
98 // 相关资讯列表 (3篇) 103 // 相关资讯列表 (3篇)
99 $result['getArticleByBrand'] = array(); 104 $result['getArticleByBrand'] = array();
100 - Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . 'guang/service/v1/article/', 'getArticleByBrand', array($brandInfo['brand_id'], 3, $udid), function($retval) use(&$result) { 105 + Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_BRANDINFO_ARTICLE, 'getArticleByBrand', array($brandInfo['brand_id'], 3, $udid), function($retval) use(&$result) {
101 $result['getArticleByBrand'] = empty($retval) ? array() : $retval; 106 $result['getArticleByBrand'] = empty($retval) ? array() : $retval;
102 }); 107 });
103 108
@@ -132,7 +137,7 @@ class PlusstarData @@ -132,7 +137,7 @@ class PlusstarData
132 $skn = $value['product_skn']; 137 $skn = $value['product_skn'];
133 $result['getUidProductFav'][ $skn ] = false; 138 $result['getUidProductFav'][ $skn ] = false;
134 if ($isUidOk) { 139 if ($isUidOk) {
135 - Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . 'shops/service/v1/favorite/', 'getUidProductFav', array($uid, $value['product_skn']), function($retval) use(&$result,&$skn) { 140 + Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_BRANDINFO_FAVORITE, 'getUidProductFav', array($uid, $value['product_skn']), function($retval) use(&$result,&$skn) {
136 $result['getUidProductFav'][ $skn ] = empty($retval['data']) ? false : $retval['data']; 141 $result['getUidProductFav'][ $skn ] = empty($retval['data']) ? false : $retval['data'];
137 }); 142 });
138 } 143 }
1 <?php 1 <?php
2 2
3 -/*  
4 - * To change this license header, choose License Headers in Project Properties.  
5 - * To change this template file, choose Tools | Templates  
6 - * and open the template in the editor.  
7 - */ 3 +namespace LibModels\Wap\Passport;
  4 +
  5 +use Api\Sign;
  6 +use Api\Yohobuy;
8 7
  8 +/**
  9 + * 登录的数据模型
  10 + *
  11 + * @name LoginData
  12 + * @package LibModels/Wap/Passport
  13 + * @copyright yoho.inc
  14 + * @version 1.0 (2015-10-12 14:05:04)
  15 + * @author fei.hong <fei.hong@yoho.cn>
  16 + */
  17 +class LoginData
  18 +{
  19 +
  20 +}
1 <?php 1 <?php
2 2
3 -/*  
4 - * To change this license header, choose License Headers in Project Properties.  
5 - * To change this template file, choose Tools | Templates  
6 - * and open the template in the editor. 3 +namespace LibModels\Wap\Passport;
  4 +
  5 +use Api\Sign;
  6 +use Api\Yohobuy;
  7 +
  8 +/**
  9 + * 注册的数据模型
  10 + *
  11 + * @name RegData
  12 + * @package LibModels/Wap/Passport
  13 + * @copyright yoho.inc
  14 + * @version 1.0 (2015-10-12 14:04:55)
  15 + * @author fei.hong <fei.hong@yoho.cn>
7 */ 16 */
  17 +class RegData
  18 +{
  19 +
  20 + /**
  21 + * 获取地区数据
  22 + *
  23 + * @return array 地区数据
  24 + */
  25 + public static function getAreasData()
  26 + {
  27 + $param = Yohobuy::param();
  28 + $param['method'] = 'app.passport.getArea';
  29 + $param['client_secret'] = Sign::getSign($param);
  30 +
  31 + return Yohobuy::get(Yohobuy::API_URL, $param);
  32 + }
  33 +
  34 + /**
  35 + * 发送手机注册验证码
  36 + *
  37 + * @param string $area 地区号 如"86"
  38 + * @param string $mobile 手机号
  39 + * @return array
  40 + */
  41 + public static function sendCodeToMobile($area, $mobile)
  42 + {
  43 + $param = Yohobuy::param();
  44 + $param['method'] = 'app.register.sendRegCodeToMobile';
  45 + $param['area'] = $area;
  46 + $param['mobile'] = $mobile;
  47 + $param['client_secret'] = Sign::getSign($param);
  48 +
  49 + return Yohobuy::post(Yohobuy::API_URL, $param);
  50 + }
  51 +
  52 + /**
  53 + * 验证手机注册的识别码
  54 + *
  55 + * @param string $area 地区号 如"86"
  56 + * @param string $mobile 手机号
  57 + * @param string $code 验证码
  58 + * @return array
  59 + */
  60 + public static function validMobileCode($area, $mobile, $code)
  61 + {
  62 + $param = Yohobuy::param();
  63 + $param['method'] = 'app.register.validRegCode';
  64 + $param['area'] = $area;
  65 + $param['mobile'] = $mobile;
  66 + $param['code'] = $code;
  67 + $param['client_secret'] = Sign::getSign($param);
  68 +
  69 + return Yohobuy::post(Yohobuy::API_URL, $param);
  70 + }
  71 +
  72 + /**
  73 + * 通过手机注册
  74 + *
  75 + * @param string $area 地区号 如"86"
  76 + * @param string $mobile 手机号
  77 + * @param string $password 登录密码
  78 + * @return array
  79 + */
  80 + public static function regMobile($area, $mobile, $password)
  81 + {
  82 + $param = Yohobuy::param();
  83 + $param['method'] = 'app.passport.register';
  84 + $param['area'] = $area;
  85 + $param['mobile'] = $mobile;
  86 + $param['profile'] = $password;
  87 + $param['client_secret'] = Sign::getSign($param);
  88 +
  89 + return Yohobuy::post(Yohobuy::API_URL, $param);
  90 + }
8 91
  92 +}
@@ -79,8 +79,11 @@ class TemplateLayout implements View_Interface @@ -79,8 +79,11 @@ class TemplateLayout implements View_Interface
79 if (!file_exists($viewName)) { 79 if (!file_exists($viewName)) {
80 return ''; 80 return '';
81 } 81 }
82 -  
83 - $tpl_vars = array_merge($this->tpl_vars, $tpl_vars); 82 +
  83 + // 合并通过assign传递的参数
  84 + if (is_array($this->_tpl_vars)) {
  85 + $tpl_vars = array_merge($this->_tpl_vars, $tpl_vars);
  86 + }
84 // 取得模板的最后修改时间戳 87 // 取得模板的最后修改时间戳
85 $lastModifyTime = filemtime($viewName); 88 $lastModifyTime = filemtime($viewName);
86 // 使用MD5生成唯一的键名 89 // 使用MD5生成唯一的键名
@@ -131,7 +134,7 @@ class TemplateLayout implements View_Interface @@ -131,7 +134,7 @@ class TemplateLayout implements View_Interface
131 { 134 {
132 $result = false; 135 $result = false;
133 if (is_dir($path)) { 136 if (is_dir($path)) {
134 - $this->tpl_dir = $path; 137 + $this->_tpl_dir = $path;
135 $result = true; 138 $result = true;
136 } 139 }
137 return $result; 140 return $result;
  1 +{{>layout/header}}
  2 +
  3 +<code>
  4 +{{#focus}}
  5 +<ul>
  6 +{{#each data}}
  7 +{{#data}}
  8 +<li><img src="{{src}}" alt="{{title}}"></li>
  9 +{{/data}}
  10 +{{/each}}
  11 +</ul>
  12 +{{/focus}}
  13 +</code>
  14 +
  15 +{{>layout/footer}}
@@ -23,7 +23,7 @@ @@ -23,7 +23,7 @@
23 }()); 23 }());
24 })(document, window); 24 })(document, window);
25 </script> 25 </script>
26 - <link rel="stylesheet" href="http://static.dev.yohobuy.com/css/index.css"> 26 + <link rel="stylesheet" href="http://172.16.6.248:8088/css/index.css">
27 </head> 27 </head>
28 <body {{#if isPassportPage}}class=passport-body{{/if}}> 28 <body {{#if isPassportPage}}class=passport-body{{/if}}>
29 {{> layout/page_header}} 29 {{> layout/page_header}}
1 <?php 1 <?php
  2 +
2 use Action\AbstractAction; 3 use Action\AbstractAction;
3 use LibModels\Wap\Guang\PlusstarData; 4 use LibModels\Wap\Guang\PlusstarData;
  5 +use Plugin\Helpers;
4 6
5 /** 7 /**
6 * 明星品牌和原创品牌 8 * 明星品牌和原创品牌
7 */ 9 */
8 class PlusstarController extends AbstractAction 10 class PlusstarController extends AbstractAction
9 { 11 {
10 - 12 +
11 /** 13 /**
12 * 品牌列表页 14 * 品牌列表页
  15 + *
  16 + * @param int gender "1,3"表示男, "2,3"表示女
13 */ 17 */
14 public function listAction() 18 public function listAction()
15 { 19 {
16 - $data = array(  
17 - 'star' => array(  
18 - array(  
19 - 'imgs' => array(  
20 - array(  
21 - 'url' => 'http://stussy.m.yohobuy.com',  
22 - 'img' => 'http://ad.yoho.cn/yohobuy/newfestival/img/brandsmap/6KTZ_01.jpg'  
23 - ),  
24 - array(  
25 - 'url' => 'http://stussy.m.yohobuy.com',  
26 - 'img' =>'http://ad.yoho.cn/yohobuy/newfestival/img/brandsmap/5HUF_01.jpg'  
27 - )  
28 - )  
29 - ),  
30 - array(  
31 - 'url' => 'http://stussy.m.yohobuy.com',  
32 - 'img' => 'http://ad.yoho.cn/yohobuy/newfestival/img/brandsmap/4STAYREAL_02.jpg',  
33 - 'deps' => '优秀的自助品牌,高瞻远瞩的建设性意见来测试文字溢出后的处理问题'  
34 - )  
35 - ),  
36 - 'plus' => array(  
37 - )  
38 - );  
39 - $this->_view->assign('title', 'YOHO!有货');  
40 - $this->_view->display('list', array('test' => 'hello world'));  
41 -  
42 - $test = PlusstarData::brandList("1,3", 1);  
43 - var_dump($test); 20 + $data = array('ps' => array('star' => array(), 'plus' => array()));
  21 +
  22 + $brandList = array();
  23 + $build = array();
  24 + $imgs = array();
  25 +
  26 + $gender = $this->get('gender', '1,3');
  27 + // 女
  28 + if ($gender === '2,3') {
  29 + $brandList = PlusstarData::brandList('2,3', 2);
  30 + }
  31 + // 男
  32 + else {
  33 + $brandList = PlusstarData::brandList('1,3', 1);
  34 + }
  35 +
  36 + // 明星品牌列表
  37 + if (!empty($brandList['star']['data']['list'][0]['data'])) {
  38 + foreach ($brandList['star']['data']['list'][0]['data'] as $star) {
  39 + $imgs = array();
  40 + $build = array();
  41 +
  42 + // 情况1: 多张图
  43 + if (isset($star['data'][1])) {
  44 + foreach ($star['data'] as $value) {
  45 + $build['url'] = $value['url'];
  46 + $build['img'] = Helpers::getImageUrl($value['src'], 640, 310);
  47 + $imgs[] = $build;
  48 + }
  49 + $data['ps']['star'][] = array('imgs' => $imgs);
  50 + }
  51 + // 情况2: 单张图
  52 + elseif (isset($star['data'][0])) {
  53 + $build['url'] = $star['data'][0]['url'];
  54 + $build['img'] = $star['data'][0]['src'];
  55 + $data['ps']['star'][] = $build;
  56 + }
  57 + }
  58 + }
  59 +
  60 + // 原创品牌列表
  61 + if (!empty($brandList['original']['data']['list'][0]['data'])) {
  62 + foreach ($brandList['original']['data']['list'][0]['data'] as $original) {
  63 + $imgs = array();
  64 + $build = array();
  65 +
  66 + // 情况1: 多张图
  67 + if (isset($original['data'][1])) {
  68 + foreach ($original['data'] as $value) {
  69 + $build['url'] = $value['url'];
  70 + $build['img'] = Helpers::getImageUrl($value['src'], 640, 310);
  71 + $build['deps'] = $original['brand_title'];
  72 + $imgs[] = $build;
  73 + }
  74 + $data['ps']['plus'][] = array('imgs' => $imgs);
  75 + }
  76 + // 情况2: 单张图
  77 + elseif (isset($original['data'][0])) {
  78 + $build['url'] = $original['data'][0]['url'];
  79 + $build['img'] = Helpers::getImageUrl($original['data'][0]['src'], 640, 310);
  80 + $build['deps'] = $original['brand_title'];
  81 + $data['ps']['plus'][] = $build;
  82 + }
  83 + }
  84 + }
  85 +
  86 + $this->_view->display('list', $data);
  87 +
  88 + $brandList = array();
  89 + $data = array();
44 } 90 }
45 - 91 +
46 /** 92 /**
47 * 品牌介绍页 93 * 品牌介绍页
48 */ 94 */
49 public function detailAction() 95 public function detailAction()
50 { 96 {
  97 + $id = $this->get('id');
  98 + $gender = $this->get('gender', '1,3');
  99 +
  100 +
51 $test = PlusstarData::brandInfo(67, '1,3', 123456); 101 $test = PlusstarData::brandInfo(67, '1,3', 123456);
52 var_dump($test); 102 var_dump($test);
53 } 103 }
54 -  
55 -}  
  104 +
  105 +}