index.vue 7.61 KB
<template>
  <div class="app-container">
    <!-- 我是 赛事 -->
    <div class="adBanner">
      <img src="/img/banner.jpg">
    </div>
    <div class="kind mt20">

      <div class="box">
        <el-card>
          <ul>
            <li>
              <label>状态:</label>
              <el-radio-group
                v-model="query.progressStatusCode"
                @change="getList"
              >
                <el-radio-button label="-1">全部</el-radio-button>
                <el-radio-button label="2">报名中</el-radio-button>
                <el-radio-button label="4">赛事进行中</el-radio-button>
                <el-radio-button label="3">即将开始</el-radio-button>
                <el-radio-button label="5">已结束</el-radio-button>
              </el-radio-group>
            </li>
            <li>
              <label>时间:</label>
              <el-radio-group v-model="query.month" @change="getList">
                <el-radio-button label="">全部</el-radio-button>
                <el-radio-button v-for="m in monthList" :key="m" :label="m" />
              </el-radio-group>
            </li>
          </ul>
        </el-card>
      </div>

    </div>
    <div class="box">
      <div class="listTitle">
        <h3>赛事列表</h3>
        <div class="search">
          <el-input
            v-model="query.name"
            placeholder="请输入赛事名称查询"
            class="input-with-select" @change="getList"
          >
            <template #append>
              <el-button type="success" round @click="getList">查询</el-button>
            </template>
          </el-input>
        </div>
      </div>

      <el-row :gutter="30" class="pt-20">
        <el-col v-for="n in list" :key="n" :md="8" :sm="12" :xs="24">
          <div class="matchItem" @click="goDetail(n.id)">
            <el-image class="matchCover" :src="n.coverUrl" style="width:100%; height: 190px" fit="contain" />
            <div class="info">
              <h3 class="esp">{{ n.name }}
              </h3>
              <p v-if="n.type == '1'" class="esp">
                <el-icon :size="20">
                  <Checked />
                </el-icon>
                报名时间:{{ n.signBeginTime?.substring(0, 10) }} - {{ n.signEndTime?.substring(0, 10) }}
              </p>
              <p v-if="n.type == '0'" class="esp">
                <el-icon :size="20">
                  <Failed />
                </el-icon>
                报名截止:{{ n.signEndTime.substring(0, 10) }}
              </p>
              <p class="esp">
                <el-icon :size="20">
                  <Flag />
                </el-icon>
                比赛时间:{{ n.beginTime.substring(0, 10) }} - {{ n.endTime.substring(0, 10) }}
              </p>
              <p v-if="n.type == '1'" class="esp">
                <el-icon :size="20">
                  <Opportunity />
                </el-icon>
                分站赛:<span class="text-primary">{{ n.cptsSize }}</span>
              </p>
              <p v-if="n.type == '0'" class="esp">
                <el-icon :size="20">
                  <LocationFilled />
                </el-icon>
                比赛地点:{{ n.address }}
              </p>
              <span v-if="n.type == '0'" class="typeTag blue">独立赛</span>
              <span v-else class="typeTag">联赛</span>
              <div class="mtag">
                <el-button v-if="n.progressStatusCode == 3" round type="warning">即将开始</el-button>
                <el-button v-if="n.progressStatusCode == 2" round type="primary">报名中</el-button>
                <el-button v-if="n.progressStatusCode == 4" round class="goldbtn">赛事进行中</el-button>
                <el-button v-if="n.progressStatusCode == 5" round type="info">已结束</el-button>
                <el-button v-if="n.progressStatusCode == 1" round type="info">报名未开始</el-button>
                <el-button v-if="n.progressStatusCode == 1" round type="info">报名未开始</el-button>
              </div>
            </div>
          </div>
        </el-col>
      </el-row>
      <el-empty v-if="list.length == 0" description="暂无数据" />

      <div v-if="total>18" class="pc-page-box mb20">
        <PaginationPc v-model:page="query.pageNum" v-model:limit="query.pageSize" :total="total" @pagination="getList" />
      </div>
    </div>
  </div>
