index.vue 2.19 KB
<template>
  <div>
    <img v-if="isHome" @click="toHome" class="icon-home" referrerpolicy="no-referrer" :src="icon_home" />
    <img v-if="isMe" @click="toMe" class="icon-me" referrerpolicy="no-referrer" :src="icon_me" />
  </div>
</template>

<script setup>
import Cookies from 'js-cookie'

import icon_me from '@images/icon-my@2x.png'
import icon_home from '@images/icon-home@2x.png'

import { ref, reactive, onMounted } from 'vue'
// const props = defineProps({
//   type: String
// })
const emit = defineEmits(['on-click']);
const handle = () => {
  emit('on-click', '')
}
  onMounted(() => {
    
  })
</script>

<script>
// FIXME: VUE2写法
export default {
  props: ['type', 'item'],
  data () {
    return {
      userType: Cookies.get('userType') ? Cookies.get('userType') : ''
    }
  },
  computed: {
    isHome () {
      return this.item.indexOf('home') !== -1 ? true : false
    },
    isMe () {
      return this.item.indexOf('me') !== -1 ? true : false
    },
  },
  mounted () {
  },
  methods: {
    toHome () {
      // 返回首页
      if (this.type === 'B') { // 服务端判断
        this.$router.push({
          path: '/business/index'
        });
      } else {
        // C 端返回首页需要判断是否,访客或客户
        switch (this.userType) {
          case 'visitor':
            this.$router.push({
              path: '/client/chooseBook'
            });
            break;
          case 'client':
            this.$router.push({
              path: '/client/chooseSchool'
            });
            break;
          default:
            this.$router.push({
              path: '/client/index'
            });
            break;
        }
      }
    },
    toMe () {
      if (this.type === 'B') { // 服务端判断
        this.$router.push({
          path: '/business/me'
        });
      } else {
        this.$router.push({
          path: '/me/index'
        });
      }
    }
  }
}
</script>

<style lang="less" scoped>
  .icon-home {
    z-index: 169;
    position: fixed;
    right: 2rem;
    bottom: 12rem;
    width: 3rem;
    height: 3rem;
  }
  .icon-me {
    z-index: 169;
    position: fixed;
    right: 2rem;
    bottom: 8rem;
    width: 3rem;
    height: 3rem;
  }
</style>