编辑代码

/*
Name: fnMainGetInhouseReservationList
Function: main of this function
            1.store the nature onmessage function
            2.return the param by post message to main onmessage
            3.reset the onmessage function
            4.tell the parent msg loop task is complete
Param: null
Return: onmessage.name==fnCallBackMainGetInhouseReservationList
        let objParam = {
                "name": "fnCallbackGetInhouseReservationList",
                "aryObjReservationList": aryObjReservationList
            }
 */
function fnMainGetInhouseReservationList()
{
    window.fnOldOnmessage= window.onmessage;

    window.onmessage= function(objMsg){
        

        console.log(objMsg);
        //alert(objMsg);

        if( objMsg.data.strName.match("fnCallbackGetInhouseReservationList"))
        {
            //alert('fnCallbackGetInhouseReservationList');

            fnResetOnmessage();

            //console.log("a");

           
            objMsg.data.strName= "fnCallBackMainGetInhouseReservationList";
            objMsg.data.bIfContinue= true;

            window.postMessage(objMsg.data);
            
        }
        else
            window.fnOldOnmessage(objMsg);
        
    }

    fnGetInhouseReservationList();
    
}

function fnResetOnmessage( )
{
    window.onmessage = window.fnOldOnmessage;
    window.fnOldOnmessage= null;

}



//arrived number
/*
Name: fnGetInhouseReservationList
Function: Get In-House reservation list
Param: null
Return: In-House reservation list
future: property need to update
 */

function fnGetInhouseReservationList()
{
        let date = new Date();
        let strSymble1;
        let strSymble2;

        //如果月或者日小于10,strSymble '-'或者‘-0’
        if (parseInt(date.getMonth()) < 9) {
            strSymble1 = '-0';
        }
        else
            strSymble1 = '-';
        if (parseInt(date.getDate()) < 10) {
            strSymble2 = '-0';
        }
        else
            strSymble2 = '-';

        let nProperty;
        nProperty= JSON.parse(window.localStorage.getItem("RM_Property")).data.split('_')[0];
        let objParam = {
            "FromDate": date.getFullYear() + strSymble1
                + parseInt(date.getMonth() + 1) + strSymble2
                + date.getDate(),
            "ToDate": date.getFullYear() + strSymble1
                + parseInt(date.getMonth() + 1) + strSymble2
                + date.getDate(),
            "OnlyShowPrimaryClient": true,
            "ShowGroupMasterOnly": false,
            "Properties": [nProperty],
            "BookingTypeId": 0,
            "ReportView": 3,
            "ResView": 0,
            "CatGrpIds": [],
            "CatIds": []
        }
        let xmlhttp= new XMLHttpRequest();
        xmlhttp.onreadystatechange = function () {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            console.log("fnGetInhouseReservationList: ");
            console.log(xmlhttp.responseText);
            //objParam.objReservationDetails= rtn.responseJSON.ResScreenData.ResRows;
            //fnTasksLoop("fnGetReservationDetails",xmlhttp.responseText);
            window.objParam= null;
            window.objParam= (xmlhttp.responseText);

            let objParam = {
                "strName": "fnCallbackGetInhouseReservationList",
                "objValue": JSON.parse(xmlhttp.responseText).InOutData
            }
            window.postMessage(objParam);
            }
            }

        xmlhttp.open("POST","https://app9.rmscloud.cn/api/Reservation/InOutScreen/RetrieveScreenData");
        xmlhttp.setRequestHeader('content-Type','application/json; charset=utf-8');
        xmlhttp.send(JSON.stringify(objParam));
        
}


console.log("get reservation list");