Ext.define('com.aa.bb.HomeUtil',{
ldCallInfo:"",//全局变量,来电手机号的用户信息拼接串
getUserInfo:function(teleNum){
var me=this;
ajaxRequest({
url:'userAction!findUserPageInfo.action',
params:{mobile:teleNum},
callBack:function(result){
if(result.infoMap.totalProperty>0){
var uinfo = result.infoMap.list[0];
me.ldCallInfo = "来自" +uinfo.organName+"的"+uinfo.empName;
}else{
me.ldCallInfo = "未知来电!";
}
}
});
},
getUserInfoFun:function(teleNum,callBackFun){
var me=this;
ajaxRequest({
url:'userAction!findUserPageInfo.action',
callBack:function(result){
if(result.infoMap.totalProperty>0){
var uinfo = result.infoMap.list[0];
me.ldCallInfo = "来自" +uinfo.organName+"的"+uinfo.empName;
}else{
me.ldCallInfo = "未知来电!";
}
callBackFun();
}
});
}
Ext.define('com.aa.bb.HomeDeviceFun',{
ajaxRequest({
url:'userAction!findUserPageInfo.action',
noMask:true,
params:{
mobile:mobile
},
callBack:function(result){
if(result.infoMap.totalProperty>0){
var uinfo = result.infoMap.list[0];
me.homeU.ldCallInfo =uinfo.mobile+"来自" +uinfo.organName+"的"+uinfo.empName;
}else{
me.homeU.ldCallInfo = teleNum+"未知来电!";
}
console.log("--callInHandle---"+me.homeU.ldCallInfo);
me.homeCallWinFun.addWinFun({
mobile:mobile,
callWay:callType,
empName:mobile,
passivity:true
});
}
});
ajax 异步执行(2在ajax的回调你执行addWinFun方法,即把法1写得好看点):
this.homeU.getUserInfoFun(mobile,function(){
this.homeCallWinFun.addWinFun({
mobile:mobile,
passivity:true
});
});
ajax 异步执行(3在ajax执行完后赋值给全局变量后再执行addWinFun方法):
this.homeU.getUserInfo(mobile);
this.homeCallWinFun.addWinFun({
mobile:mobile,
passivity:true
});
ajax同步执行:
在ajax中添加属性async:false.即修改为同步了,什么意思?(一般解释就是,这是等这个ajax有了返回值后才会执行下面的js。一语道破天机,怪不得以前很多ajax调用里面的赋值都不起作用)。这样等ajax给bol赋值完毕后,才执行下面的js部分。而刚刚异步的话,还没有来得及赋值,就已经return了。
ajaxRequest({
url:'userAction!findUserPageInfo.action',
noMask:true,
params:{mobile:this.callData.callTele},
async:false, callBack:function(result){ 。。。。。。。。。。 } });