Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHO-ACTIVITY-PHP
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
xuqi
9 years ago
Commit
1e04438d4c53643dd27b250e9f1eb94fcaf28ff1
2 parents
8748f5a8
3843a417
Merge branch 'develop' of
http://git.dev.yoho.cn/web/yohobuy
into develop
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
131 additions
and
57 deletions
library/Configs/CacheConfig.php
library/LibModels/Wap/Category/BrandData.php
library/LibModels/Wap/Guang/DetailData.php
static/sass/category/_brand.scss
static/sass/index/_search.scss
yohobuy/m.yohobuy.com/application/controllers/Boys.php
yohobuy/m.yohobuy.com/application/controllers/Girls.php
yohobuy/m.yohobuy.com/application/controllers/Kids.php
yohobuy/m.yohobuy.com/application/controllers/Lifestyle.php
yohobuy/m.yohobuy.com/application/controllers/Search.php
yohobuy/m.yohobuy.com/application/models/Product/List.php
yohobuy/m.yohobuy.com/application/modules/Guang/controllers/Index.php
yohobuy/m.yohobuy.com/application/modules/Guang/controllers/Info.php
yohobuy/m.yohobuy.com/application/modules/Guang/controllers/Plusstar.php
yohobuy/m.yohobuy.com/application/modules/Product/controllers/Index.php
yohobuy/m.yohobuy.com/application/modules/Product/controllers/Opt.php
yohobuy/m.yohobuy.com/public/index.php
yohobuy/m.yohobuy.com/public/robots.txt
library/Configs/CacheConfig.php
View file @
1e04438
...
...
@@ -39,6 +39,7 @@ class CacheConfig
const
KEY_ACTION_PRODUCT_BRAND_DOMAINS
=
'key_action_product_brand_domains'
;
// 所有品牌域名列表
const
KEY_ACTION_PRODUCT_BRAND_NAMES
=
'key_action_product_brand_names'
;
// 所有品牌名称列表
const
KEY_ACTION_PRODUCT_BRAND_LOGO
=
'key_action_product_brand_logo'
;
// 品牌信息
const
KEY_ACTION_PRODUCT_BRAND_LOGO_DOMAIN
=
'key_action_product_brand_logo_domain'
;
// 品牌信息通过域名取得
const
KEY_ACTION_SEARCH_SEARCH
=
'key_action_search_search'
;
// 搜索的数据
const
KEY_ACTION_SEARCH_FILTER
=
'key_action_search_filter'
;
// 搜索的过滤条件
...
...
library/LibModels/Wap/Category/BrandData.php
View file @
1e04438
...
...
@@ -212,5 +212,16 @@ class BrandData
{
return
Yohobuy
::
yarClient
(
Yohobuy
::
SERVICE_URL
.
'/shops/service/v1/brand'
,
'getBrandByids'
,
array
(
$id
));
}
/**
* 通过域名获取品牌LOGO信息
*
* @param int $id 用户ID
* @return array
*/
public
static
function
getBrandLogoByDomain
(
$domain
)
{
return
Yohobuy
::
yarClient
(
Yohobuy
::
SERVICE_URL
.
'/shops/service/v1/brand'
,
'getBrandByDomain'
,
array
(
$domain
));
}
}
...
...
library/LibModels/Wap/Guang/DetailData.php
View file @
1e04438
...
...
@@ -15,6 +15,7 @@ use Api\Yohobuy;
*/
class
DetailData
{
const
URI_PACKAGE_ARTICLE
=
'guang/service/v2/article/'
;
const
URI_PACKAGE_AUTHOR
=
'guang/service/v1/author/'
;
...
...
@@ -36,15 +37,13 @@ class DetailData
// 客户端类型
$clientType
=
$isApp
?
'iphone'
:
'h5'
;
// 获取资讯
$article
=
Yohobuy
::
yarClient
(
Yohobuy
::
SERVICE_URL
.
self
::
URI_PACKAGE_ARTICLE
,
'getArticle'
,
array
(
$id
,
$clientType
));
if
(
!
isset
(
$article
[
'tag'
]))
{
$article
=
Yohobuy
::
yarClient
(
Yohobuy
::
SERVICE_URL
.
self
::
URI_PACKAGE_ARTICLE
,
'getArticle'
,
array
(
$id
,
$clientType
),
3600
);
if
(
!
isset
(
$article
[
'author_id'
]))
{
return
$result
;
}
else
{
$result
[
'getArticle'
]
=
$article
;
}
$result
[
'getArticle'
]
=
$article
;
// 获取作者信息
Yohobuy
::
yarConcurrentCall
(
Yohobuy
::
SERVICE_URL
.
self
::
URI_PACKAGE_AUTHOR
,
'getAuthor'
,
array
(
$article
[
'author_id'
],
$clientType
),
function
(
$retval
)
use
(
&
$result
)
{
...
...
@@ -62,9 +61,11 @@ class DetailData
});
// 获取资讯相关的其它资讯
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
;
});
if
(
isset
(
$article
[
'tag'
]))
{
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
;
});
}
// 调用发起请求
Yohobuy
::
yarConcurrentLoop
();
...
...
static/sass/category/_brand.scss
View file @
1e04438
...
...
@@ -68,6 +68,7 @@
.clear-text
{
margin-right
:
20rem
/
$pxConvertRem
;
color
:
#666
;
}
}
}
...
...
static/sass/index/_search.scss
View file @
1e04438
...
...
@@ -29,7 +29,7 @@
top
:
24rem
/
$pxConvertRem
;
right
:
145rem
/
$pxConvertRem
;
font-size
:
32rem
/
$pxConvertRem
;
color
:
#
b2b2b2
;
color
:
#
666
;
}
.search
{
...
...
yohobuy/m.yohobuy.com/application/controllers/Boys.php
View file @
1e04438
...
...
@@ -23,7 +23,7 @@ class BoysController extends AbstractAction
}
// 设置COOKIE标识用户访问过该页面了
Index\HomeModel
::
setSwitchToCookie
(
Index\HomeModel
::
COOKIE_NAME_BOYS
);
//
Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_BOYS);
// 设置网站标题
$this
->
setTitle
(
'男生首页'
);
...
...
yohobuy/m.yohobuy.com/application/controllers/Girls.php
View file @
1e04438
...
...
@@ -18,7 +18,7 @@ class GirlsController extends AbstractAction
$this
->
setExpires
(
300
);
// 缓存5分钟
// 设置COOKIE标识用户访问过该页面了
Index\HomeModel
::
setSwitchToCookie
(
Index\HomeModel
::
COOKIE_NAME_GIRLS
);
//
Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_GIRLS);
// 设置网站标题
$this
->
setTitle
(
'女生首页'
);
...
...
yohobuy/m.yohobuy.com/application/controllers/Kids.php
View file @
1e04438
...
...
@@ -18,7 +18,7 @@ class KidsController extends AbstractAction
$this
->
setExpires
(
300
);
// 缓存5分钟
// 设置COOKIE标识用户访问过该页面了
Index\HomeModel
::
setSwitchToCookie
(
Index\HomeModel
::
COOKIE_NAME_KIDS
);
//
Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_KIDS);
// 设置网站标题
$this
->
setTitle
(
'潮童首页'
);
...
...
yohobuy/m.yohobuy.com/application/controllers/Lifestyle.php
View file @
1e04438
...
...
@@ -18,7 +18,7 @@ class LifestyleController extends AbstractAction
$this
->
setExpires
(
300
);
// 缓存5分钟
// 设置COOKIE标识用户访问过该页面了
Index\HomeModel
::
setSwitchToCookie
(
Index\HomeModel
::
COOKIE_NAME_LIFESTYLE
);
//
Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_LIFESTYLE);
// 设置网站标题
$this
->
setTitle
(
'创意生活首页'
);
...
...
yohobuy/m.yohobuy.com/application/controllers/Search.php
View file @
1e04438
...
...
@@ -16,11 +16,6 @@ class SearchController extends AbstractAction
*/
public
function
indexAction
()
{
// 设置客户端浏览器1小时内不改变
$this
->
setLastModified
(
mktime
(
date
(
'H'
),
0
,
0
,
date
(
'n'
),
date
(
'j'
),
date
(
'Y'
)));
// 设置浏览器缓存5分钟
$this
->
setExpires
(
300
);
// 缓存5分钟
$this
->
setNavHeader
(
'搜索'
,
true
,
SITE_MAIN
);
//$this->_view->html('search');
...
...
yohobuy/m.yohobuy.com/application/models/Product/List.php
View file @
1e04438
...
...
@@ -168,7 +168,7 @@ class ListModel
}
// 调用接口查询数据
$brandLogo
=
BrandData
::
getBrandLogo
(
$id
);
$brandLogo
=
BrandData
::
getBrandLogo
(
$id
);
var_dump
(
$brandLogo
);
exit
;
// 处理返回的数据
if
(
isset
(
$brandLogo
[
'data'
][
0
]))
{
$result
=
array
(
...
...
@@ -192,6 +192,53 @@ class ListModel
return
$result
;
}
/**
* 根据品牌ID获取品牌LOGO
*
* @param int $id 品牌ID
* @param string $title 品牌标题
* @return array | false
*/
public
static
function
getBrandLogoByDomain
(
$domain
,
&
$title
)
{
$result
=
false
;
if
(
USE_CACHE
)
{
$key
=
CacheConfig
::
KEY_ACTION_PRODUCT_BRAND_LOGO_DOMAIN
.
strval
(
$domain
);
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result
=
Cache
::
get
(
$key
,
'master'
);
if
(
!
empty
(
$result
))
{
return
$result
;
}
}
// 调用接口查询数据
$brandLogo
=
BrandData
::
getBrandLogoByDomain
(
$domain
);
// 处理返回的数据
if
(
isset
(
$brandLogo
[
'data'
]))
{
$result
=
array
(
'id'
=>
$brandLogo
[
'data'
][
'id'
],
'url'
=>
Helpers
::
url
(
''
,
null
,
$brandLogo
[
'data'
][
'brand_domain'
]),
'thumb'
=>
Helpers
::
getImageUrl
(
$brandLogo
[
'data'
][
'brand_ico'
],
75
,
40
),
'name'
=>
$brandLogo
[
'data'
][
'brand_name'
],
);
$title
=
$result
[
'name'
];
}
if
(
USE_CACHE
)
{
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if
(
empty
(
$result
))
{
$result
=
Cache
::
get
(
$key
,
'slave'
);
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else
{
Cache
::
set
(
$key
,
$result
);
// 缓存1小时
}
}
return
$result
;
}
/**
* 获取所有的品牌名称列表
...
...
yohobuy/m.yohobuy.com/application/modules/Guang/controllers/Index.php
View file @
1e04438
...
...
@@ -28,6 +28,8 @@ class IndexController extends AbstractAction
$gender
=
$this
->
get
(
'gender'
,
'1,2,3'
);
if
(
is_string
(
$gender
))
{
$gender
=
rawurldecode
(
$gender
);
}
else
{
$gender
=
Helpers
::
getGenderByCookie
();
}
// // 设置侧边栏逛的默认选中状态
// if ($gender === '1,3') {
...
...
yohobuy/m.yohobuy.com/application/modules/Guang/controllers/Info.php
View file @
1e04438
...
...
@@ -26,18 +26,26 @@ class InfoController extends AbstractAction
$this
->
error
();
}
$data
=
array
();
$data
[
'guangDetail'
]
=
true
;
// 模板中使用JS的标识
$data
[
'guang'
][
'id'
]
=
$id
;
// 标识是不是APP访问的
$isApp
=
null
!==
$this
->
get
(
'app_version'
,
null
);
// 获取详情内容信息, 异常则跳到错误页面
$detail
=
DetailData
::
package
(
$id
,
$isApp
);
if
(
empty
(
$detail
[
'getArticle'
]))
{
$this
->
error
();
}
// 标识是否是微信访问
$isWeixin
=
stripos
(
$this
->
server
(
'HTTP_USER_AGENT'
,
''
),
'MicroMessenger'
)
!==
false
;
// WAP上设置头部导航
if
(
!
$isApp
)
{
if
(
!
$isApp
&&
!
$isWeixin
)
{
$this
->
setNavHeader
(
'逛'
,
true
,
SITE_MAIN
);
}
}
// 获取详情内容信息, 异常则跳到错误页面
$detail
=
DetailData
::
package
(
$id
,
$isApp
);
if
(
empty
(
$detail
[
'getArticle'
]))
{
$this
->
_view
->
display
(
'index'
,
$data
);
return
;
}
$data
=
array
();
$data
[
'guangDetail'
]
=
true
;
// 模板中使用JS的标识
...
...
@@ -179,7 +187,7 @@ class InfoController extends AbstractAction
$data
[
'shareImg'
]
=
Helpers
::
getImageUrl
(
$detail
[
'getArticle'
][
'cover_image'
],
640
,
320
);
}
}
// 标识有微信分享
$data
[
'hasWxShare'
]
=
true
;
...
...
@@ -188,7 +196,7 @@ class InfoController extends AbstractAction
$detail
=
array
();
$data
=
array
();
}
/**
* APP里使用的收藏内容的接口
*
...
...
@@ -202,15 +210,14 @@ class InfoController extends AbstractAction
if
(
!
$this
->
isAjax
())
{
break
;
}
$id
=
$this
->
get
(
'id'
);
$type
=
$this
->
get
(
'type'
);
// 收藏
if
(
$type
==
'fav'
)
{
}
}
while
(
false
);
}
}
while
(
false
);
}
}
...
...
yohobuy/m.yohobuy.com/application/modules/Guang/controllers/Plusstar.php
View file @
1e04438
...
...
@@ -85,6 +85,8 @@ class PlusstarController extends AbstractAction
$channel
=
$this
->
get
(
'yh_channel'
);
// 标识是不是APP客户端
$isApp
=
is_numeric
(
$channel
);
// 标识是否是微信访问
$isWeixin
=
stripos
(
$this
->
server
(
'HTTP_USER_AGENT'
,
''
),
'MicroMessenger'
)
!==
false
;
// APP访问时通过频道参数判断性别
if
(
$isApp
)
{
switch
(
intval
(
$channel
))
{
...
...
@@ -99,7 +101,7 @@ class PlusstarController extends AbstractAction
}
$uid
=
$this
->
get
(
'uid'
);
$udid
=
$this
->
get
(
'udid'
);
$this
->
setSession
(
'uid'
,
$uid
);
}
// 从Cookie获取
...
...
@@ -138,14 +140,14 @@ class PlusstarController extends AbstractAction
$data
[
'ps'
][
'newArrival'
][
'moreUrl'
]
=
$url
;
$data
[
'ps'
][
'newArrival'
][
'naList'
]
=
$brandInfo
[
'getNewProduct'
];
$data
[
'ps'
][
'infos'
]
=
array
();
// 拼收藏的URL, 一个坑!
// 备注:此处是根据原来逛的代码硬扒过来的
$defaultUrl
=
Helpers
::
url
(
'/plustar/brandinfo'
,
array
(
'id'
=>
$id
),
'guang'
);
if
(
$isApp
)
{
$url
=
$defaultUrl
;
$url
.=
'&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http:\/\/guang.m.yohobuy.com\/plustar\/brandinfo","param":{"id":'
.
$id
.
'}},"requesturl":{"url":"\/guang\/api\/v1\/favorite\/togglebrand","param":{"brand_id":"'
.
$brandId
.
'"}},"priority":"Y"}}'
;
$url
.=
'&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http:\/\/guang.m.yohobuy.com\/plustar\/brandinfo","param":{"id":'
.
$id
.
'}},"requesturl":{"url":"\/guang\/api\/v1\/favorite\/togglebrand","param":{"brand_id":"'
.
$brandId
.
'"}},"priority":"Y"}}'
;
}
else
{
$url
=
Helpers
::
url
(
'/signin.html'
,
array
(
'refer'
=>
$defaultUrl
));
}
...
...
@@ -161,16 +163,16 @@ class PlusstarController extends AbstractAction
}
// 设置头部信息
if
(
!
$isApp
)
{
if
(
!
$isApp
&&
!
$isWeixin
)
{
$this
->
setNavHeader
(
$data
[
'ps'
][
'name'
],
true
,
SITE_MAIN
);
}
// 标识有微信分享
$data
[
'hasWxShare'
]
=
true
;
$data
[
'shareLink'
]
=
$defaultUrl
;
$data
[
'shareTitle'
]
=
$data
[
'ps'
][
'name'
];
$data
[
'shareDesc'
]
=
(
mb_strlen
(
$data
[
'ps'
][
'intro'
],
'utf-8'
)
>
800
)
?
mb_substr
(
$data
[
'ps'
][
'intro'
],
0
,
800
,
'utf-8'
)
.
'...'
:
$data
[
'ps'
][
'intro'
];
$data
[
'shareDesc'
]
=
(
mb_strlen
(
$data
[
'ps'
][
'intro'
],
'utf-8'
)
>
800
)
?
mb_substr
(
$data
[
'ps'
][
'intro'
],
0
,
800
,
'utf-8'
)
.
'...'
:
$data
[
'ps'
][
'intro'
];
$data
[
'shareImg'
]
=
$data
[
'ps'
][
'logo'
];
$brandInfo
=
array
();
...
...
yohobuy/m.yohobuy.com/application/modules/Product/controllers/Index.php
View file @
1e04438
...
...
@@ -85,18 +85,23 @@ class IndexController extends AbstractAction
$this
->
go
(
SITE_MAIN
);
}
/* 通过品牌域名找到对应的品牌ID */
$domainList
=
Product\ListModel
::
getAllBrandDomains
();
$brandIds
=
array_keys
(
$domainList
,
$domain
);
// 存标题信息
$title
=
''
;
$brandLogo
=
Product\ListModel
::
getBrandLogoByDomain
(
$domain
,
$title
);
$brandId
=
0
;
if
(
isset
(
$brandIds
[
0
]))
{
$brandId
=
$brandIds
[
0
];
}
if
(
$brandLogo
&&
isset
(
$brandLogo
[
'id'
]))
{
$brandId
=
$brandLogo
[
'id'
];
}
/* 通过品牌域名找到对应的品牌ID */
// $domainList = Product\ListModel::getAllBrandDomains();
// $brandIds = array_keys($domainList, $domain);
// $brandId = 0;
// if (isset($brandIds[0])) {
// $brandId = $brandIds[0];
// }
// 当前的登录用户UID
$uid
=
$this
->
getUid
();
// 存标题信息
$title
=
''
;
/* 搜索框相关 */
$from
=
$this
->
get
(
'from'
);
...
...
@@ -114,7 +119,7 @@ class IndexController extends AbstractAction
'gender'
=>
FILTER_DEFAULT
,
'p_d'
=>
FILTER_DEFAULT
,),
false
);
$condition
[
'brand'
]
=
$brandId
;
if
(
$brandId
===
0
)
{
$condition
[
'query'
]
=
$domain
;
}
...
...
@@ -131,12 +136,13 @@ class IndexController extends AbstractAction
// 从搜索页过来的,显示搜索框, 和进入品牌引导信息
if
(
$from
===
'search'
)
{
$data
[
'goodList'
]
=
array
();
$data
[
'goodList'
][
'brandWay'
]
=
\Product\ListModel
::
getBrandLogoByIds
(
$brandId
,
$title
);
//$data['goodList']['brandWay'] = \Product\ListModel::getBrandLogoByIds($brandId, $title);
$data
[
'goodList'
][
'brandWay'
]
=
$brandLogo
;
$data
[
'goodList'
][
'search'
][
'default'
]
=
$query
;
$data
[
'goodList'
][
'search'
][
'url'
]
=
Helpers
::
url
(
''
,
null
,
'search'
);
}
// 品牌一览过来的展示品牌介绍和LOGO
else
{
else
if
(
$brandId
!==
0
)
{
$data
[
'brandHome'
]
=
\Product\ListModel
::
getBrandIntro
(
$brandId
,
$uid
,
$title
);
$data
[
'goodList'
]
=
array
();
}
...
...
yohobuy/m.yohobuy.com/application/modules/Product/controllers/Opt.php
View file @
1e04438
...
...
@@ -40,7 +40,7 @@ class OptController extends AbstractAction
}
/* 判断用户是否登录 */
$uid
=
$this
->
getU
d
id
();
$uid
=
$this
->
getUid
();
if
(
!
$uid
)
{
$referer
=
$this
->
server
(
'HTTP_REFERER'
,
SITE_MAIN
);
$result
=
array
(
'code'
=>
400
,
'message'
=>
'未登录'
,
'data'
=>
Helpers
::
url
(
'/signin.html'
,
array
(
'refer'
=>
$referer
)));
...
...
@@ -60,6 +60,7 @@ class OptController extends AbstractAction
$result
=
array
(
'code'
=>
401
,
'message'
=>
'参数不正确'
,
'data'
=>
false
);
break
;
}
}
while
(
false
);
$this
->
echoJson
(
$result
);
...
...
yohobuy/m.yohobuy.com/public/index.php
View file @
1e04438
<?php
use
Yaf\Application
;
define
(
'SITE_MAIN'
,
'http://m
testh5
.yohobuy.com'
);
// 网站主域名
define
(
'SITE_MAIN'
,
'http://m.yohobuy.com'
);
// 网站主域名
define
(
'OLD_MAIN'
,
'http://m.yohobuy.com'
);
// 网站旧域名
define
(
'COOKIE_DOMAIN'
,
'.yohobuy.com'
);
// COOKIE作用域
define
(
'SUB_DOMAIN'
,
'.m
testh5
.yohobuy.com'
);
// 子域名后缀
define
(
'SUB_DOMAIN'
,
'.m.yohobuy.com'
);
// 子域名后缀
define
(
'USE_CACHE'
,
true
);
// 缓存的开关
define
(
'APPLICATION_PATH'
,
dirname
(
__DIR__
));
// 应用目录
define
(
'ROOT_PATH'
,
dirname
(
dirname
(
APPLICATION_PATH
)));
// 根目录
...
...
yohobuy/m.yohobuy.com/public/robots.txt
View file @
1e04438
User-agent: *
Disallow: /
\ No newline at end of file
Disallow:
\ No newline at end of file
...
...
Please
register
or
login
to post a comment