浏览代码

新门户接口对接

xiaoyue5430 2 年之前
父节点
当前提交
74801af903

+ 1 - 0
spring-cloud/server-page/src/main/resources/static/jsc/css/index.css

@@ -50,6 +50,7 @@ main {
     letter-spacing: 20px;
     background: -webkit-linear-gradient(top, #E3E6E9, #BBC4CD, #ABB6C1);
     -webkit-background-clip: text;
+    -moz-background-clip: text;
 }
 
 

+ 5 - 240
spring-cloud/server-page/src/main/resources/static/jsc/index.html

@@ -63,9 +63,9 @@
             <div class="left-center">
                 <!-- <p class="x-line1"></p> -->
                 <!-- <p class="x-line2"></p> -->
-                <div class="theme">
+                <div class="theme" data-id="5">
                     <div>
-                        <span>市环卫主题</span>
+                        <span>大数据平台</span>
                         <i class="iconfont icon-juminxiaoqu"></i>
                     </div>
                 </div>
@@ -100,8 +100,8 @@
                 </div>
             </div>
             <div class="left-bottom">
-                <div class="sw">
-                    <span class="text">城市水务主题</span>
+                <div class="sw" data-id="10">
+                    <span class="text">资源保障</span>
                     <i class="iconfont icon-shuibiao_shiti text"></i>
                 </div>
                 <div class="left-center-ative">
@@ -167,242 +167,7 @@
         </div>
     </main>
     <script src="js/jquery.min.js"></script>
-    <script>
-        $(function() {
-            // 开场动画效果
-            $(".left-content").animate({
-                left: 0
-            }, 1000);
-            $(".right-content").animate({
-                right: 0
-            }, 1000);
-            $(".top-content").animate({
-                top: 0
-            }, 1000);
-            $(".bottom-content").animate({
-                bottom: 0
-            }, 1000);
-
-            let leftId = 1;
-            $(".left-center").on("mousewheel", function(e) {
-                let html = ""
-                if (e.originalEvent.wheelDelta > 0) {
-                    // 切片数据,翻转
-                    // [].slice()
-                    if (leftId >= 1) {
-                        $(".left-center>div:not(.theme)").remove();
-                        for (let i = 7 * leftId; i > 0 + (7 * (leftId - 1)); i--) {
-                            html += `
-                                <div>
-                                    <span class="text">环卫作业车辆${i}</span>
-                                    <i class="iconfont icon-lajiche text"></i>
-                                </div>
-                            `;
-                        }
-                        setTimeout(() => {
-                            if (leftId > 1) {
-                                leftId--
-                            }
-                        })
-                    }
-
-                } else {
-                    if (leftId < 3) {
-                        $(".left-center>div:not(.theme)").remove();
-                        for (let i = 0 + (7 * (leftId - 1)); i < 7 * leftId; i++) {
-                            html += `
-                            <div>
-                                <span class="text">环卫作业车辆${i}</span>
-                                <i class="iconfont icon-lajiche text"></i>
-                            </div>
-                        `;
-                        }
-                        setTimeout(() => {
-                            if (leftId >= 1) {
-                                leftId++
-                            }
-                        })
-                    }
-                }
-                if (leftId <= 3) {
-                    $(".left-center").append(html);
-                    leftCenterClick();
-                }
-            });
-
-            $(".right-center").on("mousewheel", function(e) {
-                $(".right-center").empty();
-                let html = ""
-                if (e.originalEvent.wheelDelta > 0) {
-                    html = `
-                        <div class="themes">
-                            <i class="iconfont icon-yingjiche text"></i>
-                            <span class="text">应急资源主题</span>
-                        </div>
-                        <div class="themes">
-                            <i class="iconfont icon-taizhang text"></i>
-                            <span class="text">风险台账主题</span>
-                        </div>
-                        <div class="themes">
-                            <i class="iconfont icon-tiaoduguanli_1 text"></i>
-                            <span class="text">应急指挥调度</span>
-                        </div>
-                        <div class="themes">
-                            <i class="iconfont icon-duiwu text"></i>
-                            <span class="text">应急队伍主题</span>
-                        </div>
-                        <div class="themes">
-                            <i class="iconfont icon-yuanguanli text"></i>
-                            <span class="text">应急预案主题</span>
-                        </div>
-                        <div class="themes">
-                            <i class="iconfont icon-zhibanzhishou text"></i>
-                            <span class="text">应急值守主题</span>
-                        </div>`
-                } else {
-                    for (let i = 0; i < 6; i++) {
-                        html += `
-                            <div class="themes">
-                            <i class="iconfont icon-zhibanzhishou text"></i>
-                            <span class="text">应急值守主题${i}</span>
-                        </div>`;
-                    }
-                }
-
-                $(".right-center").append(html)
-            });
-
-            $(".left-bottom").on("mousewheel", function(e) {
-                $(".left-bottom>div:not(.sw)").remove();
-                let html = ""
-                if (e.originalEvent.wheelDelta > 0) {
-                    html = `
-                        <div>
-                            <span class="text">区县自来水统计</span>
-                            <i class="iconfont icon-shuiwuju text"></i>
-                        </div>
-                        <div>
-                            <span class="text">水务设施统计</span>
-                            <i class="iconfont icon-yushuiguan text"></i>
-                        </div>
-                        <div>
-                            <span class="text">区域供水</span>
-                            <i class="iconfont icon-yangshi_icon_tongyong_maps text"></i>
-                        </div>`
-                } else {
-                    $(".left-bottom>div:not(.sw)").remove();
-                    for (let i = 0; i < 3; i++) {
-                        html += `
-                            <div>
-                                <span class="text">区域供水${i}</span>
-                                <i class="iconfont icon-yangshi_icon_tongyong_maps text"></i>
-                            </div>`;
-                    }
-                }
-
-                $(".left-bottom").append(html);
-                // dom渲染完重新调用点击
-                leftBottomClick();
-            });
-
-
-            // 封装点击事件,在dom结构变化事件会消失
-            function leftCenterClick() { //左边中间的点击
-                $(".theme").on("click", function() {
-                    console.log(1)
-                })
-                $(".left-center>div:not(.theme)").on("click", function() {
-                    // 判断当前点击是否有选中类
-                    if (!$(this).hasClass("left-center-ative")) {
-                        $(this).not(".theme").siblings().removeClass("left-center-ative");
-                        $(this).addClass("left-center-ative")
-                    }
-                })
-            }
-
-            function leftBottomClick() { //左边底部的点击
-                $(".sw").on("click", function() {
-                    console.log(3)
-                })
-                $(".left-bottom>div:not(.sw)").on("click", function() {
-                    // 判断当前点击是否有选中类
-                    if (!$(this).hasClass("left-center-ative")) {
-                        $(this).not(".sw").siblings().removeClass("left-center-ative");
-                        $(this).addClass("left-center-ative")
-                    }
-                })
-            }
-
-            function rightCenterClick() { //右边中间的点击
-                $(".themes").on("click", function() {
-                    console.log(5)
-                })
-            }
-
-            // 初始化调用,点击事件
-            leftCenterClick();
-            leftBottomClick();
-            rightCenterClick();
-
-            // 请求数据处理
-            // 除数据数组的长度,向上取值,作为标识id的最大值
-
-            // 封装dom渲染逻辑  id 标识变量  len 限制变量
-            function renderDom(event, id, len) {
-                let html = ""
-                if (event.originalEvent.wheelDelta > 0) {
-                    // 切片数据,翻转
-                    // [].slice()
-                    if (leftId >= 1) {
-                        $(".left-center>div:not(.theme)").remove(); //删除除第一个子元素外的使用元素
-                        for (let i = 7 * leftId; i > 0 + (7 * (leftId - 1)); i--) {
-                            html += `
-                                <div>
-                                    <span class="text">环卫作业车辆${i}</span>
-                                    <i class="iconfont icon-lajiche text"></i>
-                                </div>
-                            `;
-                        }
-                        setTimeout(() => {
-                            if (leftId > 1) {
-                                leftId--
-                            }
-                        })
-                    }
-
-                } else {
-                    if (leftId < 3) {
-
-                        $(".left-center").empty();
-                        html = `
-                            <div class="theme">
-                            <div>
-                                <span>市环卫主题</span>
-                                <i class="iconfont icon-juminxiaoqu"></i>
-                            </div>
-                        </div>
-                        `;
-                        for (let i = 0 + (7 * (leftId - 1)); i < 7 * leftId; i++) {
-                            html += `
-                            <div>
-                                <span class="text">环卫作业车辆${i}</span>
-                                <i class="iconfont icon-lajiche text"></i>
-                            </div>
-                        `;
-                        }
-                        setTimeout(() => {
-                            if (leftId >= 1) {
-                                leftId++
-                            }
-                        })
-                    }
-                }
-                if (leftId <= 3) {
-                    $(".left-center").append(html);
-                }
-            }
-        })
-    </script>
+    <script src="js/init.js"></script>
 </body>
 
 </html>

+ 325 - 0
spring-cloud/server-page/src/main/resources/static/jsc/js/init.js

@@ -0,0 +1,325 @@
+// const GATEWAY_URL = "http://23.37.100.87:8084";
+// const GATEWAY_URL = "http://23.37.100.80:8084";
+const GATEWAY_URL = "http://192.168.0.95:8084";
+const PAGE_BASIC = GATEWAY_URL + "/basic";
+
+$(function() {
+    // 长度控制对象
+    let lenObj = {
+        "left-center": 7,
+        "right-center": 6,
+        "left-bottom": 3
+    }
+
+    // 数据对象
+    let dataObj = reqGet(PAGE_BASIC + '/apiNoProcess/scence/getAllSceneAndThemeAndSystem');
+    let scene = dataObj.scenes; //场景
+    let theme = dataObj.sceneThemes; //主题
+
+    // 开场动画效果
+    (function() {
+        $(".left-content").animate({
+            left: 0
+        }, 1000);
+        $(".right-content").animate({
+            right: 0
+        }, 1000);
+        $(".top-content").animate({
+            top: 0
+        }, 1000);
+        $(".bottom-content").animate({
+            bottom: 0
+        }, 1000);
+    })()
+
+    // 左中
+    let idenId = $(".left-center>.theme").attr("data-id") * 1;
+    let leftTheme = theme.filter(function(item) {
+        return item.sceneId == idenId
+    });
+    let leftCenterHtml = '';
+    let leftId = 1; //中间变量控制
+    let leftIdenId = Math.ceil(leftTheme.length / 7); //控制变量的最大值限制
+    $(".left-center>div:not(.theme)").remove();
+    for (let i = 0; i < (leftTheme.length <= 7 ? leftTheme.length : 7); i++) {
+        leftCenterHtml += `
+                <div data-url="${leftTheme[i].url}">
+                    <span class="text">${leftTheme[i].themeName}</span>
+                    <i class="iconfont icon-lajiche text"></i>
+                </div>
+            `;
+    }
+    $(".left-center").append(leftCenterHtml);
+
+    $(".left-center").on("mousewheel", function(e) {
+        if (leftTheme.length > 7) {
+            let html = ""
+            if (e.originalEvent.wheelDelta > 0) {
+                if (leftId > 1) {
+                    $(".left-center>div:not(.theme)").remove();
+                    leftId--;
+                    // 切片数据
+                    const data = leftTheme.slice(7 * (leftId - 1), 7 * leftId).reverse();
+                    for (let i = data.length; i > 0; i--) {
+                        html += `
+                            <div data-url="${data[i - 1].url}">
+                                <span class="text">${data[i - 1].themeName}</span>
+                                <i class="iconfont icon-lajiche text"></i>
+                            </div>`;
+                    }
+                }
+
+            } else {
+                if (leftId < leftIdenId) {
+                    $(".left-center>div:not(.theme)").remove();
+                    // 切片数据
+                    const data = leftTheme.slice(7 * leftId, 7 * (leftId + 1));
+                    leftId++;
+                    for (let i = 0; i < data.length; i++) {
+                        html += `
+                            <div data-url="${data[i].url}">
+                                <span class="text">${data[i].themeName}</span>
+                                <i class="iconfont icon-lajiche text"></i>
+                            </div>
+                        `;
+                    }
+                }
+            }
+            if (leftId <= leftIdenId) {
+                $(".left-center").append(html);
+                leftCenterClick();
+            }
+        }
+    });
+
+    // 右中
+    let htmlRight = '';
+    let rightId = 1;
+    let rightIdenId = Math.ceil(scene.length / 6); //控制变量的最大值限制
+    $(".right-center").empty();
+    for (let i = 0; i < (scene.length <= 6 ? scene.length : 6); i++) {
+        htmlRight += `
+                <div class="themes" data-id="${scene[i].id}">
+                <i class="iconfont icon-zhibanzhishou text"></i>
+                <span class="text">${scene[i].sceneName}</span>
+            </div>`;
+    }
+    $(".right-center").append(htmlRight);
+    $(".right-center").on("mousewheel", function(e) {
+        if (scene.length > 6) {
+            let html = ""
+            if (e.originalEvent.wheelDelta > 0) {
+                if (rightId > 1) {
+                    $(".right-center").empty();
+                    rightId--;
+                    // 切片数据
+                    const data = scene.slice(6 * (rightId - 1), 6 * rightId).reverse();
+                    for (let i = data.length; i > 0; i--) {
+                        html += `
+                            <div class="themes" data-id="${data[i - 1].id}">
+                            <i class="iconfont icon-zhibanzhishou text"></i>
+                            <span class="text">${data[i - 1].sceneName}</span>
+                        </div>`;
+                    };
+                }
+            } else {
+                if (rightId < rightIdenId) {
+                    $(".right-center").empty();
+                    // 切片数据
+                    const data = scene.slice(6 * rightId, 6 * (rightId + 1));
+                    rightId++;
+                    for (let i = 0; i < data.length; i++) {
+                        html += `
+                            <div class="themes" data-id="${data[i].id}">
+                            <i class="iconfont icon-zhibanzhishou text"></i>
+                            <span class="text">${data[i].sceneName}</span>
+                        </div>`;
+                    };
+                }
+            }
+            if (rightId <= rightIdenId) {
+                $(".right-center").append(html)
+                rightCenterClick();
+            }
+        }
+    });
+
+    // 左下
+    let idenBId = $(".left-bottom>.sw").attr("data-id") * 1;
+    let leftBottomTheme = theme.filter(function(item) {
+        return item.sceneId == idenBId
+    });
+    let leftBottomHtml = '';
+    let leftBId = 1; //中间变量控制
+    let leftBIdenId = Math.ceil(leftBottomTheme.length / 3); //控制变量的最大值限制
+    $(".left-bottom>div:not(.sw)").remove();
+    for (let i = 0; i < (leftBottomTheme.length <= 3 ? leftBottomTheme.length : 3); i++) {
+        leftBottomHtml += `
+                <div data-url="${leftBottomTheme[i].url}">
+                        <span class="text">${leftBottomTheme[i].themeName}</span>
+                        <i class="iconfont icon-shuiwuju text"></i>
+                    </div>`;
+    }
+    $(".left-bottom").append(leftBottomHtml);
+    $(".left-bottom").on("mousewheel", function(e) {
+        if (leftBottomTheme.length > 3) {
+            let html = ""
+            if (e.originalEvent.wheelDelta > 0) {
+                if (leftBId > 1) {
+                    $(".left-bottom>div:not(.sw)").remove();
+                    leftBId--;
+                    // 切片数据
+                    const data = leftBottomTheme.slice(3 * (leftBId - 1), 3 * leftBId).reverse();
+                    console.log("data-bleft----", data);
+                    for (let i = data.length; i > 0; i--) {
+                        html += `
+                            <div data-url="${data[i - 1].url}">
+                                <span class="text">${data[i - 1].themeName}</span>
+                                <i class="iconfont icon-yangshi_icon_tongyong_maps text"></i>
+                            </div>`;
+                    }
+                }
+            } else {
+                if (leftBId < leftBIdenId) {
+                    $(".left-bottom>div:not(.sw)").remove();
+                    // 切片数据
+                    const data = leftBottomTheme.slice(3 * leftBId, 3 * (leftBId + 1));
+                    leftBId++;
+                    console.log("data--", data)
+                    console.log("leftBId---", leftBId)
+                    for (let i = 0; i < data.length; i++) {
+                        html += `
+                        <div data-url="${data[i].url}">
+                        <span class="text">${data[i].themeName}</span>
+                        <i class="iconfont icon-yangshi_icon_tongyong_maps text"></i>
+                    </div>`;
+                    }
+                }
+            }
+
+            if (leftBId <= leftBIdenId) {
+                $(".left-bottom").append(html);
+                // dom渲染完重新调用点击
+                leftBottomClick();
+            }
+        }
+    });
+
+
+    // 封装点击事件,在dom结构变化事件会消失
+    function leftCenterClick() { //左边中间的点击
+        $(".theme").on("click", function() {
+            console.log(1)
+        })
+        $(".left-center>div:not(.theme)").on("click", function() {
+            // 判断当前点击是否有选中类
+            if (!$(this).hasClass("left-center-ative")) {
+                $(this).not(".theme").siblings().removeClass("left-center-ative");
+                $(this).addClass("left-center-ative")
+            }
+            location.href = $(this).attr("data-url")
+        })
+    }
+
+    function leftBottomClick() { //左边底部的点击
+        $(".sw").on("click", function() {
+            console.log(3)
+        })
+        $(".left-bottom>div:not(.sw)").on("click", function() {
+            // 判断当前点击是否有选中类
+            if (!$(this).hasClass("left-center-ative")) {
+                $(this).not(".sw").siblings().removeClass("left-center-ative");
+                $(this).addClass("left-center-ative");
+            };
+            location.href = $(this).attr("data-url");
+        });
+    }
+
+    function rightCenterClick() { //右边中间的点击
+        $(".themes").on("click", function() {
+            console.log($(this).attr("data-id") * 1 + 1);
+        });
+    };
+
+    // 初始化调用,点击事件
+    leftCenterClick();
+    leftBottomClick();
+    rightCenterClick();
+
+    // 请求数据处理
+    // 除数据数组的长度,向上取值,作为标识id的最大值
+
+    // 封装dom渲染逻辑  id 标识变量  len 限制变量
+    function renderDom(event, id, len) {
+        let html = ""
+        if (event.originalEvent.wheelDelta > 0) {
+            // 切片数据,翻转
+            // [].slice()
+            if (id >= 1) {
+                $(".left-center>div:not(.theme)").remove(); //删除除第一个子元素外的使用元素
+                for (let i = len * id; i > 0 + (len * (id - 1)); i--) {
+                    html += `
+                                <div>
+                                    <span class="text">环卫作业车辆${i}</span>
+                                    <i class="iconfont icon-lajiche text"></i>
+                                </div>
+                            `;
+                }
+                setTimeout(() => {
+                    if (id > 1) {
+                        id--
+                    }
+                })
+            }
+
+        } else {
+            if (id < 3) {
+                $(".left-center").empty();
+                html = `
+                            <div class="theme">
+                            <div>
+                                <span>市环卫主题</span>
+                                <i class="iconfont icon-juminxiaoqu"></i>
+                            </div>
+                        </div>
+                        `;
+                for (let i = 0 + (7 * (id - 1)); i < 7 * id; i++) {
+                    html += `
+                            <div>
+                                <span class="text">环卫作业车辆${i}</span>
+                                <i class="iconfont icon-lajiche text"></i>
+                            </div>
+                        `;
+                }
+                setTimeout(() => {
+                    if (id >= 1) {
+                        id++
+                    }
+                })
+            }
+        }
+        if (id <= 3) {
+            $(".left-center").append(html);
+        }
+    }
+
+    // ajax get
+    function reqGet(url) {
+        let data = {}
+        $.ajax({
+            type: "GET",
+            url: url,
+            async: false,
+            dataType: "json",
+            success: function(res) {
+                data = res.data
+            },
+            error: function(err) {
+                console.log("请求失败!");
+                console.log(err)
+            }
+        });
+
+        return data
+    }
+})