index.vue 8.42 KB
<template>
  <div>
    <!-- top -->
    <div class="container top">
      <img :src="fillImgUrl(matchForm.ticketImg)" class="cover_img"/>
      <div class="info">
        <div class="title">{{ matchForm.name }}</div>
        <div class="time">
          {{ languageFormat(language, "时间", "Event Date & Time") }}{{
            matchForm.ticketStart
              ? dayjs(matchForm.ticketStart).format("YYYY.MM.DD")
              : ""
          }}
          {{
            matchForm.ticketStart
              ? getDayName(
                new Date(matchForm.ticketStart),
                language == 1 ? "en-US" : "zh-CN"
              )
              : ""
          }}

          {{
            matchForm.ticketEnd
              ? dayjs(matchForm.ticketEnd).format("YYYY.MM.DD")
              : ""
          }}
          {{
            matchForm.ticketEnd
              ? getDayName(
                new Date(matchForm.ticketEnd),
                language == 1 ? "en-US" : "zh-CN"
              )
              : ""
          }}
        </div>
        <div class="address">
          {{ languageFormat(language, "地址", "Location") }}{{
            matchForm.address
          }}
        </div>
        <!-- 时间 -->
        <div class="select_item_box">
          <div class="label">
            {{ languageFormat(language, "票档", "Tickets") }}
          </div>
          <div class="select_item">
            <div
              v-for="(it, index) in tickClass"
              :key="index"
              :class="[
                it.id == selectForm.latId ? 'tagActive' : 'tag',
              ]"
              @click="select(it)"
            >
              {{ it.name }}
            </div>
          </div>
        </div>
        <!-- 时间 -->
        <div class="select_item_box">
          <div class="label">
            {{ languageFormat(language, "时间", "Event Date & Time") }}
          </div>
          <div class="select_item">
            <div
              v-for="(it, index) in tickList"
              :key="index"
              :class="[
                it.id == selectForm.id ? 'tagActive' : 'tag',
              ]"
              @click="selectTick(it)"
            >
              {{ it.name }}
            </div>
          </div>
        </div>

        <!-- button -->
        <div class="btn forPc" @click="toSelectSeat()">
          {{ languageFormat(language, "添加观影人", "Add Moviegoers") }}
        </div>
      </div>
    </div>

    <div class="container bottom">
      <div class="rich_content" v-html="matchForm.ticketDes"></div>
    </div>
  </div>
</template>


<script setup>
import {ref, reactive, onMounted, watch} from "vue";
import {listApi, getTicketInfoByActivityId, getTicketListApi} from '@/apiPc/booking'

import {dayjs} from "element-plus";
import {ElMessageBox, ElMessage} from "element-plus";
import {languageFormat, getDayName} from "@/viewsPc/seat/utils/language";
import {fillImgUrl} from "/@/utils/ruoyi";
import useUserStore from "/@/store/modules/user";

const useStore = useUserStore()
const language = useStore.language;
const user = useStore.user
const route = useRoute();
const router = useRouter();
const activeId = ref(route.params.activeId)
const props = defineProps({
  activityId: [String, Number],
});

const matchForm = ref({})
const tickClass = ref([])
const selectForm = ref({
  latId: null,
  id: null
})
const tickList = ref([])

// 获取票务信息
getDetail()

async function getDetail() {
  const res = await getTicketInfoByActivityId({activityId: activeId.value})
  matchForm.value = res.data
}

// 根据赛事ID获取票档
getTicketList()

async function getTicketList() {
  const res = await getTicketListApi({activityId: activeId.value})
  tickClass.value = res.rows
  selectForm.value.latId = tickClass.value?.[0]?.id
  await getTicketListType()
}

// 根据票档获取场次
async function getTicketListType() {
  const res = await listApi({latId: selectForm.value.latId})
  tickList.value = res.rows
}

function select(v) {
  selectForm.value.latId = v.id
  getTicketListType()
}

function selectTick(v) {
  selectForm.value.id = v.id
}

function toSelectSeat() {
  if (!selectForm.value.latId) return ElMessage.error(language.value == 0 ? "请选择票档" : 'Please select a ticket file')
  if (!selectForm.value.id) return ElMessage.error(language.value == 0 ? "请选择时间" : 'Please select time')
  console.log(user)
  if (!user) {
    useStore().setVisitor()
    return
  }
  router.push({
    name: 'confirmOrder',
    params: {
      activeId: activeId.value,
      latId: selectForm.value.latId,
      attId: selectForm.value.id
    }
  })
}

