反饋已提交
網絡繁忙
決策平臺單點登入API 適合在 Web 或者跨域場景使用,返回的資料結構為 JSONP。
其他比如 Android 原生,或者 Java 後臺呼叫單點API獲取 Token,如果使用上面跨域的API,結果請求回來的資料不是標準 JSON,都是({accesstoken:xxx}),需要再去掉括號,取 Token。
安卓原生不存在跨域問題,可以直接使用普通登入的API,返回的資料結構直接使用的 JSON 即可。
<!DOCTYPE html><html><head> <meta http-equiv="Content-Type" content="text/html; " charset="UTF-8"> <script src="http://code.jquery.com/jquery-2.1.4.min.js"></script> <script type="text/javascript"> function doSubmit() { var username = document.getElementById("username").value.trim(); var password = document.getElementById("password").value.trim(); if (username === "") { window.alert("請輸入使用者名稱"); return false; } if (password === "") { window.alert("請輸入密碼"); return false; } var url = "/webroot/decision/login"; var data = { username: username, password: password, validity: -2, //是否保持登入,-2表示是 origin: "" }; jQuery.ajax({ type: "POST", url: url, dataType: "json", contentType: "application/json", data: JSON.stringify(data), success: function (res) { console.log(res); if (res.errorCode) { window.alert(res.errorMsg); }else { // 保存token并跳轉到對應鏈接 var tokenCookie = "fine_auth_token=" + res.data.accessToken + ";path=/"; if(res.data.validity === -2) { var exdate = new Date(); exdate.setDate(exdate.getDate() + 14); tokenCookie += ";expires=" + exdate.toGMTString(); } document.cookie = tokenCookie; window.location.href = res.data.url; } }, error: function () { alert("超時或伺服器其他錯誤");// 登入失敗(超時或伺服器其他錯誤) } }); } </script></head><body><p>請登入</p><form id="login" name="login" method="POST" action=""> <p>使用者名稱:<input id="username" type="text" name="username"/></p> <p>密 碼:<input id="password" type="password" name="password"/></p> <input type="button" value="登入" onClick="doSubmit()"/></form></body></html>
将login.html,保存到 %FR_HOME%/webroot/ 路徑下。
啓動設計器,輸入http://localhost:8075/webroot/login.html,效果如下圖所示。
login.html
文 檔回 饋
滑鼠選中內容,快速回饋問題
滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。
不再提示
10s後關閉