index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <view class="shortcut" :style="{ right: right, bottom: bottom }">
  3. <!-- 首页 -->
  4. <view class="nav-item" :class="[isShow ? 'show_60' : (transparent ? '' : 'hide_60')]" @click="onTargetPage(0)">
  5. <text class="iconfont icon-home"></text>
  6. </view>
  7. <view class="nav-item" :class="[isShow ? 'show_40' : (transparent ? '' : 'hide_40')]" @click="onTargetPage(1)">
  8. <text class="iconfont icon-cate"></text>
  9. </view>
  10. <!-- 个人中心 -->
  11. <view class="nav-item" :class="[isShow ? 'show_20' : (transparent ? '' : 'hide_20')]" @click="onTargetPage(3)">
  12. <text class="iconfont icon-profile"></text>
  13. </view>
  14. <!-- 显示隐藏开关 -->
  15. <view class="nav-item nav-item__switch" :class="{ shortcut_click_show: isShow }" @click="onToggleShow()">
  16. <text class='iconfont icon-daohang'></text>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import { getTabBarLinks } from '@/utils/app'
  22. export default {
  23. /**
  24. * 组件的属性列表
  25. * 用于组件自定义设置
  26. */
  27. props: {
  28. right: {
  29. type: String,
  30. default: '30rpx'
  31. },
  32. bottom: {
  33. type: String,
  34. default: '200rpx'
  35. }
  36. },
  37. data() {
  38. return {
  39. // 弹窗显示控制
  40. isShow: false,
  41. transparent: true
  42. }
  43. },
  44. methods: {
  45. /**
  46. * 导航菜单切换事件
  47. */
  48. onToggleShow() {
  49. const app = this
  50. app.isShow = !app.isShow
  51. app.transparent = false
  52. },
  53. /**
  54. * 导航页面跳转
  55. */
  56. onTargetPage(index = 0) {
  57. const tabLinks = getTabBarLinks()
  58. this.$navTo(tabLinks[index])
  59. }
  60. }
  61. }
  62. </script>
  63. <style lang="scss" scoped>
  64. /* 快捷导航 */
  65. .shortcut {
  66. position: fixed;
  67. right: 24rpx;
  68. bottom: 250rpx;
  69. width: 76rpx;
  70. line-height: 1;
  71. z-index: 5;
  72. border-radius: 50%;
  73. }
  74. /* 导航菜单元素 */
  75. .nav-item {
  76. position: absolute;
  77. bottom: 0;
  78. padding: 0;
  79. width: 76rpx;
  80. height: 76rpx;
  81. line-height: 76rpx;
  82. color: #fff;
  83. background: rgba(0, 0, 0, 0.4);
  84. border-radius: 50%;
  85. text-align: center;
  86. transform: rotate(0deg);
  87. opacity: 0;
  88. }
  89. .nav-item .iconfont {
  90. font-size: 40rpx;
  91. }
  92. /* 导航开关 */
  93. .nav-item__switch {
  94. opacity: 1;
  95. }
  96. .shortcut_click_show {
  97. margin-bottom: 0;
  98. background: #ff5454;
  99. }
  100. /* 显示动画 */
  101. .show_80 {
  102. bottom: 384rpx;
  103. animation: show_80 0.3s forwards;
  104. }
  105. .show_60 {
  106. bottom: 288rpx;
  107. animation: show_60 0.3s forwards;
  108. }
  109. .show_40 {
  110. bottom: 192rpx;
  111. animation: show_40 0.3s forwards;
  112. }
  113. .show_20 {
  114. bottom: 96rpx;
  115. animation: show_20 0.3s forwards;
  116. }
  117. @keyframes show_20 {
  118. from {
  119. bottom: 0;
  120. transform: rotate(0deg);
  121. opacity: 0;
  122. }
  123. to {
  124. bottom: 96rpx;
  125. transform: rotate(360deg);
  126. opacity: 1;
  127. }
  128. }
  129. @keyframes show_40 {
  130. from {
  131. bottom: 0;
  132. transform: rotate(0deg);
  133. opacity: 0;
  134. }
  135. to {
  136. bottom: 192rpx;
  137. transform: rotate(360deg);
  138. opacity: 1;
  139. }
  140. }
  141. @keyframes show_60 {
  142. from {
  143. bottom: 0;
  144. transform: rotate(0deg);
  145. opacity: 0;
  146. }
  147. to {
  148. bottom: 288rpx;
  149. transform: rotate(360deg);
  150. opacity: 1;
  151. }
  152. }
  153. @keyframes show_80 {
  154. from {
  155. bottom: 0;
  156. transform: rotate(0deg);
  157. opacity: 0;
  158. }
  159. to {
  160. bottom: 384rpx;
  161. transform: rotate(360deg);
  162. opacity: 1;
  163. }
  164. }
  165. /* 隐藏动画 */
  166. .hide_80 {
  167. bottom: 0;
  168. animation: hide_80 0.3s;
  169. opacity: 0;
  170. }
  171. .hide_60 {
  172. bottom: 0;
  173. animation: hide_60 0.3s;
  174. opacity: 0;
  175. }
  176. .hide_40 {
  177. bottom: 0;
  178. animation: hide_40 0.3s;
  179. opacity: 0;
  180. }
  181. .hide_20 {
  182. bottom: 0;
  183. animation: hide_20 0.3s;
  184. opacity: 0;
  185. }
  186. @keyframes hide_20 {
  187. from {
  188. bottom: 96rpx;
  189. transform: rotate(360deg);
  190. opacity: 1;
  191. }
  192. to {
  193. bottom: 0;
  194. transform: rotate(0deg);
  195. opacity: 0;
  196. }
  197. }
  198. @keyframes hide_40 {
  199. from {
  200. bottom: 192rpx;
  201. transform: rotate(360deg);
  202. opacity: 1;
  203. }
  204. to {
  205. bottom: 0;
  206. transform: rotate(0deg);
  207. opacity: 0;
  208. }
  209. }
  210. @keyframes hide_60 {
  211. from {
  212. bottom: 288rpx;
  213. transform: rotate(360deg);
  214. opacity: 1;
  215. }
  216. to {
  217. bottom: 0;
  218. transform: rotate(0deg);
  219. opacity: 0;
  220. }
  221. }
  222. @keyframes hide_80 {
  223. from {
  224. bottom: 384rpx;
  225. transform: rotate(360deg);
  226. opacity: 1;
  227. }
  228. to {
  229. bottom: 0;
  230. transform: rotate(0deg);
  231. opacity: 0;
  232. }
  233. }
  234. </style>