You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
1.8 KiB
82 lines
1.8 KiB
{% extends 'base/base.html' %}
|
|
{% load static %}
|
|
{% load thumbnail %}
|
|
|
|
{% block content %}
|
|
|
|
<h3 class="ui header">我的喜欢</h3>
|
|
<div class="ui unstackable items">
|
|
|
|
{% for item in video_list %}
|
|
<div class="item">
|
|
<div class="ui tiny image">
|
|
{% thumbnail item.cover "300x200" crop="center" as im %}
|
|
<img class="ui image" src="{{ im.url }}">
|
|
{% empty %}
|
|
{% endthumbnail %}
|
|
</div>
|
|
<div class="middle aligned content">
|
|
<a class="header" href="{% url 'video:detail' item.pk %}">{{ item.title }}</a>
|
|
<a class="del" onclick="unlike({{item.id}})">取消喜欢</a>
|
|
</div>
|
|
</div>
|
|
{% empty %}
|
|
<h3>暂无数据</h3>
|
|
{% endfor %}
|
|
|
|
</div>
|
|
|
|
|
|
{% include "base/page_nav.html" %}
|
|
|
|
{% endblock content %}
|
|
|
|
|
|
{% block javascript %}
|
|
|
|
<script>
|
|
|
|
// 写入csrf
|
|
$.getScript("/static/js/csrftoken.js");
|
|
|
|
function unlike(id) {
|
|
var x;
|
|
var r=confirm("确定删除?");
|
|
if (r==true){
|
|
console.log('click ok');
|
|
}
|
|
else{
|
|
return;
|
|
}
|
|
|
|
$.ajax({
|
|
url: '/video/like/',
|
|
data: {
|
|
video_id: id,
|
|
'csrf_token': csrftoken
|
|
},
|
|
type: 'POST',
|
|
dataType: 'json',
|
|
success: function (data) {
|
|
var code = data.code
|
|
if(code == 0){
|
|
alert('删除成功')
|
|
window.location.reload()
|
|
}else{
|
|
var msg = data.msg
|
|
alert(msg)
|
|
}
|
|
|
|
},
|
|
error: function(data){
|
|
alert("收藏失败")
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
|
|
<script src="{% static 'js/detail.js' %}"></script>
|
|
{% endblock javascript %}
|
|
|
|
|