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.

158 lines
3.0 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" @click="goRegister">如果您还没有账号点击注册</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 goRegister = () => {
  49. uni.navigateTo({
  50. url: "/pages/start/Registration/Registration",
  51. });
  52. hide();
  53. };
  54. // 以访客身份继续
  55. const continueAsVisitor = () => {
  56. // 设置访客模式
  57. uni.setStorageSync("visitorMode", true);
  58. hide();
  59. };
  60. // 暴露方法给外部使用
  61. defineExpose({
  62. show,
  63. hide,
  64. });
  65. </script>
  66. <style scoped>
  67. .login-prompt {
  68. position: fixed;
  69. top: 0;
  70. left: 0;
  71. right: 0;
  72. bottom: 0;
  73. z-index: 999;
  74. }
  75. .mask {
  76. position: absolute;
  77. top: 0;
  78. left: 0;
  79. right: 0;
  80. bottom: 0;
  81. background-color: rgba(0, 0, 0, 0.8);
  82. opacity: 0;
  83. transition: opacity 0.3s ease;
  84. }
  85. .mask.mask-show {
  86. opacity: 1;
  87. }
  88. .prompt-content {
  89. position: absolute;
  90. bottom: 0;
  91. left: 0;
  92. right: 0;
  93. height: 400rpx;
  94. border-radius: 20rpx 20rpx 0 0;
  95. background-color: white;
  96. padding: 20rpx 70rpx;
  97. transform: translateY(100%);
  98. transition: transform 0.3s ease;
  99. box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
  100. }
  101. .prompt-content.slide-up {
  102. transform: translateY(0);
  103. }
  104. .prompt-title {
  105. display: block;
  106. text-align: center;
  107. font-size: 40rpx;
  108. font-weight: 700;
  109. color: #000000;
  110. margin-top: 30rpx;
  111. margin-bottom: 40rpx;
  112. }
  113. .login-btn {
  114. width: 100%;
  115. height: 80rpx;
  116. background-color: rgb(0, 0, 0);
  117. color: white;
  118. font-size: 32rpx;
  119. line-height: 80rpx;
  120. border-radius: 40rpx;
  121. margin-bottom: 20rpx;
  122. }
  123. .visitor-btn {
  124. width: 100%;
  125. height: 80rpx;
  126. background-color: #f5f5f5;
  127. color: #333;
  128. font-size: 32rpx;
  129. line-height: 80rpx;
  130. border-radius: 40rpx;
  131. }
  132. .prompt-title-small {
  133. display: block;
  134. text-align: center;
  135. font-size: 24rpx;
  136. color: #6a6a6a;
  137. margin-top: 30rpx;
  138. margin-bottom: 40rpx;
  139. line-height: 15.5px;
  140. letter-spacing: 0.3px;
  141. font-style: normal;
  142. font-family: "PingFang SC";
  143. }
  144. </style>