Authored by Rock Zhang

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

Conflicts:
	library/LibModels/Wap/Product/NewsaleData.php
... ... @@ -70,25 +70,28 @@
//header
{
header: {
back: true/false,
title: '',
home: '' //对应页面有就传,没有就不传
pageHeader: {
//对应页面有就传,没有就不传
navBack: '',
navTitle: '',
navHome: ''
}
}
//footer已登录
{
footer: {
name: '',
url: '',
signoutUrl: ''
pageFooter: {
user: {
name: '',
url: '',
signoutUrl: ''
}
}
}
//footer未登录
{
footer: {
pageFooter: {
loginUrl: '',
signupUrl: ''
}
... ... @@ -520,11 +523,9 @@
### 通用头部(包含在每个页面中)
{
showGoBack: true/false, //是否显示GO-BACK链接
backUrl: '',
backUrl: '', //GO-BACK链接, 不显示则不传
showHeaderImg: true/false, //显示头部图片
showHeaderText: true/false, //显示头部文字
headerText: ''
headerText: '' //头部标题文字
}
### 区域列表
... ...
... ... @@ -13,6 +13,7 @@ namespace Api;
class Yohobuy
{
const API_URL = 'http://api2.open.yohobuy.com/';
const SERVICE_URL = 'http://service.api.yohobuy.com/';
... ... @@ -26,11 +27,11 @@ class Yohobuy
'iphone' => 'a85bb0674e08986c6b115d5e3a4884fa',
'ipad' => 'ad9fcda2e679cf9229e37feae2cdcf80',
);
/**
* 取得当前的客户端类型
*/
public static function clientType()
public static function clientType()
{
// 苹果设备
if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone')) {
... ... @@ -45,7 +46,7 @@ class Yohobuy
return 'android';
}
}
/**
* 取得公共的参数
*
... ... @@ -64,7 +65,7 @@ class Yohobuy
);
return $param;
}
/**
* 构建URL
*
... ... @@ -74,6 +75,10 @@ class Yohobuy
*/
public static function httpBuildQuery($url, $data)
{
// 销毁私钥参数
if (isset($data['private_key'])) {
unset($data['private_key']);
}
if (strstr($url, '?') !== false) {
$url .= '&' . http_build_query($data, null, '&');
} else {
... ... @@ -81,7 +86,7 @@ class Yohobuy
}
return $url;
}
/**
* get方式调用接口
*
... ... @@ -93,13 +98,14 @@ class Yohobuy
*/
public static function get($url, $data = array(), $returnJson = false, $timeout = 5)
{
// 销毁私钥参数
if (isset($data['private_key'])) {
unset($data['private_key']);
}
if (!empty($data)) {
$url = self::httpBuildQuery($url, $data);
}
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
... ... @@ -128,11 +134,12 @@ class Yohobuy
public static function post($url, $data = array(), $returnJson = false, $timeout = 5, $header = array(), $cookie = array())
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
if (!empty($header)) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
} else {
}
else {
curl_setopt($ch, CURLOPT_HEADER, 0);
}
... ... @@ -146,6 +153,7 @@ class Yohobuy
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
// 销毁私钥参数
if (isset($data['private_key'])) {
unset($data['private_key']);
}
... ... @@ -158,7 +166,7 @@ class Yohobuy
}
curl_close($ch);
$data = array();
return $result;
}
... ... @@ -173,14 +181,15 @@ class Yohobuy
{
$result = array();
$response = array();
$running = null;
$running = 0;
$data = '';
$error = '';
$defaultOptions = array(
CURLOPT_HEADER => 0,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_CONNECTTIMEOUT => 5,
CURLOPT_TIMEOUT => 5,
CURLOPT_CONNECTTIMEOUT => 3,
CURLOPT_TIMEOUT => 3,
CURLOPT_NOSIGNAL => 1, //忽略所有的curl传递给php的信号,减少并发crash
);
$mh = curl_multi_init();
$ch = array();
... ... @@ -202,17 +211,20 @@ class Yohobuy
// 调用API接口
do {
$status = curl_multi_exec($mh, $running);
}
while ($status == CURLM_CALL_MULTI_PERFORM);
while ($running && $status == CURLM_OK) {
if (curl_multi_select($mh, 0.5) != -1) {
do {
$status = curl_multi_exec($mh, $running);
}
while ($status == CURLM_CALL_MULTI_PERFORM);
do {
$status = curl_multi_exec($mh, $running);
}
while ($status == CURLM_CALL_MULTI_PERFORM);
if ($status != CURLM_OK) {
break;
}
if ($running > 0) {
curl_multi_select($mh, 0.5);
}
}
while ($running);
// 获取API接口响应的结果
foreach ($urlList as $name => $api) {
... ... @@ -236,26 +248,49 @@ class Yohobuy
curl_close($ch[$name]);
}
curl_multi_close($mh);
return $result;
}
/**
* rpc调用远程服务(YAR)
*
* @see http://php.net/manual/zh/yar-client.setopt.php
* @return array
*/
public static function yarClient($uri, $method, $data = array(), $timeout = 3000)
public static function yarClient($uri, $method, $parameters = array(), $timeout = 3000)
{
$client = new \Yar_Client($uri);
$client->SetOpt(YAR_OPT_PACKAGER, 'php');
$client->SetOpt(YAR_OPT_TIMEOUT, $timeout);
$client->SetOpt(YAR_OPT_CONNECT_TIMEOUT, $timeout);
$result = $client->$method($data);
$result = $client->$method($parameters);
return $result;
}
/**
* 并行(异步)调用远程服务
*
* @see http://php.net/manual/zh/class.yar-concurrent-client.php
* @param string $uri
* @param string $method
* @param array $parameter
* @param callable $callback
* @param int $timeout
* @return void
*/
public static function yarConcurrentCall($uri, $method, $parameters, $callback, $timeout = 3000)
{
\Yar_Concurrent_Client::call($uri, $method, array($parameters), $callback, null, array(
YAR_OPT_PACKAGER => 'php',
YAR_OPT_TIMEOUT => $timeout,
YAR_OPT_CONNECT_TIMEOUT => $timeout
));
}
public static function yarConcurrentLoop($callback = null)
{
\Yar_Concurrent_Client::loop($callback);
}
}
... ...
<?php
use Action\AbstractAction;
namespace LibModels\Wap\Guang;
use Api\Sign;
use Api\Yohobuy;
/**
* 明星品牌和原创品牌
* 明星品牌和原创品牌相关的数据模型
*
* @name PlusstarData
* @package Library/LibModels/Wap/Guang
* @copyright yoho.inc
* @version 1.0 (2015-10-9 10:22:10)
* @author fei.hong <fei.hong@yoho.cn>
*/
class PlusstarController extends AbstractAction
class PlusstarData
{
/**
* 品牌列表页
* 品牌列表
*
* @param string $gender "1,3"表示男, "2,3"表示女
* @param string $channel 1表示男, 2表示女
* @return array(
* "star" => array(明星品牌列表数据),
* "original" => array(原创品牌列表数据)
* )
*/
public function listAction()
public static function brandList($gender, $channel)
{
$this->_view->assign('title', 'YOHO!有货');
$this->_view->display('list', array('test' => 'hello world'));
// 存放接口列表
$urlList = array();
// 接口调用的URL
$url = Yohobuy::SERVICE_URL . 'guang/api/v1/plustar/getlist';
// 公共的参数
$param = Yohobuy::param();
$param['gender'] = $gender;
$param['is_recommend'] = '0';
$param['yh_channel'] = $channel;
// 构建明星品牌参数及调用接口的URL
$star = $param;
$star['brand_type'] = '2';
$star['client_secret'] = Sign::getSign($star);
$urlList['star'] = Yohobuy::httpBuildQuery($url, $star);
// 构建原创品牌参数及调用接口的URL
$original = $param;
$original['brand_type'] = '3';
$original['client_secret'] = Sign::getSign($original);
$urlList['original'] = Yohobuy::httpBuildQuery($url, $original);
return Yohobuy::getMulti($urlList);
}
/**
* 品牌介绍
* 品牌介绍
*/
public function detailAction()
public static function brandInfo($id)
{
$result = array();
Yohobuy::yarConcurrentCall('http://service.api.yohobuy.com/guang/service/v1/plustar/', 'getBrandInfo', array('id' => 289), function($retval, $callinfo) use(&$result) {
$result[ $callinfo['method'] ] = empty($retval['data']) ? array() : $retval['data'];
});
Yohobuy::yarConcurrentCall('http://service.api.yohobuy.com/guang/service/v1/plustar/', 'getList', array('id' => 289), function($retval, $callinfo) use(&$result) {
$result[ $callinfo['method'] ] = empty($retval['data']) ? array() : $retval['data'];
});
Yohobuy::yarConcurrentLoop();
return $result;
}
}
\ No newline at end of file
}
... ...
... ... @@ -60,7 +60,7 @@ class NewsaleData
$urlList['week'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
$param['dayLimit'] = 3;
$urlList['sale'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
// var_dump($urlList);exit;
//var_dump($urlList);exit;
return Yohobuy::getMulti($urlList);
}
... ...
... ... @@ -3,6 +3,8 @@ $pxConvertRem: 40;
* {
-webkit-tap-highlight-color: rgba(0,0,0,0);
-moz-tap-highlight-color: rgba(0,0,0,0);
tap-highlight-color: rgba(0,0,0,0);
}
html, body {
... ... @@ -45,4 +47,4 @@ a {
color: #000;
}
@import "passport/index";
\ No newline at end of file
@import "layout/header", "layout/footer", "passport/index";
\ No newline at end of file
... ...
.yoho-footer {
font-size: 12px;
background-color: #fff;
.op-row {
position: relative;
padding: 0 30px;
height: 60px;
line-height: 60px;
.user-name {
text-decoration: underline;
}
.back-to-top {
position: absolute;
right: 20px;
}
}
.copyright {
height: 60px;
line-height: 60px;
border-top: 1px solid #ccc;
text-align: center;
color: #666;
background-color: #eee;
}
}
\ No newline at end of file
... ...
.yoho-header {
position: relative;
background-color: #000;
color: #fff;
width: 100%;
overflow: hidden;
height: 44px;
line-height: 44px;
.nav-back {
position: absolute;
left: 17px;
top: 14px;
width: 9px;
height: 16px;
background: image-url('layout/back.png') no-repeat;
background-size: 100% 100%;
outline: none;
}
.nav-home {
position: absolute;
top: 14px;
right: 17px;
width: 20px;
height: 20px;
background: image-url('layout/home.png') no-repeat;
background-size: 100% 100%;
outline: none;
}
.nav-title {
position: absolute;
margin-left: 26px;
margin-right: 32px;
height: 100%;
font-size: 18px;
color: #fff;
font-weight: bold;
top: 0;
right: 0;
left: 0;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
text-align: center;
}
}
\ No newline at end of file
... ...
{{> layout/page_footer}}
<script src="http://172.16.6.248:8000/static/js/sea.js?nowrap"></script>
<script>
seajs.config({
... ...
... ... @@ -25,4 +25,5 @@
</script>
<link rel="stylesheet" href="http://static.dev.yohobuy.com/css/index.css">
</head>
<body {{#if isPassportPage}}class=passport-body{{/if}}>
\ No newline at end of file
<body {{#if isPassportPage}}class=passport-body{{/if}}>
{{> layout/page_header}}
\ No newline at end of file
... ...
{{#pageFooter}}
<footer class="yoho-footer">
<p class="op-row">
{{# user}}
Hi,
<a class="user-name" href="{{url}}">{{name}}</a>
<a href="{{signoutUrl}}">退出</a>
{{^}}
<a href="{{loginUrl}}">登录</a>
<span class="sep-line">|</span>
<a href="{{signupUrl}}">注册</a>
{{/ user}}
<span class="back-to-top">
Back to top
<i class="iconfont">&#xe608;</i>
</span>
</p>
<address class="copyright">
CopyRight©2007-2016 南京新与力文化传播有限公司
</address>
</footer>
{{/pageFooter}}
\ No newline at end of file
... ...
{{#pageHeader}}
<header class="yoho-header">
{{#navBack}}
<a href={{.}} class="nav-back"></a>
{{/navBack}}
{{#navHome}}
<a href={{.}} class="nav-home"></a>
{{/navHome}}
{{#navTitle}}
<p class="nav-title">{{.}}</p>
{{/navTitle}}
</header>
{{/pageHeader}}
\ No newline at end of file
... ...
<div class="header">
{{#if showGoBack}}
<a class="go-back" href={{../backUrl}}>
{{#backUrl}}
<a class="go-back" href={{.}}>
<img src="http://static.dev.yohobuy.com/img/passport/go-back.png">
</a>
{{/if}}
{{#if showHeaderImg}}
{{/backUrl}}
{{#showHeaderImg}}
<img class="img-header" src="http://static.dev.yohobuy.com/img/passport/yoho-family.png">
{{/if}}
{{#if showHeaderText}}
<p class="title">{{../headerText}}</p>
{{/if}}
{{/showHeaderImg}}
{{#headerText}}
<p class="title">{{.}}</p>
{{/headerText}}
</div>
\ No newline at end of file
... ...
<?php
use Action\AbstractAction;
use Api\Yohobuy;
use LibModels\Wap\Guang\PlusstarData;
/**
* 频道选择
... ... @@ -12,6 +12,7 @@ class IndexController extends AbstractAction
$this->_view->assign('title', 'YOHO!有货');
$this->_view->display('index', array('test' => 'hello world'));
//$test = Yohobuy::yarClient('http://service.api.yohobuy.com/guang/service/v1/plustar/', 'getBrandInfo', array('id' => 289));
$test = PlusstarData::brandInfo();
var_dump($test);
}
}
\ No newline at end of file
... ...
... ... @@ -13,9 +13,7 @@ class BackController extends AbstractAction
public function emailAction()
{
$data = array(
'showGoBack' => true,
'backUrl' => '',
'showHeaderText' => true,
'backUrl' => 'm.yohobuy.com',
'headerText' => '找回密码',
'isPassportPage' => true,
'modulePath' => 'passport/back/email'
... ... @@ -28,9 +26,7 @@ class BackController extends AbstractAction
public function successAction()
{
$data = array(
'showGoBack' => true,
'backUrl' => '',
'showHeaderText' => true,
'backUrl' => 'm.yohobuy.com',
'headerText' => '找回密码',
'isPassportPage' => true,
'modulePath' => 'passport/back/email-success',
... ... @@ -45,9 +41,7 @@ class BackController extends AbstractAction
public function mobileAction()
{
$data = array(
'showGoBack' => true,
'backUrl' => '',
'showHeaderText' => true,
'backUrl' => 'm.yohobuy.com',
'headerText' => '找回密码',
'isPassportPage' => true,
'modulePath' => 'passport/back/mobile',
... ... @@ -72,9 +66,7 @@ class BackController extends AbstractAction
public function codeAction()
{
$data = array(
'showGoBack' => true,
'backUrl' => '',
'showHeaderText' => true,
'backUrl' => 'm.yohobuy.com',
'headerText' => '找回密码',
'isPassportPage' => true,
'modulePath' => 'passport/back/code',
... ... @@ -89,12 +81,19 @@ class BackController extends AbstractAction
public function passwordAction()
{
$data = array(
'showGoBack' => true,
'backUrl' => '',
'showHeaderText' => true,
'backUrl' => 'm.yohobuy.com',
'headerText' => '找回密码',
'isPassportPage' => true,
'modulePath' => 'passport/back/new-password'
'modulePath' => 'passport/back/new-password',
'pageHeader' => array(
'navBack' => 'm.yohobuy.com',
'navHome' => 'm.yohobuy.com',
'navTitle' => '上衣'
),
'pageFooter' => array(
'loginUrl' => 'm.yohobuy.com/login.html',
'signupUrl' => 'm.yohobuy.com/signup.html'
)
);
$this->_view->assign('title', 'YOHO!有货');
... ...
... ... @@ -6,8 +6,7 @@ class LoginController extends AbstractAction
public function indexAction()
{
$data = array(
'showGoBack' => true,
'backUrl' => '',
'backUrl' => 'm.yohobuy.com',
'showHeaderImg' => true,
'isPassportPage' => true,
'modulePath' => 'passport/login/login'
... ... @@ -20,9 +19,7 @@ class LoginController extends AbstractAction
public function interationalAction()
{
$data = array(
'showGoBack' => true,
'backUrl' => '',
'showHeaderText' => true,
'backUrl' => 'm.yohobuy.com',
'headerText' => '登录',
'isPassportPage' => true,
'modulePath' => 'passport/login/interational',
... ...
... ... @@ -6,9 +6,7 @@ class RegController extends AbstractAction
public function indexAction()
{
$data = array(
'showGoBack' => true,
'backUrl' => '',
'showHeaderText' => true,
'backUrl' => 'm.yohobuy.com',
'headerText' => '注册',
'isPassportPage' => true,
'modulePath' => 'passport/register/register',
... ... @@ -33,9 +31,7 @@ class RegController extends AbstractAction
public function codeAction()
{
$data = array(
'showGoBack' => true,
'backUrl' => '',
'showHeaderText' => true,
'backUrl' => 'm.yohobuy.com',
'headerText' => '注册',
'isPassportPage' => true,
'modulePath' => 'passport/register/code',
... ... @@ -50,9 +46,7 @@ class RegController extends AbstractAction
public function passwordAction()
{
$data = array(
'showGoBack' => true,
'backUrl' => '',
'showHeaderText' => true,
'backUrl' => 'm.yohobuy.com',
'headerText' => '注册',
'isPassportPage' => true,
'modulePath' => 'passport/register/password'
... ...