index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <!-- 悬浮导航按钮 -->
  3. <view :style="colorStyle">
  4. <view style="touch-action: none;">
  5. <view class="home" style="position:fixed;" :style="{ top: top + 'px'}" id="right-nav"
  6. @touchmove.stop.prevent="setTouchMove">
  7. <view class="homeCon bg-color" :class="homeActive === true ? 'on' : ''" v-if="homeActive">
  8. <navigator hover-class='none' open-type="switchTab" url='/pages/index/index'
  9. class='iconfont icon-shouye-xianxing'>
  10. </navigator>
  11. <navigator hover-class='none' open-type="switchTab" url='/pages/order_addcart/order_addcart'
  12. class='iconfont icon-caigou-xianxing'></navigator>
  13. <navigator hover-class='none' open-type="switchTab" url='/pages/user/index'
  14. class='iconfont icon-yonghu1'></navigator>
  15. <slot name="bottom"></slot>
  16. </view>
  17. <view @click="open" class="pictrueBox">
  18. <view class="pictrue">
  19. <image :src="
  20. homeActive === true
  21. ? imgHost + '/statics/images/close.gif'
  22. : imgHost + '/statics/images/open.gif'
  23. " class="image" />
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import {
  32. mapGetters
  33. } from "vuex";
  34. import colors from '@/mixins/color.js';
  35. import {HTTP_REQUEST_URL} from '@/config/app';
  36. export default {
  37. name: "Home",
  38. props: {},
  39. mixins:[colors],
  40. data: function() {
  41. return {
  42. top: "545",
  43. imgHost:HTTP_REQUEST_URL
  44. };
  45. },
  46. computed: mapGetters(["homeActive"]),
  47. methods: {
  48. setTouchMove(e) {
  49. var that = this;
  50. if (e.touches[0].clientY < 545 && e.touches[0].clientY > 66) {
  51. that.top = e.touches[0].clientY
  52. // that.setData({
  53. // top: e.touches[0].clientY
  54. // })
  55. }
  56. },
  57. open: function() {
  58. this.homeActive ?
  59. this.$store.commit("CLOSE_HOME") :
  60. this.$store.commit("OPEN_HOME");
  61. }
  62. },
  63. created() {},
  64. beforeDestroy() {
  65. this.$store.commit("CLOSE_HOME")
  66. }
  67. };
  68. </script>
  69. <style scoped>
  70. .pictrueBox {
  71. width: 130rpx;
  72. height: 120rpx;
  73. }
  74. /*返回主页按钮*/
  75. .home {
  76. position: fixed;
  77. color: white;
  78. text-align: center;
  79. z-index: 9999;
  80. right: 15rpx;
  81. display: flex;
  82. }
  83. .home .homeCon {
  84. border-radius: 50rpx;
  85. opacity: 0;
  86. height: 0;
  87. width: 0;
  88. }
  89. .home .homeCon.on {
  90. opacity: 1;
  91. animation: bounceInRight 0.5s cubic-bezier(0.215, 0.610, 0.355, 1.000);
  92. width: 300rpx;
  93. height: 86rpx;
  94. margin-bottom: 20rpx;
  95. display: flex;
  96. justify-content: center;
  97. align-items: center;
  98. background: var(--view-theme) !important;
  99. border: 1px solid #fff;
  100. }
  101. .home .homeCon .iconfont {
  102. font-size: 48rpx;
  103. color: #fff;
  104. display: inline-block;
  105. margin: 0 auto;
  106. }
  107. .home .pictrue {
  108. width: 86rpx;
  109. height: 86rpx;
  110. border-radius: 50%;
  111. margin: 0 auto;
  112. background-color: var(--view-theme);
  113. border: 1px solid #fff;
  114. }
  115. .home .pictrue .image {
  116. width: 100%;
  117. height: 100%;
  118. border-radius: 50%;
  119. transform: rotate(90deg);
  120. ms-transform: rotate(90deg);
  121. moz-transform: rotate(90deg);
  122. webkit-transform: rotate(90deg);
  123. o-transform: rotate(90deg);
  124. }
  125. </style>