</template>

<script setup>
import { getCurrentInstance, ref } from 'vue'
import { reactive, onMounted } from '@vue/runtime-core'
import { useRouter } from 'vue-router'
import { dayjs } from 'element-plus'

const router = useRouter()
const { proxy } = getCurrentInstance()
import * as match from '@/apiPc/match'

const typeList = ref([{ label: '全部', id: '0' }])
const list = ref([])
const projectList = ref([])
const monthList = ref([])
const activeName = ref('')
const total = ref(0)
const query = ref({
  projectId: '',
  progressStatusCode: '-1',
  month: '',
  pageNum: 1,
  pageSize: 18
})
onMounted(() => {
  activeName.value = typeList.value[0].id
  getMonthList()
  getList()
})


function getMonthList() {
  // const date = new Date()
  const arr = []
  // 获取年
  let year = dayjs().year()
  // 获取月
  let mon = dayjs().month() - 6
  if (mon < 1) {
    year = year - 1
    mon = 12 + mon
  }
  for (var i = 0; i <= 11; i++) {
    if (++mon > 12) {
      mon = 1
      year++
    }
    if (mon < 10) {
      mon = '0' + mon
    }
    // console.log(year + '-' + mon)
    arr.push(year + '-' + mon)
  }
  monthList.value = arr
}

function getList() {
  match.getMaList(query.value).then((res) => {
    list.value = res.rows
    total.value = res.total
  })
}

function goDetail(id) {
  const routeLocation = router.resolve({
    name: 'matchDetail',
    params: {
      id: id
    }
  })
  window.open(routeLocation.href, '_blank')
}
</script>

<style scoped lang="scss">
.app-container {
  background: #f5f7f9;
  padding: 0;
}

.matchItem {
  padding: 20px;
  cursor: pointer;
  box-shadow: 0px 0px 24px 1px rgba(99, 99, 99, 0.22);
  margin-bottom: 40px;
  min-height: 180px;
  background: #ffffff;
  position: relative;
  border-radius: 10px;

  .el-icon {
    color: rgba(210, 215, 217, 1);
    position: relative;
    top: 4px;
  }

  .el-tag {
    margin-left: 6px;
  }

  :deep(.matchCover) {
    --el-avatar-bg-color: #fff;
  }

  .info {
    p {
      margin: 0 0 5px;
      font-size: 14px;
    }
  }

  .typeTag {
    position: absolute;
    left: 20px;
    bottom: 20px;
    border-radius: 5px;
    padding: 2px 12px;
    background: #ff8124;
    font-size: 14px;
    color: #fff;
  }

  .typeTag.blue {
    background: #00a0e9;
  }

  h3 {
    font-weight: 500;
    font-size: 18px;
    color: #000000;
    margin: 10px 0;
    text-overflow: ellipsis;
  }

  &:hover {
    box-shadow: 0 0 10px 0px #e7e7e7;
  }

  .mtag {
    text-align: right;
    margin-top: 10px;
  }
}

.el-pagination {
  --el-pagination-button-disabled-bg-color: transparent;
  justify-content: center;
  --el-pagination-bg-color: transparent;

}

.kind {
  .el-radio-group{width: 90%;}
  ul {
    list-style: none;

    li {
      margin: 0 0 20px;
      display: flex;padding-bottom: 15px;
      align-items: center;
      border-bottom: 1px solid #e6e6e6;
      & > label {
        width:5em;text-align: right;
        border-left: 4px solid var(--el-color-primary);
      }
      .el-radio-button{width: 90px;text-align: center;margin: 5px}
      &:last-child{border-bottom: none;margin: 0}
    }
  }
}

.listTitle {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.goldbtn {
  color: #fff;
  border: #D5AC5A;
  background: #D5AC5A;
}

.el-button--primary:hover {
  background: var(--el-color-primary)
}
</style>