Home.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <div style="touch-action: none;">
  3. <div
  4. class="home"
  5. :style="{ top: top + 'px', bottom: bottom }"
  6. style="position:fixed;"
  7. id="right-nav"
  8. @touchmove="touchmove($event)"
  9. >
  10. <div
  11. class="homeCon bg-color-red"
  12. :class="homeActive === true ? 'on' : ''"
  13. v-if="homeActive"
  14. >
  15. <router-link
  16. :to="'/'"
  17. class="iconfont icon-shouye-xianxing"
  18. ></router-link>
  19. <router-link
  20. :to="'/cart'"
  21. class="iconfont icon-caigou-xianxing"
  22. ></router-link>
  23. <router-link :to="'/user'" class="iconfont icon-yonghu1"></router-link>
  24. </div>
  25. <div @click="open" class="pictrueBox">
  26. <div class="pictrue">
  27. <img
  28. :src="
  29. homeActive === true
  30. ? require('../assets/images/close.gif')
  31. : require('../assets/images/open.gif')
  32. "
  33. class="image"
  34. />
  35. </div>
  36. </div>
  37. </div>
  38. </div>
  39. </template>
  40. <script>
  41. import { mapGetters } from "vuex";
  42. export default {
  43. name: "Home",
  44. props: {},
  45. data: function() {
  46. return {
  47. top: "",
  48. bottom: ""
  49. };
  50. },
  51. computed: mapGetters(["homeActive"]),
  52. methods: {
  53. touchmove(event) {
  54. this.bottom = "auto";
  55. event.preventDefault();
  56. let top =
  57. event.touches[0].pageY -
  58. (document.documentElement.scrollTop || document.body.scrollTop) -
  59. this.$el.clientHeight;
  60. if (top > document.body.clientHeight - 150) {
  61. top = document.body.clientHeight - 150;
  62. } else if (top < 55) top = 55;
  63. this.top = top;
  64. },
  65. open: function() {
  66. this.homeActive
  67. ? this.$store.commit("CLOSE_HOME")
  68. : this.$store.commit("OPEN_HOME");
  69. }
  70. },
  71. created() {
  72. this.bottom = "50px";
  73. }
  74. };
  75. </script>
  76. <style scoped>
  77. .pictrueBox {
  78. width: 1.3rem;
  79. height: 1.2rem;
  80. }
  81. </style>