liteblog/views/details.html

82 lines
2.4 KiB
HTML
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>评论-闲言轻博客</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
{{ template "shares/link.html" .}}
</head>
<body class="lay-blog">
{{ template "shares/header.html" .}}
<div class="container-wrap">
<div class="container container-message container-details">
<div class="contar-wrap">
<div class="item">
{{ template "shares/note_tpl.html" .note}}
</div>
<a name="comment"> </a>
<div class="comt layui-clear">
<a href="javascript:;" class="pull-left">评论</a>
<a href="/comment/{{ .note.Key }}" class="pull-right">写评论</a>
</div>
<div id="LAY-msg-box">
{{ range .comments }}
<div class="info-item">
<img class="info-img" src="/static/images/info-img.png" alt="">
<div class="info-text">
<p class="title count">
<span class="name">{{ .User.Name }}</span>
<span class="info-img like"><i class="layui-icon layui-icon-praise"></i>5.8万</span>
</p>
<p class="info-intr">{{ .Content }}</p>
</div>
</div>
{{ end }}
</div>
</div>
</div>
</div>
{{ template "shares/footer.html" .}}
<script>
var user = {{ .User }};
var note = {userId:{{ .note.UserId }}, key:{{ .note.Key }}};
layui.use(['util','jquery'], function(){
var util = layui.util,$= layui.jquery;
//用户必须登陆,
//登陆的用户的role必须为0可以修改文章
//登陆的用户的id必须等于当前文章详情页的文章所属用户的id
if(user&& user.id >0&&user.role===0&&user.id ===note.userId){
util.fixbar({
bar1: '&#xe642;',//编辑的图标
bar2:'&#xe640;' //删除的图标
,click: function(type){
console.log(type);
if(type === 'bar1'){
//跳转到修改文章的页面
window.location.href="/note/edit/"+note.key
}
if(type === 'bar2'){
//删除的逻辑,等待实现。
$.post("/note/del/"+note.key,function (data) {
if (data.code === 0) {
layer.msg("删除成功");
if (data.action) {
setTimeout(function () {
window.location.href = data.action;
}, 300);
}
} else {
layer.msg("删除失败:" + data.msg);
}
}, "json").error(function () {
layer.msg("网络异常")
});
}
}
});
}
});
</script>
</body>
</html>