登陆跳转

This commit is contained in:
pplokijuhyg 2019-12-26 10:00:24 +08:00
parent c901454332
commit faeb1f9ae1
7 changed files with 49 additions and 23 deletions

View File

@ -123,7 +123,7 @@ export default {
t.list = res.data.data; t.list = res.data.data;
window.console.log(t.list.length, "hfihaifohog"); window.console.log(t.list.length, "hfihaifohog");
if (t.list.length < 5) { if (t.list.length < 5) {
t.text = "暂无数据"; t.text = "暂无相关数据";
} }
window.$(window).scroll(() => { window.$(window).scroll(() => {
var windowH = window.$(window).height(); // var windowH = window.$(window).height(); //
@ -139,7 +139,7 @@ export default {
}); });
} else { } else {
window.console.log("errir"); window.console.log("errir");
t.text = "暂无数据"; t.text = "暂无相关数据";
} }
}); });
}, },

View File

@ -3,7 +3,10 @@
<div class="header"> <div class="header">
<img class="portrait" :src="'http://lawpro.earnest.pro' + userimg" alt /> <img class="portrait" :src="'http://lawpro.earnest.pro' + userimg" alt />
<div class="introduce"> <div class="introduce">
<p class="name">{{username}}</p> <p class="name">
<span>{{username}}</span>
<img :src="home" alt="" style="width:0.5rem;position: absolute;right:0.5rem;top:0.3rem" @click="gohome">
</p>
<div class="follow"> <div class="follow">
<p> <p>
<span>{{attention}}</span> <span>{{attention}}</span>
@ -71,7 +74,7 @@
:title="item.title" :title="item.title"
types="1" types="1"
:sid="item.id" :sid="item.id"
:type="item.status" :type="1"
></answer> ></answer>
<answer <answer
v-if="types==2" v-if="types==2"
@ -105,7 +108,6 @@
:types="item.type" :types="item.type"
:sid="item.id" :sid="item.id"
:type="item.type" :type="item.type"
></answer> ></answer>
</div> </div>
</div> </div>
@ -190,11 +192,13 @@
import follow from "./components/PersonafFollow"; import follow from "./components/PersonafFollow";
// import follows from "./components/PersonafFollows" // import follows from "./components/PersonafFollows"
import answer from "./components/PersonalAnswer"; import answer from "./components/PersonalAnswer";
import home from "./assets/home.png"
// import { log } from 'util'; // import { log } from 'util';
export default { export default {
name: "Personal-homepage", name: "Personal-homepage",
data() { data() {
return { return {
home,
userimg: "", userimg: "",
username: "", username: "",
myfollow: "", myfollow: "",
@ -220,7 +224,12 @@ export default {
path: "/articledetail?id=" + b path: "/articledetail?id=" + b
}); });
}, },
getlist() { gohome(){
this.$router.push({
path:"/"
})
},
getlist(types) {
if (this.lock) { if (this.lock) {
return; return;
} }
@ -233,19 +242,21 @@ export default {
page: this.page page: this.page
}) })
.then(res => { .then(res => {
this.lock = false;
window.console.log(res); window.console.log(res);
if (res.data.code == 200) { if (res.data.code == 200) {
if (res.data.data.length == 0) { if (types != this.types) {
// alert(1) // alert(1)
return; return;
} }
this.dynamiclist = res.data.data; this.dynamiclist = res.data.data;
this.lock = false; window.console.log(this.lock);
} }
}); });
}, },
getlists() { getlists(types) {
if (this.lock) { if (this.lock) {
return; return;
} }
@ -257,7 +268,9 @@ export default {
page: this.page page: this.page
}) })
.then(res => { .then(res => {
window.console.log(res); this.lock = false;
if (types != this.types) window.console.log(res);
if (res.data.code == 200) { if (res.data.code == 200) {
// if(res.data.data.length == 0){ // if(res.data.data.length == 0){
@ -266,14 +279,14 @@ export default {
// alert(1) // alert(1)
this.dynamiclist = res.data.data; this.dynamiclist = res.data.data;
this.lock = false; window.console.log(this.lock);
} }
}); });
} }
}, },
mounted() { mounted() {
document.title= "个人中心" document.title = "个人中心";
if (localStorage.getItem("token") == "") { if (localStorage.getItem("token") == "") {
this.$router.push({ path: "/login" }); this.$router.push({ path: "/login" });
} }
@ -313,22 +326,27 @@ export default {
// alert(2); // alert(2);
window.console.log(1); window.console.log(1);
if (this.types == 5) { if (this.types == 5) {
t.getlists(0); t.getlists(this.types);
} else { } else {
t.getlist(); t.getlist(this.types);
} }
} }
}); });
}, },
watch: { watch: {
types() { types() {
// window.console.log(a,b)
// if(this.lock == true){
// this.types = b
// return ;
// }
this.page = 0; this.page = 0;
this.dynamiclist = []; this.dynamiclist = [];
this.lock = false; // this.lock = false;
if (this.types == 5) { if (this.types == 5) {
this.getlists(0); this.getlists(this.types);
} else { } else {
this.getlist(); this.getlist(this.types);
} }
} }
}, },

BIN
src/assets/home.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
src/assets/login.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

@ -21,7 +21,10 @@
></list> ></list>
</div> </div>
<div style="width:100%;height:0.5rem;text-align:center;line-height:0.3rem">{{text}}</div> <div style="width:100%;height:0.5rem;text-align:center;line-height:0.3rem">
<img :src="login" style="width:0.5rem" alt="" v-if="text == '加载中' ">
{{text}}
</div>
<!-- <list></list> <!-- <list></list>
<list></list>--> <list></list>-->
</div> </div>
@ -42,6 +45,7 @@
<script> <script>
import list from "./components/IndexList"; import list from "./components/IndexList";
import heads from "./components/indexhead"; import heads from "./components/indexhead";
import login from "./assets/login.gif"
export default { export default {
name: "index", name: "index",
data() { data() {
@ -49,7 +53,8 @@ export default {
list: [], list: [],
page: 1, page: 1,
lock: false, lock: false,
text: "加载中" text: "加载中",
login
}; };
}, },
methods: { methods: {
@ -70,7 +75,7 @@ export default {
t.list = t.list.concat(res.data.data); t.list = t.list.concat(res.data.data);
t.lock = false; t.lock = false;
} else { } else {
t.text = "暂无更多"; t.text = "暂无更多数据";
} }
}); });
}, },

View File

@ -75,7 +75,7 @@ export default {
localStorage.setItem('token', res.data.data) localStorage.setItem('token', res.data.data)
this.$router.push({ this.$router.push({
path: `/`, path: `/PersonalHomepage`,
}) })
}else{ }else{
alert("登录失败,请重试") alert("登录失败,请重试")

View File

@ -87,6 +87,9 @@ router.beforeEach((to, from, next) => {
// location.href = "loaclhost:8080" + to.fullPath // location.href = "loaclhost:8080" + to.fullPath
next() next()
window.history.pushState({},0, "loaclhost:8080" + to.fullPath); if(from.name !== null){
window.location.reload();
}
}) })
export default router; export default router;