修改后 // 文件列表 function queryFilerList() { n=pageNum var docType=$("#docType").val(); var docName=$("#docName").val(); $.ajax({ type:"post", url: '/downLoadZoneController/findAll', //地址,就是json文件的请求路径 data:{fileType:docType,fileName:docName,pageIndex:pageNum,pageSize:pageSize}, dataType: 'json', //数据类型可以为 text xml json script jsonp success: function (result) { if (result.isSuccess === 1) { var fileStr = ''; var icon = null; $.each(result.data.DownLoadFileList, function (i, val) { var ftype = getFileViewType(val.fileId); switch (ftype) { case 'doc': icon = 1; break; case 'docx': icon = 1; break; case 'xls': icon = 2; break; case 'xlsx': icon = 2; break; case 'ppt': icon = 3; break; case 'mp4': icon = 4; break; case 'zip': icon = 6; break; case 'rar': icon = 6; break; case 'pdf': icon = 5; break; default: break; } fileStr += '<div class="item"><a target="_blank" href="' + val.fileUrl + '" download="' + val.fileName + '">' + '<div class="icons filetype file' + icon + '"></div>' + '<div class="word">' + '<div class="txt1">' + val.fileName + '</div>' + ' <div class="txt2">' + val.timeStr + '</div>' + '</div>' + '<div class="icons downicon down2"></div>' + '</></div>'; }); $('#filelist').html(fileStr); if(n==0){ laypage.render({ elem: 'page1', count: result.data.pageUtil.rowCount, //数据总数,从服务端得到 limit:15, layout: ['count', 'prev', 'page', 'next', 'skip'], theme: '#1d6cf7', jump: function (obj, first) { //obj包含了当前分页的所有参数,比如: console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。 console.log(obj.limit); //得到每页显示的条数 //首次不执行 if (!first) { //do something pageNum=obj.curr; queryFilerList(); } }, }); } } }, }); }
修改前:
switch (ftype) { case 'doc': icon = 1; break; case 'docx': icon = 1; break; case 'xls': icon = 2; break; case 'xlsx': icon = 2; break; case 'ppt': icon = 3; break; case 'mp4': icon = 4; break; case 'zip' || 'rar': icon = 6; break; case 'pdf': icon = 5; break; default: break; }
语法中不允许用 ||