</script>


<style lang="scss" scoped>
.forWei {
  display: none
}

.container {
  width: 1200px;
  margin: 0 auto;
  background-color: #fff;
  box-shadow: 0px 0px 46px 0px rgba(1, 16, 64, 0.08);
  border-radius: 8px;
  box-sizing: border-box;
  font-family: SourceHanSansCN, SourceHanSansCN;
  padding-bottom: 20px;
}

.top {
  display: flex;
  padding: 19px;
  margin-top: 26px;

  .cover_img {
    width: 390px;
    height: 517px;
    object-fit: fill;
    margin-right: 36px;
  }

  .info {
    padding-top: 12px;

    .title {
      font-weight: bold;
      font-size: 28px;
      color: #000000;
      line-height: 42px;
      margin-bottom: 34px;
    }

    .time {
      font-weight: 500;
      font-size: 16px;
      color: #4a4a4a;
      line-height: 24px;
      margin-bottom: 16px;
    }

    .address {
      font-weight: 500;
      font-size: 16px;
      color: #4a4a4a;
      line-height: 24px;
      margin-bottom: 33px;
    }

    .select_item_box {
      display: flex;
      margin-bottom: 30px;

      &:last-child {
        margin-bottom: 0;
      }

      .label {
        font-weight: 600;
        font-size: 16px;
        color: #000;
        line-height: 24px;
        margin-right: 12px;
        flex-shrink: 0;
      }

      .select_item {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        user-select: none;

        .tag_t {
          padding: 1px 15px;
          font-weight: 400;
          font-size: 14px;
          color: #493ceb;
          border-radius: 6px;
          border: 1px solid #453dea;
          margin-left: 5px;
        }

        .tag {
          display: flex;
          padding: 12px 18px;
          background: #eeeeee;
          border-radius: 4px;
          border: 1px solid #29343c;
          font-size: 14px;
          color: #4a4a4a;
          cursor: pointer;
        }

        .tagActive {
          display: flex;
          padding: 12px 18px;
          background: #fff;
          border-radius: 4px;
          border: 1px solid #493ceb;
          font-size: 14px;
          color: #493ceb;
          cursor: pointer;
        }

        .tagDisabled {
          padding: 12px 18px;
          background: #878787;
          border-radius: 4px;
          border: 1px solid #29343c;
          font-size: 14px;
          color: #4a4a4a;
          cursor: no-drop;
        }
      }
    }

    .btn {
      width: 175px;
      height: 40px;
      background: linear-gradient(270deg, #493ceb 0%, #8623fc 100%);
      border-radius: 20px;
      line-height: 40px;
      text-align: center;
      font-weight: 500;
      font-size: 16px;
      color: #ffffff;
      cursor: pointer;
    }
  }
}

.bottom {
  padding: 50px;
  margin-top: 30px;
  margin-bottom: 30px;

  .title {
    padding: 20px 30px;
    background: linear-gradient(270deg, #493ceb 0%, #8623fc 100%);
    font-weight: bold;
    font-size: 20px;
    color: #ffffff;
    line-height: 30px;
    margin-bottom: 30px;
  }

  .rich_content {
    margin-top: 30px;
  }
}

@media screen and (max-width: 768px) {
  .container {
    width: 100%;
  }
  .forWei {
    display: block
  }
  .top {
    //transform: scale(0.5);transform-origin: left top;
    .cover_img {
      width: 120px;
      height: 160px;
      margin-right: 15px;
    }

    .info {
      .title {
        font-size: 14px;
      }

      .time, .address, .label, .tip {
        font-size: 12px;
      }

      .title, .time, .address, .tip, .select_item_box {
        margin-bottom: 3px;
      }

      .select_item_box {
        .label {
          font-size: 12px;
        }

        .select_item .tag {
          padding: 2px 10px;
          font-size: 12px;
        }

        .select_item .tagActive {
          padding: 2px 10px;
          font-size: 12px;
        }

        .select_item .tagDisabled {
          padding: 2px 10px;
          font-size: 12px;
        }
      }
    }
  }
  .bottom {
    padding: 0
  }
}
</style>