63 lines
1.7 KiB
JavaScript
63 lines
1.7 KiB
JavaScript
(function(){
|
|
|
|
var LikeData = localStorage.getItem("like") == null
|
|
? []
|
|
: JSON.parse(localStorage.getItem("like"));
|
|
|
|
function renderLike () {
|
|
if(LikeData.length == 0) {
|
|
$(".list-theme1").append("<p class='error'>没有收藏</p>")
|
|
} else {
|
|
LikeData.forEach(val => {
|
|
$(".list-theme1").append(`<a href="#" class="list-item">
|
|
<div class="list-img">
|
|
<img src="${val.albums[0]}">
|
|
</div>
|
|
<div class="list-mes">
|
|
<h3 class="list-title">${val.title}</h3>
|
|
</div>
|
|
</a>`)
|
|
});
|
|
}
|
|
}
|
|
|
|
function BindTagaClick() {
|
|
$("article a").on('click', function() {
|
|
localStorage.setItem("info", JSON.stringify(LikeData[$(this).index()]))
|
|
location.href="info.html"
|
|
});
|
|
|
|
var $as = $('#J_ActionSheet'), index = null;
|
|
|
|
$(".list-theme1 .list-item").on({
|
|
touchstart: function(e){
|
|
index = $(this).index()
|
|
setTimeout(function(){
|
|
$as.actionSheet('open');
|
|
},500);
|
|
}
|
|
});
|
|
|
|
$('.delete-like').on("click",function() {
|
|
LikeData.splice(index,1);
|
|
localStorage.setItem("like", JSON.stringify(LikeData));
|
|
|
|
$("article a").eq(index).remove();
|
|
$as.actionSheet('close');
|
|
|
|
if(LikeData.length == 0) {
|
|
$(".list-theme1").append("<p class='error'>没有收藏</p>")
|
|
}
|
|
|
|
})
|
|
|
|
$("#J_Cancel").on("click",function() {
|
|
$as.actionSheet('close');
|
|
})
|
|
}
|
|
|
|
|
|
renderLike()
|
|
BindTagaClick()
|
|
|
|
})() |