You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

151 lines
2.8 KiB

  1. <template>
  2. <view class="login-prompt" v-if="showPrompt">
  3. <view
  4. class="mask"
  5. :class="{ 'mask-show': showAnimation }"
  6. ></view>
  7. <view class="prompt-content" :class="{ 'slide-up': showAnimation }">
  8. <text class="prompt-title">登录以获得更好的体验</text>
  9. <button class="login-btn" @click="goLogin">登录</button>
  10. <button class="visitor-btn" @click="continueAsVisitor">
  11. 以访客身份继续
  12. </button>
  13. <text class="prompt-title-small">如果您还没有账号点击注册</text>
  14. </view>
  15. </view>
  16. </template>
  17. <script setup>
  18. import { ref, nextTick } from "vue";
  19. // 定义响应式数据
  20. const showPrompt = ref(false);
  21. const showAnimation = ref(false);
  22. // 显示弹窗
  23. const show = () => {
  24. showPrompt.value = true;
  25. // 在下一帧触发动画
  26. nextTick(() => {
  27. setTimeout(() => {
  28. showAnimation.value = true;
  29. }, 10);
  30. });
  31. };
  32. // 隐藏弹窗
  33. const hide = () => {
  34. showAnimation.value = false;
  35. // 等待动画结束后再隐藏
  36. setTimeout(() => {
  37. showPrompt.value = false;
  38. }, 300);
  39. };
  40. // 跳转到登录页面
  41. const goLogin = () => {
  42. uni.navigateTo({
  43. url: "/pages/start/login/login",
  44. });
  45. hide();
  46. };
  47. // 以访客身份继续
  48. const continueAsVisitor = () => {
  49. // 设置访客模式
  50. uni.setStorageSync("visitorMode", true);
  51. hide();
  52. };
  53. // 暴露方法给外部使用
  54. defineExpose({
  55. show,
  56. hide,
  57. });
  58. </script>
  59. <style scoped>
  60. .login-prompt {
  61. position: fixed;
  62. top: 0;
  63. left: 0;
  64. right: 0;
  65. bottom: 0;
  66. z-index: 999;
  67. }
  68. .mask {
  69. position: absolute;
  70. top: 0;
  71. left: 0;
  72. right: 0;
  73. bottom: 0;
  74. background-color: rgba(0, 0, 0, 0.8);
  75. opacity: 0;
  76. transition: opacity 0.3s ease;
  77. }
  78. .mask.mask-show {
  79. opacity: 1;
  80. }
  81. .prompt-content {
  82. position: absolute;
  83. bottom: 0;
  84. left: 0;
  85. right: 0;
  86. height: 400rpx;
  87. border-radius: 20rpx 20rpx 0 0;
  88. background-color: white;
  89. padding: 20rpx 70rpx;
  90. transform: translateY(100%);
  91. transition: transform 0.3s ease;
  92. box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
  93. }
  94. .prompt-content.slide-up {
  95. transform: translateY(0);
  96. }
  97. .prompt-title {
  98. display: block;
  99. text-align: center;
  100. font-size: 40rpx;
  101. font-weight: 700;
  102. color: #000000;
  103. margin-top: 30rpx;
  104. margin-bottom: 40rpx;
  105. }
  106. .login-btn {
  107. width: 100%;
  108. height: 80rpx;
  109. background-color: rgb(0, 0, 0);
  110. color: white;
  111. font-size: 32rpx;
  112. line-height: 80rpx;
  113. border-radius: 40rpx;
  114. margin-bottom: 20rpx;
  115. }
  116. .visitor-btn {
  117. width: 100%;
  118. height: 80rpx;
  119. background-color: #f5f5f5;
  120. color: #333;
  121. font-size: 32rpx;
  122. line-height: 80rpx;
  123. border-radius: 40rpx;
  124. }
  125. .prompt-title-small {
  126. display: block;
  127. text-align: center;
  128. font-size: 24rpx;
  129. color: #6a6a6a;
  130. margin-top: 30rpx;
  131. margin-bottom: 40rpx;
  132. line-height: 15.5px;
  133. letter-spacing: 0.3px;
  134. font-style: normal;
  135. font-family: "PingFang SC";
  136. }
  137. </style>