Authored by hf

fixes bug refs YBW-2680 cuxiao coupon

... ... @@ -2,10 +2,11 @@ var $tip, tipItime;
/* 领指定券 */
var activityId = $('#coupon-container').attr('param');
var isApp;
$('.get-coupon').click(function() {
var couponId = $(this).attr('param');
var isApp = $(this).attr('href') !== 'javascript:;';
isApp = $(this).attr('href') !== 'javascript:;';
if (!isNaN(activityId) && !isNaN(couponId)) {
getNamedCoupon(activityId, couponId, isApp);
}
... ... @@ -16,6 +17,12 @@ $('#get-all-coupon').click(function() {
getAllCoupon(activityId, isApp);
});
/* 检查是否有在领取中的券,有则直接领取 */
var cookieCouponId = cookie('_Coupon' + activityId);
if (cookieCouponId && !isNaN(cookieCouponId)) {
getNamedCoupon(activityId, cookieCouponId, isApp);
}
/**
* 微信分享
*/
... ... @@ -114,6 +121,54 @@ $('#get-all-coupon').click(function() {
});
}());
function cookie(name) {
var cookies = document.cookie,
cookieVal,
offset;
if (document.cookie && document.cookie !== '') {
offset = cookies.indexOf(name + '=');
if (offset > -1) {
offset += name.length + 1;
cookieVal = decodeURIComponent($.trim(cookies.substring(offset, cookies.indexOf(';', offset))));
}
}
return cookieVal;
}
function setCookie(name, value, options) {
var expires = '',
path,
domain,
secure,
date;
if (typeof value !== 'undefined') {
options = options || {};
if (value === null) {
value = '';
options.expires = -1;
}
if (options.expires &&
(typeof options.expires === 'number' || options.expires.toUTCString)) {
if (typeof options.expires === 'number') {
date = new Date();
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
}
expires = '; expires=' + date.toUTCString();
}
path = options.path ? '; path=' + options.path : '';
domain = options.domain ? '; domain=' + options.domain : '';
secure = options.secure ? '; secure' : '';
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
}
}
/**
* 显示提示
*/
... ... @@ -148,11 +203,16 @@ function getNamedCoupon(activityId, couponId, isApp)
success: function(data) {
if (data.code == 200) {
showTip('恭喜你成功领取品牌优惠券<br><br>快去分享给你的小伙伴吧!');
setCookie('_Coupon' + activityId, null);
}
else if (data.code == 201) {
showTip('你已领取过品牌优惠券<br><br>快去选购心仪的商品吧!');
}
else if (data.code == 400) {
setCookie('_Coupon' + activityId, couponId, {
expires: 1,
domain: '.m.yohobuy.com'
});
if (isApp) {
showTip('请先登录!');
} else {
... ... @@ -162,7 +222,9 @@ function getNamedCoupon(activityId, couponId, isApp)
else if (data.message) {
//showTip(data.message);
showTip('系统繁忙,请稍候再试!');
setCookie('_Coupon' + activityId, null);
}
},
error: function() {
showTip('网络断开连接啦~');
... ...
... ... @@ -50,7 +50,7 @@ class CouponController extends HuodongAction
$urlGirls = Helpers::url('/cuxiao/coupon/girlsbrand');
$urlKids = Helpers::url('/cuxiao/coupon/kidsbrand');
$urlLifestyle = Helpers::url('/cuxiao/coupon/lifestylebrand');
$urlShare = Helpers::url('/cuxiao/coupon/getShare');
$urlShare = Yohobuy::SERVICE_URL . '/operations/api/v5/webshare/getShare';
$urlEncode = strtr($urlBoys, array('/' => '\\/'));
$this->_view->display('boysbrand', array(
... ... @@ -64,10 +64,10 @@ class CouponController extends HuodongAction
'shareImg' => 'http://img12.static.yhbimg.com/couponImg/2015/11/26/09/0226ad7f8bcf5467a789e17b761c7557e0.jpg',
'shareDesc' => '2015感恩季!品牌专属优惠券限时送!先领券,再购物,让你乐享整个冬季!',
'url_boys' => $urlBoys . '?yohobuy={"action":"go.h5","params":{"id":"75","share":"' . $urlShare . '","shareparam":{"id":"75"},"islogin":"N","type":0,"url":"' . $urlBoys . '","param":{}}}',
'url_girls' => $urlGirls . '?yohobuy={"action":"go.h5","params":{"id":"76","share":"' . $urlShare . '","shareparam":{"id":"76"},"islogin":"N","type":0,"url":"' . $urlGirls . '","param":{}}}',
'url_kids' => $urlKids . '?yohobuy={"action":"go.h5","params":{"id":"77","share":"' . $urlShare . '","shareparam":{"id":"77"},"islogin":"N","type":0,"url":"' . $urlKids . '","param":{}}}',
'url_lifestyle' => $urlLifestyle . '?yohobuy={"action":"go.h5","params":{"id":"78","share":"' . $urlShare . '","shareparam":{"id":"78"},"islogin":"N","type":0,"url":"' . $urlLifestyle . '","param":{}}}',
'url_boys' => $urlBoys . '?yohobuy={"action":"go.h5","params":{"id":"75","share":"' . $urlShare . '","shareparam":{"share_id":"406"},"islogin":"N","type":0,"url":"' . $urlBoys . '","param":{}}}',
'url_girls' => $urlGirls . '?yohobuy={"action":"go.h5","params":{"id":"76","share":"' . $urlShare . '","shareparam":{"share_id":"408"},"islogin":"N","type":0,"url":"' . $urlGirls . '","param":{}}}',
'url_kids' => $urlKids . '?yohobuy={"action":"go.h5","params":{"id":"77","share":"' . $urlShare . '","shareparam":{"share_id":"410"},"islogin":"N","type":0,"url":"' . $urlKids . '","param":{}}}',
'url_lifestyle' => $urlLifestyle . '?yohobuy={"action":"go.h5","params":{"id":"78","share":"' . $urlShare . '","shareparam":{"share_id":"412"},"islogin":"N","type":0,"url":"' . $urlLifestyle . '","param":{}}}',
'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=60&openby:yohobuy={"action":"go.list","params":{"gender":"1,3","brand":"60","title":"izzue"}}',
... ... @@ -137,7 +137,7 @@ class CouponController extends HuodongAction
$urlGirls = Helpers::url('/cuxiao/coupon/girlsbrand');
$urlKids = Helpers::url('/cuxiao/coupon/kidsbrand');
$urlLifestyle = Helpers::url('/cuxiao/coupon/lifestylebrand');
$urlShare = Helpers::url('/cuxiao/coupon/getShare');
$urlShare = Yohobuy::SERVICE_URL . '/operations/api/v5/webshare/getShare';
$urlEncode = strtr($urlGirls, array('/' => '\\/'));
$this->_view->display('girlsbrand', array(
... ... @@ -151,10 +151,10 @@ class CouponController extends HuodongAction
'shareImg' => 'http://img12.static.yhbimg.com/couponImg/2015/11/26/09/0226ad7f8bcf5467a789e17b761c7557e0.jpg',
'shareDesc' => '2015感恩季!品牌专属优惠券限时送!先领券,再购物,让你乐享整个冬季!',
'url_boys' => $urlBoys . '?yohobuy={"action":"go.h5","params":{"id":"75","share":"' . $urlShare . '","shareparam":{"id":"75"},"islogin":"N","type":0,"url":"' . $urlBoys . '","param":{}}}',
'url_girls' => $urlGirls . '?yohobuy={"action":"go.h5","params":{"id":"76","share":"' . $urlShare . '","shareparam":{"id":"76"},"islogin":"N","type":0,"url":"' . $urlGirls . '","param":{}}}',
'url_kids' => $urlKids . '?yohobuy={"action":"go.h5","params":{"id":"77","share":"' . $urlShare . '","shareparam":{"id":"77"},"islogin":"N","type":0,"url":"' . $urlKids . '","param":{}}}',
'url_lifestyle' => $urlLifestyle . '?yohobuy={"action":"go.h5","params":{"id":"78","share":"' . $urlShare . '","shareparam":{"id":"78"},"islogin":"N","type":0,"url":"' . $urlLifestyle . '","param":{}}}',
'url_boys' => $urlBoys . '?yohobuy={"action":"go.h5","params":{"id":"75","share":"' . $urlShare . '","shareparam":{"share_id":"406"},"islogin":"N","type":0,"url":"' . $urlBoys . '","param":{}}}',
'url_girls' => $urlGirls . '?yohobuy={"action":"go.h5","params":{"id":"76","share":"' . $urlShare . '","shareparam":{"share_id":"408"},"islogin":"N","type":0,"url":"' . $urlGirls . '","param":{}}}',
'url_kids' => $urlKids . '?yohobuy={"action":"go.h5","params":{"id":"77","share":"' . $urlShare . '","shareparam":{"share_id":"410"},"islogin":"N","type":0,"url":"' . $urlKids . '","param":{}}}',
'url_lifestyle' => $urlLifestyle . '?yohobuy={"action":"go.h5","params":{"id":"78","share":"' . $urlShare . '","shareparam":{"share_id":"412"},"islogin":"N","type":0,"url":"' . $urlLifestyle . '","param":{}}}',
'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"}}',
'url_864' => 'http://list.m.yohobuy.com/?gender=2,3&brand=868&openby:yohobuy={"action":"go.list","params":{"gender":"2,3","brand":"868","title":"Mango"}}',
... ... @@ -228,7 +228,7 @@ class CouponController extends HuodongAction
$urlGirls = Helpers::url('/cuxiao/coupon/girlsbrand');
$urlKids = Helpers::url('/cuxiao/coupon/kidsbrand');
$urlLifestyle = Helpers::url('/cuxiao/coupon/lifestylebrand');
$urlShare = Helpers::url('/cuxiao/coupon/getShare');
$urlShare = Yohobuy::SERVICE_URL . '/operations/api/v5/webshare/getShare';
$urlEncode = strtr($urlKids, array('/' => '\\/'));
$this->_view->display('kidsbrand', array(
... ... @@ -243,10 +243,10 @@ class CouponController extends HuodongAction
'shareImg' => 'http://img12.static.yhbimg.com/couponImg/2015/11/26/09/0226ad7f8bcf5467a789e17b761c7557e0.jpg',
'shareDesc' => '2015感恩季!品牌专属优惠券限时送!先领券,再购物,让你乐享整个冬季!',
'url_boys' => $urlBoys . '?yohobuy={"action":"go.h5","params":{"id":"75","share":"' . $urlShare . '","shareparam":{"id":"75"},"islogin":"N","type":0,"url":"' . $urlBoys . '","param":{}}}',
'url_girls' => $urlGirls . '?yohobuy={"action":"go.h5","params":{"id":"76","share":"' . $urlShare . '","shareparam":{"id":"76"},"islogin":"N","type":0,"url":"' . $urlGirls . '","param":{}}}',
'url_kids' => $urlKids . '?yohobuy={"action":"go.h5","params":{"id":"77","share":"' . $urlShare . '","shareparam":{"id":"77"},"islogin":"N","type":0,"url":"' . $urlKids . '","param":{}}}',
'url_lifestyle' => $urlLifestyle . '?yohobuy={"action":"go.h5","params":{"id":"78","share":"' . $urlShare . '","shareparam":{"id":"78"},"islogin":"N","type":0,"url":"' . $urlLifestyle . '","param":{}}}',
'url_boys' => $urlBoys . '?yohobuy={"action":"go.h5","params":{"id":"75","share":"' . $urlShare . '","shareparam":{"share_id":"406"},"islogin":"N","type":0,"url":"' . $urlBoys . '","param":{}}}',
'url_girls' => $urlGirls . '?yohobuy={"action":"go.h5","params":{"id":"76","share":"' . $urlShare . '","shareparam":{"share_id":"408"},"islogin":"N","type":0,"url":"' . $urlGirls . '","param":{}}}',
'url_kids' => $urlKids . '?yohobuy={"action":"go.h5","params":{"id":"77","share":"' . $urlShare . '","shareparam":{"share_id":"410"},"islogin":"N","type":0,"url":"' . $urlKids . '","param":{}}}',
'url_lifestyle' => $urlLifestyle . '?yohobuy={"action":"go.h5","params":{"id":"78","share":"' . $urlShare . '","shareparam":{"share_id":"412"},"islogin":"N","type":0,"url":"' . $urlLifestyle . '","param":{}}}',
'url_907' => 'http://list.m.yohobuy.com/?msort=365&brand=907&gender=1,2,3&openby:yohobuy={"action":"go.list","params":{"brand":"907","title":"AMES BROS"}}',
'url_600' => 'http://list.m.yohobuy.com/?msort=365&brand=600&gender=1,2,3&openby:yohobuy={"action":"go.list","params":{"brand":"600","title":"HAPPYATOMIC"}}',
'url_888' => 'http://list.m.yohobuy.com/?msort=365&brand=888&gender=1,2,3&openby:yohobuy={"action":"go.list","params":{"brand":"888","title":"Am&ot"}}',
... ... @@ -276,7 +276,7 @@ class CouponController extends HuodongAction
$urlGirls = Helpers::url('/cuxiao/coupon/girlsbrand');
$urlKids = Helpers::url('/cuxiao/coupon/kidsbrand');
$urlLifestyle = Helpers::url('/cuxiao/coupon/lifestylebrand');
$urlShare = Helpers::url('/cuxiao/coupon/getShare');
$urlShare = Yohobuy::SERVICE_URL . '/operations/api/v5/webshare/getShare';
$urlEncode = strtr($urlLifestyle, array('/' => '\\/'));
$this->_view->display('lifestylebrand', array(
... ... @@ -291,10 +291,10 @@ class CouponController extends HuodongAction
'shareImg' => 'http://img12.static.yhbimg.com/couponImg/2015/11/26/09/0226ad7f8bcf5467a789e17b761c7557e0.jpg',
'shareDesc' => '2015感恩季!品牌专属优惠券限时送!先领券,再购物,让你乐享整个冬季!',
'url_boys' => $urlBoys . '?yohobuy={"action":"go.h5","params":{"id":"75","share":"' . $urlShare . '","shareparam":{"id":"75"},"islogin":"N","type":0,"url":"' . $urlBoys . '","param":{}}}',
'url_girls' => $urlGirls . '?yohobuy={"action":"go.h5","params":{"id":"76","share":"' . $urlShare . '","shareparam":{"id":"76"},"islogin":"N","type":0,"url":"' . $urlGirls . '","param":{}}}',
'url_kids' => $urlKids . '?yohobuy={"action":"go.h5","params":{"id":"77","share":"' . $urlShare . '","shareparam":{"id":"77"},"islogin":"N","type":0,"url":"' . $urlKids . '","param":{}}}',
'url_lifestyle' => $urlLifestyle . '?yohobuy={"action":"go.h5","params":{"id":"78","share":"' . $urlShare . '","shareparam":{"id":"78"},"islogin":"N","type":0,"url":"' . $urlLifestyle . '","param":{}}}',
'url_boys' => $urlBoys . '?yohobuy={"action":"go.h5","params":{"id":"75","share":"' . $urlShare . '","shareparam":{"share_id":"406"},"islogin":"N","type":0,"url":"' . $urlBoys . '","param":{}}}',
'url_girls' => $urlGirls . '?yohobuy={"action":"go.h5","params":{"id":"76","share":"' . $urlShare . '","shareparam":{"share_id":"408"},"islogin":"N","type":0,"url":"' . $urlGirls . '","param":{}}}',
'url_kids' => $urlKids . '?yohobuy={"action":"go.h5","params":{"id":"77","share":"' . $urlShare . '","shareparam":{"share_id":"410"},"islogin":"N","type":0,"url":"' . $urlKids . '","param":{}}}',
'url_lifestyle' => $urlLifestyle . '?yohobuy={"action":"go.h5","params":{"id":"78","share":"' . $urlShare . '","shareparam":{"share_id":"412"},"islogin":"N","type":0,"url":"' . $urlLifestyle . '","param":{}}}',
'url_166' => 'http://list.m.yohobuy.com/?msort=10&brand=166&gender=1,2,3&openby:yohobuy={"action":"go.list","params":{"brand":"166","title":"九口山"}}',
'url_201' => 'http://list.m.yohobuy.com/?msort=10&brand=201&gender=1,2,3&openby:yohobuy={"action":"go.list","params":{"brand":"201","title":"wesc"}}',
... ...