Authored by hf

code review by fei.hong: do format huodong girlday codes

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>{{staticTitle}}</title>
<link rel="stylesheet" href="{{imgUrl}}/2016xinshili-3/css/style.css">
</head>
<body class="{{pageType}}">
<div class="header-wrap">
<div class="header">
</div>
{{#if tab}}
<div class="tab">
{{#tab}}
<div class="tab-item tab-{{@index}}" data-type="{{.}}">
<div class="before"></div>
</div>
{{/tab}}
</div>
{{/if}}
</div>
<div class="main-wrap home">
<div class="content">
</div>
<script type="text/tmpl" id="tmpl">
<div class="coupons">
\{{#coupons}}
<img class="lazy coupon" src="" data-original="{{imgUrl}}/\{{img}}" data-id="\{{id}}">
\{{/coupons}}
</div>
<div class="brands clearfix">
\{{#brands}}
<a class="brand" href='\{{url}}'>
<img class="lazy" src="" data-original="{{imgUrl}}/\{{img}}">
</a>
\{{/brands}}
<div class="after"></div>
</div>
<div class="more">
<div class="more-title">
</div>
<a class="link" href='\{{more.url}}'>
<img class="lazy" src="" data-original="{{imgUrl}}/\{{more.img}}">
</a>
</div>
</script>
<div class="footer">
</div>
</div>
<div class="tip hide fail">
<div class="title">
领取失败<br>
请刷新重新领取
</div>
<div class="desc">
如多次领取失败,请联系客服人员<br>
带来不便敬请谅解
</div>
<a class="button" href="">
刷新
</a>
</div>
<div class="tip hide success">
<div class="title">
领取成功
</div>
<div class="sub-title">
快去分享给更多<br>
喜爱<span class="title">潮流</span>的小伙伴吧!
</div>
<a class="button close" href="">
返回
</a>
</div>
<div class="tip hide geted">
<div class="title">
您已领取过了
</div>
<div class="sub-title">
快去分享给更多<br>
喜爱<span class="title">潮流</span>的小伙伴吧!
</div>
<a class="button close" href="">
返回
</a>
</div>
<input type="hidden" value="{{pageType}}" id="page-type">
<input type="hidden" value="{{activityId}}" id="activity-id">
<script type="text/javascript">
var isOnline = {{isOnline}};
</script>
<script type="text/javascript" src="{{jsUrl}}/2016xinshili-3/js/libs.js"></script>
{{# staticJS}}
<script type="text/javascript" src="{{../jsUrl}}/2016xinshili-3/js/{{.}}"></script>
{{/ staticJS}}
</body>
... ...
... ... @@ -17,7 +17,7 @@
<div class="share">
</div>
<a class="banner" href="{{banner.url}}">
<img src="{{banner.img}}" style="border: none;">
<img src="{{banner.img}}">
</a>
<div class="footer">
</div>
... ...
... ... @@ -8,7 +8,6 @@
namespace Cuxiao;
use LibModels\Wap\Cuxiao\ActivityData;
class GirldayModel
{
/**
... ...
<?php
/**
* Created by PhpStorm.
* User: Administrator
... ... @@ -8,41 +9,190 @@
use Action\HuodongWebAction;
use Cuxiao\GirldayModel;
use WebPlugin\Helpers;
use LibModels\Wap\Cuxiao\ActivityData;
use Plugin\Cache;
/**
* 女生节活动领券-第二波
* @author Administrator
*/
class GirldayController extends HuodongWebAction
{
// const STATIC_FILE = 'http://localhost:2222/1.0.3';
const STATIC_FILE = 'http://cdn.yoho.cn/huodong/2016xinshili-2-web/1.0.3';
const STATIC_FILE = 'http://cdn.yoho.cn/huodong/2016xinshili-2-web/1.0.2';
/**
* 检测登录状态
*
* @return int
* 第二波
*/
private function getLoggedUid()
public function indexAction()
{
if ($this->_isApp) {
$uid = $this->get('uid');
} else {
$uid = $this->getUid();
//echo
$this->checkLogin();
//获取跳转到个人中心-我的优惠券链接,并调用接口,完成领券操作
$myCouponUrl = Helpers::url('/home/coupons', null, 'default');
$this->_view->display('index', array(
'staticTitle' => 'YOHO!BUY有货【春潮新势力】', // 标题
'staticFile' => self::STATIC_FILE,
'staticJS' => array(
'home.js'
),
'couponUrl' => $myCouponUrl, // 个人中心优惠券地址
'banner' => array(
'img' => '',
'url' => 'http://www.yohobuy.com/special_14548_0310PCHOME.html',
),
'selectUrl' => 'http://www.yohobuy.com/home/coupons',
));
}
return $uid;
/**
* 领券活动-第三波页面控制器
*/
public function girlthreeBoyAction()
{
$this->_view->display('girlsday-three', array(
'staticTitle' => 'YOHO!BUY有货【春潮新势力】',
'staticJS' => array(
'main.js'
),
'jumpUrl' => 'javascript:;',
'pageType' => 'boy',
'tab' => array('us', 'bag', 'yohope', 'shoes'),
'isOnline' => $this->getisOnline(),
'shareTitle' => 'YOHO!BUY有货【春潮新势力】千万元优惠券限时派送中!',
'shareDesc' => '全球1000+潮牌春季上新,万款新品首发,唤醒潮流尽在有货【春潮新势力】!',
'shareLink' => 'http://feature.yoho.cn/0318/0318APPHOME/index.html',
));
}
/**
* 判断是否登录
* 女生节第3波-女生的品牌领券
*/
private function checkLogin()
public function girlthreeGirlAction()
{
$url = Helpers::url('/cuxiao/girlday/index');
$this->_view->display('girlsday-three', array(
'staticTitle' => 'YOHO!BUY有货【春潮新势力】',
'staticJS' => array(
'main.js'
),
'jumpUrl' => 'javascript:;',
'pageType' => 'girl',
'tab' => array('us', 'huimei', 'sport', 'yohope'),
'isOnline' => $this->getisOnline(),
'shareTitle' => 'YOHO!BUY有货【春潮新势力】千万元优惠券限时派送中!',
'shareDesc' => '全球1000+潮牌春季上新,万款新品首发,唤醒潮流尽在有货【春潮新势力】!',
'shareLink' => 'http://feature.yoho.cn/0318/0318APPHOME/index.html',
));
}
/**
* 女生节第3波-童品牌领券
*/
public function girlthreeKidAction()
{
$this->_view->display('girlsday-three', array(
'staticTitle' => 'YOHO!BUY有货【春潮新势力】',
'staticJS' => array(
'main.js'
),
'jumpUrl' => 'javascript:;',
'pageType' => 'kid',
// 'tab' => array('us', 'bag', 'yohope', 'shoes'),
'isOnline' => $this->getisOnline(),
'shareTitle' => 'YOHO!BUY有货【春潮新势力】千万元优惠券限时派送中!',
'shareDesc' => '全球1000+潮牌春季上新,万款新品首发,唤醒潮流尽在有货【春潮新势力】!',
'shareLink' => 'http://feature.yoho.cn/0318/0318APPHOME/index.html',
));
}
/**
* 女生节第3波-创意生活品牌领券
*/
public function girlthreeLifestyleAction()
{
$this->_view->display('girlsday-three', array(
'staticTitle' => 'YOHO!BUY有货【春潮新势力】',
'staticJS' => array(
'main.js'
),
'jumpUrl' => 'javascript:;',
'pageType' => 'lifestyle',
'tab' => array('us', 'hot'),
'isOnline' => $this->getisOnline(),
'shareTitle' => 'YOHO!BUY有货【春潮新势力】千万元优惠券限时派送中!',
'shareDesc' => '全球1000+潮牌春季上新,万款新品首发,唤醒潮流尽在有货【春潮新势力】!',
'shareLink' => 'http://feature.yoho.cn/0318/0318APPHOME/index.html',
));
}
/**
* 领券接口
*/
public function sendCouponAction()
{
$result = array('code' => 201);
do {
if (!$this->isAjax()) {
break;
}
$activityId = $this->getActivityId();
$uid = $this->getLoggedUid();
$result = GirldayModel::getGirldayCoupon($uid, $activityId);
} while (false);
$this->echoJson($result);
}
/**
* 领取指定的优惠券
*
* @param int activityId 活动ID
* @param int couponId 优惠券ID
* @return json
*/
public function getnamedAction()
{
$result = array('code' => 401, 'message' => '领取失败', 'data' => '');
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
/* 判断参数是否有效 */
$activityId = $this->getthreeActivityId();
$couponId = $this->post('couponId');
if (!is_numeric($activityId) || !is_numeric($couponId)) {
break;
}
$uid = $this->getUid();
if (!$uid) {
$this->go(Helpers::url('/signin.html', array('refer' => $url), 'default'));
$result['code'] = 400;
$result['message'] = '请先登录';
$result['data'] = Helpers::url('/signin.html', array('refer' => $this->server('HTTP_REFERER', '/')), 'default');
break;
}
/* 领取指定的优惠券操作 */
$result = ActivityData::getCouponNamed($uid, $activityId, $couponId);
if ($uid && isset($result['code']) && $result['code'] == 200) {
// 领取成功, 发送站内信消息
$couponuid = 'couponnvshengjiedisanbo' . $uid;
$status = Cache::get($couponuid);
if (!$status) {
$this->sendMessage($uid, '【优惠券】您已成功领取春潮新势力-品牌优惠券。', '尊敬的客户:恭喜您成功获得春潮新势力-品牌优惠券 !您可以在个人中心查看优惠券详情。');
Cache::set($couponuid, true, 3600 * 24 * 5);
}
}
} while (false);
$this->echoJson($result);
}
/**
* 根据环境来获取活动ID
... ... @@ -59,50 +209,87 @@ class GirldayController extends HuodongWebAction
case 'testing': // 测试
case 'develop': // 开发
default:
return 528; //490;
return 540;
}
}
/**
* 领券接口
* 根据环境来获取活动ID
*
* @return int
*/
public function sendCouponAction()
private function getthreeActivityId()
{
$result = array('code' => 201);
do {
if (!$this->isAjax()) {
break;
// 设置环境变量
switch (APPLICATION_ENV) {
case 'production': // 生产
return 544;
case 'preview': // 预览
case 'testing': // 测试
case 'develop': // 开发
default:
return 496;
}
}
$activityId = $this->getActivityId();
$uid = $this->getLoggedUid();
$result = GirldayModel::getGirldayCoupon($uid, $activityId);
} while (false);
$this->echoJson($result);
/**
* 发送站内信
*
* @param int $uid 用户ID
*/
private function sendMessage($uid, $title, $content)
{
try {
ActivityData::message($uid, $title, $content);
} catch (Exception $e) {
// do nothing
}
}
public function indexAction()
/**
* 根据环境来获取线上线下
*
* @return int
*/
private function getisOnline()
{
// 设置环境变量
switch (APPLICATION_ENV) {
case 'production': // 生产
return 1;
case 'preview': // 预览
case 'testing': // 测试
case 'develop': // 开发
default:
return 0;
}
}
$this->checkLogin();
//获取跳转到个人中心-我的优惠券链接,并调用接口,完成领券操作
$myCouponUrl = Helpers::url('/home/coupons', null, 'default');
/**
* 检测登录状态
*
* @return int
*/
private function getLoggedUid()
{
if ($this->_isApp) {
$uid = $this->get('uid');
} else {
$uid = $this->getUid();
}
return $uid;
}
$this->_view->display('index', array(
'staticTitle' => 'YOHO!BUY有货【春潮新势力】', // 标题
'staticFile' => self::STATIC_FILE,
'staticJS' => array(
'home.js'
),
'couponUrl' => $myCouponUrl, // 个人中心优惠券地址
'banner' => array(
'img' => 'http://img02.yohoboys.com/staticimg/2016/03/10/10/020ea7cb1f9c2f26b14e08107f778485ff.jpg',
'url' => 'http://www.yohobuy.com/special_14548_0310PCHOME.html',
),
'selectUrl' => 'http://www.yohobuy.com/home/coupons',
));
/**
* 判断是否登录
*/
private function checkLogin()
{
$url = Helpers::url('/cuxiao/girlday/index');
$uid = $this->getLoggedUid();
if (!$uid) {
$this->go(Helpers::url('/signin.html', array('refer' => $url), 'default'));
}
}
}
... ...
... ... @@ -58,6 +58,7 @@ application.seo.keywords = "Yoho! 有货官网,潮流志,潮流男装,潮牌,美
application.seo.description = "YOHO! 有货,年轻人潮流购物中心,中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。作为YOHO!旗下的购物平台,汇集了全球潮流时尚商品和中国最流行的商品,也是国内最大的原创文化商品平台,也是香港,台湾地区流行商品的集中地。同时包含日本、韩国等众多国外潮流品牌,带给您全新潮流购物体验。"
; 网站静态资源
application.js.url = "http://static.dev.yohobuy.com/huodong"
application.css.url = "http://static.dev.yohobuy.com/huodong"
application.img.url = "http://static.dev.yohobuy.com/huodong"
application.js.url = "http://cdn.yoho.cn/huodong-web"
application.css.url = "http://cdn.yoho.cn/huodong-web"
application.img.url = "http://cdn.yoho.cn/huodong-web"
... ...
... ... @@ -58,6 +58,6 @@ application.seo.keywords = "Yoho! 有货官网,潮流志,潮流男装,潮牌,美
application.seo.description = "YOHO! 有货,年轻人潮流购物中心,中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。作为YOHO!旗下的购物平台,汇集了全球潮流时尚商品和中国最流行的商品,也是国内最大的原创文化商品平台,也是香港,台湾地区流行商品的集中地。同时包含日本、韩国等众多国外潮流品牌,带给您全新潮流购物体验。"
; 网站静态资源
application.js.url = "http://buy.static.test.yoho.cn/huodong"
application.css.url = "http://buy.static.test.yoho.cn/huodong"
application.img.url = "http://buy.static.test.yoho.cn/huodong"
\ No newline at end of file
application.js.url = "http://cdn.yoho.cn/huodong-web"
application.css.url = "http://cdn.yoho.cn/huodong-web"
application.img.url = "http://cdn.yoho.cn/huodong-web"
\ No newline at end of file
... ...
... ... @@ -58,6 +58,6 @@ application.seo.keywords = "Yoho! 有货官网,潮流志,潮流男装,潮牌,美
application.seo.description = "YOHO! 有货,年轻人潮流购物中心,中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。作为YOHO!旗下的购物平台,汇集了全球潮流时尚商品和中国最流行的商品,也是国内最大的原创文化商品平台,也是香港,台湾地区流行商品的集中地。同时包含日本、韩国等众多国外潮流品牌,带给您全新潮流购物体验。"
; 网站静态资源
application.js.url = "http://cdn.yoho.cn/huodong"
application.css.url = "http://cdn.yoho.cn/huodong"
application.img.url = "http://cdn.yoho.cn/huodong"
\ No newline at end of file
application.js.url = "http://cdn.yoho.cn/huodong-web"
application.css.url = "http://cdn.yoho.cn/huodong-web"
application.img.url = "http://cdn.yoho.cn/huodong-web"
\ No newline at end of file
... ...
... ... @@ -58,6 +58,6 @@ application.seo.keywords = "Yoho! 有货官网,潮流志,潮流男装,潮牌,美
application.seo.description = "YOHO! 有货,年轻人潮流购物中心,中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。作为YOHO!旗下的购物平台,汇集了全球潮流时尚商品和中国最流行的商品,也是国内最大的原创文化商品平台,也是香港,台湾地区流行商品的集中地。同时包含日本、韩国等众多国外潮流品牌,带给您全新潮流购物体验。"
; 网站静态资源
application.js.url = "http://static.buy.test.yoho.cn/huodong"
application.css.url = "http://static.buy.test.yoho.cn/huodong"
application.img.url = "http://static.buy.test.yoho.cn/huodong"
\ No newline at end of file
application.js.url = "http://huodong.static.yohobuy.com/huodong"
application.css.url = "http://huodong.static.yohobuy.com/huodong"
application.img.url = "http://huodong.static.yohobuy.com/huodong"
\ No newline at end of file
... ...