parking-html/Parking_spaces/Views/Engineering/Engineering_Index_.cshtml

119 lines
2.7 KiB
Plaintext
Raw Normal View History

2024-02-01 11:37:15 +08:00

@{
ViewData["Title"] = "Engineering_Index";
Layout = "~/Views/Shared/_Layout_Engineering.cshtml";
}
<h1>工程模式</h1>
<div>
<button class="btn btn-primary" onclick="webcam_view()">查看WEBCAM</button>
<button class="btn btn-primary" onclick="LED_view()">字幕機顯示</button>
<button class="btn btn-primary" onclick="Violation_view()">違規區域</button>
</div>
<!--跳轉頁面-->
<script>
function webcam_view(){
window.location = "/Engineering/Engineering_CAM" ;
}
function LED_view() {
window.location = "/Engineering/Engineering_LED";
}
function Violation_view() {
window.location = "/Engineering/Engineering_Violation";
}
</script>
<!--檢查token-->
<script>
function token_check() {
// 检查本地存储中是否存在JWT令牌
var token = localStorage.getItem('token_park_space');
console.log(token)
$.ajax({
type: "GET",
url: 'http://140.125.20.183:7700/Users/token_check',
headers: {
'Authorization': token
},
success: function (response) {
console.log(response)
token_check = "true"
from_token_import_id()
},
error: function (xhr) {
token_check = "false"
window.location.href = '/';
// 处理错误响应,例如跳转到未授权页面
//window.location.href = 'https://example.com/unauthorized_page';
}
});
}
function from_token_import_id() {
var token = localStorage.getItem('token_park_space');
$.ajax({
type: "GET",
url: 'http://140.125.20.183:7700/Users/token-' + token,
headers: {
'Authorization': token
},
success: function (response) {
console.log(response)
from_id_import_user_data(response)
}
});
}
function from_id_import_user_data(id) {
var token = localStorage.getItem('token_park_space');
$.ajax({
type: "GET",
url: 'http://140.125.20.183:7700/Users/user_id-' + id,
headers: {
'Authorization': token
},
success: function (model) {
model = model.result
position = model.lastname
console.log(position)
if (position == "engineer") {
get_data()
}
else {
window.location.href = '/';
}
}
});
}
</script>
<!--開機自啟-->
<script>
window.onload = token_check;
</script>