...
|
...
|
@@ -140,6 +140,49 @@ let _getCoupon = function(data){ |
|
|
});
|
|
|
};
|
|
|
|
|
|
let isSendRedEnevlope = false;
|
|
|
let _getRedEnevlope = function(data){
|
|
|
data.app = utils.queryString();
|
|
|
|
|
|
data.app.uid = data.app.uid || cookies.cookie('app_uid');
|
|
|
data.app.app_version = data.app.app_version || cookies.cookie('app_version');
|
|
|
data.app.client_type = data.app.client_type || cookies.cookie('app_client_type');
|
|
|
data.app.session_key = data.app.session_key || cookies.cookie('app_session_key');
|
|
|
|
|
|
if (isSendRedEnevlope) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
isSendRedEnevlope = true;
|
|
|
jsonp({
|
|
|
url: '//m.yohobuy.com/activity/feature/redenvelope?callback=?',
|
|
|
timeout: 5000, // 5s
|
|
|
data: data
|
|
|
}).then(function(res) {
|
|
|
isSendRedEnevlope = false;
|
|
|
if (res.code === 200) {
|
|
|
utils.showTip({
|
|
|
title: '领取成功',
|
|
|
content: res.message,
|
|
|
close: true
|
|
|
});
|
|
|
} else if (res.message) {
|
|
|
utils.showTip({
|
|
|
title: '领取失败<br>请刷新重新领取',
|
|
|
content: res.message + '<br>如多次领取失败,请联系客服人员<br>带来不便敬请谅解',
|
|
|
close: false
|
|
|
});
|
|
|
}
|
|
|
}, function(){
|
|
|
isSendRedEnevlope = false;
|
|
|
utils.showTip({
|
|
|
title: '领取失败<br>请刷新重新领取',
|
|
|
content: '如多次领取失败,请联系客服人员<br>带来不便敬请谅解',
|
|
|
close: false
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
|
|
|
let _initCoin = function(uid){
|
|
|
if (uid) {
|
|
|
let cointoken = cookies.cookie('yoho-coin-token');
|
...
|
...
|
@@ -218,9 +261,49 @@ let _initCoupon = function(uid) { |
|
|
});
|
|
|
};
|
|
|
|
|
|
let _initRedEnvelope = function(uid) {
|
|
|
if (uid) {
|
|
|
let redevenlopetoken = cookies.cookie('yoho-redenvelope-token');
|
|
|
if (redevenlopetoken) {
|
|
|
_getRedEnevlope({
|
|
|
token: redevenlopetoken,
|
|
|
uid: uid
|
|
|
});
|
|
|
|
|
|
cookies.setCookie('yoho-redenvelope-token', '');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$('body').on('click', '.yoho-redenvelope', function() {
|
|
|
let token = $(this).data('token');
|
|
|
if (user.uid) {
|
|
|
_getRedEnevlope({
|
|
|
token: token,
|
|
|
uid: user.uid
|
|
|
});
|
|
|
} else {
|
|
|
cookies.setCookie('yoho-redenvelope-token', token);
|
|
|
|
|
|
if (window.__wxjs_environment === 'miniprogram' && typeof wx !== 'undefined' && wx.miniProgram) {
|
|
|
wx.miniProgram.navigateTo({
|
|
|
url: `../bindPhoneNumber/bindPhoneNumber?h5back=${location.href}`
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if ($('#intimacy-link').length <= 0) {
|
|
|
$('body').append('<a href=\'' + user.noLoginUrl() + '\' style="display:none;" id="intimacy-link"><span class="intimacy-link"></span></a>');
|
|
|
}
|
|
|
$('.intimacy-link').click();
|
|
|
return;
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
export default {
|
|
|
init(uid) {
|
|
|
_initCoin(uid); // 初始化有货币
|
|
|
_initCoupon(uid); // 初始化优惠券
|
|
|
_initRedEnvelope(uid); // 初始化红包
|
|
|
}
|
|
|
}; |
...
|
...
|
|