my-picture.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. $(function () {
  2. initOther();
  3. search(1, true, false);
  4. });
  5. var scale = 1; // 初始缩放比例
  6. var lastfirstFlag = '';
  7. /**
  8. * 初始化其他操作
  9. */
  10. function initOther() {
  11. $(".slideDown-btn").click(function () {
  12. var display = $('.slideDown-box');
  13. if (display.css('display') == 'block') {
  14. display.slideUp("slow");
  15. $(this).html('展开 <i class="fa fa-angle-down"></i>');
  16. } else {
  17. display.slideDown("slow");
  18. $(this).html('收起 <i class="fa fa-angle-up"></i>');
  19. }
  20. });
  21. $("#searchbutton").click(function () {
  22. search(1, false, false);
  23. });
  24. $("#shaixuan").click(function () {
  25. $("#wd").val("");
  26. search(1, false, false);
  27. });
  28. $("#wd").keydown(function (e) {
  29. if (e.keyCode == 13) {
  30. search(1, false, false);
  31. }
  32. });
  33. $(".dropdown-box").find("li").click(function () {
  34. $("#bigType").text($(this).text());
  35. $("#bigType").attr("prepath", $(this).attr("prepath"));
  36. $(".dropdown-box").attr("style", "display: none;");
  37. if ($(this).text() == '足舐') {
  38. $(".lovefoot").attr("style", "display: block;");
  39. } else {
  40. $(".lovefoot").attr("style", "display: none;");
  41. }
  42. getQueryHeaderInfo($("#bigType").text(), false, true);
  43. search(1, false, true);
  44. });
  45. $(".dropdown-hover").mouseover(function () {
  46. $(".dropdown-box").attr("style", "display: block;");
  47. });
  48. $(".dropdown-hover").mouseout(function () {
  49. $(".dropdown-box").attr("style", "display: none;");
  50. });
  51. $(".clearAll").click(function () {
  52. $("#playvideo").find("video").attr("src", "");
  53. $("#bigpreview").find("img").attr("src", "");
  54. $("#playvideo").css("display", "none");
  55. $("#bigpreview").css("display", "none");
  56. });
  57. var minScale = 0.5; // 最小缩放比例
  58. var maxScale = 3; // 最大缩放比例
  59. var step = 0.05; // 缩放步幅,改为较小值以平滑缩放
  60. $('#modal-image').on('mousewheel', function (event) {
  61. event.preventDefault(); // 防止页面滚动
  62. if (event.originalEvent.deltaY < 0) {
  63. // 鼠标滚轮向上滚动 -> 放大图片
  64. scale += step;
  65. } else {
  66. // 鼠标滚轮向下滚动 -> 缩小图片
  67. scale -= step;
  68. }
  69. // 限制缩放比例在 minScale 和 maxScale 之间
  70. scale = Math.min(Math.max(scale, minScale), maxScale);
  71. // 使用 CSS transform 属性缩放图片
  72. $('#modal-image').css('transform', 'scale(' + scale + ')');
  73. });
  74. }
  75. /**
  76. * 多条件搜索
  77. * @param pageNo
  78. */
  79. function search(pageNo, startFlag, searchSelectFlag) {
  80. var genres = "";
  81. var cast = "";
  82. var keyword = "";
  83. if (searchSelectFlag) {
  84. $("#wd").val("");
  85. }
  86. if (!startFlag) {
  87. genres = $(".leixingul").find(".btn-warm").text().replace("全部", "");
  88. cast = $(".yanyuanul").find(".btn-warm").text().replace("全部", "");
  89. keyword = $("#wd").val();
  90. }
  91. var orderField = $(".paixuul").find(".btn-warm").attr("orderField");
  92. var order = $(".paixuul").find(".btn-warm").attr("order");
  93. var bigType = $("#bigType").text();
  94. var prepath = $("#bigType").attr("prepath");
  95. if (searchSelectFlag) {
  96. genres = "";
  97. cast = "";
  98. if (bigType == '爬虫') {
  99. genres = "福利吧";
  100. orderField = "fcil.publish_time";
  101. } else if (bigType == '上传') {
  102. genres = "";
  103. orderField = "fi.create_time";
  104. } else {
  105. orderField = "vi.issue_date";
  106. }
  107. order = "desc";
  108. } else {
  109. if (bigType == '爬虫') {
  110. genres = "福利吧";
  111. orderField = "fcil.publish_time";
  112. }
  113. }
  114. $.ajax({
  115. url: "pictureInfo/getPictureInfoPage", //请求的url地址
  116. dataType: "json", //返回格式为json
  117. data: JSON.stringify({
  118. "pageNo": pageNo,
  119. "pageSize": 10,
  120. "genres": genres,
  121. "cast": cast,
  122. "orderField": orderField,
  123. "order": order,
  124. "keyword": keyword,
  125. "bigType": bigType
  126. }), //参数值
  127. type: "post", //请求方式
  128. contentType: "application/json;charset=utf-8",
  129. async: true, //请求是否异步,默认为异步,这也是ajax重要特性
  130. success: function (data) {
  131. //请求成功时处理
  132. if (data != null && $.trim(data) != "" && data.success) {
  133. if (startFlag) {
  134. getQueryHeaderInfo($("#bigType").text(), startFlag, false);
  135. }
  136. data = data.data;
  137. var picInfoList = data.list;
  138. var str = "";
  139. for (var i = 0; i < picInfoList.length; i++) {
  140. var picInfo = picInfoList[i];
  141. var date = picInfo.createTime;
  142. if (orderField === 'fci.modify_time') {
  143. date = picInfo.modifyTime;
  144. }
  145. if (bigType === '爬虫') {
  146. date = picInfo.publishTime;
  147. }
  148. var scoreStr = '';
  149. var orginUrl= '';
  150. var picTagTop2 = '';
  151. var title = '';
  152. if (bigType === '上传') {
  153. scoreStr += picInfo.size + '|';
  154. scoreStr += picInfo.modifyTime;
  155. picTagTop2 = picInfo.categoryName;
  156. title = picInfo.remark;
  157. } else if (bigType === '爬虫') {
  158. scoreStr += picInfo.categoryName + '|';
  159. scoreStr += picInfo.size + '|';
  160. scoreStr += picInfo.modifyTime;
  161. picTagTop2 = picInfo.sort;
  162. title = picInfo.mainTitle;
  163. } else {
  164. scoreStr = picInfo.size;
  165. }
  166. str += "<li class=\"col-lg-8 col-md-6 col-sm-4 col-xs-3\">" +
  167. " <div class=\"myui-vodlist__box\">" +
  168. " <a class=\"myui-vodlist__thumb lazyload\" title=\"\" style=\"background-image: url(&quot;" + picInfo.thumbnailPath + "&quot;),url(&quot;" + picInfo.path + "&quot;);\">" +
  169. " <span class=\"bigpreview playvideo play hidden-xs\" imgUrl='" + picInfo.path + "'></span>" +
  170. " <span class=\"pic-tag pic-tag-top\">" +
  171. " <span class=\"tag identificationDate\" title=\"" + orginUrl + "\" style=\"background-color: #00C0FF;\">" + date + "</span>" +
  172. " <span class=\"tag identificationDate\" title=\"" + orginUrl + "\" style=\"background-color: #00C0FF;\">" + picTagTop2 + "</span>" +
  173. " </span>" +
  174. " <span class=\"pic-text text-right\" title=\"\" \">" + scoreStr + "</span>" +
  175. " </a>" +
  176. " <div class=\"myui-vodlist__detail\">" +
  177. " <h4 class=\"videodetail title text-overflow\" orginUrl='" + picInfo.path + "'><a title=\" " + picInfo.remark + " \">" + picInfo.remark + "</a></h4>" +
  178. " </div>" +
  179. " </div>" +
  180. "</li>";
  181. }
  182. $(".myui-vodlist").html(str);
  183. if (str == "") {
  184. $(".vodlistnone").attr("style", "padding: 50px;display: block;");
  185. $(".myui-page").html("");
  186. } else {
  187. $(".vodlistnone").attr("style", "padding: 50px;display: none;");
  188. $(".myui-page").pagination({
  189. pageSize: "10",
  190. pageNo: pageNo,
  191. total: data.total,
  192. callback: function (pageNo) {
  193. //$("#wd").val("");
  194. search(pageNo, false, false);
  195. }
  196. });
  197. }
  198. initContentEvent();
  199. } else {
  200. alert(data.message);
  201. }
  202. },
  203. beforeSend: function () {
  204. //请求前的处理
  205. if (startFlag) {
  206. $("#cover").css("display", "block");
  207. } else {
  208. $(".loading").css("display", "block");
  209. }
  210. },
  211. complete: function () {
  212. //请求完成的处理
  213. if (startFlag) {
  214. $("#cover").css("display", "none");
  215. } else {
  216. $(".loading").css("display", "none");
  217. }
  218. },
  219. error: function (data) {
  220. //请求出错处理
  221. alert('error:' + data);
  222. }
  223. });
  224. }
  225. /**
  226. * 查询头信息
  227. * @param bigType
  228. * @param startFlag
  229. */
  230. function getQueryHeaderInfo(bigType, startFlag, searchSelectFlag) {
  231. var infantryType = "";
  232. if (bigType == '步兵' && !searchSelectFlag) {
  233. infantryType = $(".leixingul").find(".btn-warm").text().replace("全部", "");
  234. }
  235. $.ajax({
  236. url: "queryHeader/getQueryPictureHeaderInfo", //请求的url地址
  237. dataType: "json", //返回格式为json
  238. data: {"bigType": bigType, "infantryType": infantryType}, //参数值
  239. type: "post", //请求方式
  240. async: !startFlag, //请求是否异步,默认为异步,这也是ajax重要特性
  241. success: function (data) {
  242. if (bigType == '步兵') {
  243. $(".leixingli").css("display", "none");
  244. } else {
  245. $(".leixingli").css("display", "block");
  246. }
  247. if (searchSelectFlag) {
  248. $("ul.leixingul").find("a:eq(1)").addClass("btn-warm");
  249. $("ul.yanyuanul").find("a:eq(1)").addClass("btn-warm");
  250. $("ul.paixuul").find("a.btn-warm").removeClass("btn-warm");
  251. if (bigType == '足舐') {
  252. $("ul.paixuul").find("a:eq(3)").addClass("btn-warm");
  253. } else if (bigType == '码池') {
  254. $("ul.paixuul").find("a:eq(2)").addClass("btn-warm");
  255. } else {
  256. $("ul.paixuul").find("a:eq(1)").addClass("btn-warm");
  257. }
  258. }
  259. //请求成功时处理
  260. if (data != null && $.trim(data.data) != "" && data.success) {
  261. data = data.data;
  262. if ($.isEmptyObject(data)) {
  263. if ($(".displayli").length > 0) {
  264. $(".displayli").remove();
  265. }
  266. $(".vodlistnone").attr("style", "padding: 50px;display: block;");
  267. $(".myui-vodlist").html("");
  268. $(".myui-page").html("");
  269. return;
  270. }
  271. if ($(".displayli").length > 0) {
  272. $(".displayli").remove();
  273. }
  274. if (data.videoCastList.length > 0) {
  275. var videoCastList = data.videoCastList;
  276. var str = "";
  277. for (var i = 0; i < videoCastList.length; i++) {
  278. var videoCast = videoCastList[i];
  279. str += "<li class='displayli'><a class=\"btn searchbtn\" title='" + videoCast.count + "'>" + videoCast.name + "</a></li>";
  280. }
  281. $(".yanyuanul").append(str);
  282. }
  283. if (data.videoGenresList.length > 0) {
  284. var videoGenresList = data.videoGenresList;
  285. var str = "";
  286. for (var i = 0; i < videoGenresList.length; i++) {
  287. var videoGenres = videoGenresList[i];
  288. if (bigType == '步兵' && i == 0) {
  289. str += "<li class='displayli'><a class=\"btn btn-warm searchbtn\" title='" + videoGenres.count + "'>" + videoGenres.name + "</a></li>";
  290. } else {
  291. str += "<li class='displayli'><a class=\"btn searchbtn\" title='" + videoGenres.count + "'>" + videoGenres.name + "</a></li>";
  292. }
  293. }
  294. $(".leixingul").append(str);
  295. }
  296. if (searchSelectFlag && bigType != '步兵') {
  297. $("ul.leixingul").find("a.btn-warm").removeClass("btn-warm");
  298. if (bigType == '足舐') {
  299. $("ul.leixingul").find("a:eq(3)").addClass("btn-warm");
  300. } else if (bigType == '码池') {
  301. $("ul.leixingul").find("a:eq(1)").addClass("btn-warm");
  302. } else {
  303. $("ul.leixingul").find("a:eq(1)").addClass("btn-warm");
  304. }
  305. }
  306. $(".searchbtn").unbind("click");
  307. $(".searchbtn").click(function () {
  308. $(this).closest('ul').find(".searchbtn").removeClass("btn-warm");
  309. $(this).addClass("btn-warm");
  310. if ($(this).attr('order') != undefined) {
  311. var order = $(this).attr('order');
  312. if ("desc" == order) {
  313. $(this).attr("order", "asc");
  314. } else if ("asc" == order) {
  315. $(this).attr("order", "desc");
  316. }
  317. }
  318. $("#wd").val("");
  319. search(1, false, false);
  320. });
  321. } else {
  322. alert(data.message);
  323. }
  324. },
  325. beforeSend: function () {
  326. //请求前的处理
  327. if (!startFlag) {
  328. $(".loading-shaixuan").css("display", "block");
  329. }
  330. },
  331. complete: function () {
  332. //请求完成的处理
  333. if (!startFlag) {
  334. $(".loading-shaixuan").css("display", "none");
  335. }
  336. },
  337. error: function (data) {
  338. //请求出错处理
  339. alert('error:' + data);
  340. }
  341. });
  342. }
  343. /**
  344. * 初始化主内容事件
  345. */
  346. function initContentEvent() {
  347. $(".videodetail").click(function () {
  348. var orginUrl = $(this).attr("orginUrl");
  349. window.open(orginUrl, "_blank");
  350. });
  351. var currentIndex = -1; // 当前图片索引
  352. var bigpreviewlist = $("ul.myui-vodlist .bigpreview");
  353. if ($(".modal").is(':visible')) {
  354. if (lastfirstFlag === 'last') {
  355. currentIndex = 0;
  356. } else if (lastfirstFlag === 'first') {
  357. currentIndex = 9;
  358. }
  359. $("#modal").find("img").attr("src", bigpreviewlist.eq(currentIndex).attr('imgurl'));
  360. }
  361. lastfirstFlag = '';
  362. $(".bigpreview,.close").click(function () {
  363. if ($("#modal").css("display") === 'none') {
  364. $("#modal").css("display", "block");
  365. $("#modal").find("img").attr("src", $(this).attr("imgUrl"));
  366. currentIndex = bigpreviewlist.index(this);
  367. } else if ($("#modal").css("display") === 'block') {
  368. $("#modal").css("display", "none");
  369. $("#modal").find("img").attr("src", "");
  370. }
  371. scale = 1;
  372. $('#modal-image').css('transform', 'scale(' + scale + ')');
  373. });
  374. $("#modal").dblclick(function () {
  375. $(this).hide();
  376. });
  377. $(window).on('click', function(event) {
  378. var $modal = $('#modal');
  379. if ($(event.target).is($modal)) {
  380. $modal.hide();
  381. }
  382. });
  383. $(document).on('keydown', function (event) {
  384. if (event.key === "Escape" || event.keyCode === 27) {
  385. if ($("#modal").css("display") === 'block') {
  386. $("#modal").css("display", "none");
  387. $("#modal").find("img").attr("src", "");
  388. scale = 1;
  389. $('#modal-image').css('transform', 'scale(' + scale + ')');
  390. }
  391. } else if ($(".modal").is(':visible')) {
  392. // 左右方向键切换图片
  393. if (event.key === 'ArrowRight') {
  394. if (currentIndex === bigpreviewlist.length - 1) {
  395. console.log("到头了end");
  396. var xsPage = $("ul.myui-page > li.visible-xs").find("a").text();
  397. var currentPageNo = xsPage.split("/")[0];
  398. var totalPageNo = xsPage.split("/")[1];
  399. if (currentPageNo === totalPageNo) {
  400. alert("真到头了end");
  401. } else {
  402. unbindPageEvent();
  403. lastfirstFlag = 'last';
  404. $(".myui-page").find("#last-page").click();
  405. $("#modal").find("img").attr("src", "cover/loading.gif");
  406. }
  407. } else {
  408. currentIndex = (currentIndex + 1) % bigpreviewlist.length; // 循环切换到下一张图片
  409. $("#modal").find("img").attr("src", bigpreviewlist.eq(currentIndex).attr('imgurl'));
  410. }
  411. } else if (event.key === 'ArrowLeft') {
  412. if (currentIndex === 0) {
  413. console.log("到头了start");
  414. var xsPage = $("ul.myui-page > li.visible-xs").find("a").text();
  415. var currentPageNo = xsPage.split("/")[0];
  416. var totalPageNo = xsPage.split("/")[1];
  417. if (currentPageNo === '1') {
  418. alert("真到头了start");
  419. } else {
  420. unbindPageEvent();
  421. lastfirstFlag = 'first';
  422. $(".myui-page").find("#first-page").click();
  423. $("#modal").find("img").attr("src", "cover/loading.gif");
  424. }
  425. } else {
  426. currentIndex = (currentIndex - 1 + bigpreviewlist.length) % bigpreviewlist.length; // 循环切换到上一张图片
  427. $("#modal").find("img").attr("src", bigpreviewlist.eq(currentIndex).attr('imgurl'));
  428. }
  429. }
  430. }
  431. });
  432. }
  433. function unbindPageEvent() {
  434. $(document).off('keydown');
  435. // $(window).off('click');
  436. $(".close").off('click');
  437. }