index.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <!-- 在线客服 -->
  3. <view v-if="!(params.type === 'chat' && !isMpWeiXin)" class="diy-service"
  4. :style="{ right: `${itemStyle.right}%`, bottom: `${itemStyle.bottom}%` }">
  5. <!-- 拨打电话 -->
  6. <block v-if="params.type === 'phone'">
  7. <view class="service-icon" @click="onMakePhoneCall">
  8. <image class="image" :src="params.image"></image>
  9. </view>
  10. </block>
  11. <!-- 在线聊天 -->
  12. <block v-else-if="params.type == 'chat'">
  13. <button open-type="contact" class="btn-normal">
  14. <view class="service-icon">
  15. <image class="image" :src="params.image"></image>
  16. </view>
  17. </button>
  18. </block>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. /**
  24. * 组件的属性列表
  25. * 用于组件自定义设置
  26. */
  27. props: {
  28. itemStyle: Object,
  29. params: Object
  30. },
  31. /**
  32. * 私有数据,组件的初始数据
  33. * 可用于模版渲染
  34. */
  35. data() {
  36. return {
  37. isMpWeiXin: false,
  38. isShow: true
  39. }
  40. },
  41. created() {
  42. // #ifdef MP-WEIXIN
  43. this.isMpWeiXin = true
  44. // #endif
  45. },
  46. /**
  47. * 组件的方法列表
  48. * 更新属性和数据的方法与更新页面数据的方法类似
  49. */
  50. methods: {
  51. /**
  52. * 点击拨打电话
  53. */
  54. onMakePhoneCall(e) {
  55. uni.makePhoneCall({
  56. phoneNumber: this.params.tel
  57. })
  58. }
  59. }
  60. }
  61. </script>
  62. <style lang="scss" scoped>
  63. /* #ifdef H5 */
  64. uni-page-wrapper {
  65. position: relative;
  66. }
  67. /* #endif */
  68. .diy-service {
  69. position: fixed;
  70. // left: var(--window-left);
  71. // right: var(--window-right);
  72. z-index: 999;
  73. /* #ifdef H5 */
  74. position: absolute;
  75. /* #endif */
  76. .service-icon {
  77. padding: 10rpx;
  78. .image {
  79. display: block;
  80. width: 90rpx;
  81. height: 90rpx;
  82. }
  83. }
  84. }
  85. </style>