sugangqiang 1 жил өмнө
parent
commit
4b800f96cc

+ 32 - 0
app/common/view/api/img_viewer.html

@@ -15,6 +15,38 @@
             fullscreen: false
         });
         $("#_pic0001").click();
+        $(".viewer-prev").click(function () {
+            var src = $("#_pic0001").attr("src");
+            var imgs = parent.$(".imgUrl");
+            var showPicIndex = 0;
+            var showTitleName = "";
+            imgs.each(function (index) {
+                if ($(this).attr("src") == src) {
+                    showPicIndex = index;
+                    showPicIndex = showPicIndex == 0 ? imgs.length - 1 : showPicIndex - 1;
+                    showTitleName = imgs.eq(showPicIndex).parent("div").prev("div").text();
+                    var newUrl = imgs.eq(showPicIndex).attr("src");
+                    parent.$(".layui-layer-title").text(showTitleName);
+                    window.location.href = "/common/api/imgViewer?picShow=" + encodeURIComponent(newUrl);
+                }
+            })
+        })
+        $(".viewer-next").click(function () {
+            var src = $("#_pic0001").attr("src");
+            var imgs = parent.$(".imgUrl");
+            var showPicIndex = 0;
+            var showTitleName = "";
+            imgs.each(function (index) {
+                if ($(this).attr("src") == src) {
+                    showPicIndex = index;
+                    showPicIndex = showPicIndex == imgs.length - 1 ? 0 : showPicIndex + 1;
+                    showTitleName = imgs.eq(showPicIndex).parent("div").prev("div").text();
+                    var newUrl = imgs.eq(showPicIndex).attr("src");
+                    parent.$(".layui-layer-title").text(showTitleName);
+                    window.location.href = "/common/api/imgViewer?picShow=" + encodeURIComponent(newUrl);
+                }
+            })
+        })
     }();
 </script>
 {/block}