customerService.vue 2.6 KB

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