<template>
<div class="card-wrapper">
  <div class="card-title" :style="`color:${color};background-image:url(${require('@/assets/images/mode4-bg.png')})`">
    <img v-if="icon" :src="icon"/>
    {{title}}
    <img @click="handleClick" class="btn" v-if="btn" :src="require(`@/assets/images/${btn}.png`)"/>
  </div>
  <div class="card-content">
    <slot />
  </div>
</div>
</template>

<script>
export default {
  name: 'Mode4',
  props: {
    icon: {},
    btn: {
      type: String,
    },
    title: {
      type: String,
      default: '标题',
    },
    color: {
      type: String,
    },
  },
  methods: {
    handleClick() {
      if (this.btn == 'map-icon') {
        this.$store.commit('SET_STREETMENU', true)
      } else if (this.btn == 'zj') {
        this.$store.commit('SET_ELEMENTMODAL', true)
      }
    },
  },
}
</script>

<style lang="stylus" scoped>
.card-wrapper
  padding 0 !important
  .card-title
    display flex
    align-items center
    position relative
    color #fff
    font-size 1rem
    font-weight bold
    height 2.4rem
    padding 0 0.5rem
    background-size 90% 70%
    background-position left center
    background-repeat no-repeat
    background-color #063a6f
    >img
      width 1rem
      margin-right 0.5rem
      &.btn
        position absolute
        right 0.5rem
        cursor pointer
  .card-content
    background #052749
    padding 1rem
</style>
