初始化项目
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
var root = 'http://134.122.134.63/index.php?s=/'
|
||||
let url = window.location.href
|
||||
let searchParams = new URLSearchParams(url.split('?')[1])
|
||||
var orderId = searchParams.get('orderId')
|
||||
var passageway = searchParams.get('passageway')
|
||||
var timer = null
|
||||
var count = '' //倒计时
|
||||
var min = '' //分
|
||||
var sec = '' //秒
|
||||
var seconds = 300 // 倒计时秒数
|
||||
var money = 0
|
||||
var qrcode = ''
|
||||
var qrcodeTemplate = `
|
||||
<img class='qrcode' src="${qrcode}" />
|
||||
`;
|
||||
var qrcodeButTemplate = `
|
||||
<a class="ali-a" href="${qrcode}">点击打开支付宝</a>
|
||||
`;
|
||||
|
||||
$(document).ready(function() {
|
||||
Time()
|
||||
getDetail()
|
||||
window.addEventListener('click', (event) => {
|
||||
if (event.target === $('.modal')) {
|
||||
closeModal();
|
||||
}
|
||||
});
|
||||
});
|
||||
function clickNum() {
|
||||
// 发送异步请求
|
||||
$.ajax({
|
||||
url: root+'store/passport/clickNum&orderId='+orderId,
|
||||
method: 'GET',
|
||||
success: function(response) {
|
||||
},
|
||||
error: function() {
|
||||
console.log('提交失败,请稍后再试');
|
||||
}
|
||||
});
|
||||
}
|
||||
function getDetail() {
|
||||
// 显示加载样式
|
||||
$('body').append('<div class="loading">加载中...</div>');
|
||||
// 发送异步请求
|
||||
$.ajax({
|
||||
url: root+'store/passport/detail&orderId='+orderId,
|
||||
method: 'GET',
|
||||
//data: {foo: 'bar'},
|
||||
success: function(result) {
|
||||
// 隐藏加载样式
|
||||
$('.loading').remove();
|
||||
|
||||
if(result.status === 200) {
|
||||
if (result.data.qrcode === '') {
|
||||
openModal('提示','订单已关闭,请重新发起订单')
|
||||
} else {
|
||||
if(result.data.passageway === 'SNZFBH5'){
|
||||
window.location.href = result.data.qrcode
|
||||
}else {
|
||||
// 当前记录
|
||||
money = result.data.money
|
||||
seconds = result.data.seconds
|
||||
qrcode = result.data.qrcode
|
||||
$('.money').text(money)
|
||||
$('.container').css('display', 'none')
|
||||
if(passageway === 'WX') {
|
||||
qrcodeTemplate = `
|
||||
<img class='qrcode' src="${qrcode}" />
|
||||
`;
|
||||
$('.qrcode-div').html(qrcodeTemplate)
|
||||
$('#WX').css('display', 'block')
|
||||
}else{
|
||||
qrcodeButTemplate = `
|
||||
<a class="ali-a" href="${qrcode}">点击打开支付宝</a>
|
||||
`;
|
||||
$('.qrcode-div').html(qrcodeButTemplate)
|
||||
$('#ZFBH5').css('display', 'block')
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
openModal('提示','订单已关闭,请重新发起订单')
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
// 隐藏加载样式
|
||||
$('.loading').remove();
|
||||
// 处理异步请求失败的情况
|
||||
openModal('错误','提交失败,请稍后再试')
|
||||
}
|
||||
});
|
||||
}
|
||||
function Time() {
|
||||
timer = setInterval(() => {
|
||||
seconds -= 1
|
||||
countDown()
|
||||
}, 1000)
|
||||
}
|
||||
function countDown() {
|
||||
if(seconds <= 0){
|
||||
clearInterval(timer);
|
||||
timer = null;
|
||||
count = '已超时'
|
||||
qrcode = ''
|
||||
$('#remainTime').text(count)
|
||||
$('.qrcode-div').html('')
|
||||
openModal('提示','订单已关闭,请重新发起订单')
|
||||
return false;
|
||||
}
|
||||
let d = parseInt(seconds / (24 * 60 * 60))
|
||||
d = d < 10 ? "0" + d : d
|
||||
let h = parseInt(seconds / (60 * 60) % 24);
|
||||
h = h < 10 ? "0" + h : h
|
||||
let m = parseInt(seconds / 60 % 60);
|
||||
m = m < 10 ? "0" + m : m
|
||||
let s = parseInt(seconds % 60);
|
||||
s = s < 10 ? "0" + s : s
|
||||
//this.count = d + '天' + h + '时' + m + '分' + s + '秒'
|
||||
count = m + '分' + s + '秒'
|
||||
min = m
|
||||
sec = s
|
||||
timeAssignment()
|
||||
}
|
||||
function timeAssignment(){
|
||||
$('.min').text(min)
|
||||
$('.sec').text(sec)
|
||||
$('#remainTime').text(count)
|
||||
$('.money').text(money)
|
||||
}
|
||||
function openModal(title, text) {
|
||||
$('.modal-title').text(title)
|
||||
$('.modal-text').text(text)
|
||||
$('.modal').css('display', 'block')
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
$('.modal').css('display', 'none')
|
||||
}
|
||||
Reference in New Issue
Block a user