1. get获取数据
//获取信息
function getusertInfo(){
var url = ipVal+"m=user&a=userInfo&userId="+userId;
// $toast("正在加载……");
$.getJSON(url,function(json){
if (json.status == 1) {
$$("username").value=!isDefine(json.data.name) ? json.data.name="" : json.data.name;
$$("phoneNumber").value=!isDefine(json.data.phone) ? json.data.phone="" : json.data.phone;
}else{
$toast(json.message, 2000);
}
},'json',function(err){
getJSONError(err);
},"GET")
}
2. post提交数据
//修改信息
function saveuserInfo(){
var schoolName = $$("username").value;
var phoneNumber = $$("phoneNumber").value;
var postArr=[
{'key':'phoneNumber','type':'0','value':phoneNumber},
{'key':'userId','type':'0','value':userId},
{'key':'schoolName','type':'0','value':schoolName}
]
if(!isDefine(phoneNumber)){
$alert("电话还没填写!");
return
}
var text=$$("phoneNumber").value;
var _emp = /^\s*|\s*$/g;
text = text.replace(_emp, "");
var _y = /^(134[0-8]\d{7}|1[34578][0-35-9]\d{8})$/g;
if (_y.test(text)) {
}
else {
$alert("格式错误!")
return;
}
var url =ipVal+"m=user&a=editInfo";
$.getJSON(url,function(json){
if (json.status == 1) {
$toast(json.message,500);
setTimeout(function(){
uescript("userInfo","winClose()");
},500);
}
else {
$toast(json.message,2000);
}
},'json',function(err){
getJSONError(err);
},"POST",postArr);
}