let form, laydate, flow,layer,rightPopup; let pageNum = 1, pageSize = 15; // 定义分页 let queryType = 2; // 默认最近上传 layui.config({ base: "../../js/layui-v2.9.14/layui/", //此处路径请自行处理, 可以使用绝对路径 }).extend({ rightPopup: "rightPopup", }).use(["form", 'laydate', 'flow','layer','rightPopup'], function () { form = layui.form; laydate = layui.laydate; flow = layui.flow; layer = layui.layer; rightPopup = layui.rightPopup; dataFlow(); }); /**数据流加载*/ function dataFlow() { flow.load({ elem: '#ID-flow-demo', // 流加载容器 scrollElem: '#ID-flow-demo', // 滚动条所在元素,一般不用填,此处只是演示需要。 end: '数据加载完毕', direction: 'bottom', done: function (page, next) { // 执行下一页的回调 console.error(page); pageNum = page; let lis = []; let returnData = loadData(); if (returnData != null) { lis = initImgData(returnData.data.list) next(lis.join(''), page < returnData.data.total / 15); $('.img-info').on('mouseenter', function () { this.querySelector('.hidden-actions').style.display = 'block'; }); $('.img-info').on('mouseleave', function () { this.querySelector('.hidden-actions').style.display = 'none'; }); } } }); } /*切换查询类型*/ function changeType(type, that) { queryType = type; pageNum = 1; $(that).removeClass("noCheckedElement"); if ($(that).hasClass("checkedElement") && type === 1) { $(that).next().removeClass("checkedElement").addClass("noCheckedElement"); } else if (!$(that).hasClass("checkedElement") && type === 1) { $(that).addClass("checkedElement"); $(that).next().removeClass("checkedElement").addClass("noCheckedElement"); } else if ($(that).hasClass("checkedElement") && type === 2) { $(that).prev().removeClass("checkedElement").addClass("noCheckedElement"); } else if (!$(that).hasClass("checkedElement") && type === 2) { $(that).addClass("checkedElement"); $(that).prev().removeClass("checkedElement").addClass("noCheckedElement"); } $('#ID-flow-demo').empty(); dataFlow(); } /**加载图片数据*/ function loadData() { let returnData = null; let url = dataUrl + "/backstage/synthesisQuery/getImgList" let obj = { pageNum: pageNum, pageSize: pageSize, queryType: queryType } let params = { encryptedData: encryptCBC(JSON.stringify(obj)) } ajaxRequest(url, "POST", params, false, function () { }, function (result) { if (result.status === 200) { console.log(result) returnData = result; } else { layer.msg(result.msg, {icon: 2}) } }, function (xhr) { error(xhr) }); return returnData; } /**渲染图片*/ function initImgData(list) { let htmlArr = []; if (list && list.length > 0) { $.each(list, function (index, item) { htmlArr.push("
" + item.uploadTime + "
" + "" + item.uploadTypeName + "
" + "" + item.sourceTypeName + "
" + setCollectData(item) + "
";
}
return "";
}
}
/**放大*/
function viewImg(item) {
layer.photos({
shade: 0.5,
footer: false,
photos: {
"title": "图片预览",
"start": 0,
"data": [
{
"pid": 1,
"src": "../../img/synthesisQuery/7.jpg",
}
]
},
});
}
/**放大*/
function imgDownLoad(item) {
alert(item.id)
}
/**水印下载*/
function waterImgDownLoad(item) {
alert(item.id)
}
/**收藏*/
function collectImg(that, item, type) {
if (type === 0) { // 收藏
$(that).next().removeAttr("style");
$(that).css({'display': 'none'})
$(that).parent().parent().prev().find('img').eq(0).removeAttr('style')
} else if (type === 1) { // 取消收藏
$(that).prev().removeAttr("style");
$(that).css({'display': 'none'});
$(that).parent().parent().prev().find('img').eq(0).css({'display': 'none'})
}
}
/**高级筛选*/
function highSearch(){
rightPopup.rightPopupLayer("../../pages/synthesisQuery/highSearchForm.html", JSON.stringify({}),["45%", "100%"]);
}
/*图片类型查询*/
function queryByType(that,type){
$('.type-num').each(function(){
$(this).removeClass('type-num-check');
})
$(that).addClass('type-num-check');
}