Authored by hf

modify guang detail page to support app

... ... @@ -304,7 +304,7 @@ class AbstractAction extends Controller_Abstract
*/
protected function setDescription($description)
{
$this->_view->assign('description', $description);
$this->_view->assign('description', $description . ' ');
}
/**
... ...
... ... @@ -20,8 +20,12 @@ class DetailData
/**
* 逛资讯详情页数据封装
*
* @param int $id 内容ID
* @param bool $isApp 标识是否是APP访问
* @return array
*/
public static function package($id)
public static function package($id, $isApp = false)
{
$result = array();
$result['getAuthor'] = array();
... ... @@ -30,8 +34,11 @@ class DetailData
$result['getBrand'] = array();
$result['getOtherArticle'] = array();
// 客户端类型
$clientType = $isApp ? 'iphone' : 'h5';
// 获取资讯
$article = Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getArticle', array($id));
$article = Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getArticle', array($id, $clientType));
if (!isset($article['tag'])) {
return $result;
}
... ... @@ -40,22 +47,22 @@ class DetailData
}
// 获取作者信息
Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_PACKAGE_AUTHOR, 'getAuthor', array($article['author_id']), function ($retval) use (&$result) {
Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_PACKAGE_AUTHOR, 'getAuthor', array($article['author_id'], $clientType), function ($retval) use (&$result) {
$result['getAuthor'] = empty($retval) ? array() : $retval;
});
// 获取资讯内容
Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getArticleContent', array($id), function ($retval) use (&$result) {
Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getArticleContent', array($id, $clientType), function ($retval) use (&$result) {
$result['getArticleContent'] = empty($retval) ? array() : $retval;
});
// 获取资讯相关的品牌
Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getBrand', array($id), function ($retval) use (&$result) {
Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getBrand', array($id, $clientType), function ($retval) use (&$result) {
$result['getBrand'] = empty($retval) ? array() : $retval;
});
// 获取资讯相关的其它资讯
Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getOtherArticle', array($article['tag'], $id, 0, 3), function ($retval) use (&$result) {
Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getOtherArticle', array($article['tag'], $id, 0, 3, $clientType), function ($retval) use (&$result) {
$result['getOtherArticle'] = empty($retval) ? array() : $retval;
});
... ...
... ... @@ -58,7 +58,7 @@ class ListData
if (isset($sortId)) {
$param['sort_id'] = $sortId;
}
if (isset($tag)) {
if (!empty($tag)) {
$param['tag'] = $tag;
}
if (isset($authorId) && is_numeric($authorId)) {
... ... @@ -110,7 +110,7 @@ class ListData
$result = array();
if (is_numeric($id)) {
$result = Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_AUTHOR, 'getAuthor', array($id));
$result = Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_AUTHOR, 'getAuthor', array($id), 3600); // 缓存1小时
}
return $result;
... ...
... ... @@ -35,7 +35,7 @@ class Helpers
case 'index': // 默认
$url = '';
break;
default:
default: // 其它子域名
$url = 'http://' . $module . SUB_DOMAIN;
}
$url .= $uri;
... ... @@ -48,6 +48,7 @@ class Helpers
/**
* 根据尺寸获得图片url
*
* @param string $url 路径
* @param integer $width 图片宽度
* @param integer $height 图片高度
... ... @@ -60,7 +61,7 @@ class Helpers
}
/**
* 获取过滤后的URL链接
* 获取过滤APP里附加参数后的URL链接
*
* @param string $url 路径
* @return string 去除掉如&openby:yohobuy={"action":"go.brand"}这样的APP附加参数
... ... @@ -117,6 +118,31 @@ class Helpers
}
/**
* 获取商品的ICON
*
* @param int $type
* @return array
*/
public static function getProductIcon($type)
{
static $icons = array(
1 => 'cloth',
3 => 'pants',
4 => 'dress',
6 => 'shoe',
7 => 'bag',
10 => 'lamp',
241 => 'headset',
8 => 'watch',
360 => 'swim-suit',
308 => 'under'
);
$type = intval($type);
return isset($icons[$type]) ? $icons[$type] : '';
}
/**
* 格式化商品信息
*
* @param array $productData 需要格式化的商品数据
... ... @@ -127,7 +153,6 @@ class Helpers
*/
public static function formatProduct($productData, $showTags = true, $showNew = true, $showSale = true)
{
// 商品信息有问题,则不显示
if (!isset($productData['product_skn']) || !isset($productData['goods_list'][0])) {
return false;
... ... @@ -154,7 +179,7 @@ class Helpers
$result['is_soon_sold_out'] = ($productData['is_soon_sold_out'] === 'Y');
$result['url'] = OLD_MAIN . '/product/pro_' . $productData['product_id'] . '_'
. $productData['goods_list'][0]['goods_id']
. '/'. $productData['cn_alphabet'] . '.html';
. '/' . $productData['cn_alphabet'] . '.html';
if ($showTags) {
$result['tags'] = array();
... ... @@ -190,7 +215,7 @@ class Helpers
$result['id'] = $articleData['id'];
$result['showTags'] = $showTag;
$result['img'] = self::getImageUrl($articleData['src'], 640, 640);
$result['url'] = $isApp && !empty($articleData['url']) ? $articleData['url'] : '/info/index?id=' . $articleData['id'];
$result['url'] = $isApp ? $articleData['url'] : self::url('/info/index', array('id' => $articleData['id']), 'guang');
$result['title'] = $articleData['title'];
$result['text'] = $articleData['intro'];
$result['publishTime'] = $articleData['publish_time'];
... ... @@ -402,29 +427,4 @@ class Helpers
return false;
}
/**
* 获取商品的ICON
*
* @param int $type
* @return array
*/
public static function getProductIcon($type)
{
static $icons = array(
1 => 'cloth',
3 => 'pants',
4 => 'dress',
6 => 'shoe',
7 => 'bag',
10 => 'lamp',
241 => 'headset',
8 => 'watch',
360 => 'swim-suit',
308 => 'under'
);
$type = intval($type);
return isset($icons[$type]) ? $icons[$type] : '';
}
}
... ...
... ... @@ -20,6 +20,7 @@ use Plugin\LightnCandy;
class TemplateLayout implements View_Interface
{
/* 模板变量 */
protected $_tpl_vars;
/* 模板目录 */
protected $_tpl_dir;
... ... @@ -118,6 +119,23 @@ class TemplateLayout implements View_Interface
// 应用版本号
$tpl_vars['version'] = $config->version;
// SEO相关的标题、关键词、描述内容信息
if (isset($tpl_vars['title'])) {
$tpl_vars['title'] .= $config->seo->title;
} else {
$tpl_vars['title'] = $config->seo->title;
}
if (isset($tpl_vars['keywords'])) {
$tpl_vars['keywords'] .= $config->seo->keywords;
} else {
$tpl_vars['keywords'] = $config->seo->keywords;
}
if (isset($tpl_vars['description'])) {
$tpl_vars['description'] .= $config->seo->description;
} else {
$tpl_vars['description'] = $config->seo->description;
}
// 取得模板的最后修改时间戳
$lastModifyTime = filemtime($viewName);
// 使用MD5生成唯一的键名
... ... @@ -151,8 +169,7 @@ class TemplateLayout implements View_Interface
// 装载内容,调用PHP函数
try {
$result = $renderer($tpl_vars);
}
catch (Exception $e) {
} catch (Exception $e) {
$result = '';
}
... ...
... ... @@ -14,9 +14,11 @@ var winH = $(window).height(),
var $author = $('#author-infos');
var $tag = $('#tag');
var $gender = $('#gender');
var $isApp = $('#isApp');
var setting = {
page: 1,
page: 2,
end: false
};
... ... @@ -32,7 +34,9 @@ if ($author.length > 0) {
if ($tag.length > 0) {
$.extend(setting, {
tag: $tag.val()
tag: $tag.val(),
gender: $gender.val(),
isApp: $isApp.val()
});
}
... ...
{{> layout/header}}
<div class="guang-list-page guang-page yoho-page">
{{# guang}}
{{# guang}}
{{# author}}
<div id="author-infos" class="editor-header clearfix" data-id={{id}}>
<div class="avatar">
... ... @@ -25,9 +25,16 @@
</div>
<span class="no-more status hide">没有更多啦</span>
</div>
{{#if tag}}
<input id="tag" type="hidden" value={{tag}}>
{{/if}}
{{/ guang}}
{{#if gender}}
<input id="gender" type="hidden" value={{gender}}>
{{/if}}
{{#if isApp}}
<input id="isApp" type="hidden" value={{isApp}}>
{{/if}}
{{/ guang}}
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -2,9 +2,9 @@
<html>
<head>
<meta charset="utf-8">
<title>{{title}}Yoho!Buy有货</title>
<meta name="keywords" content="{{keywords}}Yoho! 有货官网,潮流志,潮流男装,潮牌,美国潮牌,日本潮牌,香港潮牌,潮牌店,新品首发,欧美潮流,全球购,代购,时尚,流行,特卖,B2C,正品,购物网站,网上购物,货到付款">
<meta name="description" content="{{description}}YOHO! 有货,年轻人潮流购物中心,中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。作为YOHO!旗下的购物平台,汇集了全球潮流时尚商品和中国最流行的商品,也是国内最大的原创文化商品平台,也是香港,台湾地区流行商品的集中地。同时包含日本、韩国等众多国外潮流品牌,带给您全新潮流购物体验。">
<title>{{title}}</title>
<meta name="keywords" content="{{keywords}}">
<meta name="description" content="{{description}}">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta http-equiv="cleartype" content="on">
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
... ...
... ... @@ -23,8 +23,12 @@ class IndexController extends AbstractAction
$uid = $this->getUid();
$udid = $this->getUdid();
$type = $this->get('id', 0);
$gender = rawurldecode($this->get('gender', '1,2,3'));
$gender = $this->get('gender', '1,2,3');
if (is_string($gender)) {
$gender = rawurldecode($gender);
}
// // 设置侧边栏逛的默认选中状态
// if ($gender === '1,3') {
... ... @@ -51,19 +55,36 @@ class IndexController extends AbstractAction
$tag = $this->get('query');
$channel = $this->get('yh_channel');
// 标识是不是APP客户端
$isApp = is_numeric($channel);
// APP访问时通过频道参数判断性别
if ($isApp) {
switch (intval($channel)) {
case 1: // 男
$gender = '1,3';
break;
case 2: // 女
$gender = '2,3';
break;
default: // 所有
$gender = '1,2,3';
}
}
// 从Cookie获取
else {
$gender = Helpers::getGenderByCookie();
$this->setNavHeader($tag, true, SITE_MAIN);
}
// 标签聚合内容列表
$article = ListData::article('', 0, $uid, $udid, 1, $tag);
$article = ListData::article($gender, 0, $uid, $udid, 1, $tag);
// 标签聚合内容不存在, 跳到错误页面
if (empty($article['data']['list']['artList'])) {
$this->error();
}
// 标识是不是APP客户端
$isApp = isset($channel);
$this->setTitle($tag);
if (!$isApp) {
$this->setNavHeader($tag, true, SITE_MAIN);
}
$data = array();
// 模板中使用JS的标识
... ... @@ -78,6 +99,8 @@ class IndexController extends AbstractAction
// 分页需要的参数
$data['guang']['tag'] = $tag;
$data['guang']['gender'] = $gender;
$data['guang']['isApp'] = $isApp ? 1 : 0;
$this->_view->display('list', $data);
}
... ... @@ -99,14 +122,31 @@ class IndexController extends AbstractAction
if (!isset($author['name'])) {
$this->error();
}
// 标识是不是APP客户端
$isApp = isset($channel);
$isApp = is_numeric($channel);
// APP访问时通过频道参数判断性别
if ($isApp) {
switch (intval($channel)) {
case 1: // 男
$gender = '1,3';
break;
case 2: // 女
$gender = '2,3';
break;
default: // 所有
$gender = '1,2,3';
}
}
// 从Cookie获取
else {
$gender = Helpers::getGenderByCookie();
$this->setTitle('编辑简介');
if (!$isApp) {
$this->setNavHeader('编辑简介', true, SITE_MAIN);
}
$this->setTitle('编辑简介');
$uid = $this->getUid();
$udid = $this->getUdid();
... ... @@ -122,16 +162,19 @@ class IndexController extends AbstractAction
$data['author']['id'] = $id;
// 标签聚合内容列表
$article = ListData::article('', 0, $uid, $udid, 1, null, $id);
$article = ListData::article($gender, 0, $uid, $udid, 1, null, $id);
// 构建资讯文章内容
if (!empty($article['data']['list']['artList'])) {
$build = array();
foreach ($article['data']['list']['artList'] as $article) {
$build[] = Helpers::formatArticle($article, true, false, false);
$build[] = Helpers::formatArticle($article, true, $isApp, false);
}
$data['guang']['infos'] = $build;
}
$data['guang']['gender'] = $gender;
$data['guang']['isApp'] = $isApp ? 1 : 0;
$this->_view->display('list', $data);
}
... ... @@ -161,6 +204,7 @@ class IndexController extends AbstractAction
$page = $this->get('page');
$gender = $this->get('gender');
$authorId = $this->get('authorId');
$isApp = $this->get('isApp', false);
$showAuthor = true;
if (!empty($sortId) && !is_numeric($sortId)) {
break;
... ... @@ -185,7 +229,7 @@ class IndexController extends AbstractAction
$data = array();
$build = array();
foreach ($article['data']['list']['artList'] as $article) {
$build[] = Helpers::formatArticle($article, true, false, $showAuthor);
$build[] = Helpers::formatArticle($article, true, $isApp, $showAuthor);
}
$data['infos'] = $build;
... ...
... ... @@ -25,14 +25,16 @@ class InfoController extends AbstractAction
$this->error();
}
// 标识是不是APP访问的
$isApp = null !== $this->get('app_version', null);
// 获取详情内容信息, 异常则跳到错误页面
$detail = DetailData::package($id);
$detail = DetailData::package($id, $isApp);
if (empty($detail['getArticle'])) {
$this->error();
}
// WAP上设置头部导航
if (null === $this->get('openby:yohobuy', null)) {
if (!$isApp) {
$this->setNavHeader('逛', true, SITE_MAIN);
}
... ... @@ -46,7 +48,7 @@ class InfoController extends AbstractAction
$data['guang']['author']['avatar'] = $detail['getAuthor']['avatar'];
$data['guang']['author']['name'] = $detail['getAuthor']['name'];
$data['guang']['author']['intro'] = $detail['getAuthor']['author_desc'];
$data['guang']['author']['url'] = Helpers::url('/author/index', array('id' => $detail['getArticle']['author_id']), 'guang');
$data['guang']['author']['url'] = $isApp ? $detail['getAuthor']['url'] : Helpers::url('/author/index', array('id' => $detail['getArticle']['author_id']), 'guang');
}
$data['detail'] = array();
... ... @@ -70,8 +72,7 @@ class InfoController extends AbstractAction
// 单张图
elseif (isset($value['singleImage'])) {
$build['bigImage'] = Helpers::getImageUrl($value['singleImage']['data'][0]['src'], 640, 640);
}
elseif (isset($value['smallPic'])) {
} elseif (isset($value['smallPic']['data'])) {
$imgs = $value['smallPic']['data'];
$build['smallImage'] = array(
array(
... ... @@ -148,7 +149,9 @@ class InfoController extends AbstractAction
// 相关标签
if (!empty($detail['getArticle']['tags'])) {
foreach ($detail['getArticle']['tags'] as $value) {
if (!$isApp) {
$value['url'] = Helpers::url('/tags/index', array('query=' => $value['name']), 'guang');
}
$data['relatedTag'][] = $value;
}
}
... ... @@ -156,15 +159,30 @@ class InfoController extends AbstractAction
// 相关文章
if (!empty($detail['getOtherArticle'])) {
foreach ($detail['getOtherArticle'] as $value) {
if (!$isApp) {
$value['url'] = Helpers::url('/info/index', array('id' => $value['id']), 'guang');
}
$value['thumb'] = Helpers::getImageUrl($value['thumb'], 279, 175);
$data['relatedInfo'][] = $value;
}
}
// 分享参数
if (isset($detail['getArticle']['cover_image'])) {
$data['shareLink'] = Helpers::url('/info/index', array('id' => $id), 'guang');
$data['shareTitle'] = $detail['getArticle']['article_title'];
$data['shareDesc'] = $detail['getArticle']['article_summary'];
if ($detail['getArticle']['cover_image_type'] == 1) {
$data['shareImg'] = Helpers::getImageUrl($detail['getArticle']['cover_image'], 640, 640);
} else {
$data['shareImg'] = Helpers::getImageUrl($detail['getArticle']['cover_image'], 640, 320);
}
}
$this->_view->display('index', $data);
$detail = array();
$data = array();
}
}
... ...
... ... @@ -51,3 +51,8 @@ application.assets.path = ROOT_PATH "/assets"
; 应用的版本号
application.version = "0.0.5"
; 网站SEO信息
application.seo.title = "Yoho!Buy有货"
application.seo.keywords = "Yoho! 有货官网,潮流志,潮流男装,潮牌,美国潮牌,日本潮牌,香港潮牌,潮牌店,新品首发,欧美潮流,全球购,代购,时尚,流行,特卖,B2C,正品,购物网站,网上购物,货到付款"
application.seo.description = "YOHO! 有货,年轻人潮流购物中心,中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。作为YOHO!旗下的购物平台,汇集了全球潮流时尚商品和中国最流行的商品,也是国内最大的原创文化商品平台,也是香港,台湾地区流行商品的集中地。同时包含日本、韩国等众多国外潮流品牌,带给您全新潮流购物体验。"
\ No newline at end of file
... ...
... ... @@ -51,3 +51,8 @@ application.assets.path = ROOT_PATH "/assets"
; 应用的版本号
application.version = "0.0.5"
; 网站SEO信息
application.seo.title = "Yoho!Buy有货"
application.seo.keywords = "Yoho! 有货官网,潮流志,潮流男装,潮牌,美国潮牌,日本潮牌,香港潮牌,潮牌店,新品首发,欧美潮流,全球购,代购,时尚,流行,特卖,B2C,正品,购物网站,网上购物,货到付款"
application.seo.description = "YOHO! 有货,年轻人潮流购物中心,中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。作为YOHO!旗下的购物平台,汇集了全球潮流时尚商品和中国最流行的商品,也是国内最大的原创文化商品平台,也是香港,台湾地区流行商品的集中地。同时包含日本、韩国等众多国外潮流品牌,带给您全新潮流购物体验。"
\ No newline at end of file
... ...
... ... @@ -51,3 +51,8 @@ application.assets.path = ROOT_PATH "/assets"
; 应用的版本号
application.version = "0.0.5"
; 网站SEO信息
application.seo.title = "Yoho!Buy有货"
application.seo.keywords = "Yoho! 有货官网,潮流志,潮流男装,潮牌,美国潮牌,日本潮牌,香港潮牌,潮牌店,新品首发,欧美潮流,全球购,代购,时尚,流行,特卖,B2C,正品,购物网站,网上购物,货到付款"
application.seo.description = "YOHO! 有货,年轻人潮流购物中心,中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。作为YOHO!旗下的购物平台,汇集了全球潮流时尚商品和中国最流行的商品,也是国内最大的原创文化商品平台,也是香港,台湾地区流行商品的集中地。同时包含日本、韩国等众多国外潮流品牌,带给您全新潮流购物体验。"
\ No newline at end of file
... ...
... ... @@ -89,4 +89,11 @@ routes.girls.route.module = Index
routes.girls.route.controller = Girls
routes.girls.route.action = index
; 商品筛选
routes.goodsfilter.type = "rewrite"
routes.goodsfilter.match = "/search/filter"
routes.goodsfilter.route.module = Index
routes.goodsfilter.route.controller = Search
routes.goodsfilter.route.action = Filter
... ...
; 商品筛选
routes.goodsfilter.type = "rewrite"
routes.goodsfilter.match = "/search/filter"
routes.goodsfilter.route.module = Index
routes.goodsfilter.route.controller = Search
routes.goodsfilter.route.action = Filter
\ No newline at end of file
... ...