index.vue 4.8 KB

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