112 lines
2.6 KiB
Vue
112 lines
2.6 KiB
Vue
<template>
|
|
<div class="box">
|
|
<heads></heads>
|
|
<div class="list">
|
|
<div v-for="(item,index) in list" :key="index" @click="todetail(item.id,item.type)">
|
|
<list
|
|
:title="item.title"
|
|
:id="item.id"
|
|
:num="item.comment"
|
|
:img="item.img"
|
|
:text="item.text"
|
|
></list>
|
|
</div>
|
|
|
|
<div style="width:100%;height:0.5rem;text-align:center;line-height:0.3rem">{{text}}</div>
|
|
<!-- <list></list>
|
|
<list></list>-->
|
|
</div>
|
|
</div>
|
|
</template>
|
|
<style lang="scss" scoped>
|
|
.box {
|
|
min-height: 100vh;
|
|
background-color: #f6f6f6;
|
|
padding-top: 88px;
|
|
box-sizing: border-box;
|
|
|
|
.list {
|
|
width: 100%;
|
|
}
|
|
}
|
|
</style>
|
|
<script>
|
|
import list from "./components/IndexList";
|
|
import heads from "./components/indexhead";
|
|
export default {
|
|
name: "index",
|
|
data() {
|
|
return {
|
|
list: [],
|
|
page: 1,
|
|
lock: false,
|
|
text: "加载中"
|
|
};
|
|
},
|
|
methods: {
|
|
getlist() {
|
|
if (this.lock) {
|
|
return "lock";
|
|
}
|
|
this.lock = true;
|
|
var t = this;
|
|
this.page += 1;
|
|
this.axios
|
|
.post("http://lawpro.earnest.pro/api/login_main/articleList", {
|
|
page: t.page
|
|
})
|
|
.then(res => {
|
|
if (res.data.code == 200) {
|
|
t.list = t.list.concat(res.data.data);
|
|
t.lock = false;
|
|
} else {
|
|
t.text = "暂无更多";
|
|
}
|
|
});
|
|
},
|
|
todetail(e, type) {
|
|
window.console.log(e);
|
|
if (type == 2) {
|
|
this.$router.push({
|
|
path: `/IndexArticleDetaill?id=` + e
|
|
});
|
|
} else {
|
|
this.$router.push({
|
|
path: `/articledetail?id=` + e
|
|
});
|
|
}
|
|
}
|
|
},
|
|
components: {
|
|
list,
|
|
heads
|
|
},
|
|
mounted() {
|
|
var t = this;
|
|
this.axios
|
|
.post("http://lawpro.earnest.pro/api/login_main/articleList", {
|
|
page: t.page
|
|
})
|
|
.then(res => {
|
|
window.console.log(res.data);
|
|
if (res.data.code == 200) {
|
|
t.list = res.data.data;
|
|
window.$(window).scroll(() => {
|
|
var windowH = window.$(window).height(); //设备可见区域高度
|
|
var documentH = window.$(document).height(); //整个网页的高度(包括未显示的部分)
|
|
var scrollH = window.$(window).scrollTop(); //滚动条滚动上去的高度
|
|
//或者 scrollH = $(document).scrollTop();
|
|
if (windowH + scrollH >= documentH) {
|
|
// do something
|
|
// alert(2);
|
|
window.console.log(1);
|
|
t.getlist();
|
|
}
|
|
});
|
|
} else {
|
|
t.text = "暂无数据";
|
|
}
|
|
});
|
|
}
|
|
};
|
|
</script> |