My-shade.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <view v-if="show" class="main" @click="handleClick">
  3. <view class="head" @click.stop>
  4. <view class="text" @click.stop>
  5. 当前页面需要登录才能继续使用
  6. </view>
  7. <My-button @onClick="toLogin" :customStyle="{
  8. width: '200rpx',
  9. height: '60rpx',
  10. backgroundColor: '#007AFF',
  11. color: '#fff',
  12. borderRadius: '30rpx',
  13. fontSize: '24rpx'
  14. }" text="立即登录" />
  15. </view>
  16. </view>
  17. </template>
  18. <script setup>
  19. import { onShow } from '@dcloudio/uni-app';
  20. import { ref, getCurrentInstance } from 'vue'
  21. const { $Http } = getCurrentInstance().proxy;
  22. let show = ref(false);
  23. onShow(() => {
  24. setTimeout(() => {
  25. show.value = !$Http.isLoad;
  26. if (!$Http.isLoad) setTimeout(() => show.value = !$Http.isLoad, 800);
  27. });
  28. });
  29. function handleClick() {
  30. uni.showModal({
  31. title: '提示',
  32. content: '当前页面需要登录才能继续使用',
  33. confirmText: '立即登录',
  34. success: ({ confirm }) => {
  35. if (confirm) toLogin()
  36. },
  37. })
  38. }
  39. function toLogin() {
  40. uni.navigateTo({
  41. url: '/pages/login/login'
  42. });
  43. }
  44. </script>
  45. <style lang="scss" scoped>
  46. .main {
  47. position: fixed;
  48. width: 100vw;
  49. height: 100vh;
  50. left: 0;
  51. z-index: 2;
  52. .head {
  53. display: flex;
  54. align-items: center;
  55. justify-content: space-between;
  56. width: 100vw;
  57. background: rgba($color: #000000, $alpha: .5);
  58. padding: 20rpx;
  59. box-sizing: border-box;
  60. margin-top: env(safe-area-inset-top)px;
  61. .text {
  62. color: #fff;
  63. font-size: 24rpx;
  64. }
  65. }
  66. }
  67. </style>