index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <div class="toolBar">
  3. <div class="item">
  4. <el-popover placement="left" width="170" trigger="hover">
  5. <div>
  6. <div style="text-align: center;font-weight:bold;color:#222;" class="text">扫码进入小程序</div>
  7. <img
  8. style="width: 150px; height: 150px"
  9. src="@/assets/xcxqrcode.jpg"
  10. alt=""
  11. />
  12. </div>
  13. <div slot="reference">
  14. <img src="@/assets/qr.png" class="img" alt="" />
  15. <div class="text">手机端</div>
  16. </div>
  17. </el-popover>
  18. </div>
  19. <div class="item" v-if="userInfo" @click="go('/cart')">
  20. <el-badge :value="cartCount || ''">
  21. <i class="img el-icon-shopping-cart-2"></i>
  22. <div class="text">购物车</div>
  23. </el-badge>
  24. </div>
  25. <div class="item">
  26. <el-popover placement="left" width="180" trigger="hover">
  27. <div style="height: 100px; text-align: center">
  28. <img
  29. style="width: 26px; height: 25px; margin-top: 10px"
  30. src="@/assets/phone.png"
  31. alt=""
  32. />
  33. <div
  34. style="
  35. font-size: 16px;
  36. font-family: Microsoft YaHei;
  37. font-weight: bold;
  38. color: #3f8dfd;
  39. line-height: 16px;
  40. "
  41. >
  42. 020-87085982
  43. </div>
  44. <div
  45. style="
  46. font-size: 12px;
  47. font-family: Microsoft YaHei;
  48. font-weight: 400;
  49. color: #999999;
  50. line-height: 24px;
  51. margin-top: 10px;
  52. "
  53. >
  54. 报名电话
  55. </div>
  56. </div>
  57. <div slot="reference">
  58. <img src="@/assets/contact.png" class="img" alt="" />
  59. <div class="text">报名咨询</div>
  60. </div>
  61. </el-popover>
  62. </div>
  63. <div class="item" @click="scollTop">
  64. <img src="@/assets/top.png" class="img" alt="" />
  65. <div class="text">返回顶部</div>
  66. </div>
  67. </div>
  68. </template>
  69. <script>
  70. import { mapGetters, mapMutations } from "vuex";
  71. export default {
  72. name: "ToolBar",
  73. computed: {
  74. ...mapGetters(["userInfo", "cartCount"]),
  75. },
  76. data() {
  77. return {
  78. scrollTimer: null,
  79. };
  80. },
  81. mounted() {
  82. if (this.$tools.isLogin()) {
  83. this.getCartCount();
  84. }
  85. },
  86. methods: {
  87. ...mapMutations(["getCartCount"]),
  88. go(path) {
  89. this.$router.push({
  90. path,
  91. });
  92. },
  93. scollTop() {
  94. clearInterval(this.scrollTimer);
  95. this.scrollTimer = setInterval(() => {
  96. const top = document.documentElement.scrollTop;
  97. const speed = top / 10;
  98. if (document.documentElement.scrollTop !== 0) {
  99. document.documentElement.scrollTop -= speed;
  100. } else {
  101. clearInterval(this.scrollTimer);
  102. }
  103. }, 16);
  104. },
  105. },
  106. };
  107. </script>
  108. <!-- Add "scoped" attribute to limit CSS to this component only -->
  109. <style scoped lang="scss">
  110. .toolBar {
  111. border: 1px solid #eeeeee;
  112. box-shadow: 0px 3px 6px 0px rgba(213, 218, 224, 0.8);
  113. border-radius: 10px;
  114. padding: 4px;
  115. position: fixed;
  116. right: 0;
  117. top: 380px;
  118. background: #fff;
  119. display: flex;
  120. flex-direction: column;
  121. z-index: 9999;
  122. .item {
  123. cursor: pointer;
  124. width: 56px;
  125. height: 80px;
  126. border-bottom: 1px solid #eeeeee;
  127. display: flex;
  128. flex-direction: column;
  129. align-items: center;
  130. justify-content: center;
  131. color: #3f8dfd;
  132. position: relative;
  133. &:nth-last-of-type(1) {
  134. border: 0;
  135. }
  136. .img {
  137. width: 24px;
  138. font-size: 24px;
  139. height: 24px;
  140. display: block;
  141. margin: 0 auto 5px;
  142. }
  143. .text {
  144. text-align: center;
  145. word-break: break-all;
  146. font-size: 12px;
  147. font-family: Microsoft YaHei;
  148. font-weight: 400;
  149. color: #999999;
  150. line-height: 16px;
  151. }
  152. .blue {
  153. font-weight: bold;
  154. font-size: 14px;
  155. color: #3f8dfd;
  156. }
  157. .el-badge {
  158. text-align: center;
  159. }
  160. }
  161. }
  162. </style>