<script setup lang="ts">
import { showConfirm } from '@/components/Toast'
import { ref, computed, onMounted } from 'vue'
import { useUserStore } from '@/stores/user'
import { openPay, getOrderInfo, wxLogin } from '@/api/api'
import { useRoute } from 'vue-router'
import { GetRequest, getWeChatCode, getRemark } from '@/utils/index'
import { ElMessage } from "element-plus";
import { useI18n } from 'vue-i18n'
import { toolsList, serviceList } from './data'
const route = useRoute()
const { locale: language, t } = useI18n()
const tabs = [
  {
    name: t('manage.appProduct.toolsType'),
    id: 'tools'
  },
  {
    name: t('manage.appProduct.serviceType'),
    id: 'service'
  }
]
const activeTab = ref('tools')
const showList = computed(()=> activeTab.value === 'tools' ? toolsList(t) : serviceList(t))

function handleNoneLinkClick () {
  ElMessage.warning(t('manage.unsx'));
}
// const userStore = useUserStore();
// const isEur = userStore.isEur
</script>
<template>
  <div class="appProduct">
    <div class="appProduct-header">
      <ul class="tab-list">
        <li
          v-for="item in tabs"
          :key="item.id"
          @click="activeTab = item.id"
          :class="{ active: activeTab === item.id }"
        >
          {{ item.name }}
        </li>
      </ul>
    </div>
    <div class="appProduct-content">
      <el-row class="app-list" :gutter="20">
        <el-col :span="12" v-for="item in showList" :key="item.name">
          <div class="list-items">
            <div class="app-info">
              <img :src="item.enimg && language == 'en' ? item.enimg : item.img" />
              <div class="app-info-right">
                <h5>{{ item.name }}</h5>
                <div class="channel" v-if="item.channels">
                  <span>{{ $t('manage.appProduct.channel') }}</span>
                  <ul class="channel-list">
                    <li
                      v-for="channel in item.channels"
                      :key="channel.icon"
                      :style="{ 'background-image': `url(${channel.icon})` }"
                    >
                      <img :src="channel.qrCode" style="width: 150px" alt="" />
                    </li>
                  </ul>
                </div>
                <div v-else-if="item.link">
                  <a
                    href="javascript:;"
                    class="use-btn"
                    v-if="item.link === 'none'"
                    @click="handleNoneLinkClick"
                    >{{ $t('manage.appProduct.useBtnText') }}</a
                  >
                  <a
                    v-else
                    class="use-btn"
                    :href="`${item.link}?token=${token}&lang=${language}`"
                    target="_blank"
                    >{{ $t('manage.appProduct.useBtnText') }}</a
                  >
                </div>
              </div>
            </div>
            <p class="app-desc">{{ item.desc }}</p>
          </div>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<style lang="less" scoped>
.appProduct {
  padding: 30px 30px 384px;
  background: #fff;
  .tab-list {
    display: inline-block;
    position: relative;
    height: 40px;
    line-height: 40px;
    margin-bottom: 20px;
    li {
      display: inline-block;
      margin-right: 30px;
      cursor: pointer;
      font-size: 16px;
      line-height: 1.5;
      color: #909090;
      font-weight: 600;
      &:last-child {
        margin-right: 0;
      }
    }
    .active {
      color: #323233;
      &::after {
        content: '';
        display: block;
        width: 40px;
        height: 2px;
        background: #15bec8;
      }
    }
  }
  // .app-list {
  //   display: flex;
  //   flex-wrap: wrap;
  // }
  .list-items {
    width: 448px;
    min-height: 264px;
    // overflow: hidden;
    border: 1px solid #ebebeb;
    padding: 20px;
    margin-bottom: 22px;
    .app-info {
      display: flex;
      border-bottom: 1px solid #ebebeb;
      padding-bottom: 20px;
      & > img {
        width: 90px;
        height: 90px;
      }
    }
    .app-desc {
      font-size: 14px;
      color: #909090;
      padding: 20px 0 0;
      overflow: hidden;
      line-height: 18px;
    }
    .app-info-right {
      padding-left: 20px;
      padding-top: 8px;
      .channel {
        margin-top: 12px;
        display: flex;
        align-items: center;
        & > span {
          font-size: 14px;
          color: #909090;
        }
        & > ul {
          display: flex;
          align-items: center;
          li {
            display: inline-block;
            width: 20px;
            height: 20px;
            background-size: cover;
            background-position: center center;
            margin-left: 10px;
            cursor: pointer;
            position: relative;
            img {
              display: none;
              width: 150px;
              max-width: 150px;
              position: absolute;
              z-index: 1;
              left: 0;
              bottom: -0px;
              transform: translateY(100%);
            }
            &:hover {
              img {
                display: block;
              }
            }
          }
        }
      }
      .use-btn {
        padding: 0 24px;
        height: 32px;
        line-height: 32px;
        background: #15bec8;
        font-size: 14px;
        color: #fff;
        border-radius: 4px;
        display: inline-block;
        margin-top: 10px;
        text-align: center;
        width: 104px;
      }
    }
  }
}
</style>
