img_viewer.html 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. {extend name="layout/content"}
  2. {block name="content"}
  3. <style>
  4. .wrapper-content{padding:0;margin:0;}
  5. .viewer-close{display:none;}
  6. </style>
  7. <div id="showBigPic">
  8. <img id="_pic0001" src="{$img}" style="width:0;height:0;"/>
  9. </div>
  10. <script type="text/javascript">
  11. var __initialize = function () {
  12. var sbp = $("#showBigPic");
  13. $("#_pic0001").viewer({
  14. toolbar: true,
  15. fullscreen: false
  16. });
  17. $("#_pic0001").click();
  18. $(".viewer-prev").click(function () {
  19. var src = $("#_pic0001").attr("src");
  20. var imgs = parent.$(".imgUrl");
  21. var showPicIndex = 0;
  22. var showTitleName = "";
  23. imgs.each(function (index) {
  24. if ($(this).attr("src") == src) {
  25. showPicIndex = index;
  26. showPicIndex = showPicIndex == 0 ? imgs.length - 1 : showPicIndex - 1;
  27. showTitleName = imgs.eq(showPicIndex).parent("div").prev("div").text();
  28. var newUrl = imgs.eq(showPicIndex).attr("src");
  29. parent.$(".layui-layer-title").text(showTitleName);
  30. window.location.href = "/common/api/imgViewer?picShow=" + encodeURIComponent(newUrl);
  31. }
  32. })
  33. })
  34. $(".viewer-next").click(function () {
  35. var src = $("#_pic0001").attr("src");
  36. var imgs = parent.$(".imgUrl");
  37. var showPicIndex = 0;
  38. var showTitleName = "";
  39. imgs.each(function (index) {
  40. if ($(this).attr("src") == src) {
  41. showPicIndex = index;
  42. showPicIndex = showPicIndex == imgs.length - 1 ? 0 : showPicIndex + 1;
  43. showTitleName = imgs.eq(showPicIndex).parent("div").prev("div").text();
  44. var newUrl = imgs.eq(showPicIndex).attr("src");
  45. parent.$(".layui-layer-title").text(showTitleName);
  46. window.location.href = "/common/api/imgViewer?picShow=" + encodeURIComponent(newUrl);
  47. }
  48. })
  49. })
  50. }();
  51. </script>
  52. {/block}