<template>
  <div class="real-time-price-wrap">
    <div class="tab-warp">
      <el-carousel
        indicator-position="none"
        :autoplay="false"
        :arrow="'always'"
        :height="'120px'"
        :style="{
          '--arrow-left-bg': `url(${arrowRightBg})`,
          '--arrow-right-bg': `url(${arrowLeftBg})`,
        }"
      >
        <el-carousel-item v-for="item in tablist" :key="item">
          <div class="item-warp" :style="{ 'background-image': 'url(' + getAssetsFile('images/early/back2.png') + ')' }">
            <div class="img-wrap">
              <img :src="getAssetsFile('images/early/icon3.png')" />
            </div>

            <div class="name">
              <span class="name-val">{{ item.name }}</span>
            </div>
          </div>
        </el-carousel-item>
      </el-carousel>
    </div>
    <div class="price-list">
      <div
        v-for="(n, index) in pricelist"
        :key="index"
        :style="{
          'background-image': 'url(' + getAssetsFile('images/early/bg5.png') + ')',
          height: 'calc((100% - 50px) /' + 3 + ')',
        }"
        class="data-item"
      >
        <div class="data-warp">
          <div class="small-bg">
            <img :src="getAssetsFile('images/early/back3.png')" />
            <img :src="getAssetsFile('images/early/' + n.icon)" class="img-icon" />
          </div>
          <div class="data-pos">
            <div class="data-pos-center">
              <div class="pos-center">
                <div class="label">
                  <span class="val">{{ n.title }}</span>
                  <span class="unit">{{ n.unit }}</span>
                </div>
                <span class="value">{{ n.value }}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { ref, reactive, onMounted, computed } from 'vue';
import { isEmpty, getAssetsFile } from '@/utils';
let tablist = reactive([
  { name: '西红柿', label: '价格', scr: '' },
  { name: '甘蔗', label: '价格', scr: '' },
  { name: '白菜', label: '价格', scr: '' },
]);

let pricelist = reactive([
  { title: '今日最高价', value: 1.24, unit: '元/kg', icon: 'icon1.png' },
  { title: '今日最低价', value: 0.87, unit: '元/kg', icon: 'icon2.png' },
  { title: '最多价格', value: 1.19, unit: '元/kg', icon: 'icon3.png' },
  { title: '建议售价', value: 1.21, unit: '元/kg', icon: 'icon5.png' },
  { title: '历史最高价', value: 1.36, unit: '元/kg', icon: 'icon6.png' },
  { title: '历史最低价', value: 0.75, unit: '元/kg', icon: 'icon7.png' },
]);

// 动态获取箭头图片路径
const arrowLeftBg = getAssetsFile('images/early/arrowL.png');
const arrowRightBg = getAssetsFile('images/early/arrowR.png');
</script>
<style lang="scss" scoped>
div {
  box-sizing: border-box;
}
.real-time-price-wrap {
  height: 100%;
  width: 100%;
  padding: 10px 0;
  text-align: center;
  ::v-deep() {
    .el-carousel__arrow--left {
      background-image: var(--arrow-left-bg);
      background-size: 100% 100%;
      background-position: left center;
      width: 68px;
      height: 54px;
      i {
        display: none;
      }
    }
    .el-carousel__arrow--right {
      background-image: var(--arrow-right-bg);
      background-size: 100% 100%;
      background-position: left center;
      width: 68px;
      height: 54px;
      i {
        display: none;
      }
    }
  }
  .item-warp {
    width: calc(100% - 136px);
    text-align: center;
    margin: 0 auto;
    background-size: 80% 80%;
    background-position: center 8px;
    height: 100%;
    background-repeat: no-repeat;
    .img-wrap {
      width: 80%;
      height: 80%;
      text-align: center;
      margin-left: 10%;
      img {
        width: 100%;
        height: 100%;
        margin: auto;
      }
    }
    .name {
      width: 100%;
      .name-val {
        font-size: 16px;
        font-weight: bold;
        color: #fff;
      }
    }
  }

  .price-list {
    width: 100%;
    height: calc(100% - 120px);
    padding-top: 10px;
    display: inline-flex;
    justify-content: space-between;
    flex-wrap: wrap;
    .data-item {
      width: calc((100% - 10px) / 2);
      display: inline-flex;
      flex-direction: column;
      justify-content: center;
      background-size: 100% 100%;
      position: relative;
    }
    .data-warp {
      padding: 8px;
      text-align: center;
      z-index: 1;
      display: inline-flex;
      justify-content: center;
      .small-bg,
      .data-pos {
        display: inline-flex;
        vertical-align: middle;
        .data-pos-center {
          display: inline-flex;
          justify-content: space-around;
          flex-direction: column;
          height: 100%;
          .pos-center {
          }
        }
      }
      .small-bg {
        width: 54px;
        height: 54px;
        position: relative;
        .img-icon {
          position: absolute;
          left: 50%;
          top: 50%;
          transform: translate(-50%, -50%);
          width: 38%;
          height: 38%;
        }
      }
      .data-pos {
        width: calc(100% - 54px);
        padding-left: 8px;
        .label,
        .value {
          display: inline-block;
          width: 100%;
        }
        .label {
          color: #fff;
          text-align: left;
          .val {
            font-size: 12px;
          }
          .unit {
            font-size: 10px;
            padding-left: 3px;
          }
          .unit::before {
            content: '(';
          }
          .unit::after {
            content: ')';
          }
        }
        .value {
          color: #6beff9;
          font-size: 16px;
          font-weight: bold;
          margin-top: 6px;
          text-align: left;
        }
      }
    }
  }
}
</style>
