Home > Mobile >  App bosses to help beginners, when the interface for less than the param value
App bosses to help beginners, when the interface for less than the param value

Time:11-02

The function userLogin () {//click event
If (frameName=='Dealer_Login') {//
Var username=$(" # username "). Val ();
Var password=$(" # "password," "). Val ();
The console. The log (" mobile phone number, password: "+ username + ', '+ password);
//determine whether the user account is empty
If (judgeIsAnyNullStr (username)) {
ShowAlert (TIP_STR, 'please enter the user name');
return;
}
//phone number format is the right
If (regular (' phone_num 'username)!==true) {
Dialog_evaluation (TIP_STR, 'please fill in the correct cell phone number, [{text:' confirmed '}], function (ret, err) {
CloseDialogBox (' evaluation ')
})
Return
}
//determine whether the user password is empty
If (password=="" | | password==undefined) {
ShowAlert (TIP_STR, "password is null");
return;
}

//configuration parameter
Var param={
Account_type: 'XCX',
Phonenum: username,
Password: password,
}
ShowProgress (" login ")
Value for user_login (param, handleLogin);
} else if (frameName=='Company_Login')}
OpenWin (' company_win ', '../Company/' {name: 'uio}, 0, null);

} else if (frameName=='Market_Login') {//
//alert (' 333 ');
OpenWin ();

} else if (frameName=='Install_Login') {//
//alert (' 444 ');
OpenWin ();

}

}

//handle the login
The function handleLogin (ret, err) {
Consoledebug. Log (" handleLogin ret is: "+ JSON. The stringify (ret));
//the judgment
ClearWaitingForProgress ();
If (judgeIsAnyNullStr (ret. Data)) {
ShowToast (" user name or password error ")
return;
}
If (ret. Result) {
//login successful, deposited in the cache the userinfo
SetStorage (' user_info, ret. Ret)
RefreshIndex ();
Consoledebug. The log (" handleLogin>>>>>>>>>> Ret is: "+ (JSON. Stringify (getStorageUser ())));
} else {
ShowToast (ret. Message);
}
}
The function refreshIndex () {
Var jsfun='login (); ';
API. ExecScript ({
Name: "root",
Script: jsfun
});
}


The method of encapsulation:
//login
The function value for user_login (param, callBack) {
Ajax (param, SERVER_URL + '/user/login', 'POST' callBack, true)
}
Function ajax (param, url, method, the callBack, loading_flag) {
If (connectionType ()=='none') {
ShowToast (' network request timeout, please try again later ')
return;
}
If (loading_flag) {
WaitingForProgress ()
}
if (! IsHasUserInfo ()) {
The console. The log (' Ajax from the user info ')
} else {
The console. The log (' Ajax from the user info ')
if (! IsObjectOwnProperty (getStorageUser (), "id")) {
Var user=getStorageUser ();
//var language='en'
//consoledebug. The log (' getStorageUser - & gt; : "+ JSON. Stringify (user)
Param. User_id=user. Id
Param. User_token=user. Token
}
}
Consoledebug. Log (" param is: "+ JSON. Stringify (param))
Consoledebug. Log (" ajax param is: "+ JSON. Stringify (" param:" + JSON. Stringify (param) + "url:" + url + "method:" + method))
API. Ajax ({
Url: the url,
Method: method,
Headers: {
The content-type: "application/json; Charset=utf-8 "
},
Data: {
Body: param
}
{} function (ret, err)
Consoledebug. Log (" Ajax ret is: "+ JSON. Stringify (ret))//the above param no incoming
ClearWaitingForProgress ();
If (ret) result | | ret. Code=='200') {
The callBack (ret, err)
} else {
Consoledebug. Log (' Ajax err is: '+ JSON. Stringify (err))
The callBack (ret, err)
//toast (" network request timeout, please try again later ")
return;
}
//callBack (ret, err)
//}
})
}
  • Related