headerTitle.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <view class="header-title">
  3. <!-- 个人信息 -->
  4. <view class="user-info-box">
  5. {{ userInfo?.realName || '欢迎登录' }},{{ timeStatus }}好
  6. </view>
  7. <!-- 流程按钮 -->
  8. <view class="right-flows" @tap="handleClick">
  9. <uni-badge class="uni-badge-left-margin" :is-dot="true" :text="flowNumber" absolute="rightTop"
  10. :offset="[10, 5]">
  11. <view class="flow-text">我的流程 ></view>
  12. </uni-badge>
  13. </view>
  14. </view>
  15. </template>
  16. <script setup>
  17. import {
  18. onMounted,
  19. ref
  20. } from 'vue';
  21. import {
  22. useUserStore
  23. } from '@/store/index.js';
  24. import moment from 'moment';
  25. const userStore = useUserStore();
  26. const userInfo = userStore.userInfo || uni.getStorageSync('userInfo')
  27. const flowNumber = ref(10);
  28. const timeStatus = ref('早上')
  29. onMounted(() => {
  30. getTimeStatus()
  31. setInterval(() => {
  32. getTimeStatus()
  33. }, 300000)
  34. })
  35. const getTimeStatus = () => {
  36. let hours = moment().hours()
  37. if (hours < 9) {
  38. timeStatus.value = '早上'
  39. } else if (hours >= 9 && hours < 12) {
  40. timeStatus.value = '上午'
  41. } else if (hours >= 12 && hours < 14) {
  42. timeStatus.value = '中午'
  43. } else if (hours >= 14 && hours < 18) {
  44. timeStatus.value = '下午'
  45. } else if (hours >= 18) {
  46. timeStatus.value = '晚上'
  47. }
  48. }
  49. const handleClick = () => {
  50. uni.navigateTo({
  51. url:'/pages/index/pages/MyFlow/index'
  52. })
  53. }
  54. </script>
  55. <style lang="scss" scoped>
  56. .header-title {
  57. margin: 40rpx 0 26rpx;
  58. display: flex;
  59. justify-content: space-between;
  60. align-items: center;
  61. color: $uni-text-color;
  62. .user-info-box {
  63. font-family: Source Han Sans;
  64. font-size: 40rpx;
  65. font-weight: bold;
  66. font-feature-settings: "kern" on;
  67. }
  68. .right-flows {
  69. .flow-text {
  70. font-family: Source Han Sans;
  71. font-size: 40rpx;
  72. font-weight: bold;
  73. font-feature-settings: "kern" on;
  74. }
  75. }
  76. }
  77. </style>