<template>
  <div
    :class="
      isDrag
        ? isHard
          ? 'bottom_container drag h_bottom'
          : 'bottom_container drag'
        : isHard
        ? 'bottom_container h_bottom'
        : 'bottom_container'
    "
  >
    <div class="online">
      <img class="img1" :src="A1" alt="" />
      <span class="text1">在线咨询</span>
    </div>
    <div class="phone">
      <div :class="isHard ? 'box hard' : 'box'" @click="toPhone">
        <img class="img3" :src="A2" alt="" />
        <span class="text2">拨打电话</span>
      </div>
    </div>
    <div class="online" @click="addWeChat">
      <img class="img2" :src="A3" alt="" /> <span class="text1">添加微信</span>
    </div>
  </div>
</template>

<script setup>
import A1 from '@/static/img/bottom/kefu.png'
import A2 from '@/static/img/bottom/phone.png'
import A3 from '@/static/img/bottom/wechat.png'
import { useRoute } from 'vue-router'
import { ref, onMounted } from 'vue'
const route = useRoute()
const props = defineProps({
  isDrag: {
    type: Boolean,
  },
})

const addWeChat = () => {
  console.log(window.location)
  const origin = window.location.origin
  const pathname = window.location.pathname
  const p = `${origin}${pathname}#/code`
  window.open(p)
}

const toPhone = () => {
  window.location.href = 'tel:13717892018'
}

const isHard = ref(false)
onMounted(() => {
  if (route.path.indexOf('/hardware') != -1) {
    isHard.value = true
  }
})
</script>

<style lang="scss" scoped>
.bottom_container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: $bottom-height;
  background: #ffa18e;
  z-index: 100;
  display: flex;
  box-sizing: border-box;
  align-items: center;
  justify-content: space-between;
  padding: 0 35px;
  .online {
    display: flex;
    align-items: center;
    white-space: nowrap;
    box-sizing: border-box;
    .img1 {
      width: 14px;
      height: 14px;
      margin-right: 6px;
    }
    .img2 {
      width: 16px;
      height: 13px;
      margin-right: 6px;
    }
    .text1 {
      font-size: 9px;
      font-family: Alibaba PuHuiTi;
      font-weight: 400;
      color: #ffffff;
    }
  }
  .phone {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    .box {
      width: 110px;
      height: $bottom-height;
      background: linear-gradient(90deg, #f98222, #f94622);
      border-radius: 16px;
      display: flex;
      align-items: center;
      .img3 {
        width: 24px;
        height: 24px;
        margin-left: 4px;
        margin-right: 11px;
      }
      .text2 {
        font-size: 13px;
        font-family: Alibaba PuHuiTi;
        font-weight: 500;
        color: #ffffff;
      }
    }
    .hard {
      background: linear-gradient(90deg, #2beec3, #74fddf);
    }
  }
}
.drag {
  opacity: 0.3;
  transition-property: all;
  transition-duration: 0.7s;
  animation-fill-mode: forwards;
}
.h_bottom {
  background: #14e1b4;
}
</style>
