|
@@ -1,46 +1,18 @@
|
|
|
<template>
|
|
|
- <div class="home flex-column">
|
|
|
+ <div class="home">
|
|
|
<transition name="tab" mode="out-in">
|
|
|
<component :is="current" class="page" />
|
|
|
</transition>
|
|
|
- <footer class="footer">
|
|
|
- <div class="btnDiv" @click="handleGoPage('page-learn')">
|
|
|
- <!-- <img class="btnImg" :src="current === 'page-home' ? homeSelected: homeNormal" /> -->
|
|
|
- <button
|
|
|
- class="btn"
|
|
|
- :class="[current === 'page-learn' ? 'page-select' : '']"
|
|
|
- >
|
|
|
- 学习
|
|
|
- </button>
|
|
|
- </div>
|
|
|
- <div class="btnDiv" @click="handleGoPage('page-answer')">
|
|
|
- <!-- <img class="btnImg" :src="current === 'page-home' ? homeSelected: homeNormal" /> -->
|
|
|
- <button
|
|
|
- class="btn"
|
|
|
- :class="[current === 'page-answer' ? 'page-select' : '']"
|
|
|
- >
|
|
|
- 答题
|
|
|
- </button>
|
|
|
- </div>
|
|
|
- <div class="btnDiv" @click="handleGoPage('page-exam')">
|
|
|
- <!-- <img class="btnImg" :src="current === 'page-home' ? homeSelected: homeNormal" /> -->
|
|
|
- <button
|
|
|
- class="btn"
|
|
|
- :class="[current === 'page-exam' ? 'page-select' : '']"
|
|
|
- >
|
|
|
- 考试
|
|
|
- </button>
|
|
|
- </div>
|
|
|
- <div class="btnDiv" @click="handleGoPage('page-person')">
|
|
|
- <!-- <img class="btnImg" :src="current === 'page-personal-center' ? personalSelected: personalNormal" /> -->
|
|
|
- <button
|
|
|
- class="btn"
|
|
|
- :class="[current === 'page-personal' ? 'page-select' : '']"
|
|
|
- >
|
|
|
- 我的
|
|
|
- </button>
|
|
|
- </div>
|
|
|
- </footer>
|
|
|
+ <van-tabbar :active="active" @change="onChange">
|
|
|
+ <van-tabbar-item
|
|
|
+ v-for="(item, index) in tabbars"
|
|
|
+ :key="index"
|
|
|
+ :icon="item.icon"
|
|
|
+ @click="tab(index, item)"
|
|
|
+ >
|
|
|
+ <span>{{ item.title }}</span>
|
|
|
+ </van-tabbar-item>
|
|
|
+ </van-tabbar>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -54,13 +26,38 @@ export default {
|
|
|
components: { PageLearn, PageAnswer, PageExam, PagePerson },
|
|
|
data() {
|
|
|
return {
|
|
|
- current: "page-learn"
|
|
|
+ active: 0,
|
|
|
+ current: "page-learn",
|
|
|
+ pageList: ["page-learn", "page-answer", "page-exam", "page-person"],
|
|
|
+ tabbars: [
|
|
|
+ { title: "学习", icon: "home-o", pageName: "page-learn" },
|
|
|
+ { title: "答题", icon: "search", pageName: "page-answer" },
|
|
|
+ { title: "考试", icon: "setting-o", pageName: "page-exam" },
|
|
|
+ { title: "我的", icon: "friends-o", pageName: "page-person" }
|
|
|
+ ]
|
|
|
};
|
|
|
},
|
|
|
+ created() {
|
|
|
+ this.tab(0, this.tabbars[0]);
|
|
|
+ },
|
|
|
methods: {
|
|
|
- handleGoPage(name) {
|
|
|
- this.current = name;
|
|
|
- this.$router.replace({ name: "home", query: { page: name } });
|
|
|
+ onChange(event) {
|
|
|
+ console.log("---" + event);
|
|
|
+ this.active = event;
|
|
|
+ let pageName = this.pageList[this.active];
|
|
|
+ if (this.current !== pageName) {
|
|
|
+ this.current = pageName;
|
|
|
+ this.$router.replace({ name: "home", query: { page: pageName } });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ tab(index, tabbar) {
|
|
|
+ this.active = index;
|
|
|
+ console.log("---index" + index + "---" + JSON.stringify(tabbar));
|
|
|
+ let pageName = tabbar.pageName;
|
|
|
+ if (this.current !== pageName) {
|
|
|
+ this.current = pageName;
|
|
|
+ this.$router.replace({ name: "home", query: { page: pageName } });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -70,53 +67,4 @@ export default {
|
|
|
.home {
|
|
|
height: 100vh;
|
|
|
}
|
|
|
-.tab-leave-active,
|
|
|
-.tab-enter-active {
|
|
|
- transition: all 0.3s;
|
|
|
-}
|
|
|
-.tab-enter {
|
|
|
- opacity: 0;
|
|
|
- transform: translateX(-1.25rem);
|
|
|
-}
|
|
|
-.tab-leave-to {
|
|
|
- opacity: 0;
|
|
|
- transform: translateX(1.25rem);
|
|
|
-}
|
|
|
-.page {
|
|
|
- width: 100%;
|
|
|
- height: calc(100vh - 2.5rem);
|
|
|
- flex: 1;
|
|
|
-}
|
|
|
-.footer {
|
|
|
- position: fixed;
|
|
|
- bottom: 0;
|
|
|
- left: 0;
|
|
|
- width: 100%;
|
|
|
- z-index: 10;
|
|
|
- height: 2.5rem;
|
|
|
- display: flex;
|
|
|
- justify-content: space-around;
|
|
|
- border-top: 1px solid #f7f5f6;
|
|
|
- background-color: #fff;
|
|
|
-}
|
|
|
-.btnDiv {
|
|
|
- width: 25%;
|
|
|
- display: flex;
|
|
|
- flex-direction: column;
|
|
|
- justify-content: center;
|
|
|
- align-items: center;
|
|
|
- position: relative;
|
|
|
- .btnImg {
|
|
|
- width: 1rem;
|
|
|
- height: 1rem;
|
|
|
- }
|
|
|
- .btn {
|
|
|
- border: none;
|
|
|
- font-size: 0.7rem;
|
|
|
- background-color: white;
|
|
|
- }
|
|
|
-}
|
|
|
-.page-select {
|
|
|
- color: #438bef;
|
|
|
-}
|
|
|
</style>
|