bottomTab.vue 5.07 KB
<template>
  <div class="bottom-tab">
    <div :class="{actived:$route.name === 'index'}" @click="toUrl('index')">
      <div class="index img">
        <img :src="imgurl.indexBottom" alt>
      </div>
      启蒙
    </div>
    <div v-if="userCourse2.start_periods_id!=null||userCourse2.automation_id" :class="{actived:$route.name === 'map'||$route.name === 'secMap'||$route.name === 'hasaccount'}" @click="toUrl('map')">
      <div class="map img">
        <img :src="imgurl.indexBottom" alt>
      </div>
      上课
    </div>
    <div :class="{actived:$route.name === 'mine'}" @click="toUrl('mine')">
      <div class="mine img">
        <img :src="imgurl.indexBottom" alt>
      </div>
      我的
    </div>
  </div>
</template>

<script>
import { IndexImage } from "../../util/imgUrl";
export default {
  name: "bottomTab",
  data() {
    return {
      imgurl: IndexImage,
      userCourse2:{
      },
      ownDetail:{}
    };
  },
  mounted() {
    // debugger
    let userCourse2 = JSON.parse(localStorage.getItem("userCourse"));
    this.ownDetail = JSON.parse(localStorage.getItem("userDesc"));

    if(userCourse2){
      this.userCourse2 = userCourse2
    }
  },
  methods: {
    toUrl(data) {
      // debugger
      if (data == "map") {
        this.$sa.track("buttonClick", {
        tabTitle: "底部导航",
        moduleTitle: "功能按钮",
        buttonType: "切换按钮",
        buttonName: "切换到上课"
        });
        if(this.ownDetail.family_user!=1){
            if(this.userCourse2.start_periods_id!=null&&this.userCourse2.start_periods_course_type!=null){
            //  debugger
            this.$router.push({
            name: "map",
            query: {
              course_type: this.userCourse2.start_periods_course_type
            }
            });
          }else{
            this.$router.push({
            name: "secMap",
            query: {
              periods_id: this.userCourse2.start_periods_id,
              course_type: this.userCourse2.start_periods_course_type
            }
            });
          }
        }else{
          this.$router.push({
          name: "hasaccount"
         });
        }

        // this.$router.push({
        //   name: "secMap",
        //   query: {
        //     periods_id: this.userCourse2.start_periods_id,
        //     course_type: this.userCourse2.start_periods_course_type
        //   }
        // });
      } else {
        this.$sa.track("buttonClick", {
        tabTitle: "底部导航",
        moduleTitle: "功能按钮",
        buttonType: "切换按钮",
        buttonName: data === "index" ? "切换到首页" : "切换到我的"
        });
        this.$router.push({ name: data });
      }
    },
    setBtn(){
      let userCourse2 = JSON.parse(localStorage.getItem("userCourse"));
      this.userCourse2 = userCourse2
      // console.log(this.userCourse2)
    }
  }
};
</script>

<style scoped lang="less">
@import "../../util/public";
.bottom-tab {
  width: 375 * @toVw;
  height: 48 * @toVw;
  position: fixed;
  left: 0;
  bottom: 0;
  box-shadow: 0px -1px 2px 0px rgba(204, 204, 204, 0.5);
  padding: 0 24 * @toVw;
  box-sizing: border-box;
  display: flex;
  display: -webkit-flex;
  font-size: 10 * @toVw;
  font-family: PingFang-SC-Medium;
  text-align: center;
  font-weight: normal;
  color: #666666;
  line-height: 14 * @toVw;
  z-index: 30;
  background: white;
  & > div {
    width: 50%;
  }
  .left {
    // border-right: 1px solid #eeeeee;
  }
  .img {
    width: 28 * @toVw;
    height: 28 * @toVw;
    overflow: hidden;
    position: relative;
    img {
      width: 28 * @toVw;
      position: absolute;
      left: 0;
    }
  }
  .index {
    img {
      top: -28 * @toVw;
    }
  }
  .map {
    img {
      top: -56 * @toVw;
    }
  }
  .mine {
    img {
      top: -84 * @toVw;
    }
  }
  .actived {
    .index {
      img {
        top: -140 * @toVw;
      }
    }
    .map {
      img {
        top: -112 * @toVw;
      }
    }
    .mine {
      img {
        top: 0;
      }
    }
  }
}

@media screen and (min-width: 600px) {
  @toVw: 100/1024vw;
  .bottom-tab {
    width:100%;
    height: 66 * @toVw;
    position: fixed;
    left: 0;
    bottom: 0;
    box-shadow: 0px -1px 2px 0px rgba(204, 204, 204, 0.5);
    padding: 0 6 * @toVw;
    display: flex;
    display: -webkit-flex;
    font-size: 10 * @toVw;
    font-family: PingFang-SC-Medium;
    text-align: center;
    font-weight: normal;
    color: #ccc;
    line-height: 14 * @toVw;
    z-index: 30;
    background: white;
    & > div {
      width: 50%;
    }
    .actived {
      color: #6eb1ff;
    }
    .img {
    width: 30 * @toVw;
    height: 30 * @toVw;
    overflow: hidden;
    position: relative;
    img {
      width: 30 * @toVw;
      position: absolute;
      left: 0;
    }
   }
   .index {
    img {
      top: -30 * @toVw;
    }
  }
  .map {
    img {
      top: -60 * @toVw;
    }
  }
  .mine {
    img {
      top: -91 * @toVw;
    }
  }
  .actived {
    .index {
      img {
        top: -151 * @toVw;
      }
    }
    .map {
      img {
        top: -119 * @toVw;
      }
    }
    .mine {
      img {
        top: 0;
      }
    }
  }
  }
}
</style>