<template>
  <div class="app-container-datav">
    <div
      ref="datavFullscreen"
      class="office-efficiency-index"
      @dblclick="screen"
    >
      <div v-if="!mobile" class="office-header">
        <div class="title-info">{{ $t('pages.datav.title') }}</div>
        <div class="analysis-info">{{ $t('pages.datav.subtitle') }}</div>
      </div>
      <el-row
        v-if="buttonPermissions.includes('datav:query')"
        class="office-content"
      >
        <el-col :xs="24" :sm="6">
          <el-row>
            <el-col>
              <div id="today-pay" class="col-info">
                <div class="title">{{ $t('pages.datav.section.purchaseUsers') }}</div>
                <div class="content">
                  <latest-purchase />
                </div>
              </div>
            </el-col>
            <!-- <el-col>
              <div id="today-pay-tim-chat" class="col-info">
                <div class="content">
                  <latest-purchase-tim-chat />
                </div>
              </div>
            </el-col> -->
          </el-row>
        </el-col>
        <el-col :xs="24" :sm="18">
          <el-row>
            <el-col
              v-if="buttonPermissions.includes('datav:paid:preview')"
              :span="24"
            >
              <div id="online-info" class="col-info">
                <div class="title">{{ $t('pages.datav.section.todayPaymentPreview') }}</div>
                <div class="content">
                  <purchase-count />
                </div>
              </div>
            </el-col>

            <el-col :span="24">
              <div id="online-info-tim-chat" class="col-info">
                <div class="title">{{ $t('pages.datav.section.aslanOnline') }}</div>
                <div class="content">
                  <online-user-count-origin origin="ATYOU" />
                </div>
              </div>
            </el-col>
          </el-row>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
// import OnlineUserMap from './online-user-map'
import LatestPurchase from "./latest-purchase";
// import LatestPurchaseTimChat from './latest-purchase-timchat'
import OnlineUserCountOrigin from "./online-user-count-origin";
import PurchaseCount from "./purchase-count";
import { mapGetters } from "vuex";
import { mobile } from "@/utils/device";
export default {
  name: "DatavContent",
  components: { LatestPurchase, OnlineUserCountOrigin, PurchaseCount },
  data() {
    return {
      mobile: mobile()
    };
  },
  computed: {
    ...mapGetters(["permissionsSysOriginPlatforms", "buttonPermissions"]),
    permissionsSysOriginCode() {
      if (!this.permissionsSysOriginPlatforms) {
        return [];
      }
      return this.permissionsSysOriginPlatforms.map(item => item.value);
    }
  },
  mounted() {},
  methods: {
    screen() {
      const element = this.$refs.datavFullscreen;
      if (this.fullscreen) {
        if (document.exitFullscreen) {
          document.exitFullscreen();
        } else if (document.webkitCancelFullScreen) {
          document.webkitCancelFullScreen();
        } else if (document.mozCancelFullScreen) {
          document.mozCancelFullScreen();
        } else if (document.msExitFullscreen) {
          document.msExitFullscreen();
        }
      } else {
        if (element.requestFullscreen) {
          element.requestFullscreen();
        } else if (element.webkitRequestFullScreen) {
          element.webkitRequestFullScreen();
        } else if (element.mozRequestFullScreen) {
          element.mozRequestFullScreen();
        } else if (element.msRequestFullscreen) {
          // IE11
          element.msRequestFullscreen();
        }
      }
      this.fullscreen = !this.fullscreen;
    }
  }
};
</script>
<style scoped lang="scss">
.app-container-datav {
  overflow: auto;
  min-height: calc(100vh - 50px);
  margin: 18px;

  .office-efficiency-index {
    min-height: calc(100vh - 86px);
    font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Arial, sans-serif;
    background:
      radial-gradient(circle at top right, rgba(254, 178, 25, 0.18), transparent 26%),
      radial-gradient(circle at left top, rgba(255, 147, 38, 0.12), transparent 22%),
      linear-gradient(180deg, var(--brand-primary-pale) 0%, #ffffff 100%);
    background-size: cover;
    padding: 18px;

    /* header styles */
    .office-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      min-height: 72px;
      padding: 0 24px;
      background: linear-gradient(135deg, #fff8ef 0%, #fff1df 100%);
      border: 1px solid rgba(255, 147, 38, 0.2);
      border-radius: 16px;
      box-shadow: 0 12px 28px rgba(148, 84, 19, 0.12);

      .title-info {
        color: var(--brand-text-main);
        text-align: left;
        font-size: 24px;
        font-weight: 700;
        line-height: 1.3;
      }
    }

    .analysis-info {
      line-height: 1.4;
      padding: 8px 14px;
      font-size: 14px;
      font-weight: 600;
      color: #8c5b2a;
      background: #fff9f2;
      border: 1px solid rgba(255, 147, 38, 0.22);
      border-radius: 999px;
    }

    /* data module styles */
    .office-content {
      margin-top: 20px;

      .col-info {
        margin: 0 10px 20px 10px;
        overflow: hidden;
        border-radius: 16px;
        background: rgba(255, 255, 255, 0.94);
        border: 1px solid rgba(255, 147, 38, 0.18);
        box-shadow: 0 14px 32px rgba(148, 84, 19, 0.12);

        .title {
          line-height: 1.35;
          padding: 18px 22px 12px;
          font-size: 18px;
          font-weight: 700;
          color: var(--brand-text-main);
          text-align: left;
          border-bottom: 1px solid rgba(255, 147, 38, 0.12);
        }

        .content {
          vertical-align: middle;
          padding: 14px 16px 18px;
          font-size: 14px;
          color: var(--brand-text-main);
        }
      }

      #today-pay {
        height: 100%;
        overflow: hidden;
      }
      #real-time-charts {
        height: 5.6rem;
      }
      #online-map {
        height: 7.3rem;
        .content {
          padding-top: 0.6rem;
        }
      }
    }
  }
}

@media (max-width: 768px) {
  .app-container-datav {
    margin: 10px;

    .office-efficiency-index {
      padding: 12px;

      .office-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
        padding: 16px;
      }

      .office-content .col-info {
        margin: 0 0 14px 0;
      }
    }
  }
}
</style>
