82 lines
1.8 KiB
JavaScript
82 lines
1.8 KiB
JavaScript
|
|
|
|
|
|
SetDirviceData()
|
|
|
|
var $as = $('#J_ActionSheet'), index = 0;
|
|
|
|
|
|
var ListData = JSON.parse(localStorage.getItem(list))
|
|
|
|
function isRender() {
|
|
if(ListData.length == 0 ) {
|
|
$('.list-theme4').empty()
|
|
$('.list-theme4').append(`<p style="text-align: center;margin: 100px 0;font-size: 16px;color: #8d8d8d;"> 没有数据 </p>`)
|
|
} else {
|
|
Render(ListData)
|
|
}
|
|
}
|
|
function Render(data) {
|
|
$(".list-theme4").empty()
|
|
data.forEach((val,index) => {
|
|
$(".list-theme4").append(`<a class="list-item">
|
|
<div class="list-img" data-id="${index}">
|
|
<img src="${val.albums[0]}">
|
|
</div>
|
|
<div class="list-mes">
|
|
<h3 class="list-title">${val.title}</h3>
|
|
<div class="list-mes-item">
|
|
<div>
|
|
<span class="list-del-price">
|
|
${val.imtro.substring(0,20)}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</a>`)
|
|
});
|
|
}
|
|
|
|
|
|
isRender()
|
|
touchStart()
|
|
|
|
|
|
function touchStart() {
|
|
$(".list-theme4 .list-item").on({
|
|
touchstart: function(e){
|
|
index = $(this).index()
|
|
timeOutEvent = setTimeout(function(){
|
|
$as.actionSheet('open');
|
|
},300);
|
|
}
|
|
});
|
|
}
|
|
|
|
$('#J_Cancel').on('click', function () {
|
|
$as.actionSheet('close');
|
|
});
|
|
|
|
$('.delete').on('click', function () {
|
|
|
|
ListData.splice(index,1)
|
|
// Render(ListData)
|
|
isRender()
|
|
|
|
touchStart()
|
|
|
|
|
|
|
|
$as.actionSheet('close');
|
|
localStorage.setItem(list,JSON.stringify(ListData))
|
|
});
|
|
|
|
$(".list-theme4 .list-item").on('click',function() {
|
|
var current = ListData[$(this).index()];
|
|
localStorage.setItem("info",JSON.stringify(current))
|
|
location.href = "./info.html"
|
|
})
|
|
|
|
|
|
|