Commit 72e8b35f authored by Mac's avatar Mac

修改活动首页失败的情况

parent 38a6dea7
...@@ -335,141 +335,105 @@ ...@@ -335,141 +335,105 @@
$('.click_use p').html('立即登录'); $('.click_use p').html('立即登录');
} }
var that=this
that.loadData()
function loadData(){
$.ajax({
type: "POST",
url: `${getApiUrl().urlJava}api/appActivity/getUserPurchaseTime`,
contentType: "application/json",
data: getJavaData({}),
async: false,
$.ajax({ success: function(res) {
type: "POST", if (res.resultCode === 1) {
url: `${getApiUrl().urlJava}api/appActivity/getUserPurchaseTime`, couponId=res.data.couponId;
contentType: "application/json", //getTicketList(res.data.couponId);
data: getJavaData({}),
async: false,
success: function(res) {
if (res.resultCode === 1) {
couponId=res.data.couponId;
//getTicketList(res.data.couponId);
let num = res.data.repertory; //优惠券总共数量
// let num = 5000; //优惠券总共数量
$('.box_title_2 p').html(res.data.redemptionPrice + '元抢购');
$('.box_title h5').html(res.data.remark);
$('.explain p').html('活动规则' + '<br/>' + res.data.instructions);
if (login == false) {
$('.use_o').html('暂无登录');
} else {
$('.use_o').html(res.data.contact);
$('.use_t').html(res.data.customerName);
}
let activityStartDate = new Date(res.data.activityStartDate.replace('T', ' ').replace(/-/g, '/')).getTime(); //活动开始时间
let activityEndDate = new Date(res.data.activityEndDate.replace('T', ' ').replace(/-/g, '/')).getTime(); //活动结束时间
let nowDate = new Date(res.data.currentTime.replace('T', ' ').replace(/-/g, '/')).getTime(); //服务器时间
let nextActivity = res.data.nextActivity;
let nextAc = false;
if (nextActivity != null) {
nextAc = true
}
$('.dataStatistics').dataStatistics({ let num = res.data.repertory; //优惠券总共数量
max: num, // let num = 5000; //优惠券总共数量
min: num, $('.box_title_2 p').html(res.data.redemptionPrice + '元抢购');
len: 4, $('.box_title h5').html(res.data.remark);
add: true,
price: res.data.redemptionPrice,
couponId: res.data.couponId,
platform: platform,
login: login,
count: res.data.count, //判断是否可以抢购 0为不可以
activityStartDate: activityStartDate,
activityEndDate: activityEndDate,
nextAc: nextAc
}); //刚进入页面不执行动画
$('.explain p').html('活动规则' + '<br/>' + res.data.instructions);
if (login == false) {
$('.use_o').html('暂无登录');
} else {
$('.use_o').html(res.data.contact);
$('.use_t').html(res.data.customerName);
}
// let activityStartDate = new Date('2019/11/08 17:43:50').getTime(); let activityStartDate = new Date(res.data.activityStartDate.replace('T', ' ').replace(/-/g, '/')).getTime(); //活动开始时间
// let activityEndDate = new Date('2019/11/14 11:23:00').getTime(); //活动结束时间 let activityEndDate = new Date(res.data.activityEndDate.replace('T', ' ').replace(/-/g, '/')).getTime(); //活动结束时间
if (nextActivity != null) { let nowDate = new Date(res.data.currentTime.replace('T', ' ').replace(/-/g, '/')).getTime(); //服务器时间
let nextActivity = res.data.nextActivity;
let nextAc = false;
if (nextActivity != null) {
nextAc = true
}
let nexttime = nextActivity.activityStartDate; $('.dataStatistics').dataStatistics({
let year = nexttime.split('T')[0].split('-')[0]; max: num,
let month = nexttime.split('T')[0].split('-')[1]; min: num,
let day = nexttime.split('T')[0].split('-')[2]; len: 4,
let hour = nexttime.split('T')[1].split(':')[0]; add: true,
$('.notice_content').html('下期活动将于' + year + '年' + month + '月' + day + '日' + hour + '点开始。'); price: res.data.redemptionPrice,
$('.notice_content2').html('届时会有' + nextActivity.couponCount + '张价值' + nextActivity.denomination + '的折扣券等待您的抢 购(抢购价' + nextActivity.redemptionPrice + '元),请准时参加。'); couponId: res.data.couponId,
// var time2 = setInterval(setTimer3, 1000); //计时器 platform: platform,
let beforeDawn = new Date(year + '/' + month + '/' + day + ' 00:00:00').getTime() login: login,
let time = ((beforeDawn - nowDate) / 1000).toFixed(0); count: res.data.count, //判断是否可以抢购 0为不可以
runtime(time) activityStartDate: activityStartDate,
activityEndDate: activityEndDate,
nextAc: nextAc
}); //刚进入页面不执行动画
// let activityStartDate = new Date('2019/11/08 17:43:50').getTime();
// let activityEndDate = new Date('2019/11/14 11:23:00').getTime(); //活动结束时间
if (nextActivity != null) {
let nexttime = nextActivity.activityStartDate;
let year = nexttime.split('T')[0].split('-')[0];
let month = nexttime.split('T')[0].split('-')[1];
let day = nexttime.split('T')[0].split('-')[2];
let hour = nexttime.split('T')[1].split(':')[0];
$('.notice_content').html('下期活动将于' + year + '年' + month + '月' + day + '日' + hour + '点开始。');
$('.notice_content2').html('届时会有' + nextActivity.couponCount + '张价值' + nextActivity.denomination + '的折扣券等待您的抢 购(抢购价' + nextActivity.redemptionPrice + '元),请准时参加。');
// var time2 = setInterval(setTimer3, 1000); //计时器
let beforeDawn = new Date(year + '/' + month + '/' + day + ' 00:00:00').getTime()
let time = ((beforeDawn - nowDate) / 1000).toFixed(0);
runtime(time)
} }
//判断当前时间是否到了抢购时间 //判断当前时间是否到了抢购时间
if (activityStartDate >= nowDate) { //没到抢购时间 显示抢购的具体时间 if (activityStartDate >= nowDate) { //没到抢购时间 显示抢购的具体时间
$('#t1').html('抢购时间:'); $('#t1').html('抢购时间:');
$('#t2').html(''); $('#t2').html('');
let startDate = res.data.activityStartDate; let startDate = res.data.activityStartDate;
let month = startDate.split('T')[0].split('-')[1]; let month = startDate.split('T')[0].split('-')[1];
let day = startDate.split('T')[0].split('-')[2]; let day = startDate.split('T')[0].split('-')[2];
let hour = startDate.split('T')[1].split(':')[0]; let hour = startDate.split('T')[1].split(':')[0];
$('#p1').html(month); $('#p1').html(month);
$('#p2').html(day); $('#p2').html(day);
$('#p3').html(hour); $('#p3').html(hour);
$('#t3').html('月'); $('#t3').html('月');
$('#t4').html('日'); $('#t4').html('日');
$('#t5').html('点整'); $('#t5').html('点整');
$('.img_btn p').html('立即抢购'); $('.img_btn p').html('立即抢购');
$('.img_btn').css("background-image", "url(https://vt-im-bucket.oss-cn-chengdu.aliyuncs.com/activity/nobuy_btn.png)"); $('.img_btn').css("background-image", "url(https://vt-im-bucket.oss-cn-chengdu.aliyuncs.com/activity/nobuy_btn.png)");
$('.img_btn p').css("color", "#FFFFFF");
// $(".received_img").attr("src", "");
let time = ((activityStartDate - nowDate) / 1000).toFixed(0);
runtime(time)
} else if (nowDate > activityEndDate || res.data.activityIsEnding == 1) { // 活动时间已过
// $(".received_img").attr("src", "");
$('.img_bg_M').css("background-image", "url(https://vt-im-bucket.oss-cn-chengdu.aliyuncs.com/activity/MJ_200@3x.png)");
$('.img_bg_p1').css("color", "#CCCCCC");
$('.img_bg_p2').css("color", "#CCCCCC");
$('.img_btn p').css("color", "#FFFFFF");
$('.img_btn p').html('活动结束')
$('.box_content_t').hide()
$('.img_btn').css("background-image", "url(https://vt-im-bucket.oss-cn-chengdu.aliyuncs.com/activity/nobuy_btn.png)");
$('.dataStatistics').css('display', "none");
$('.deta_replace').css('display', "flex");
$('#notice').css('display', "block");
$('.notice_img').css('display', "block");
} else { // 到了抢购的时间显示距离结束时间的倒计时
currentTime = res.data.currentTime.replace('T', ' ').replace(/-/g, '/');
end = res.data.activityEndDate.replace('T', ' ').replace(/-/g, '/');
if (num > 0) {
$('#t1').html('结束倒计时:')
if (res.data.count != 0) {
// $(".received_img").attr("src", "");
$('.img_btn p').html('立即抢购'); $('.img_btn p').css("color", "#FFFFFF");
// $(".received_img").attr("src", "");
let time = ((activityStartDate - nowDate) / 1000).toFixed(0);
runtime(time)
} else { } else if (nowDate > activityEndDate || res.data.activityIsEnding == 1) { // 活动时间已过
$('.img_btn p').html('去使用');
$(".received_img").css('display', "block");
$('.img_btn').css("background-image", "url(https://vt-im-bucket.oss-cn-chengdu.aliyuncs.com/activity/buy_btn.png)");
//去使用状态显示弹幕
if(couponId!=null&&couponId!=undefined){
getTicketList(couponId);
}
}
} else {
// $(".received_img").attr("src", ""); // $(".received_img").attr("src", "");
$('.img_bg_M').css("background-image", "url(https://vt-im-bucket.oss-cn-chengdu.aliyuncs.com/activity/MJ_200@3x.png)"); $('.img_bg_M').css("background-image", "url(https://vt-im-bucket.oss-cn-chengdu.aliyuncs.com/activity/MJ_200@3x.png)");
...@@ -479,64 +443,94 @@ ...@@ -479,64 +443,94 @@
$('.img_btn p').html('活动结束') $('.img_btn p').html('活动结束')
$('.box_content_t').hide() $('.box_content_t').hide()
$('.img_btn').css("background-image", "url(https://vt-im-bucket.oss-cn-chengdu.aliyuncs.com/activity/nobuy_btn.png)"); $('.img_btn').css("background-image", "url(https://vt-im-bucket.oss-cn-chengdu.aliyuncs.com/activity/nobuy_btn.png)");
$('.dataStatistics').css('display', "none"); $('.dataStatistics').css('display', "none");
$('.deta_replace').css('display', "flex"); $('.deta_replace').css('display', "flex");
$('#notice').css('display', "block"); $('#notice').css('display', "block");
$('.notice_img').css('display', "block"); $('.notice_img').css('display', "block");
} else { // 到了抢购的时间显示距离结束时间的倒计时
currentTime = res.data.currentTime.replace('T', ' ').replace(/-/g, '/');
end = res.data.activityEndDate.replace('T', ' ').replace(/-/g, '/');
if (num > 0) {
$('#t1').html('结束倒计时:')
if (res.data.count != 0) {
// $(".received_img").attr("src", "");
$('.img_btn p').html('立即抢购');
} else {
$('.img_btn p').html('去使用');
$(".received_img").css('display', "block");
$('.img_btn').css("background-image", "url(https://vt-im-bucket.oss-cn-chengdu.aliyuncs.com/activity/buy_btn.png)");
//去使用状态显示弹幕
if(couponId!=null&&couponId!=undefined){
getTicketList(couponId);
}
}
} else {
// $(".received_img").attr("src", "");
$('.img_bg_M').css("background-image", "url(https://vt-im-bucket.oss-cn-chengdu.aliyuncs.com/activity/MJ_200@3x.png)");
$('.img_bg_p1').css("color", "#CCCCCC");
$('.img_bg_p2').css("color", "#CCCCCC");
$('.img_btn p').css("color", "#FFFFFF");
$('.img_btn p').html('活动结束')
$('.box_content_t').hide()
$('.img_btn').css("background-image", "url(https://vt-im-bucket.oss-cn-chengdu.aliyuncs.com/activity/nobuy_btn.png)");
$('.dataStatistics').css('display', "none");
$('.deta_replace').css('display', "flex");
$('#notice').css('display', "block");
$('.notice_img').css('display', "block");
}
} }
} //优惠券的有限时间
let expirationDate = (res.data.expirationDate).split('T')[0].replace(/-/g, '.');
let title = $('.img_bg_p1').text()
let RushbuyTime = {
RushbuyTime: expirationDate,
title: title,
userName: res.data.contact,
shopName: res.data.customerName,
}
localStorage.RushbuyTime = JSON.stringify(RushbuyTime)
$('.img_bg_p2').html('有效期截止:' + expirationDate)
} else {
$('.dataStatistics').dataStatistics({
max: 0,
min: 0,
len: 4,
add: true
}); //刚进入页面不执行动画
layer.msg(res.message);
setTimeout(loadData,3000) //失败后再次3秒后再次调接口
//优惠券的有限时间
let expirationDate = (res.data.expirationDate).split('T')[0].replace(/-/g, '.');
let title = $('.img_bg_p1').text()
let RushbuyTime = {
RushbuyTime: expirationDate,
title: title,
userName: res.data.contact,
shopName: res.data.customerName,
} }
localStorage.RushbuyTime = JSON.stringify(RushbuyTime) // clearInterval(xhtime)
$('.img_bg_p2').html('有效期截止:' + expirationDate) },
error: function(res) {
} else {
$('.dataStatistics').dataStatistics({ $('.dataStatistics').dataStatistics({
max: 0, max: 0,
min: 0, min: 0,
len: 4, len: 4,
add: true add: true
}); //刚进入页面不执行动画 }); //刚进入页面不执行动画
layer.msg(res.message);
setTimeout(loadData,3000) //失败后再次3秒后再次调接口
if (platform == 'app') {
window.postMessage(JSON.stringify({
'action': 'showToast',
'message': '请求人数过多,请返回再次进入!'
}));
} else {
layer.msg('请求人数过多,请返回再次进入!');
}
}
// clearInterval(xhtime)
},
error: function(res) {
$('.dataStatistics').dataStatistics({
max: 0,
min: 0,
len: 4,
add: true
}); //刚进入页面不执行动画
if (platform == 'app') {
window.postMessage(JSON.stringify({
'action': 'showToast',
'message': '请求人数过多,请返回再次进入!'
}));
} else {
layer.msg('请求人数过多,请返回再次进入!');
} }
} });
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment