Salazar
Salazar
  • 发布:2017-09-19 10:27
  • 更新:2017-09-19 10:27
  • 阅读:485

请问一下,点击div去访问selectday这个方法

分类:MUI

iOS下很流畅,点击一次就响应了,为什么Android端要点击好多次才响应?是不是我这个代码还需要做优化?

function selectday(obj, year, month, day) {  
    if(selDayObj != null) {  
        selDayObj.className = "calendar-week-line-cell";  
    }  
    selDayObj = obj;  
    selDayObj.className = "calendar-week-line-cell-select";  
    var objSelectDay = document.getElementById('select_work_day'); //中间具体日期   
    objSelectDay.innerHTML = day + ' ' + getmonthName() + ', ' + iCurrentYear;  
    //  console.log("1502day="+day);  
    get_task_list_by_day(year, month, day);//通过AJAX获取数据  
}  

AJAX方法:

function get_task_list_by_day(year, month, day) {  
    plus.nativeUI.showWaiting();  
    var guid = localStorage.getItem("guid");  
    var suid = document.getElementById('currentUser').innerHTML; //根据所选的用户去请求数据  
    var url = localStorage.getItem("url");  
    mui.ajax({  
        type: "get",  
        headers: {  
            'Content-Type': 'application/json'  
        },  
        data: {  
            "COMMAND": "GET_WORKER_DAY_TASK",  
            "GUID": guid,  
            "YEAR": year.toString(),  
            "MONTH": (month + 1).toString(),  
            "DAY": day.toString(),  
            "USERID": suid  
        },  
        url: url,  
        timeout: 20000, //超时时间设置为20秒;  
        success: function(json) {  
            //json = JSON.stringify(response);  
            //解析json数据  
            var status = JSON.parse(json).STATUS;  
            var message = JSON.parse(json).MESSAGE;  
            var record = JSON.parse(json).RECORD;  

            switch(status) {  
                case "OK":  
                    plus.nativeUI.closeWaiting();  
                    //回调方法  
                    display_task_list(record);  
                    break;  
                case "FAIL":  
                    plus.nativeUI.closeWaiting();  
                    mui.toast(message);  
                    break;  
                case "RELOGIN":  
                    plus.nativeUI.closeWaiting();  
                    mui.toast(message);  
                    mui.openWindow({  
                        url: "login.html",  
                        createNew: true  
                    });  
                    break;  
                case "ERROR":  
                    plus.nativeUI.closeWaiting();  
                    mui.toast(message);  
                default:  
                    break;  
            }  
        },  
        error: function(xhr, type, errorThrown) {  
            plus.nativeUI.closeWaiting();  
            console.log("login:error1036xhr=" + xhr + ",type=" + type + ",errorthorwn=" + errorThrown);  
            mui.toast(type);  
        }  
    });  
}  
2017-09-19 10:27 分享
已邀请:

要回复问题请先登录注册