Authored by Rock Zhang

Merge branch 'feature/cart' of git.dev.yoho.cn:web/yohobuy into feature/cart

Showing 61 changed files with 475 additions and 42 deletions
... ... @@ -212,10 +212,10 @@ function getNamedCoupon(activityId, couponId, isApp, userIsLogged)
return;
}
if (data.code == 200) {
showTip('恭喜成功领取优惠券!<br><br>稍后即会到账,请耐心等待。');
showTip('恭喜成功领取优惠券!<br><br>稍后即会到账,请耐心等待。');
}
else if (data.code == 201) {
showTip('已领取过品牌优惠券<br><br>快去选购心仪的商品吧!');
showTip('已领取过品牌优惠券<br><br>快去选购心仪的商品吧!');
}
else if (data.code == 400) {
setCookie('_Coupon' + activityId, couponId, {
... ...
var $tip, tipItime;
/* 领指定券 */
var activityId = $('#coupon-container').attr('param');
var userIsLogged = $('#coupon-container').attr('isLogged') === 'Y';
var isApp;
$('.get-coupon').click(function () {
var couponId = $(this).attr('param');
isApp = $(this).attr('href') !== 'javascript:;';
if (!isNaN(activityId) && !isNaN(couponId)) {
getNamedCoupon(activityId, couponId, isApp, userIsLogged);
}
});
/* 领所有券 */
$('#get-all-coupon').click(function () {
var isApp = $(this).attr('href') !== 'javascript:;';
getAllCoupon(activityId, isApp);
});
/* 检查是否有在领取中的券,有则直接领取 */
if (userIsLogged) {
var cookieCouponId = cookie('_Coupon' + activityId);
if (cookieCouponId && !isNaN(cookieCouponId)) {
getNamedCoupon(activityId, cookieCouponId, isApp, userIsLogged);
}
}
/**
* 微信分享
*/
(function ($) {
if (typeof (wx) == "undefined") {
return;
}
var _weChatInterface = 'http://www.yohoshow.com/api/wechat/getSignPackage';
$.getJSON(_weChatInterface + '?pageurl=' +
encodeURIComponent(location.href.split('#')[0]) + '&callback=?', function (json) {
var _appId, _timestamp, _nonceStr, _signature;
if (json !== undefined && json !== '') {
_appId = json.appId.toString();
_timestamp = json.timestamp;
_nonceStr = json.nonceStr.toString();
_signature = json.signature.toString();
wx.config({
debug: false,
appId: _appId,
timestamp: _timestamp,
nonceStr: _nonceStr,
signature: _signature,
jsApiList: [
'checkJsApi',
'onMenuShareTimeline',
'onMenuShareAppMessage',
'onMenuShareQQ',
'onMenuShareWeibo',
'hideMenuItems',
'showMenuItems',
'hideAllNonBaseMenuItem',
'showAllNonBaseMenuItem',
'translateVoice',
'startRecord',
'stopRecord',
'onRecordEnd',
'playVoice',
'pauseVoice',
'stopVoice',
'uploadVoice',
'downloadVoice',
'chooseImage',
'previewImage',
'uploadImage',
'downloadImage',
'getNetworkType',
'openLocation',
'getLocation',
'hideOptionMenu',
'showOptionMenu',
'closeWindow',
'scanQRCode',
'chooseWXPay',
'openProductSpecificView',
'addCard',
'chooseCard',
'openCard'
]
});
}
});
wx.ready(function () {
var shareTitle = $('#shareTitle').val();
var shareImg = $('#shareImg').val();
var shareDesc = $('#shareDesc').val();
var shareLink = $('#shareLink').val();
var shareData = {
title: shareTitle,
desc: shareDesc,
imgUrl: shareImg,
link: shareLink
};
wx.onMenuShareAppMessage(shareData);
wx.onMenuShareTimeline(shareData);
wx.onMenuShareQQ(shareData);
wx.onMenuShareWeibo(shareData);
});
}(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 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('');
}
}
/**
* 显示提示
*/
function showTip(con, dur) {
var content, duration;
if (typeof con === 'undefined') {
return;
}
content = con.toString();
duration = (dur && dur > 0) ? dur : 3000;
$tip.html(content).show();
tipItime = setTimeout(function () {
if ($tip.css('display') === 'block') {
$tip.hide();
}
}, duration);
}
/**
* 获取活动的指定优惠券
*/
function getNamedCoupon(activityId, couponId, isApp, userIsLogged)
{
$.ajax({
type: 'POST',
url: '/cuxiao/coupon/getnamed',
data: 'activityId=' + activityId + '&couponId=' + couponId,
success: function (data) {
setCookie('_Coupon' + activityId, null, {
expires: -2,
domain: '.m.yohobuy.com'
});
if (isApp && !userIsLogged) {
return;
}
if (data.code == 200) {
showTip('恭喜您成功领取优惠券!<br><br>稍后即会到账,请耐心等待。');
}
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 {
location.href = decodeURIComponent(data.data);
}
}
else if (data.message) {
//showTip(data.message);
if (data.message == '新用户才可领取') {
showTip('Sorry,新客券只有新客才能领取呦!');
} else {
showTip('领取失败<br><br>请稍候再试');
}
setCookie('_Coupon' + activityId, null);
}
},
error: function () {
showTip('网络断开连接啦~');
}
});
}
/**
* 获取活动所有的优惠券
*/
function getAllCoupon(activityId, isApp)
{
$.ajax({
type: 'POST',
url: '/cuxiao/coupon/getall',
data: 'activityId=' + activityId,
dataType: 'json',
success: function (data) {
if (data.code == 200) {
showTip('恭喜您,成功领取');
}
else if (data.code == 201) {
showTip('对不起,您已经领取过');
}
else if (data.code == 400) {
if (isApp) {
showTip('请先登录!');
} else {
location.href = decodeURIComponent(data.data);
}
}
else if (data.message) {
//showTip(data.message);
showTip('系统繁忙,请稍候再试!');
}
},
error: function () {
showTip('网络断开连接啦~');
}
});
}
\ No newline at end of file
... ...
... ... @@ -79,22 +79,18 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
});
}).on('touchstart', '.icon-edit', function() {
//var $this = $(this);
//
//var $cartgood = $this.closest('.shopping-cart-good');
//
////var id = $this.closest('.shopping-cart-good').data('id');
//
//var $viewGood = $cartgood.find('.deps');
// $editGoot = $cartgood.find('.calculate-num');
//
//if ($viewGood.hasClass('show')) {
// $viewGood.removeClass('show').addClass('hide');
// $editGoot.removeClass('hide').addClass('show');
//} else {
// $viewGood.removeClass('hide').addClass('show');
// $editGoot.removeClass('show').addClass('hide');
//}
var $this = $(this),
$cartgood = $this.closest('.shopping-cart-good'),
$viewGood = $cartgood.find('.deps'),
$editGoot = $cartgood.find('.calculate-num');
if ($viewGood.hasClass('show')) {
$viewGood.removeClass('show').addClass('hide');
$editGoot.removeClass('hide').addClass('show');
} else {
$viewGood.removeClass('hide').addClass('show');
$editGoot.removeClass('show').addClass('hide');
}
}).on('touchstart', '.icon-del', function(e) {
... ...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>{{staticTitle}}</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<style>
*{margin: 0;padding: 0;}
#coupon-container {width: 100%;}
#coupon-container img {width: 100%; height: auto; display: block;overflow: hidden;}
.img-box {width: 100%;position: relative;}
.img-box .href {width: 50%; height: 100%;position: absolute;top: 0;}
.img-box .href-left {left: 0}
.img-box .href-right {right: 0}
.img-box .href-center {width: 90%;height: 100%;position: absolute;top: 0;left: 5%;}
.show-more {height: 100%;width: 25%;position: absolute;top: 0;right: 10%;}
.yoho-tip {
position: fixed;
display: none;
text-align: center;
width: 70%;
padding: 34px 0;
top: 50%;
left: 50%;
margin-left: -35%;
margin-top: -45px;
background-color: #000;
opacity: 0.9;
color: #fff;
font-size: 18px;
border: none;
border-radius: 10px;
}
</style>
<link rel="dns-prefetch" href="//cdn.yoho.cn">
<link rel="dns-prefetch" href="//static.yohobuy.com">
</head>
<body>
<div class="coupon-container" id="coupon-container" param="{{activityId}}" isLogged="{{isLogged}}">
<img src="{{jsUrl}}/cuxiao/img/newuser2/01.jpg">
<img src="{{jsUrl}}/cuxiao/img/newuser2/02.jpg">
<img src="{{jsUrl}}/cuxiao/img/newuser2/03.jpg">
<img src="{{jsUrl}}/cuxiao/img/newuser2/line-1.jpg">
<img src="{{jsUrl}}/cuxiao/img/newuser2/04.jpg">
<div class="img-box">
<img src="{{jsUrl}}/cuxiao/img/newuser2/05.jpg">
<a class="href href-right" href="{{url_yohope}}"></a>
</div>
<div class="img-box">
<img src="{{jsUrl}}/cuxiao/img/newuser2/06.jpg">
<a class="href href-center" href="{{url_mycoupon}}"></a>
</div>
<img src="{{jsUrl}}/cuxiao/img/newuser2/line-2.jpg">
<img src="{{jsUrl}}/cuxiao/img/newuser2/07.jpg">
<div class="img-box">
<img src="{{jsUrl}}/cuxiao/img/newuser2/08.jpg">
<a class="href href-left" href="{{url_more}}"></a>
<a class="href href-right" href="{{url_more}}"></a>
</div>
<div class="img-box">
<img src="{{jsUrl}}/cuxiao/img/newuser2/09.jpg">
<span class="href href-left get-coupon" href="{{jumpUrl}}" param="12042"></span>
<span class="href href-right get-coupon" href="{{jumpUrl}}" param="12043"></span>
</div>
<img src="{{jsUrl}}/cuxiao/img/newuser2/line-1.jpg">
<div class="img-box">
<img src="{{jsUrl}}/cuxiao/img/newuser2/10.jpg">
<a class="href href-left" href="{{url_4}}"></a>
<a class="href href-right" href="{{url_343}}"></a>
</div>
<div class="img-box">
<img src="{{jsUrl}}/cuxiao/img/newuser2/11.jpg">
<span class="href href-left get-coupon" href="{{jumpUrl}}" param="12044"></span>
<span class="href href-right get-coupon" href="{{jumpUrl}}" param="12045"></span>
</div>
<img src="{{jsUrl}}/cuxiao/img/newuser2/line-1.jpg">
<div class="img-box">
<img src="{{jsUrl}}/cuxiao/img/newuser2/12.jpg">
<a class="href href-left" href="{{url_230}}"></a>
<a class="href href-right" href="{{url_536}}"></a>
</div>
<div class="img-box">
<img src="{{jsUrl}}/cuxiao/img/newuser2/13.jpg">
<span class="href href-left get-coupon" onclick="" href="{{jumpUrl}}" param="12046"></span>
<span class="href href-right get-coupon" onclick="" href="{{jumpUrl}}" param="12047"></span>
</div>
<img src="{{jsUrl}}/cuxiao/img/newuser2/line-1.jpg">
<div class="img-box">
<img src="{{jsUrl}}/cuxiao/img/newuser2/14.jpg">
<a class="href href-left" href="{{url_847}}"></a>
<a class="href href-right" href="{{url_900}}"></a>
</div>
<div class="img-box">
<img src="{{jsUrl}}/cuxiao/img/newuser2/15.jpg">
<span class="href href-left get-coupon" onclick="" href="{{jumpUrl}}" param="12048"></span>
<span class="href href-right get-coupon" onclick="" href="{{jumpUrl}}" param="12049"></span>
</div>
<img src="{{jsUrl}}/cuxiao/img/newuser2/line-1.jpg">
<div class="img-box">
<img src="{{jsUrl}}/cuxiao/img/newuser2/16.jpg">
<a class="href href-left" href="{{url_868}}"></a>
<a class="href href-right" href="{{url_1026}}"></a>
</div>
<div class="img-box">
<img src="{{jsUrl}}/cuxiao/img/newuser2/17.jpg">
<span class="href href-left get-coupon" href="{{jumpUrl}}" param="12050"></span>
<span class="href href-right get-coupon" href="{{jumpUrl}}" param="12051"></span>
</div>
<img src="{{jsUrl}}/cuxiao/img/newuser2/line-1.jpg">
<div class="img-box">
<img src="{{jsUrl}}/cuxiao/img/newuser2/24-2.jpg">
<a class="show-more" href="{{url_help}}"></a>
</div>
<img src="{{jsUrl}}/cuxiao/img/newuser2/24-3.jpg">
<img src="{{jsUrl}}/cuxiao/img/newuser2/line-2.jpg">
<img src="{{jsUrl}}/cuxiao/img/newuser2/25.jpg">
<img src="{{jsUrl}}/cuxiao/img/newuser2/26.jpg">
<img src="{{jsUrl}}/cuxiao/img/newuser2/27.jpg">
</div>
<script type="text/javascript" src="{{jsUrl}}/cuxiao/js/jquery.min.js"></script>
<script type="text/javascript" src="{{jsUrl}}/cuxiao/js/newuser/coupon2.js"></script>
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -41,23 +41,8 @@
{{> shopping-cart/cart-content}}
</div>
{{/ preSellCart}}
{{/ shoppingCart}}
</div>
<div id="advanceBuy" class="shopping-cart-page yoho-page hide">
{{# shoppingCart}}
{{# commonCart}}
{{# advanceBuy}}
<span>
{{promotionTitle}}
</span>
{{# goods}}
{{> shopping-cart/gift-advance-good}}
{{/ goods}}
{{/ advanceBuy}}
{{/ commonCart}}
{{/ shoppingCart}}
</div>
<div class="shopping-cart-zero yoho-page hide">
<div class="cart-zero">
... ... @@ -67,6 +52,5 @@
</div>
{{> product/recommend-for-you}}
</div>
{{> shopping-cart/chose-panel}}
{{> shopping-cart/chose-panel}}
{{> layout/footer}}
... ...
<div class="shopping-cart-good clearfix" data-id={{id}}>
{{#if isSoldOut}}
<p class="">失效</p>
<span class="checkbox icon-cb-checked iconfont"></span>
<!-- {{#if isSoldOut}}
<p class="">失效</p>
{{^}}
{{#if isGift}}
{{^}}
<span class="checkbox icon-cb-checked iconfont"></span>
<span class="checkbox icon-cb-checked iconfont"></span>
{{/if}}
{{/if}}
<div class="">
{{/if}}-->
<div class="info">
<img class="thumb lazy" data-original={{thumb}}>
<!--
<a class="" href="{{url}}">
<img class="thumb lazy" data-original="{{thumb}}">
</a>
... ... @@ -23,7 +25,8 @@
{{#if isSoldOut}}
<p class="few-tag">失效</p>
{{/if}}
</div>
-->
<div class="deps show">
<p class="name row">{{name}}</p>
... ...
... ... @@ -503,6 +503,52 @@ class CouponController extends HuodongAction
}
/**
* 新客领券2
*
*
*/
public function newuser2Action()
{
// 判断是否是应用访问, 拼接APP需要的URL参数
$isApp = null !== $this->get('app_version');
$isAppLogged = true;
if ($isApp) {
$isLogged = $this->get('uid') !== null;
$isAppLogged = $this->checkIsLogin();
} else {
$isLogged = $this->getUid();
}
$urlNewuser = Helpers::url('/cuxiao/coupon/newuser');
$urlYohope = Helpers::url('/cuxiao/coupon/yohope');
$urlHelp = Helpers::url('/cuxiao/coupon/help');
$urlMycoupon = Helpers::url('/home/coupons', null, 'default');
$urlEncode = strtr($urlNewuser, array('/' => '\\/'));
$gender = $this->get('gender', '1,3');
$channel = $this -> get('yh_channel','1');
$url = Helpers::url('/boys') . '?openbuy:yohobuy={"action":"go.home","params":{"gender":"' . $gender . '","channel":"' . $channel . '"}}';
$this->_view->display('newuser2', array(
'activityId' => 87, // 活动ID 444
'staticTitle' => '新人潮这看,超值惊喜等你领', // 标题
'jumpUrl' => $isAppLogged ? 'javascript:;' : $urlNewuser . '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' . $urlEncode . '","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}',
'isLogged' => $isLogged ? 'Y' : 'N', // 标识是否登录
'url_mycoupon' => $urlMycoupon . '?openby:yohobuy={"action":"go.coupon"}',
'url_yohope' => $urlYohope . '?yohobuy={"action":"go.h5","params":{"islogin":"Y","type":0,"url":"' . $urlYohope . '","param":{}}}',
'url_help' => $urlHelp . '?yohobuy={"action":"go.h5","params":{"islogin":"Y","type":0,"url":"' . $urlHelp . '","param":{}}}',
'url_more' => $url,
'url_4' => 'http://list.m.yohobuy.com/?msort=365&openby:yohobuy={"action":"go.list","params":{"msort":"365","title":"童装"}}',
'url_343' => 'http://list.m.yohobuy.com/?msort=10&openby:yohobuy={"action":"go.list","params":{"misort":"10","title":"创意生活"}}',
'url_230' => 'http://list.m.yohobuy.com/?msort=1&misort=18,20,21,22,226&openby:yohobuy={"action":"go.list","params":{"msort":"1","misort":"18,20,21,22,226","title":"冬装"}}',
'url_536' => 'http://list.m.yohobuy.com/?msort=3&misort=26,27,345&openby:yohobuy={"action":"go.list","params":{"msort":"3","misort":"26,27,345","title":"裤装"}}',
'url_847' => 'http://list.m.yohobuy.com/?msort=7,8&openby:yohobuy={"action":"go.list","params":{"msort":"7,8","title":"包配"}}',
'url_900' => 'http://list.m.yohobuy.com/?msort=4&openby:yohobuy={"action":"go.list","params":{"msort":"4","title":"裙装"}}',
'url_868' => 'http://list.m.yohobuy.com/?msort=1&misort=11,12,257,16&openby:yohobuy={"action":"go.list","params":{"msort":"1","misort":"11,12,257,16","title":"内搭"}}',
'url_1026' =>'http://list.m.yohobuy.com/?msort=6&misort=45&openby:yohobuy={"action":"go.list","params":{"msort":"6","misort":"45","title":"冬靴"}}'
));
}
/**
* 新客领券YOHOPE
*
* 上线时间2015/12/2
... ...