function fnGetEventHandler() {
let xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
console.log("fnGetEventHandler: ");
console.log(xmlhttp.responseText);
let objParam = {
"strName": "fnCallBackGetEventHandler",
"objValue": null,
"bIfContinue": true,
"strErrorDescription": ""
}
window.objGlobalParam.strEventHandler = xmlhttp.responseText;
window.postMessage(objParam);
}
}
xmlhttp.open("GET", "https://app9.rmscloud.cn/api/UtilitiesService/InitEventHandler" +
"?placeholder=" + Math.random());
xmlhttp.setRequestHeader('content-Type', 'application/json; charset=utf-8');
xmlhttp.send();
}
function fnEventStatusAsync(strEventId) {
let xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
console.log("fnEventStatusAsync: ");
console.log(xmlhttp.responseText);
if (xmlhttp.responseText.toLowerCase() == 'null') {
setTimeout(function () {
window.objGlobalParam.nExpireCounter = parseInt(window.objGlobalParam.nExpireCounter) + 1;
if (parseInt(window.objGlobalParam.nExpireCounter) >= 9) {
window.objGlobalParam.nExpireCounter = 0;
let objParam = {
"strName": "fnCallBackEventStatusAsync",
"objValue": null,
"bIfContinue": false,
"strErrorDescription": "创建失败,请重试"
}
window.postMessage(objParam);
alert('请重试');
fnClearEventHandler(strEventId);
}
else
fnEventStatusAsync(strEventId);
}, 1000)
}
else {
fnOnTaskReady(xmlhttp);
fnClearEventHandler(strEventId);
}
}
}
xmlhttp.open("GET", "https://app9.rmscloud.cn/api/UtilitiesService/EventStatusAsync?" +
"EventId=" + strEventId);
xmlhttp.setRequestHeader('content-Type', 'application/json; charset=utf-8');
xmlhttp.send();
}
function fnClearEventHandler(strEventId) {
let xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
console.log("fnClearEventHandler: ");
console.log(xmlhttp.responseText);
let objParam = {
"strName": "fnCallBackClearEventHandler",
"objValue": null,
"bIfContinue": true,
"strErrorDescription": ""
}
}
}
xmlhttp.open("GET", "https://app9.rmscloud.cn/api/UtilitiesService/ClearEventHandler?" +
"EventId=" + strEventId);
xmlhttp.setRequestHeader('content-Type', 'application/json; charset=utf-8');
xmlhttp.send();
}
function fnOnCreateReservationSuccess(xmlhttp)
{
let objParam = {
"strName": "fnCallBackEventStatusAsync",
"objValue": null,
"bIfContinue": true,
"strErrorDescription": ""
}
window.objGlobalParam.objReservationDetails = JSON.parse(xmlhttp.responseText).ResScreenData;
window.postMessage(objParam);
alert('预订成功,订单确认号: ' + JSON.parse(xmlhttp.responseText).ResScreenData.ResId);
fnClearEventHandler(strEventId);
}