<template>
  <div class="page">
    <div class="page-top">
      <div class="icon-submit-succsss"></div>
      <div class="tip">上传成功</div>
      <template v-if="!isLoading">
        <div class="msg" v-if="uploadedNum === 3">已成功上传<b>3</b>条视频，我们会尽快联系您领取奖品，敬请留意！</div>
        <div class="msg" v-else>
          已成功上传<b>{{ uploadedNum }}</b
          >条视频，再上传<b>{{ unUploadedNum }}</b
          >条视频即可获得 <span>2000元导胶一瓶</span>！
        </div>
      </template>
    </div>
    <div class="btn back" @click="onBack">返回首页</div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  layout: 'app-ross',
  data() {
    return {
      isLoading: true,
      videoList: [],
    }
  },
  computed: {
    ...mapGetters(['routePrefix', 'userInfo', 'authUserId']),
    uploadedNum() {
      return this.videoList.length
    },
    unUploadedNum() {
      return 3 - this.videoList.length
    },
  },
  created() {
    this.fetchVideoList()
  },
  methods: {
    // 获取当前机构已发布的视频列表
    async fetchVideoList() {
      try {
        this.isLoading = true
        if (!this.userInfo) return
        const { clubUserId, mobile } = this.userInfo
        const res = await this.$http.api.fetchOwnerVideoList({
          mobile: mobile,
          clubUserId: clubUserId,
          authUserId: this.authUserId,
        })
        this.videoList = res.data
        this.isLoading = false
      } catch (error) {
        console.log(error)
      }
    },
    // 返回
    onBack() {
      console.log(this.routePrefix)
      const path = `${this.routePrefix}/activity/challenge`
      this.$router.push(path)
    },
  },
}
</script>

<style lang="scss" scoped>
@media screen and (min-width: 768px) {
  .btn.back {
    width: 295px;
    height: 50px;
    background: #f3920d;
    border-radius: 4px 4px 4px 4px;
    opacity: 1;
    color: #fff;
    font-size: 16px;
    text-align: center;
    line-height: 50px;
    margin: 0 auto;
    cursor: pointer;
  }
  .page-top {
    display: flex;
    align-items: center;
    flex-direction: column;
    padding: 150px 0 64px;
    .icon-submit-succsss {
      width: 64px;
      height: 64px;
      background: url(~assets/theme-images/common/pc-icon-submit-success.png) no-repeat center;
      background-size: 64px;
    }

    .tip {
      font-size: 24px;
      font-weight: bold;
      color: #1890ff;
    }

    .msg {
      margin-top: 16px;
      font-size: 16px;

      b {
        margin: 0 2px;
      }

      span {
        color: #f3920d;
        font-weight: bold;
      }
    }
  }

  .page-content {
    width: 694px;
    margin: 0 auto;
    font-size: 14px;
    line-height: 1.8;
    .title {
      color: #666666;
      margin-bottom: 8px;
    }
    .content {
      color: #999999;
      text-align: justify;

      a {
        color: #f3920d;
      }
    }
  }
}

@media screen and (max-width: 768px) {
  .page-top {
    display: flex;
    align-items: center;
    flex-direction: column;
    padding: 20.4vw 0 12.6vw;
    .icon-submit-succsss {
      width: 12vw;
      height: 12vw;
      background: url(~assets/theme-images/common/pc-icon-submit-success.png) no-repeat center;
      background-size: 12vw;
    }

    .tip {
      font-size: 4.2vw;
      font-weight: bold;
      color: #1890ff;
    }

    .msg {
      width: 68.8vw;
      margin: 4vw auto auto;
      font-size: 3.4vw;
      text-align: center;

      span {
        color: #f3920d;
        font-weight: bold;
      }
    }
  }

  .page-content {
    width: 88.4vw;
    margin: 0 auto;
    font-size: 3vw;
    line-height: 2;
    .title {
      color: #666666;
      margin-bottom: 2.4vw;
    }
    .content {
      color: #999999;
      text-align: justify;

      a {
        color: #f3920d;
      }
    }
  }

  .btn {
    width: 85.6vw;
    height: 12vw;
    background: #f3920d;
    border-radius: 0.2vw;
    margin: 0 auto;
    color: #fff;
    text-align: center;
    line-height: 12vw;
    font-size: 3.6vw;
    margin-bottom: 24vw;
  }
}
</style>
