Newer
Older
smartwell_front / src / views / mobile / dashboard / index.vue
liyaguang on 27 Dec 4 KB 问题修改
<!--
  Description: 移动端-首页
  Author: 李亚光
  Date: 2024-09-25
 -->
<script lang="ts" setup name="DashboardMobile">
import useUserStore from '@/store/modules/user'
import useRouteStore from '@/store/modules/route'
import { ElMessage, ElMessageBox } from 'element-plus'
// import { showToast } from 'vant'
import userDialog from './userInfo.vue'
const { proxy } = getCurrentInstance() as any
const userStore = useUserStore()
const routeStore = useRouteStore()
const menu = ref([
  {
    name: '新装设备',
    auth: '/mobile/device',
    path: '/device/add',
    routeName: 'DeviceAdd',
    img: new URL('@/assets/mobile/device.png', import.meta.url),
  },
  {
    name: '设备运维',
    auth: '/mobile/operation',
    path: '/operation/equipment',
    routeName: 'OperationEquipment',
    img: new URL('@/assets/mobile/operation.png', import.meta.url),
  },
  {
    name: '信息查询',
    auth: '/mobile/info',
    path: '/info/search',
    routeName: 'InfoSearch',
    img: new URL('@/assets/mobile/search.png', import.meta.url),
  },
  {
    name: '运维记录',
    auth: '/mobile/record',
    path: '/record/search',
    routeName: 'RecordSearch',
    img: new URL('@/assets/mobile/record.png', import.meta.url),
  },
])
// 菜单跳转
const $router = useRouter()
const goRoute = (item: any) => {
  if (!proxy.hasPerm(item.auth)) {
    return
  }
  $router.push({
    // name: item.routeName,
    path: item.path,
  })
}
// 退出登录
const logout = () => {
  ElMessageBox.confirm(
    '确认退出登录吗?',
    '',
    {
      confirmButtonText: '确认',
      cancelButtonText: '取消',
      type: 'warning',
    }
  ).then(() => {
    routeStore.removeRoutes()
    userStore.logout().then(() => {
      $router.push({
        name: 'login',
      })
    })
  })

}
// 用户信息
const userRef = ref()
const viewUser = () => {
  userRef.value.initDialog()
}
// console.log(getCurrentInstance().proxy, 123)
// showToast('请填写正确的手机号')
</script>

<template>
  <div class="container">
    <!-- 背景图 -->
    <div class="bg" />
    <div class="title">
      施工管理助手
    </div>
    <!-- 菜单 -->
    <div class="menu-container">
      <div v-for="item in menu" v-show="proxy.hasPerm(item.auth)" :key="item.name" class="menu-item"
        @click="goRoute(item)">
        <div class="img">
          <img :src="item.img">
        </div>
        <div class="name">
          {{ item.name }}
        </div>
      </div>
    </div>
    <!-- 用户 -->
    <img @click="viewUser" class="user" src="../../../assets/mobile/user.png" alt="" srcset="">
    <!-- 退出登录 -->
    <!-- <div class="btn">
      <el-button style="width: 100%;" @click="logout">
        退出登录
      </el-button>
    </div> -->
    <!-- 用户信息弹窗 -->
    <!-- <nut-cell title="Title" desc="Description"></nut-cell> -->
    <user-dialog ref="userRef" />
  </div>
</template>

<style lang="scss" scoped>
.container {
  position: relative;
  height: 100vh;
  overflow: hidden;
  background: #fff;

  .bg {
    background: url("@/assets/mobile/login.png") no-repeat center center / cover;
    width: 100%;
    height: 30vh;
  }

  .title {
    position: absolute;
    width: 100%;
    text-align: center;
    font-weight: 700;
    font-size: 20px;
    color: #fff;
    top: 6vh;
  }

  .menu-container {
    width: 100%;
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    // margin-top: 10;
    padding: 0 3vh;
    position: relative;
    top: 30%;
    transform: translateY(-50%);

    .menu-item {
      margin-top: 1.5rem;
      width: 42%;
      border: 2px solid #0d76d4;
      background-color: rgba($color: #0b0b0f, $alpha: 1%);
      border-radius: 4px;
      padding: 10px;
      box-shadow: 0 0 12px rgb(0 0 0 / 12%);

      .img {
        width: 100%;
        display: flex;
        justify-content: center;

        img {
          width: 50%;
          margin: 0 auto;
        }
      }

      .name {
        margin-top: 12px;
        width: 100%;
        text-align: center;
        font-size: 1.2rem;
      }
    }
  }

  .btn {
    padding: 0 5vh;
    // margin-top: 3vh;
    position: fixed;
    bottom: 4vh;
    width: 100%;
    font-size: 1.5rem;
  }

  .user {
    position: absolute;
    bottom: 4vh;
    right: 2rem;
    width: 3rem;
    height: 3rem;
  }
}
</style>