update
This commit is contained in:
+80
-57
@@ -22,7 +22,23 @@
|
|||||||
uuid: (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
|
uuid: (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**界面初始化*/
|
||||||
|
function view_init() {
|
||||||
|
const uid = $('#uid').html()
|
||||||
|
// 未登录
|
||||||
|
if (!uid || isNaN(uid)) {
|
||||||
|
$('#login_register').show()
|
||||||
|
$('#logout_a').hide()
|
||||||
|
} else {
|
||||||
|
$('#login_register').hide()
|
||||||
|
$('#logout_a').show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
|
/**界面初始化*/
|
||||||
|
view_init()
|
||||||
|
|
||||||
// 监听modal窗口事件
|
// 监听modal窗口事件
|
||||||
$('#exampleModal').on('show.bs.modal', function (event) {
|
$('#exampleModal').on('show.bs.modal', function (event) {
|
||||||
// console.log(qr_websocket)
|
// console.log(qr_websocket)
|
||||||
@@ -152,8 +168,11 @@
|
|||||||
if (data.code === 0) {
|
if (data.code === 0) {
|
||||||
login_alert(data.msg, 'alert-primary')
|
login_alert(data.msg, 'alert-primary')
|
||||||
$('#exampleModal').modal('hide')
|
$('#exampleModal').modal('hide')
|
||||||
$('#login_register').remove()
|
// $('#login_register').hide()
|
||||||
fetch_mind()
|
// fetch_mind()
|
||||||
|
setTimeout(function () {
|
||||||
|
location.reload();
|
||||||
|
}, 500)
|
||||||
} else {
|
} else {
|
||||||
// 登录失败
|
// 登录失败
|
||||||
login_alert(data.msg)
|
login_alert(data.msg)
|
||||||
@@ -163,58 +182,6 @@
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
/**获得导图*/
|
|
||||||
function fetch_mind(page, page_size) {
|
|
||||||
if (!page) {
|
|
||||||
page = 1
|
|
||||||
}
|
|
||||||
if (!page_size) {
|
|
||||||
page_size = 10
|
|
||||||
}
|
|
||||||
$.ajax({
|
|
||||||
type: `get`,
|
|
||||||
url: `list?page=${page}&page_size=${page_size}`,
|
|
||||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
|
||||||
dataType: "json",
|
|
||||||
success: function (resp) {
|
|
||||||
if (resp.code !== 0) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// clear
|
|
||||||
$('main .container-fluid').empty()
|
|
||||||
|
|
||||||
// 解析结果
|
|
||||||
const results = resp.results
|
|
||||||
let idx = 0
|
|
||||||
let row = $(`<div class="row"></row>`)
|
|
||||||
results.forEach(function (item) {
|
|
||||||
const content = `
|
|
||||||
<div class="card col-3" style="width: 18rem;margin: 8px;">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">${item.coop_mind_name}</h5>
|
|
||||||
<img src="https://img0.baidu.com/it/u=218959243,558802769&fm=253&fmt=auto&app=138&f=JPEG?w=1377&h=500" class="card-img-top" alt="...">
|
|
||||||
<a href="#" class="btn btn-info" onclick="window.open('detail?id=${item.id}')">编辑</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`
|
|
||||||
row.append(content)
|
|
||||||
idx++
|
|
||||||
if (idx % 3 === 0) {
|
|
||||||
// 3个一行
|
|
||||||
$('main .container-fluid').append(row)
|
|
||||||
// 重置row
|
|
||||||
row = $(`<div class="row"></row>`)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// 如果不是3的整数倍,将剩余的添加
|
|
||||||
if (idx % 3 !== 0) {
|
|
||||||
$('main .container-fluid').append(row)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**新建导图*/
|
/**新建导图*/
|
||||||
$('#new_mind_btn').click(function () {
|
$('#new_mind_btn').click(function () {
|
||||||
@@ -253,12 +220,68 @@
|
|||||||
function logout_() {
|
function logout_() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "post",
|
type: "post",
|
||||||
url: "login",
|
url: "logout",
|
||||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||||
data: {'username': 'userName_login'},
|
data: {'xx': 'xx'},
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
common_alert_(data.msg)
|
common_alert_(data.msg)
|
||||||
|
setTimeout(function () {
|
||||||
|
location.reload();
|
||||||
|
}, 1000)
|
||||||
|
},
|
||||||
|
async: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**获得导图*/
|
||||||
|
function fetch_mind(page, page_size) {
|
||||||
|
if (!page) {
|
||||||
|
page = 1
|
||||||
|
}
|
||||||
|
if (!page_size) {
|
||||||
|
page_size = 10
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
type: `get`,
|
||||||
|
url: `list?page=${page}&page_size=${page_size}`,
|
||||||
|
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||||
|
dataType: "json",
|
||||||
|
success: function (resp) {
|
||||||
|
if (resp.code !== 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// clear
|
||||||
|
$('main .container-fluid').empty()
|
||||||
|
|
||||||
|
// 解析结果
|
||||||
|
const results = resp.results
|
||||||
|
let idx = 0
|
||||||
|
let row = $(`<div class="row"></row>`)
|
||||||
|
results.forEach(function (item) {
|
||||||
|
const content = `
|
||||||
|
<div class="card col-3" style="width: 18rem;margin: 8px;">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">${item.coop_mind_name}</h5>
|
||||||
|
<img src="https://img0.baidu.com/it/u=218959243,558802769&fm=253&fmt=auto&app=138&f=JPEG?w=1377&h=500" class="card-img-top" alt="...">
|
||||||
|
<a href="#" class="btn btn-info" onclick="window.open('detail?id=${item.id}')">编辑</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
row.append(content)
|
||||||
|
idx++
|
||||||
|
if (idx % 3 === 0) {
|
||||||
|
// 3个一行
|
||||||
|
$('main .container-fluid').append(row)
|
||||||
|
// 重置row
|
||||||
|
row = $(`<div class="row"></row>`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// 如果不是3的整数倍,将剩余的添加
|
||||||
|
if (idx % 3 !== 0) {
|
||||||
|
$('main .container-fluid').append(row)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async: false
|
async: false
|
||||||
});
|
});
|
||||||
@@ -267,7 +290,7 @@
|
|||||||
<!--script end-->
|
<!--script end-->
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<span id="uid" style="display: none;">{{ user.id }}</span>
|
||||||
<!-- 页眉 start-->
|
<!-- 页眉 start-->
|
||||||
<nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
|
<nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
|
||||||
<a class="navbar-brand col-md-2 col-lg-2 mr-0 px-3" href="#">协作思维导图</a>
|
<a class="navbar-brand col-md-2 col-lg-2 mr-0 px-3" href="#">协作思维导图</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user