|
|
|
@ -16,6 +16,7 @@ import HomeIcons from "./components/Icons";
@@ -16,6 +16,7 @@ import HomeIcons from "./components/Icons";
|
|
|
|
|
import HomeRecommend from "./components/Recommend"; |
|
|
|
|
import HomeWeekend from "./components/Weekend"; |
|
|
|
|
import axios from "axios"; |
|
|
|
|
import { mapState } from "vuex"; |
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
|
//单页组件名 |
|
|
|
@ -30,15 +31,19 @@ export default {
@@ -30,15 +31,19 @@ export default {
|
|
|
|
|
}, |
|
|
|
|
data: function() { |
|
|
|
|
return { |
|
|
|
|
lastCity: "", |
|
|
|
|
swiperList: [], |
|
|
|
|
iconList: [], |
|
|
|
|
recommendList: [], |
|
|
|
|
weekendList: [] |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
computed: { |
|
|
|
|
...mapState(["city"]) |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
getHomeInfo: function() { |
|
|
|
|
axios.get("/api/index.json").then(this.getHomeInfoSucc); |
|
|
|
|
axios.get("/api/index.json?city=" + this.city).then(this.getHomeInfoSucc); |
|
|
|
|
}, |
|
|
|
|
getHomeInfoSucc: function(res) { |
|
|
|
|
res = res.data; |
|
|
|
@ -53,7 +58,14 @@ export default {
@@ -53,7 +58,14 @@ export default {
|
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
mounted: function() { |
|
|
|
|
this.lastCity = this.city; |
|
|
|
|
this.getHomeInfo(); |
|
|
|
|
}, |
|
|
|
|
activated: function() { |
|
|
|
|
if (this.lastCity !== this.city) { |
|
|
|
|
this.lastCity = this.city; |
|
|
|
|
this.getHomeInfo(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
</script> |
|
|
|
|