Authored by hf

do cuxiao coupon feature

Showing 48 changed files with 228 additions and 79 deletions
... ... @@ -16,16 +16,16 @@ use Plugin\Cache;
class Yohobuy
{
/* 正式环境 */
const API_URL = 'http://api2.open.yohobuy.com/';
const SERVICE_URL = 'http://service.api.yohobuy.com/';
const YOHOBUY_URL = 'http://www.yohobuy.com/';
// /* 测试环境 */
// const API_URL = 'http://test2.open.yohobuy.com/';
// const SERVICE_URL = 'http://test.service.api.yohobuy.com/';
// /* 正式环境 */
// const API_URL = 'http://api2.open.yohobuy.com/';
// const SERVICE_URL = 'http://service.api.yohobuy.com/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
/* 测试环境 */
const API_URL = 'http://test2.open.yohobuy.com/';
const SERVICE_URL = 'http://test.service.api.yohobuy.com/';
const YOHOBUY_URL = 'http://www.yohobuy.com/';
/**
* 私钥列表
*
... ...
... ... @@ -17,7 +17,7 @@ class ActivityData
{
const URI_GET_ACTIVITY_INFO = 'event/api/v1/activity/get';
const URI_GET_NAMED_COUPON = 'event/api/v1/activity/getCoupon';
const URI_GET_ALL_COUPON = 'event/api/v1/activity/getActivityCoupon';
const URI_GET_ALL_COUPON = 'event/api/v1/activity/getCoupon';
/**
* 用户获取某个活动指定的单个优惠券
... ...

74 KB | W: | H:

73.2 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin

73.2 KB | W: | H:

58.6 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin

58.6 KB | W: | H:

63.9 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
var $tip, tipItime;
/* 领指定券 */
var activityId = $('#coupon-container').attr('param');
$('.get-coupon').click(function() {
var couponId = $(this).attr('param');
if (!isNaN(activityId) && !isNaN(couponId)) {
... ... @@ -13,38 +15,12 @@ $('#get-all-coupon').click(function() {
});
/**
* 获取活动的指定优惠券
*/
function getNamedCoupon(activityId, couponId)
{
$.ajax({
type: 'POST',
url: '/cuxiao/coupon/getnamed',
data: 'activityId' + activityId + '&couponId=' + couponId,
success: function(data) {
alert('do');
}
});
}
/**
* 获取活动所有的优惠券
* 微信分享
*/
function getAllCoupon(activityId)
{
$.ajax({
type: 'POST',
url: '/cuxiao/coupon/getall',
data: 'activityId' + activityId,
dataType: 'json',
success: function(data) {
alert('do');
}
});
}
/* 微信分享 */
(function($) {
if (!wx) {
return;
}
var _weChatInterface = 'http://www.yohoshow.com/api/wechat/getSignPackage';
$.getJSON(_weChatInterface + '?pageurl=' +
encodeURIComponent(location.href.split('#')[0]) + '&callback=?', function(json) {
... ... @@ -116,4 +92,97 @@ function getAllCoupon(activityId)
wx.onMenuShareQQ(shareData);
wx.onMenuShareWeibo(shareData);
});
}(jQuery));
\ No newline at end of file
}(jQuery));
/**
* 初始化提示框
*/
(function() {
var tipHtml = '<div id="yoho-tip" class="yoho-tip"></div>';
//插入提示HTML
$('#coupon-container').append(tipHtml);
$tip = $('#yoho-tip');
$tip.on('touchend', function() {
$tip.hide();
//清除Timeout
clearTimeout(tipItime);
});
}());
/**
* 显示提示
*/
function showTip(con, dur) {
var content, duration;
if (typeof con === 'undefined') {
return;
}
content = con.toString();
duration = (dur && dur > 0) ? dur : 2000;
$tip.text(content).show();
tipItime = setTimeout(function() {
if ($tip.css('display') === 'block') {
$tip.hide();
}
}, duration);
}
/**
* 获取活动的指定优惠券
*/
function getNamedCoupon(activityId, couponId)
{
$.ajax({
type: 'POST',
url: '/cuxiao/coupon/getnamed',
data: 'activityId=' + activityId + '&couponId=' + couponId,
success: function(data) {
if (data.code == 200) {
showTip('领取成功');
}
else if (data.code == 400) {
location.href = data.data;
}
else if (data.message) {
showTip('领取失败');
}
},
error: function() {
showTip('网络断开连接啦~');
}
});
}
/**
* 获取活动所有的优惠券
*/
function getAllCoupon(activityId)
{
$.ajax({
type: 'POST',
url: '/cuxiao/coupon/getall',
data: 'activityId=' + activityId,
dataType: 'json',
success: function(data) {
if (data.code == 200) {
showTip('领取成功');
}
else if (data.code == 400) {
location.href = data.data;
}
else if (data.message) {
showTip('领取失败');
}
},
error: function() {
showErrTip('网络断开连接啦~');
}
});
}
\ No newline at end of file
... ...
... ... @@ -8,7 +8,7 @@
<meta content="telephone=no" name="format-detection">
<meta content="yes" name="apple-touch-fullscreen">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<title>{{title}}</title>
<title>{{staticTitle}}</title>
<link rel="stylesheet" href="{{staticCss}}">
<link rel="dns-prefetch" href="//cdn.yoho.cn">
<link rel="dns-prefetch" href="//static.yohobuy.com">
... ... @@ -26,7 +26,7 @@
</script>
</head>
<body>
<div class="coupon-container" id="coupon-container" param="{{id}}">
<div class="coupon-container" id="coupon-container" param="{{activityId}}">
<div class="coupon-hd"></div>
<div class="coupon-bd">
<div class="bd-top"></div>
... ... @@ -133,16 +133,6 @@
</ul>
<ul class="img-coupon06">
<li>
<a class="enter-store" href="{{url_402}}"></a>
<a class="get-coupon" href="javascript:;" param="15685"></a>
</li>
<li>
<a class="enter-store" href="{{url_720}}"></a>
<a class="get-coupon" href="javascript:;" param="15689"></a>
</li>
</ul>
<ul class="img-coupon07">
<li>
<a class="enter-store" href="{{url_138}}"></a>
<a class="get-coupon" href="javascript:;" param="15691"></a>
</li>
... ... @@ -151,7 +141,7 @@
<a class="get-coupon" href="javascript:;" param="15695"></a>
</li>
</ul>
<ul class="img-coupon08">
<ul class="img-coupon07">
<li>
<a class="enter-store" href="{{url_419}}"></a>
<a class="get-coupon" href="javascript:;" param="15697"></a>
... ... @@ -161,6 +151,16 @@
<a class="get-coupon" href="javascript:;" param="15705"></a>
</li>
</ul>
<ul class="img-coupon08">
<li>
<a class="enter-store" href="{{url_722}}"></a>
<a class="get-coupon" href="javascript:;" param="15707"></a>
</li>
<li>
<a class="enter-store" href="{{url_191}}"></a>
<a class="get-coupon" href="javascript:;" param="15751"></a>
</li>
</ul>
</div>
<div class="logo-coupon">
<ul>
... ... @@ -205,7 +205,9 @@
<p>快去选购心仪的商品吧!</p>
<a href="javascript:history.go(-1);">返回</a>
</div>
{{#if weixinShare}}
<script type="text/javascript" charset="utf-8" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
{{/if}}
<script type="text/javascript" src="{{jqueryJs}}"></script>
<script type="text/javascript" src="{{staticJs}}"></script>
<script type="text/javascript">
... ...
... ... @@ -26,7 +26,7 @@
</script>
</head>
<body>
<div class="coupon-container">
<div class="coupon-container" id="coupon-container" param="{{activityId}}">
<div class="coupon-hd"></div>
<div class="coupon-bd">
<div class="bd-top"></div>
... ...
... ... @@ -26,7 +26,7 @@
</script>
</head>
<body>
<div class="coupon-container">
<div class="coupon-container" id="coupon-container" param="{{activityId}}">
<div class="coupon-hd hd2"></div>
<div class="coupon-bd">
<div class="bd-top"></div>
... ...
... ... @@ -26,7 +26,7 @@
</script>
</head>
<body>
<div class="coupon-container">
<div class="coupon-container" id="coupon-container" param="{{activityId}}">
<div class="coupon-hd hd2"></div>
<div class="coupon-bd">
<div class="bd-top"></div>
... ...
... ... @@ -8,26 +8,37 @@ use LibModels\Wap\Cuxiao\ActivityData;
* 领券活动
*
* @name Coupon
* @package
* @package Cuxiao
* @copyright yoho.inc
* @version 1.0 (2015-11-25 13:08:58)
* @author fei.hong <fei.hong@yoho.cn>
*/
class CouponController extends AbstractAction
{
const SESSION_UID = 'coupon_uid';
/**
* 男生的品牌领券-上线时间 2015/12/1
*/
public function boysbrandAction()
{
// 判断是否是应用访问
$isApp = null !== $this->get('app_version');
if ($isApp) {
$uid = $this->get('uid');
if ($uid && is_numeric($uid)) {
$this->setSession(self::SESSION_UID, $uid);
}
}
$this->_view->display('boysbrand', array(
'staticCss' => 'http://static.dev.yohobuy.com/css/cuxiao/coupon.mobile.css',
'staticJs' => 'http://static.dev.yohobuy.com/js/cuxiao/coupon.mobile.js',
'jqueryJs' => 'http://static.dev.yohobuy.com/js/cuxiao/jquery.min.js',
'title' => 'Yoho!Buy有货2015感恩季,1000万元+品牌专属优惠券大派送!',
'shareImg' => '',
'activityId' => 3, // 活动ID
'staticTitle' => 'Yoho!Buy有货2015感恩季,1000万元+品牌专属优惠券大派送!', // 标题
'staticCss' => 'http://static.dev.yohobuy.com/css/cuxiao/coupon.mobile.css', // CSS
'staticJs' => 'http://static.dev.yohobuy.com/js/cuxiao/coupon.mobile.js', // JS
'jqueryJs' => 'http://static.dev.yohobuy.com/js/cuxiao/jquery.min.js', // JQUERY
'weixinShare' => $isApp ? false : true, // 是否需要微信分享
'url_350' => 'http://list.m.yohobuy.com/?gender=1,3&brand=350&openby:yohobuy={"action":"go.list","params":{"gender":"1,3","brand":"350","title":"MACROPUS"}}',
'url_160' => 'http://list.m.yohobuy.com/?gender=1,3&brand=160&openby:yohobuy={"action":"go.list","params":{"gender":"1,3","brand":"160","title":"izzue"}}',
'url_341' => 'http://list.m.yohobuy.com/?gender=1,3&brand=341&openby:yohobuy={"action":"go.list","params":{"gender":"1,3","brand":"341","title":"鬼洗"}}',
... ... @@ -84,10 +95,22 @@ class CouponController extends AbstractAction
*/
public function girlsbrandAction()
{
// 判断是否是应用访问
$isApp = null !== $this->get('app_version');
if ($isApp) {
$uid = $this->get('uid');
if ($uid && is_numeric($uid)) {
$this->setSession(self::SESSION_UID, $uid);
}
}
$this->_view->display('girlsbrand', array(
'staticCss' => 'http://static.dev.yohobuy.com/css/cuxiao/coupon.mobile.css',
'staticJs' => 'http://static.dev.yohobuy.com/js/cuxiao/coupon.mobile.js',
'jqueryJs' => 'http://static.dev.yohobuy.com/js/cuxiao/jquery.min.js',
'activityId' => 4, // 活动ID
'staticTitle' => 'Yoho!Buy有货2015感恩季,1000万元+品牌专属优惠券大派送!', // 标题
'staticCss' => 'http://static.dev.yohobuy.com/css/cuxiao/coupon.mobile.css', // CSS
'staticJs' => 'http://static.dev.yohobuy.com/js/cuxiao/coupon.mobile.js', // JS
'jqueryJs' => 'http://static.dev.yohobuy.com/js/cuxiao/jquery.min.js', // JQUERY
'weixinShare' => $isApp ? false : true, // 是否需要微信分享
'title' => 'Yoho!Buy有货2015感恩季,1000万元+品牌专属优惠券大派送!',
'url_570' => 'http://list.m.yohobuy.com/?gender=2,3&brand=570&openby:yohobuy={"action":"go.list","params":{"gender":"2,3","brand":"570","title":"iyogurt"}}',
... ... @@ -150,10 +173,22 @@ class CouponController extends AbstractAction
*/
public function kidsbrandAction()
{
// 判断是否是应用访问
$isApp = null !== $this->get('app_version');
if ($isApp) {
$uid = $this->get('uid');
if ($uid && is_numeric($uid)) {
$this->setSession(self::SESSION_UID, $uid);
}
}
$this->_view->display('kidsbrand', array(
'staticCss' => 'http://static.dev.yohobuy.com/css/cuxiao/coupon.mobile.css',
'staticJs' => 'http://static.dev.yohobuy.com/js/cuxiao/coupon.mobile.js',
'jqueryJs' => 'http://static.dev.yohobuy.com/js/cuxiao/jquery.min.js',
'activityId' => 5, // 活动ID
'staticTitle' => 'Yoho!Buy有货2015感恩季,1000万元+品牌专属优惠券大派送!', // 标题
'staticCss' => 'http://static.dev.yohobuy.com/css/cuxiao/coupon.mobile.css', // CSS
'staticJs' => 'http://static.dev.yohobuy.com/js/cuxiao/coupon.mobile.js', // JS
'jqueryJs' => 'http://static.dev.yohobuy.com/js/cuxiao/jquery.min.js', // JQUERY
'weixinShare' => $isApp ? false : true, // 是否需要微信分享
'title' => 'Yoho!Buy有货2015感恩季,1000万元+品牌专属优惠券大派送!',
'url_907' => 'http://list.m.yohobuy.com/?msort=365&brand=907&openby:yohobuy={"action":"go.list","params":{"gender":"2,3","brand":"907","title":"AMES BROS"}}',
... ... @@ -172,10 +207,22 @@ class CouponController extends AbstractAction
*/
public function lifestylebrandAction()
{
// 判断是否是应用访问
$isApp = null !== $this->get('app_version');
if ($isApp) {
$uid = $this->get('uid');
if ($uid && is_numeric($uid)) {
$this->setSession(self::SESSION_UID, $uid);
}
}
$this->_view->display('lifestylebrand', array(
'staticCss' => 'http://static.dev.yohobuy.com/css/cuxiao/coupon.mobile.css',
'staticJs' => 'http://static.dev.yohobuy.com/js/cuxiao/coupon.mobile.js',
'jqueryJs' => 'http://static.dev.yohobuy.com/js/cuxiao/jquery.min.js',
'activityId' => 6, // 活动ID
'staticTitle' => 'Yoho!Buy有货2015感恩季,1000万元+品牌专属优惠券大派送!', // 标题
'staticCss' => 'http://static.dev.yohobuy.com/css/cuxiao/coupon.mobile.css', // CSS
'staticJs' => 'http://static.dev.yohobuy.com/js/cuxiao/coupon.mobile.js', // JS
'jqueryJs' => 'http://static.dev.yohobuy.com/js/cuxiao/jquery.min.js', // JQUERY
'weixinShare' => $isApp ? false : true, // 是否需要微信分享
'title' => 'Yoho!Buy有货2015感恩季,1000万元+品牌专属优惠券大派送!',
'url_166' => 'http://list.m.yohobuy.com/?msort=10&brand=166&openby:yohobuy={"action":"go.list","params":{"gender":"2,3","brand":"166","title":"九口山"}}',
... ... @@ -203,7 +250,7 @@ class CouponController extends AbstractAction
*/
public function getnamedAction()
{
$result = array('code' => 400, 'message' => '领取失败', 'data' => '');
$result = array('code' => 401, 'message' => '领取失败', 'data' => '');
do {
/* 判断是不是AJAX请求 */
... ... @@ -220,12 +267,16 @@ class CouponController extends AbstractAction
/* 判断用户是否登录 */
$uid = $this->getUid();
if (!$uid || !is_numeric($uid)) {
$result['data'] = Helpers::url('/signin.html', array('refer' => $this->server('HTTP_REFERER', '/')));
if (!$uid) {
$uid = $this->getSession(self::SESSION_UID);
if (!$uid) {
$result['data'] = Helpers::url('/signin.html', array('refer' => $this->server('HTTP_REFERER', '/')));
}
}
/* 领取指定的优惠券操作 */
$result = ActivityData::getCouponNamed($uid, $activityId, $couponId);
} while (false);
$this->echoJson($result);
... ... @@ -239,7 +290,7 @@ class CouponController extends AbstractAction
*/
public function getallAction()
{
$result = array('code' => 400, 'message' => '领取失败', 'data' => '');
$result = array('code' => 401, 'message' => '领取失败', 'data' => '');
do {
/* 判断是不是AJAX请求 */
... ... @@ -255,16 +306,43 @@ class CouponController extends AbstractAction
/* 判断用户是否登录 */
$uid = $this->getUid();
if (!$uid || !is_numeric($uid)) {
$result['data'] = Helpers::url('/signin.html', array('refer' => $this->server('HTTP_REFERER', '/')));
if (!$uid) {
$uid = $this->getSession(self::SESSION_UID);
if (!$uid) {
$result['data'] = Helpers::url('/signin.html', array('refer' => $this->server('HTTP_REFERER', '/')));
}
}
/* 领取指定的优惠券操作 */
$result = ActivityData::getCouponAll($uid, $activityId);
} while (false);
$this->echoJson($result);
}
/**
* 获取分享链接
*
* @param int id 活动ID
*/
public function getshareAction()
{
$id = $this->get('id');
$result = array(
'code' => 200,
'message' => '领券活动分享',
'data' => array(
'title' => 'Yoho!Buy有货2015感恩季,1000万元+品牌专属优惠券大派送!',
'content' => '2015感恩季!品牌专属优惠券限时送!先领券,再购物,让你乐享整个冬季!',
'pic' => '',
'url' => '',
),
);
$this->echoJson($result);
}
}
... ...