Bladeren bron

作品分享

luohailiang 2 jaren geleden
bovenliggende
commit
47c1ef68fa
4 gewijzigde bestanden met toevoegingen van 156 en 0 verwijderingen
  1. 95 0
      static/scripts/xszp.js
  2. 9 0
      static/styles/xszp.css
  3. 10 0
      static/styles/xszp.scss
  4. 42 0
      xszp.html

+ 95 - 0
static/scripts/xszp.js

@@ -0,0 +1,95 @@
+new Vue({
+    el: '#xszp',
+    data() {
+        return {
+            userInfo: {},
+            worksList: [],
+            ks_id: '',
+            ks_name:'',
+            cur_page: '1',
+            total_page:0,
+            isOver:false
+        }
+    },
+    methods: {
+        getZpList() {
+            let data = {
+                api: 'json',
+                token: this.userInfo.token,
+                ks_id: this.ks_id,
+                page: this.cur_page,
+                limit: '10'
+            }
+            const requestURL = 'https://tyyxopenapi.txhlwxx.com/ysgc/zp/index';
+            axios({
+                method: 'POST',
+                url: requestURL,
+                data: Qs.stringify(data),
+                headers: {
+                    "Content-Type": 'application/x-www-form-urlencoded;charset=UTF-8'
+                }
+            }).then(res => {
+                if (res.data.code == 1) {
+                    this.ks_name = res.data.template.ks_name;
+                    this.worksList = res.data.data.page_data;
+                    this.cur_page = res.data.data.page_now;
+                    this.total_page = res.data.data.total_page;
+
+                }
+            })
+        },
+        list_scroll() {
+            $(window).on("resize scroll", ()=> {
+
+                var windowHeight = $(window).height();//当前窗口的高度
+                var scrollTop = $(window).scrollTop();//当前滚动条从上往下滚动的距离
+                var docHeight = $(document).height(); //当前文档的高度
+                //当 滚动条距底部的距离 + 滚动条滚动的距离 >= 文档的高度 - 窗口的高度
+                //换句话说:(滚动条滚动的距离 + 窗口的高度 = 文档的高度)  这个是基本的公式
+
+                if (scrollTop + windowHeight >= docHeight) {
+                    if (this.cur_page < this.total_page) {
+                        this.cur_page ++;
+                        let data = {
+                            api: 'json',
+                            token: this.userInfo.token,
+                            ks_id: this.ks_id,
+                            page: this.cur_page,
+                            limit: '10'
+                        }
+                        const requestURL = 'https://tyyxopenapi.txhlwxx.com/ysgc/zp/index';
+                        axios({
+                            method: 'POST',
+                            url: requestURL,
+                            data: Qs.stringify(data),
+                            headers: {
+                                "Content-Type": 'application/x-www-form-urlencoded;charset=UTF-8'
+                            }
+                        }).then(res => {
+                            if (res.data.code == 1) {
+                                this.ks_name = res.data.template.ks_name;
+                                this.worksList = this.worksList.concat(res.data.data.page_data);
+                                this.cur_page = res.data.data.page_now;
+                                this.total_page = res.data.data.total_page;
+                                this.isOver = false;
+                            }
+                        })
+                    } else {
+                        this.isOver = true;
+                    }
+
+                }
+            });
+        },
+    },
+    mounted() {
+        if (localStorage.getItem('userInfo')) {
+            this.userInfo = JSON.parse(localStorage.getItem('userInfo'));
+        }
+        if (location.search.includes('ks_id')) {
+            this.ks_id = location.search.substring(7);
+            this.getZpList();
+            this.list_scroll();
+        }
+    }
+})

+ 9 - 0
static/styles/xszp.css

@@ -0,0 +1,9 @@
+.works-list {
+  width: 100%;
+}
+.works-list li {
+  width: 100%;
+}
+.works-list li + li {
+  margin-top: 10px;
+}

+ 10 - 0
static/styles/xszp.scss

@@ -0,0 +1,10 @@
+@charset "utf-8";
+.works-list{
+	width: 100%;
+	li{
+		width: 100%;
+		&+li{
+			margin-top: 10px;
+		}
+	}
+}

+ 42 - 0
xszp.html

@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <meta content="IE=edge" http-equiv="X-UA-Compatible">
+    <meta name="viewport"
+          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
+    <title>桐艺云校</title>
+    <link rel="stylesheet" href="static/styles/common.css?v=20221124">
+    <link rel="stylesheet" href="static/styles/xszp.css?v=20230114">
+</head>
+<body>
+<div class="wrapper">
+  <div id="xszp" class="ph15 pt20 pb20" v-cloak>
+      <h3 class="font-size-16">{{ks_name}}</h3>
+      <ul class="mt15 works-list">
+          <li v-for="item in worksList">
+              <h3 class="font-size-14 text-grey">{{item.yz_name}}</h3>
+              <div class="mt10">
+                  <img :src="'https://tyyxopenapi.txhlwxx.com/'+item.yz_img" alt="" class="d-block w100">
+              </div>
+          </li>
+      </ul>
+      <div v-if="isOver" class="mt20 text-center font-size-13 text-light">已加载全部数据~</div>
+  </div>
+</div>
+<script src="static/scripts/jquery.min.js"></script>
+<script src="static/scripts/vue.min.js"></script>
+<script src="static/scripts/axios.min.js"></script>
+<script src="static/scripts/qs.min.js"></script>
+<script src="static/scripts/xszp.js?v=20230114"></script>
+<script>
+    var _hmt = _hmt || [];
+    (function() {
+        var hm = document.createElement("script");
+        hm.src = "https://hm.baidu.com/hm.js?7315461a461ba4c1e7531bd3fa0b7927";
+        var s = document.getElementsByTagName("script")[0];
+        s.parentNode.insertBefore(hm, s);
+    })();
+</script>
+</body>
+</html>