Authored by hf

do plustar template

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