|
|
@ -3,6 +3,10 @@ $(document).ready(function() { |
|
|
|
var yesRadio = ''; |
|
|
|
var notChecked = ''; |
|
|
|
var checked = ''; |
|
|
|
var payResultTimer = null; |
|
|
|
|
|
|
|
var isPayDialog = false |
|
|
|
var allPostData=new Object() |
|
|
|
$.get('你的接口URL', function(response) { |
|
|
|
// 请求成功时的回调函数
|
|
|
|
console.log(response); |
|
|
@ -147,6 +151,230 @@ $(document).ready(function() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
$('.pay_every').click(function(e){ |
|
|
|
if ($('.pay_every').hasClass('pay_active')) { |
|
|
|
$('.pay_every').removeClass('pay_active') |
|
|
|
} |
|
|
|
$(this).addClass('pay_active') |
|
|
|
let pay_type = $('.pay_active').attr('pay_type'); |
|
|
|
allPostData = {...allPostData,pay_type} |
|
|
|
// $('#totalMoney').text('')
|
|
|
|
payAction() |
|
|
|
// getPayQrcode(postData,check_flag)
|
|
|
|
|
|
|
|
}) |
|
|
|
$('.close_modal').click(function(e){ |
|
|
|
$('.pageMask').addClass('hide'); |
|
|
|
$('.payModal').addClass('hide'); |
|
|
|
// clearInterval()
|
|
|
|
}) |
|
|
|
function getPayType() { |
|
|
|
var paytype = $('.pay_active').attr('pay_type'); |
|
|
|
return paytype; |
|
|
|
} |
|
|
|
function payAction(){ |
|
|
|
let check_type = $('li.active_select').attr('type'); |
|
|
|
let check_flag = $('li.active_select').attr('check_flag'); |
|
|
|
let pay_type = getPayType(); |
|
|
|
let title = $('.inputChange').val(); |
|
|
|
// goods_id 0
|
|
|
|
// const postData = {
|
|
|
|
// title:'88',
|
|
|
|
// check_type,
|
|
|
|
// pay_type,
|
|
|
|
// get_pay_goods:'1',
|
|
|
|
// aiessay_wordnum:'3000',
|
|
|
|
// // recharge_goods_id:'0',
|
|
|
|
// // value_added_services:''//增值服务
|
|
|
|
// }
|
|
|
|
const postData = { |
|
|
|
title: '123', |
|
|
|
check_type: '94', |
|
|
|
pay_type, |
|
|
|
get_pay_goods: '1', |
|
|
|
aiessay_wordnum: '3000' |
|
|
|
} |
|
|
|
allPostData = {...allPostData,check_flag,recharge_goods_id:'0',...postData} |
|
|
|
|
|
|
|
if(check_type == '94'){ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//检验信息
|
|
|
|
getPayQrcode(postData) |
|
|
|
} |
|
|
|
$('#formInputSumbtn').click(function(e){ |
|
|
|
payAction() |
|
|
|
}) |
|
|
|
function getPayQrcode(postData){ |
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
type: "post", |
|
|
|
dataType:'json', |
|
|
|
url: 'http://aitest.chachongz.com/'+ allPostData.check_flag+'/ajax_check_aisubmit', |
|
|
|
data: { |
|
|
|
...postData |
|
|
|
}, |
|
|
|
success: function (res) { |
|
|
|
if(res.data.user_not_enough_money) { |
|
|
|
if(isPayDialog){ |
|
|
|
$('.pageMask').addClass('hide'); |
|
|
|
$('.payModal').addClass('hide'); |
|
|
|
} |
|
|
|
$('.pageMask').removeClass('hide'); |
|
|
|
$('.payModal').removeClass('hide'); |
|
|
|
isPayDialog = true |
|
|
|
if(postData.pay_type == 2 || postData.pay_type == 3){ |
|
|
|
getRechargePayUrl() |
|
|
|
// getRechargeGoods(payInfo, configData);
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
function getRechargePayUrl(){ |
|
|
|
console.log(allPostData,'allPostData'); |
|
|
|
var core_content = $('.coreWordCount').val(); |
|
|
|
var postData1 = new Object(); |
|
|
|
postData1.type = allPostData.check_type; |
|
|
|
postData1.pay_type = allPostData.pay_type; |
|
|
|
// postData1.value_added_services = configData.addedServicesStr;//增值服务
|
|
|
|
// if(configData.ppt_tpl != '') postData1.ppt_tpl = configData.ppt_tpl;//ppt
|
|
|
|
// postData1.recharge_goods_id = '0';
|
|
|
|
postData1.title = allPostData.title; |
|
|
|
postData1.core_content = core_content; |
|
|
|
// type==94
|
|
|
|
// var edu= parseInt($('#paper-edu-wrapper').find('input[type="radio"]:checked').val());
|
|
|
|
// if(edu<=0 || !edu) {
|
|
|
|
// alert("请选择您的学历");
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// if(!$('.form_essayWords').hasClass('hide')){
|
|
|
|
// var wordnums= parseInt($('.textLength').find('input[type="radio"]:checked').val());
|
|
|
|
// if(wordnums<=0 || isNaN(wordnums)) {
|
|
|
|
// alert("请选择您的字数");
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// var major = parseInt($('#paper-major-wrapper').find('option:selected').val());
|
|
|
|
// if(major<=0 || !major) {
|
|
|
|
// alert("请选择您的专业");
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
$.ajax({ |
|
|
|
url:"http://aitest.chachongz.com/"+allPostData.check_flag+'/ajax_get_ai_pay_url', |
|
|
|
type:'post', |
|
|
|
dataType:'json', |
|
|
|
// data:{...postData1},
|
|
|
|
data:{ |
|
|
|
type: '94', |
|
|
|
pay_type: postData1.pay_type, |
|
|
|
value_added_services: '', |
|
|
|
recharge_goods_id: '0', |
|
|
|
title: '123', |
|
|
|
fuid: '', |
|
|
|
aiessay_wordnum: '3000', |
|
|
|
aiessay_edu: '2', |
|
|
|
aiessay_major: '1' |
|
|
|
}, |
|
|
|
success:function(res){ |
|
|
|
if(res.status){ |
|
|
|
$('#qrcode').html(''); |
|
|
|
$('#qrcode').attr('tid', res.data.tid); |
|
|
|
$('#qrcode').attr('paytype', postData1.pay_type); |
|
|
|
$('#totalMoney').text(res.data.total_fee) |
|
|
|
var qrcode = new QRCode(document.getElementById("qrcode"), { |
|
|
|
text: res.data.qrcode_url, |
|
|
|
width: 135, |
|
|
|
height: 135, |
|
|
|
colorDark : "#000000", |
|
|
|
colorLight : "#ffffff", |
|
|
|
correctLevel : QRCode.CorrectLevel.H |
|
|
|
}); |
|
|
|
getRechargePayResult(res.data) |
|
|
|
}else{ |
|
|
|
alert(res.info); |
|
|
|
} |
|
|
|
}, |
|
|
|
error:function(){ |
|
|
|
alert('网络错误1'); |
|
|
|
} |
|
|
|
}); |
|
|
|
// console.log(allPostData,'allPostData====');
|
|
|
|
} |
|
|
|
function getRechargePayResult(payinfo){ |
|
|
|
clearTimeout(payResultTimer); |
|
|
|
if (payinfo.tid) { |
|
|
|
ptid = payinfo.tid; |
|
|
|
} |
|
|
|
$.ajax({ |
|
|
|
url:"http://aitest.chachongz.com/"+ allPostData.check_flag +'/ajax_get_ai_pay_result', |
|
|
|
type:'post', |
|
|
|
dataType:'json', |
|
|
|
data:{ |
|
|
|
tid:ptid, |
|
|
|
pay_type:'2'}, |
|
|
|
success:function(res){ |
|
|
|
if(res.status){ |
|
|
|
if(res.data.pay_status == 'NOTPAY') { |
|
|
|
payResultTimer = setTimeout(function(){ |
|
|
|
getRechargePayResult(payinfo); |
|
|
|
}, 2000); |
|
|
|
return; |
|
|
|
}else if(res.data.pay_status == 'SUCCESS'){ |
|
|
|
if(isPayDialog){ |
|
|
|
$('.pageMask').addClass('hide'); |
|
|
|
$('.payModal').addClass('hide'); |
|
|
|
} |
|
|
|
} |
|
|
|
clearTimeout(payResultTimer); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
clearTimeout(payResultTimer); |
|
|
|
alert(res.info); |
|
|
|
}, |
|
|
|
error:function(err){ |
|
|
|
alert('网络错误2'); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
function payresultAction(res) { |
|
|
|
var data = res.data; |
|
|
|
$('#payresultTid').text(data.tid); |
|
|
|
if(data.wechat_qrcode_url){ |
|
|
|
$('.payresultWrap').removeClass('payresultNoGz'); |
|
|
|
$('.payresultQrcode').attr('src', data.wechat_qrcode_url); |
|
|
|
$('.payresultQrcodeClass').removeClass('hide'); |
|
|
|
} |
|
|
|
$('.payresultMask').removeClass('hide'); |
|
|
|
$('.payresultWrap').removeClass('hide'); |
|
|
|
$('.payresultBtn1').unbind('click'); |
|
|
|
$('.payresultBtn2').unbind('click'); |
|
|
|
$('.payresultBtn1').click(function(){ |
|
|
|
location.href = "/report2?oid="+data.tid; |
|
|
|
}); |
|
|
|
$('.payresultBtn2').click(function(){ |
|
|
|
if(isPayDialog) { |
|
|
|
location.reload(); |
|
|
|
return; |
|
|
|
} |
|
|
|
location.href = "/modelessay"; |
|
|
|
}); |
|
|
|
|
|
|
|
$('#payresultCopyTidBtn').unbind('click'); |
|
|
|
var clipboard2 = new Clipboard('#payresultCopyTidBtn', { |
|
|
|
text: function () { |
|
|
|
return $('#payresultTid').text(); |
|
|
|
} |
|
|
|
}); |
|
|
|
clipboard2.on('success', function(e) { |
|
|
|
alert('复制成功') |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$('li').click(function(e) { |
|
|
|
|
|
|
|
if ($('li').hasClass('active_select')) { |
|
|
|