LoginRequiredState.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <view class="empty-state">
  3. <view class="empty-icon">
  4. <text class="empty-icon-text">!</text>
  5. </view>
  6. <text class="empty-title">{{ title }}</text>
  7. <text class="empty-desc">{{ description }}</text>
  8. <button class="login-btn" hover-class="login-btn-hover" @tap="handleGoLogin">
  9. {{ buttonText }}
  10. </button>
  11. </view>
  12. </template>
  13. <script setup lang="ts">
  14. interface Props {
  15. title?: string
  16. description?: string
  17. buttonText?: string
  18. loginUrl?: string
  19. enableRedirect?: boolean
  20. }
  21. const props = withDefaults(defineProps<Props>(), {
  22. title: '暂无内容',
  23. description: '登录后可查看学术信息和产品相册',
  24. buttonText: '去登录',
  25. loginUrl: '/pages/login/index',
  26. enableRedirect: true,
  27. })
  28. const getCurrentPageUrl = (): string => {
  29. const pages = getCurrentPages()
  30. const currentPage = pages[pages.length - 1]
  31. if (!currentPage?.route) {
  32. return ''
  33. }
  34. return `/${currentPage.route}`
  35. }
  36. const handleGoLogin = (): void => {
  37. uni.navigateTo({
  38. url: props.loginUrl,
  39. })
  40. }
  41. </script>
  42. <style scoped lang="scss">
  43. .empty-state {
  44. min-height: calc(100vh - 88rpx);
  45. box-sizing: border-box;
  46. padding: 180rpx 48rpx 0;
  47. display: flex;
  48. align-items: center;
  49. flex-direction: column;
  50. background: #fff;
  51. }
  52. .empty-icon {
  53. width: 128rpx;
  54. height: 128rpx;
  55. display: flex;
  56. align-items: center;
  57. justify-content: center;
  58. border-radius: 50%;
  59. background: #f2f8ff;
  60. }
  61. .empty-icon-text {
  62. font-size: 72rpx;
  63. font-weight: 700;
  64. color: #40a9ff;
  65. }
  66. .empty-title {
  67. margin-top: 36rpx;
  68. font-size: 32rpx;
  69. font-weight: 600;
  70. color: #333;
  71. }
  72. .empty-desc {
  73. margin-top: 16rpx;
  74. font-size: 26rpx;
  75. line-height: 38rpx;
  76. color: #999;
  77. text-align: center;
  78. }
  79. .login-btn {
  80. width: 320rpx;
  81. height: 80rpx;
  82. margin-top: 48rpx;
  83. display: flex;
  84. align-items: center;
  85. justify-content: center;
  86. border-radius: 999rpx;
  87. border: none;
  88. background: #40a9ff;
  89. color: #fff;
  90. font-size: 30rpx;
  91. line-height: 80rpx;
  92. }
  93. .login-btn::after {
  94. border: none;
  95. }
  96. .login-btn-hover {
  97. opacity: 0.85;
  98. }
  99. </style>