nav-index-button.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <view class="nav-index-button" :style="{bottom: `${bottom}rpx`, right: `${right}rpx`}" @tap.stop="navIndex">
  3. <view class="nav-index-button__content">
  4. <view class="nav-index-button__content--icon tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur tn-cool-bg-color-5">
  5. <view class="tn-icon-home-fill"></view>
  6. </view>
  7. </view>
  8. <view class="nav-index-button__meteor">
  9. <view class="nav-index-button__meteor__wrapper">
  10. <view v-for="(item,index) in 6" :key="index" class="nav-index-button__meteor__item" :style="{transform: `rotateX(${-60 + (30 * index)}deg) rotateZ(${-60 + (30 * index)}deg)`}">
  11. <view class="nav-index-button__meteor__item--pic"></view>
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. name: 'nav-index-button',
  20. props: {
  21. // 距离底部的距离
  22. bottom: {
  23. type: [Number, String],
  24. default: 300
  25. },
  26. // 距离右边的距离
  27. right: {
  28. type: [Number, String],
  29. default: 75
  30. },
  31. // 首页地址
  32. indexPath: {
  33. type: String,
  34. default: '/pages/index'
  35. }
  36. },
  37. methods: {
  38. // 跳转回首页
  39. navIndex() {
  40. // 通过判断当前页面的页面栈信息,是否有上一页进行返回,如果没有则跳转到首页
  41. const pages = getCurrentPages()
  42. if (pages && pages.length > 0) {
  43. const indexPath = this.indexPath || '/pages/index'
  44. const firstPage = pages[0]
  45. if (pages.length == 1 && (!firstPage.route || firstPage.route != indexPath.substring(1, indexPath.length))) {
  46. uni.reLaunch({
  47. url: indexPath
  48. })
  49. } else {
  50. uni.navigateBack({
  51. delta: 1
  52. })
  53. }
  54. } else {
  55. uni.reLaunch({
  56. url: indexPath
  57. })
  58. }
  59. }
  60. }
  61. }
  62. </script>
  63. <style lang="scss" scoped>
  64. .nav-index-button {
  65. position: fixed;
  66. animation: suspension 3s ease-in-out infinite;
  67. z-index: 999999;
  68. &__content {
  69. position: absolute;
  70. width: 100rpx;
  71. height: 100rpx;
  72. top: 50%;
  73. left: 50%;
  74. transform: translate(-50%, -50%);
  75. &--icon {
  76. width: 100rpx;
  77. height: 100rpx;
  78. font-size: 60rpx;
  79. border-radius: 50%;
  80. margin-bottom: 18rpx;
  81. position: relative;
  82. z-index: 1;
  83. transform: scale(0.85);
  84. &::after {
  85. content: " ";
  86. position: absolute;
  87. z-index: -1;
  88. width: 100%;
  89. height: 100%;
  90. left: 0;
  91. bottom: 0;
  92. border-radius: inherit;
  93. opacity: 1;
  94. transform: scale(1, 1);
  95. background-size: 100% 100%;
  96. background-image: url(https://resource.tuniaokj.com/images/cool_bg_image/icon_bg6.png);
  97. }
  98. }
  99. }
  100. &__meteor {
  101. position: absolute;
  102. top: 50%;
  103. left: 50%;
  104. width: 100rpx;
  105. height: 100rpx;
  106. transform-style: preserve-3d;
  107. transform: translate(-50%, -50%) rotateY(75deg) rotateZ(10deg);
  108. &__wrapper {
  109. width: 100rpx;
  110. height: 100rpx;
  111. transform-style: preserve-3d;
  112. animation: spin 20s linear infinite;
  113. }
  114. &__item {
  115. position: absolute;
  116. width: 100rpx;
  117. height: 100rpx;
  118. border-radius: 1000rpx;
  119. left: 0;
  120. top: 0;
  121. &--pic {
  122. display: block;
  123. width: 100%;
  124. height: 100%;
  125. background: url(https://resource.tuniaokj.com/images/cool_bg_image/arc3.png) no-repeat center center;
  126. background-size: 100% 100%;
  127. animation: arc 4s linear infinite;
  128. }
  129. }
  130. }
  131. }
  132. @keyframes suspension {
  133. 0%, 100% {
  134. transform: translateY(0);
  135. }
  136. 50% {
  137. transform: translateY(-0.8rem);
  138. }
  139. }
  140. @keyframes spin {
  141. 0% {
  142. transform: rotateX(0deg);
  143. }
  144. 100% {
  145. transform: rotateX(-360deg);
  146. }
  147. }
  148. @keyframes arc {
  149. to {
  150. transform: rotate(360deg);
  151. }
  152. }
  153. </style>