mirror of
https://github.com/JamesonHuang/OpenWrt_Luci_Lua.git
synced 2024-11-24 06:10:11 +00:00
45 lines
1.3 KiB
HTML
45 lines
1.3 KiB
HTML
|
<%
|
||
|
local ver = require("xiaoqiang.XQVersion").webVersion
|
||
|
local XQConfigs = require "xiaoqiang.common.XQConfigs"
|
||
|
local LuciUtil = require "luci.util"
|
||
|
|
||
|
local getDvidCmd = XQConfigs.THRIFT_TO_MQTT_GET_DEVICEID
|
||
|
local deviceId = LuciUtil.exec(getDvidCmd)
|
||
|
%>
|
||
|
<%include ("web/inc/head")%>
|
||
|
<title>登录 - 小米路由器</title>
|
||
|
</head>
|
||
|
<body>
|
||
|
<%include ("web/inc/g.js.base")%>
|
||
|
<script src="<%=resource%>/web/js/requesthelper.js?v=<%=ver%>"></script>
|
||
|
<script>
|
||
|
function buildUrl(token, path){
|
||
|
var tpl = 'http://miwifi.com/cgi-bin/luci/;stok={$token}/{$path}';
|
||
|
var _path = path.join('/');
|
||
|
return StringH.tmpl(tpl, {token: token, path: _path});
|
||
|
}
|
||
|
|
||
|
if (/\?userId=\d+/.test(document.URL)) {
|
||
|
var deviceId = '<%=deviceId%>',
|
||
|
userId = StringH.queryUrl(document.URL, 'userId'),
|
||
|
url = global_event.xmServerUrl + '/w/relay/api/xqsystem/renew_token?deviceId=' + deviceId + '&userId=' + userId;
|
||
|
RequestHelper.sendRequest(url, function(rsp){
|
||
|
var rsp = $.parseJSON(rsp);
|
||
|
if (rsp.code == 0) {
|
||
|
var token = rsp.token;
|
||
|
var toUrl = buildUrl(token, ['web', 'home']);
|
||
|
global_event.pspSet({
|
||
|
uuid: userId,
|
||
|
logtype: 1,
|
||
|
token: token
|
||
|
});
|
||
|
document.location.href = toUrl;
|
||
|
}else{
|
||
|
alert('登录失败,请重试。');
|
||
|
document.location.href = 'http://miwifi.com';
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|