は、以下の両方のAndroidとiOS
は、ユーザー名とパスワードを入力した後、ログインボタンのコードであるため、この作品を願って機能
の下にこれを使用する
index.htmlを使用onloadハンドラのfillpasswordで、この後の
$('#login').click(function() {
var userName = $('#Username').val();
var password = $('#password').val();
if (userName == "" || password == "") {
window.plugins.toast.showLongBottom("Please enter a valid data");
return false;
}
var options = { dimBackground: true };
SpinnerPlugin.activityStart("Loading...", options);
$.ajax({
type: 'GET',
url: xxxxxx.xxxx.xxxxx,
data: "uid=" + userName + "&pwd=" + password + "",
success: function (resp) {
SpinnerPlugin.activityStop();
if (resp.status != 0) {
if (resp.RoleId == 1) {
mash.Session.getInstance().set({
userId: resp.sno,
userName: resp.Name,
});
var session = mash.Session.getInstance().get();
window.open('Add.html', '_self', 'location=no');
// Create session.
var today = new Date();
var expirationDate = new Date();
expirationDate.setTime(today.getTime() mash.Settings.sessionTimeoutInMSec);
}
else {
SpinnerPlugin.activityStop();
mash.Session.getInstance().set({
userId: resp.sno,
userName: resp.Name,
});
var session = mash.Session.getInstance().get();
var username = userName;
var password = password;
window.localStorage.setItem("uname", resp.Name);
window.localStorage.setItem("pass", password);
window.localStorage.setItem("sno", resp.sno);
window.localStorage.setItem("RoleId", resp.RoleId);
window.open('Main.html', '_self', 'location=no');
//window.plugins.toast.showLongBottom("Login Successfull");
// Create session.
var today = new Date();
var expirationDate = new Date();
expirationDate.setTime(today.getTime() + mash.Settings.sessionTimeoutInMSec);
}
}
else {
SpinnerPlugin.activityStop();
window.plugins.toast.showLongBottom("Please Enter valid Username and password");
SpinnerPlugin.activityStop();
}
},
error: function (e) {
SpinnerPlugin.activityStop();
window.plugins.toast.showLongBottom("Invalid Data");
SpinnerPlugin.activityStop();
}
});
});
()
function fillpassword() {
if (window.localStorage.getItem("uname") != 0) {
mash.Session.getInstance().set({
userId: window.localStorage.getItem("sno"),
userName: window.localStorage.getItem("uname"),
});
if (window.localStorage.getItem("RoleId") != 1) {
document.getElementById('Username').value = window.localStorage.getItem("uname");
document.getElementById('password').value = window.localStorage.getItem("pass");
window.open('Main.html', '_self', 'location=no');
}
}
else {
//alert("Yes")
}
}
上記のコードの作品とuはセッション
を維持するために必要なすべてのようにuはこれまで、ユーザーがアプリを閉じて、それがページ内右にリダイレクトする必要があり、再びそれを開く自動ログイン機能が必要ですか? – Madpop
そういうもの。 – bodesam