customerService.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <!-- 在线客服 -->
  3. <view class="custmer" v-show="!isSortType">
  4. <!-- #ifdef H5 || APP-PLUS -->
  5. <view
  6. class="customerService"
  7. :class="positions ? '' : 'on'"
  8. :style="'top:' + topConfig"
  9. @touchmove.stop.prevent="setTouchMove"
  10. @click="licks"
  11. >
  12. <view class="pictrue">
  13. <image :src="logoConfig"></image>
  14. </view>
  15. </view>
  16. <!-- #endif -->
  17. <!-- #ifdef MP -->
  18. <view
  19. class="customerService"
  20. :class="positions ? '' : 'on'"
  21. :style="'top:' + topConfig"
  22. @touchmove.stop.prevent="setTouchMove"
  23. v-if="routineContact === 0"
  24. @click="licks"
  25. >
  26. <view class="pictrue">
  27. <image :src="logoConfig"></image>
  28. </view>
  29. </view>
  30. <button
  31. class="customerService-sty"
  32. :class="positions ? '' : 'on'"
  33. :style="'top:' + topConfig"
  34. @touchmove.stop.prevent="setTouchMove"
  35. open-type="contact"
  36. v-if="routineContact === 1"
  37. >
  38. <image class="pictrue" :src="logoConfig"></image>
  39. </button>
  40. <!-- #endif -->
  41. </view>
  42. </template>
  43. <script>
  44. import { mapGetters } from "vuex";
  45. import { getCustomer } from "@/utils/index.js";
  46. export default {
  47. name: "customerService",
  48. computed: mapGetters(["userInfo"]),
  49. props: {
  50. dataConfig: {
  51. type: Object,
  52. default: () => {},
  53. },
  54. isSortType: {
  55. type: String | Number,
  56. default: 0,
  57. },
  58. },
  59. data() {
  60. return {
  61. routineContact: parseFloat(this.dataConfig.routine_contact_type),
  62. logoConfig: this.dataConfig.logoConfig.url,
  63. topConfig: this.dataConfig.marginConfig.val
  64. ? this.dataConfig.marginConfig.val >= 80
  65. ? 80 + "%"
  66. : this.dataConfig.marginConfig.val + "%"
  67. : "30%",
  68. positions: this.dataConfig.locationConfig.tabVal,
  69. };
  70. },
  71. created() {},
  72. methods: {
  73. licks() {
  74. if (this.dataConfig.buttonConfig.tabVal) {
  75. getCustomer(`/pages/extension/customer_list/chat`);
  76. } else {
  77. this.$util.JumpPath(this.dataConfig.logoConfig.link);
  78. }
  79. },
  80. setTouchMove(e) {
  81. var that = this;
  82. if (e.touches[0].clientY < 545 && e.touches[0].clientY > 66) {
  83. that.topConfig = e.touches[0].clientY + "px";
  84. }
  85. },
  86. },
  87. };
  88. </script>
  89. <style lang="scss">
  90. .custmer {
  91. touch-action: none;
  92. }
  93. .customerService,
  94. .customerService-sty {
  95. position: fixed;
  96. right: 20rpx;
  97. z-index: 40;
  98. &.on {
  99. left: 20rpx;
  100. }
  101. .pictrue {
  102. width: 86rpx;
  103. height: 86rpx;
  104. border-radius: 50%;
  105. image {
  106. width: 100%;
  107. height: 100%;
  108. border-radius: 50%;
  109. }
  110. }
  111. }
  112. .customerService-sty {
  113. background-color: rgba(0, 0, 0, 0) !important;
  114. }
  115. </style>