Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYWAP
·
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
郭成尧
9 years ago
Commit
d32dfb777f0e0f1b18abc078de74e7a3a8350f5c
2 parents
56c4ccfe
384b30c7
兼容原来的cuxiao_activity
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
350 additions
and
50 deletions
library/Plugin/DataProcess/CouponFloorProcess.php
static/js/index/coupon.js
template/m.yohobuy.com/actions/index/coupon/couponlist.phtml
template/m.yohobuy.com/actions/index/coupon/focus.phtml
template/m.yohobuy.com/actions/index/coupon/imagelist.phtml
template/m.yohobuy.com/actions/index/coupon/index.phtml
template/m.yohobuy.com/actions/index/coupon/newarrival.phtml
yohobuy/m.yohobuy.com/application/controllers/Coupon.php
library/Plugin/DataProcess/CouponFloorProcess.php
View file @
d32dfb7
...
...
@@ -8,8 +8,10 @@
namespace
Plugin\DataProcess
;
use
WebPlugin\Cache
;
use
Plugin\Images
;
use
Plugin\Helpers
;
use
WebPlugin\HelperSearch
;
class
CouponFloorProcess
{
...
...
@@ -159,6 +161,155 @@ class CouponFloorProcess
}
/**
* 焦点图
*
* @param $data
* @return mixed
*/
public
static
function
focus
(
$data
)
{
$result
=
array
();
$result
[
'isFocus'
]
=
true
;
foreach
(
$data
as
&
$item
)
{
$item
[
'img'
]
=
Images
::
getImageUrl
(
$item
[
'src'
],
0
,
0
);
}
$result
[
'list'
]
=
$data
;
return
$result
;
}
/**
* 这个是图片列表
* 重构
*
* @param $data
* @return mixed
*/
public
static
function
image_list
(
$data
)
{
$result
=
array
();
foreach
(
$data
[
'list'
]
as
&
$image
)
{
$num
=
$data
[
'title'
][
'column_num'
];
if
(
$num
==
0
)
{
$image
[
'src'
]
=
str_replace
(
'?imageView/{mode}/w/{width}/h/{height}'
,
''
,
$image
[
'src'
]);
}
else
{
if
(
640
%
$num
==
0
)
{
$width
=
(
int
)(
640
/
$num
);
$width
=
empty
(
$width
)
?
640
:
$width
;
$image
[
'src'
]
=
str_replace
(
'?imageView/{mode}/w/{width}/h/{height}'
,
'?imageView2/2/w/'
.
$width
,
$image
[
'src'
]);
$image
[
'src'
]
=
Images
::
getImageUrl
(
$image
[
'src'
],
$width
,
0
);
}
else
{
$image
[
'src'
]
=
str_replace
(
'?imageView/{mode}/w/{width}/h/{height}'
,
''
,
$image
[
'src'
]);
}
}
$image
[
'url'
]
=
empty
(
$image
[
'url'
])
?
'javascript:void(0);'
:
$image
[
'url'
];
}
$result
[
'isImageList'
]
=
true
;
$result
[
'imageList'
]
=
array
(
'col'
=>
$data
[
'title'
][
'column_num'
],
'title'
=>
$data
[
'title'
][
'title'
],
'list'
=>
$data
[
'list'
]
);
return
$result
;
}
/**
* 促銷
* 重构
*
* @param $data
* @return mixed
*/
public
static
function
promotion
(
$data
)
{
$result
=
array
();
$result
[
'newArrival'
]
=
array
(
'goods'
=>
self
::
getRecomProduct
(
1
,
50
,
$data
[
'promotionId'
])
);
$result
[
'isNewArrival'
]
=
true
;
return
$result
;
}
/**
* 推荐商品
* 重构
*
* @param int $page
* @param int $limit
* @param string $promotion
* @return array
*/
public
static
function
getRecomProduct
(
$page
=
1
,
$limit
=
50
,
$promotion
=
''
)
{
$receiveData
=
filter_input_array
(
INPUT_GET
,
array
(
'gender'
=>
FILTER_DEFAULT
,
'promotion'
=>
FILTER_DEFAULT
,
));
$gender
=
empty
(
$receiveData
[
'gender'
])
?
'1,2,3'
:
$receiveData
[
'gender'
];
$promotion
=
empty
(
$receiveData
[
'promotion'
])
?
$promotion
:
$receiveData
[
'promotion'
];
$genders
=
array
(
'1,3'
,
'2,3'
,
'1,2,3'
);
if
(
!
in_array
(
$gender
,
$genders
))
{
$gender
=
'1,2,3'
;
}
if
(
empty
(
$promotion
))
{
return
array
();
}
$params
=
array
(
'status'
=>
1
,
'order'
=>
's_t_desc'
,
'page'
=>
$page
,
'promotion'
=>
$promotion
,
'viewNum'
=>
$limit
,
'gender'
=>
$gender
,
'p_d'
=>
'1,1'
,
'stocknumber'
=>
3
);
$key
=
Cache
::
makeKey
(
$params
);
$data
=
Cache
::
get
(
$key
);
if
(
empty
(
$data
))
{
$productList
=
HelperSearch
::
getProductList
(
$params
,
array
(
'action'
=>
'new'
));
$data
=
array
();
foreach
(
$productList
[
'data'
][
'product_list'
]
as
$product
)
{
$is_yohood
=
false
;
$is_sale
=
false
;
if
(
isset
(
$product
[
'is_yohood'
]))
{
$is_yohood
==
'Y'
?
true
:
false
;
}
$goods_id
=
$product
[
'goods_list'
][
0
][
'goods_id'
];
$data
[]
=
array
(
'id'
=>
$product
[
'product_id'
],
'isLike'
=>
false
,
'isFew'
=>
false
,
//即将售罄
'src'
=>
str_replace
(
'?imageView/{mode}/w/{width}/h/{height}'
,
'?imageView2/1/w/320/h/426'
,
$product
[
'default_images'
]),
'name'
=>
$product
[
'product_name'
],
'price'
=>
$product
[
'market_price'
]
==
$product
[
'sales_price'
]
?
0
:
$product
[
'market_price'
],
'salePrice'
=>
$product
[
'sales_price'
],
'tags'
=>
array
(
'isNew'
=>
$product
[
'is_new'
]
==
'Y'
?
true
:
false
,
'isLimit'
=>
$product
[
'is_limited'
]
==
'Y'
?
true
:
false
,
'isYohood'
=>
$is_yohood
,
'isSale'
=>
$is_sale
,
//促销
),
'url'
=>
Helpers
::
getUrlBySkc
(
$product
[
'product_id'
],
$goods_id
,
$product
[
'cn_alphabet'
]),
);
}
Cache
::
set
(
$key
,
$data
,
600
);
}
return
$data
;
}
/**
* 获取分享
*
* @param $code 资源码
* @param string $shareTitle 分享标题
* @param string $shareDesc 分享描述
* @param string $shareImg 分享图片
* @return array
* @internal param int $share_id
*/
public
static
function
getShare
(
$code
,
$shareTitle
=
''
,
$shareDesc
=
''
,
$shareImg
=
''
)
{
return
array
(
'share'
=>
array
(
'shareLink'
=>
Helpers
::
url
(
'/coupon/floor'
,
array
(
'code'
=>
$code
),
''
),
'shareTitle'
=>
$shareTitle
,
'shareDesc'
=>
$shareDesc
,
'shareImg'
=>
$shareImg
,
'hasWxShare'
=>
true
,
),
);
}
/**
*
* 辅助方法 Debug 数据输出
*
...
...
static/js/index/coupon.js
View file @
d32dfb7
...
...
@@ -6,7 +6,8 @@ var $ = require('jquery'),
$receive
=
$
(
'.main-right-receive'
),
$mask
=
$
(
'.floor-mask'
),
$message
=
$
(
'.floor-message'
),
$tooltip
=
$
(
'.floor-tooltip'
);
$tooltip
=
$
(
'.floor-tooltip'
),
tip
=
require
(
'../plugin/tip'
);
var
bannerSwiper
;
...
...
@@ -41,7 +42,13 @@ $receive.on('click', function() {
status
=
data
.
status
;
if
(
data
.
noLogin
===
true
)
{
location
.
href
=
data
.
url
+
'?code='
+
getUrlParam
(
'code'
);
var
newUrl
=
data
.
url
+
'?code='
+
getUrlParam
(
'code'
);
if
(
$
(
'#intimacy-link'
).
length
<=
0
)
{
$
(
'body'
).
append
(
'<a href=\''
+
newUrl
+
'\' style="display:none;" id="intimacy-link">'
+
'<span class="intimacy-link"></span></a>'
);
}
$
(
'.intimacy-link'
).
click
();
}
else
{
if
(
status
)
{
$curDom
.
hide
();
...
...
@@ -57,12 +64,15 @@ $receive.on('click', function() {
$message
.
show
();
}
}
},
error
:
function
()
{
tip
.
show
(
'网络异常!'
);
}
});
});
$
(
'.coupon-floor a'
).
on
(
'click'
,
function
()
{
if
(
$
(
this
).
attr
(
'href'
).
length
<=
0
)
{
$
(
'.coupon-floor a, .banner-top a'
).
on
(
'click'
,
function
()
{
if
(
$
(
this
).
attr
(
'href'
).
length
<=
0
||
$
(
this
).
attr
(
'href'
)
===
'#'
)
{
return
false
;
}
});
...
...
@@ -78,4 +88,9 @@ if ($('.banner-swiper').find('li').size() > 1) {
slideElement
:
'li'
,
pagination
:
'.banner-top .pagination-inner'
});
}
\ No newline at end of file
}
$
(
'.coupon-message-op-rel'
).
on
(
'click'
,
function
(){
location
.
reload
();
});
...
...
template/m.yohobuy.com/actions/index/coupon/couponlist.phtml
0 → 100644
View file @
d32dfb7
<div class="coupon-floor" coupon-id="{{couponID}}">
{{#if showFloorTitle}}
<div class="floor-title">
{{floorTitle}}
</div>
{{/if}}
<div class="floor-main" style="background-image: url({{image.src}});">
<a href="{{image.url}}" class="main-left"></a>
{{#if isGet}}
<div class="main-right-receive">
<span class="on-receive"></span>
</div>
<a href="{{image.url}}" class="main-right-use" style="display: none">
<span class="received"></span>
</a>
{{/if}}
{{#if isGeted}}
<a href="{{image.url}}" class="main-right-use">
<span class="received"></span>
</a>
{{/if}}
{{#if isZero}}
<a href="{{image.url}}" class="main-right-go">
<span class="zero"></span>
</a>
{{/if}}
</div>
</div>
\ No newline at end of file
...
...
template/m.yohobuy.com/actions/index/coupon/focus.phtml
0 → 100644
View file @
d32dfb7
<div class="newfestival-container">
{{# slider}}
<div class="swiper-container newfestival-block">
<div class="swiper-wrapper">
{{# imgs}}
<div class="swiper-slide">
<a href="{{url}}">
<img src="{{src}}" alt="">
</a>
</div>
{{/ imgs}}
</div>
<div class="swiper-pagination"></div>
</div>
{{/ slider}}
</div>
\ No newline at end of file
...
...
template/m.yohobuy.com/actions/index/coupon/imagelist.phtml
0 → 100644
View file @
d32dfb7
<div class="newfestival-container">
{{# imageList}}
<div class="img-list newfestival-block newfestival-recom-{{col}} clearfix">
{{# title}}
<div class="new-arrival-header">
<span class="header-text"> {{.}}</span>
</div>
{{/ title}}
{{# list}}
<div class="newfestival-recom-item">
<a href="{{url}}" class="img-wrapper">
<img class="img" src="{{src}}" alt="" style="display:block">
</a>
</div>
{{/ list}}
</div>
{{/ imageList}}
</div>
\ No newline at end of file
...
...
template/m.yohobuy.com/actions/index/coupon/index.phtml
View file @
d32dfb7
{
{>layout/header
}
}
<div
class=
"coupon-area"
>
{
{#
content
}
}
{
{#if
isSingleImage
}
}
<a
href=
"{{url}}"
><img
src=
"{{src}}"
class=
"just-img"
/></a>
{
{#if
isSingleImage
}
}
<a
href=
"{{url}}"
><img
src=
"{{src}}"
class=
"just-img"
/></a>
{
{/if
}
}
{
{#if
isCarouselBanner
}
}
{
{>
home/banner_top
}
}
{
{/if
}
}
{
{#if
isFocus
}
}
{
{>
home/banner_top
}
}
{
{/if
}
}
{
{#if
isCoupon
}
}
<div
class=
"coupon-floor"
coupon-id=
"{{couponID}}"
>
{
{#if
showFloorTitle
}
}
<div
class=
"floor-title"
>
{
{floorTitle
}
}
</div>
{
{/if
}
}
{
{#if
isCarouselBanner
}
}
{
{>
home/banner_top
}
}
{
{/if
}
}
{
{#if
isCoupon
}
}
<div
class=
"coupon-floor"
coupon-id=
"{{couponID}}"
>
{
{#if
showFloorTitle
}
}
<div
class=
"floor-title"
>
{
{floorTitle
}
}
</div>
{
{/if
}
}
<div
class=
"floor-main"
style=
"background-image: url({{image.src}});"
>
<a
href=
"{{image.url}}"
class=
"main-left"
></a>
{
{#if
isGet
}
}
<div
class=
"main-right-receive"
>
<span
class=
"on-receive"
></span>
</div>
<a
href=
"{{image.url}}"
class=
"main-right-use"
style=
"display: none"
>
<span
class=
"received"
></span>
</a>
{
{/if
}
}
{
{#if
isGeted
}
}
<a
href=
"{{image.url}}"
class=
"main-right-use"
>
<span
class=
"received"
></span>
</a>
{
{/if
}
}
{
{#if
isZero
}
}
<a
href=
"{{image.url}}"
class=
"main-right-go"
>
<span
class=
"zero"
></span>
</a>
{
{/if
}
}
</div>
<div
class=
"floor-main"
style=
"background-image: url({{image.src}});"
>
<a
href=
"{{image.url}}"
class=
"main-left"
></a>
{
{#if
isGet
}
}
<div
class=
"main-right-receive"
>
<span
class=
"on-receive"
></span>
</div>
{
{/if
}
}
<a
href=
"{{image.url}}"
class=
"main-right-use"
style=
"display: none"
>
<span
class=
"received"
></span>
</a>
{
{/if
}
}
{
{#if
isGeted
}
}
<a
href=
"{{image.url}}"
class=
"main-right-use"
>
<span
class=
"received"
></span>
</a>
{
{/if
}
}
{
{#if
isZero
}
}
<a
href=
"{{image.url}}"
class=
"main-right-go"
>
<span
class=
"zero"
></span>
</a>
{
{/if
}
}
</div>
</div>
{
{/if
}
}
{
{#if
isImageList
}
}
{
{>
coupon/imagelist
}
}
{
{/if
}
}
{
{#if
isNewArrival
}
}
{
{>
coupon/newarrival
}
}
{
{/if
}
}
{
{#
share
}
}
<input
id=
"shareLink"
type=
"hidden"
value=
"{{shareLink}}"
>
<input
id=
"shareDesc"
type=
"hidden"
value=
"{{shareDesc}}"
>
<input
id=
"shareImg"
type=
"hidden"
value=
"{{shareImg}}"
>
<input
id=
"shareTitle"
type=
"hidden"
value=
"{{shareTitle}}"
>
{
{/
share
}
}
{
{/
content
}
}
</div>
<div
class=
"floor-mask"
></div>
<div
class=
"floor-message"
>
<div
class=
"coupon-message-content"
></div>
<div
class=
"coupon-message-op"
>
<a
href=
"http://m.dev.yohobuy.com/coupon/floor"
>
<span
class=
"coupon-message-op-rel"
>刷新</span>
</a>
<span
class=
"coupon-message-op-rel"
>刷新</span>
</div>
</div>
<div
class=
"floor-tooltip"
>
...
...
template/m.yohobuy.com/actions/index/coupon/newarrival.phtml
0 → 100644
View file @
d32dfb7
<div class="newfestival-container">
<div class="new-arrival newfestival-block">
<div class="new-arrival-header">
<span class="header-text">最新单品推荐</span>
</div>
<div class="new-arrival-content clearfix">
{{# goods}}
{{> common/good_info}}
{{/ goods}}
</div>
</div>
</div>
\ No newline at end of file
...
...
yohobuy/m.yohobuy.com/application/controllers/Coupon.php
View file @
d32dfb7
...
...
@@ -22,17 +22,27 @@ class CouponController extends AbstractAction
*/
public
function
floorAction
()
{
$this
->
setNavHeader
(
'领券中心'
,
true
,
SITE_MAIN
);
if
(
!
$this
->
isApp
())
{
$this
->
setNavHeader
(
'领券中心'
,
true
,
SITE_MAIN
);
}
$receiveData
=
filter_input_array
(
INPUT_GET
,
array
(
'code'
=>
FILTER_DEFAULT
));
$result
=
array
();
$uid
=
$this
->
getUid
();
$uid
=
''
;
if
(
$this
->
isApp
())
{
$uid
=
$this
->
get
(
'uid'
);
}
else
{
$uid
=
$this
->
getUid
();
}
$resource
=
CouponData
::
getCouponRousource
(
$receiveData
[
'code'
],
$uid
);
if
(
isset
(
$resource
[
'code'
])
&&
$resource
[
'code'
]
==
200
)
{
$result
=
CouponFloorProcess
::
getContent
(
$resource
[
'data'
]);
}
// 分享
$shareData
=
CouponFloorProcess
::
getShare
(
$receiveData
[
'code'
],
'领券中心'
);
$result
[
count
(
$result
)]
=
$shareData
;
$this
->
_view
->
display
(
'index'
,
array
(
'content'
=>
$result
,
'floorPage'
=>
true
...
...
@@ -54,7 +64,17 @@ class CouponController extends AbstractAction
// 跳转 URl
$playUrl
=
Helpers
::
url
(
'/coupon/floor'
);
// 判断用户是否登录
if
(
!
$this
->
getUid
()
||
!
is_numeric
(
$this
->
getUid
()))
{
$isLogin
=
false
;
if
(
$this
->
isApp
())
{
if
(
$this
->
get
(
'uid'
)
&&
is_numeric
(
$this
->
get
(
'uid'
)))
{
$isLogin
=
true
;
}
}
else
{
if
(
$this
->
getUid
()
&&
is_numeric
(
$this
->
getUid
()))
{
$isLogin
=
true
;
}
}
if
(
!
$isLogin
)
{
// 用户未登录,跳转登录页面
$returnData
[
'noLogin'
]
=
true
;
if
(
!
$this
->
isApp
())
{
...
...
@@ -91,7 +111,31 @@ class CouponController extends AbstractAction
*/
public
function
isApp
()
{
return
(
null
!==
$this
->
get
(
'app_version'
));
$userAgent
=
$this
->
getUserAgent
();
if
(
stristr
(
$userAgent
,
'ipad'
))
{
return
false
;
}
$mobileAgents
=
array
(
'iphone'
,
'android'
,
"240x320"
,
"acer"
,
"acoon"
,
"acs-"
,
"abacho"
,
"ahong"
,
"airness"
,
"alcatel"
,
"amoi"
,
"anywhereyougo.com"
,
"applewebkit/525"
,
"applewebkit/532"
,
"asus"
,
"audio"
,
"au-mic"
,
"avantogo"
,
"becker"
,
"benq"
,
"bilbo"
,
"bird"
,
"blackberry"
,
"blazer"
,
"bleu"
,
"cdm-"
,
"compal"
,
"coolpad"
,
"danger"
,
"dbtel"
,
"dopod"
,
"elaine"
,
"eric"
,
"etouch"
,
"fly "
,
"fly_"
,
"fly-"
,
"go.web"
,
"goodaccess"
,
"gradiente"
,
"grundig"
,
"haier"
,
"hedy"
,
"hitachi"
,
"htc"
,
"huawei"
,
"hutchison"
,
"inno"
,
"ipad"
,
"ipaq"
,
"ipod"
,
"jbrowser"
,
"kddi"
,
"kgt"
,
"kwc"
,
"lenovo"
,
"lg "
,
"lg2"
,
"lg3"
,
"lg4"
,
"lg5"
,
"lg7"
,
"lg8"
,
"lg9"
,
"lg-"
,
"lge-"
,
"lge9"
,
"longcos"
,
"maemo"
,
"mercator"
,
"meridian"
,
"micromax"
,
"midp"
,
"mini"
,
"mitsu"
,
"mmm"
,
"mmp"
,
"mobi"
,
"mot-"
,
"moto"
,
"nec-"
,
"netfront"
,
"newgen"
,
"nexian"
,
"nf-browser"
,
"nintendo"
,
"nitro"
,
"nokia"
,
"nook"
,
"novarra"
,
"obigo"
,
"palm"
,
"panasonic"
,
"pantech"
,
"philips"
,
"phone"
,
"pg-"
,
"playstation"
,
"pocket"
,
"pt-"
,
"qc-"
,
"qtek"
,
"rover"
,
"sagem"
,
"sama"
,
"samu"
,
"sanyo"
,
"samsung"
,
"sch-"
,
"scooter"
,
"sec-"
,
"sendo"
,
"sgh-"
,
"sharp"
,
"siemens"
,
"sie-"
,
"softbank"
,
"sony"
,
"spice"
,
"sprint"
,
"spv"
,
"symbian"
,
"tablet"
,
"talkabout"
,
"tcl-"
,
"teleca"
,
"telit"
,
"tianyu"
,
"tim-"
,
"toshiba"
,
"tsm"
,
"up.browser"
,
"utec"
,
"utstar"
,
"verykool"
,
"virgin"
,
"vk-"
,
"voda"
,
"voxtel"
,
"vx"
,
"wap"
,
"wellco"
,
"wig browser"
,
"wii"
,
"windows ce"
,
"wireless"
,
"xda"
,
"xde"
,
"zte"
);
$isMobile
=
false
;
foreach
(
$mobileAgents
as
$device
)
{
if
(
stristr
(
$userAgent
,
$device
))
{
$isMobile
=
true
;
break
;
}
}
return
$isMobile
;
}
/**
* 获取用户User-Agent
* @return bool
*/
public
function
getUserAgent
()
{
if
(
!
isset
(
$_SERVER
[
'HTTP_USER_AGENT'
])
||
empty
(
$_SERVER
[
'HTTP_USER_AGENT'
]))
{
return
''
;
}
return
$_SERVER
[
'HTTP_USER_AGENT'
];
}
/**
...
...
@@ -108,5 +152,4 @@ class CouponController extends AbstractAction
$this
->
helpJsonCallbackResult
(
$callback
,
$result
[
'code'
],
$result
[
'message'
],
$result
[
'data'
]);
}
}
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment