index.vue 4.7 KB

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