处理登录
*/
var doLogin=function(){
plus.nativeUI.showWaiting("登陆中...");
if(document.getElementById("tel").value && document.getElementById("pass").value){
var tel=document.getElementById("tel").value;
var pass=hex_md5(document.getElementById("pass").value);
}else{
plus.nativeUI.closeWaiting();
mui.toast('数据存在空值,不允许提交!');
return false;
}
mui.ajax(serverHost+'/interface/login',{
data:{
'tel':tel,
'pass':pass
},
dataType:'json',//服务器返回json格式数据
type:'post',//HTTP请求类型
timeout:5000,//超时时间设置为5秒;
success:function(d){
//服务器返回响应;
console.log(tel);
if(d.status==1){
setTimeout(function(){loginSuccess(d.uid,d.ukey);plus.nativeUI.closeWaiting();},480);
}else{
//mui.toast('登陆失败!');
console.log(d.message);
mui.toast(d.message);
plus.nativeUI.closeWaiting();
}
},
error:function(xhr,type,errorThrown){
//异常处理;
//console.log(errorThrown);
plus.nativeUI.closeWaiting();
plus.nativeUI.toast('网络数据链接失败!');
}
});
}
-------------php-----------------------
if(empty($data)){ajaxMsg('手机号未知或未绑定!',0);}
//密码是用密文传输的
if($data['user_pass']==trim(htmlspecialchars($_POST['pass']))){
$user=array(
'uid'=>intval($data['id']),
'ukey'=>$data['user_pass'],
);
ajaxMsg($user);
}else{
//echo time();
ajaxMsg('登录失败!',0);
}