Authored by yyq

tosta

... ... @@ -90,3 +90,26 @@
}
}
.feature-tosta {
width: 100%;
position: fixed;
bottom: 10%;
z-index: 9999;
display: none;
text-align: center;
.feature-tosta-content {
max-width: 50%;
font-size: 12px;
background-color: #333;
padding: 6px 10px;
border-radius: 3px;
color: #fff;
opacity: 0.7;
-webkit-opacity: 0.7;
word-break: break-all;
text-align: center;
display: inline-block;
}
}
... ...
... ... @@ -100,6 +100,13 @@ let _getCoupon = function(data){
return;
}
let options = {
bottom: '48%',
paddingX: 20,
paddingY: 20,
radius: 6
};
isSendCoupon = true;
jsonp({
url: '//m.yohobuy.com/activity/feature/couponSend?callback=?',
... ... @@ -107,36 +114,19 @@ let _getCoupon = function(data){
data: data
}).then(function(res) {
isSendCoupon = false;
if (res.code === 200) {
utils.showTip({
title: '领取成功',
content: '恭喜您,领取成功',
tipClassName: 'coupon-tip',
close: true
});
utils.tosta('领取成功', options);
} else if (res.code === 401) {
utils.showTip({
title: '已经领取',
content: '快去分享给更多<br>喜爱<span class="highlight">潮流</span>的小伙伴吧!',
tipClassName: 'coupon-tip',
close: true
});
utils.tosta('已经领取', options);
} else if (res.message) {
utils.showTip({
title: '领取失败<br>请刷新重新领取',
content: res.message + '<br>如多次领取失败,请联系客服人员<br>带来不便敬请谅解',
tipClassName: 'coupon-tip',
close: false
});
utils.tosta(res.message, options);
} else {
utils.tosta('领取失败', options);
}
}, function(){
isSendCoupon = false;
utils.showTip({
title: '领取失败<br>请刷新重新领取',
content: '如多次领取失败,请联系客服人员<br>带来不便敬请谅解',
tipClassName: 'coupon-tip',
close: false
});
utils.tosta('领取失败', options);
});
};
... ...
... ... @@ -22,6 +22,7 @@ const isMobile = {
const mycurrency = isMobile.any() ? '//m.yohobuy.com/home/mycurrency' : '//www.yohobuy.com/home/currency';
const $tipTmpl = $('<div class="featuretip tip-wrap"><div class="tip"><div class="title"></div><div class="content"></div><a class="button" href="">返回</a></div></div>'); // eslint-disable-line
const $cointipTmpl = $('<div class="feature-coin tip-wrap"><div class="tip"><div class="tip-close">&times;</div><div class="title"></div><div class="content"></div><div class="bottom-button"><a class="button" href="">去逛逛</a><a class="coin" href=\'' + mycurrency + '?openby:yohobuy={"action":"go.mine"}\'>查看有货币</a></div></div></div>'); // eslint-disable-line
const $tostaTmpl = $('<div class="feature-tosta feature-tosta-wrap"><div class="feature-tosta-content"></div></div>');
let _queryString = function() {
if (!window._jssdkQS) {
... ... @@ -179,5 +180,34 @@ export default {
$('body').append($cointipTmpl);
$cointipTmpl.show();
},
tosta(content, options = {}) {
if (typeof content === 'undefined') {
return;
}
let {bottom, paddingX, paddingY, radius, duration} = $.extend({
bottom: '10%',
paddingX: 6,
paddingY: 10,
radius: 3
}, options);
$tostaTmpl.css('bottom', bottom);
$tostaTmpl.find('.feature-tosta-content').html(content).css({
padding: `${paddingY || 6}px ${paddingX || 10}px`,
'border-radius': `${radius}px`
});
if (!this.tostaAppended) {
this.tostaAppended = true;
$('body').append($tostaTmpl);
}
$tostaTmpl.show();
this.tostaTimer && clearTimeout(this.tostaTimer);
this.tostaTimer = setTimeout(function() {
$tostaTmpl.hide();
}, (duration && duration > 0) ? duration : 2000);
}
};
... ...