<template>
  <div class="page">
    <div class="page-top"></div>
    <div class="page-content">
      <div class="content">
        <div class="title">赛事活动介绍</div>
        <dl>
          <dt><div>活动介绍</div></dt>
          <dd>
            采美平台和云进通在跨境物流领域达成战略合作，为广大采美客户提供轻松无忧的跨境体验！
          </dd>
          <dt><div>活动时间</div></dt>
          <dd>2022.10月10日——2022.12月31日</dd>
          <dt><div>活动奖励</div></dt>
          <dd>a、一等奖1000元；b、二等奖500元；c、三等奖300元</dd>
          <dt><div>参与方式</div></dt>
          <dd>
            第一步：申请认证和上传相关资料可以登录ROSS官方网站或品牌授权的正品认证通入口申请；第二步：通过手机号码、机构
            名称，注册账号；第三步：通过上传机构门头照片、营业地址等相关信息，进行机构认证；第四步：通过填写设备
            相关名称、图片、相关购买凭证，进行设备认证。完成后登录上传视频且抖音分享成功即可！
          </dd>
          <dt><div>评奖规则</div></dt>
          <dd>
            用户登录商城注册成功后，按在规定的时间内完成点赞数最高的评定等级
          </dd>
          <dt><div>奖项公布</div></dt>
          <dd>用户在规定时间内完成后10个工作日将公布排名以及颁发奖品</dd>
          <dt><div>注意事项</div></dt>
          <dd>一个抖音账号只能参与一次</dd>
        </dl>
      </div>
      <div class="entry">
        <div class="title">活动入口</div>
        <div class="list">
          <div class="cover" @click="toDetail">
            <span class="status" :class="activity.type">
              {{ activity.text }}
            </span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  layout: 'app-asbl',
  data() {
    return {
      activityState: 0,
    }
  },
  computed: {
    ...mapGetters(['routePrefix', 'authUserId']),
    // 活动状态
    activity() {
      const result = {
        2: { type: 'end', text: '已结束' },
        1: { type: 'start', text: '进行中' },
        0: { type: 'wait', text: '未开始' },
      }
      return result[this.activityState]
    },
  },
  created() {
    this.fetchActivityStatus()
  },
  mounted() {
    this.initAppMessageShareData()
  },
  methods: {
    initAppMessageShareData() {
      //  重试次数
      let retryCount = 1
      this.$wxReady((wx) => {
        //需在用户可能点击分享按钮前就先调用
        wx.updateAppMessageShareData({
          title: '认证通', // 分享标题
          desc: '您的好友邀请您一起来参与认证通挑战赛，赢大奖，快来参与吧！', // 分享描述
          link: window.location.href, // 分享链接，该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
          imgUrl: window.location.origin + '/activity.png', // 分享图标
          fail: () => {
            if (retryCount === 0) return
            this.initAppMessageShareData()
            retryCount--
          },
        })
      })
    },

    // 活动详情
    toDetail() {
      const url = `${this.routePrefix}/activity/challenge/list`
      this.$router.push(url)
    },

    // 获取活动状态
    async fetchActivityStatus() {
      try {
        const res = await this.$http.api.fetchActivityStatus({
          authUserId: this.authUserId,
        })
        if (!res.data) return
        this.activityState = res.data.activityState
      } catch (error) {
        console.log(error)
      }
    },
  },
}
</script>

<style lang="scss" scoped>
@media screen and (min-width: 768px) {
  .page {
    padding-bottom: 120px;
    background: #fff;
    .page-top {
      width: 100%;
      height: 530px;
      background: url(~assets/theme-images/asbl/pc-banner-activity.png)
        no-repeat center;
      background-size: auto 530px;
    }

    .page-content {
      width: 872px;
      margin: 0 auto;
      margin-top: 16px;

      .content {
        min-height: 1170px;

        .title {
          font-size: 40px;
          color: #333;
          height: 80px;
          box-sizing: border-box;
          text-align: center;
          margin-bottom: 70px;
          padding-top: 20px;
          font-weight: bold;
          background: url(~assets/theme-images/asbl/pc_activity_title_01.png)
            no-repeat center;
          background-size: auto 80px;
        }

        dl {
          dt {
            font-size: 30px;
            text-align: center;
            margin-bottom: 24px;

            div {
              line-height: 24px;
              display: inline-block;
              border-bottom: 5px;
              border-bottom-color: #ffd7c5;
              border-bottom-style: solid;
            }
          }
          dd {
            font-size: 16px;
            color: #666666;
            text-align: center;
            line-height: 32px;
            margin-bottom: 64px;
          }
        }
      }

      .entry {
        margin-top: 120px;
        .title {
          font-size: 40px;
          color: #333;
          height: 80px;
          box-sizing: border-box;
          text-align: center;
          margin-bottom: 70px;
          padding-top: 20px;
          font-weight: bold;
          background: url(~assets/theme-images/asbl/pc_activity_title_02.png)
            no-repeat center;
          background-size: auto 80px;
        }

        .cover {
          position: relative;
          width: 856px;
          height: 340px;
          margin: 0 auto;
          cursor: pointer;
          background: url(~assets/theme-images/asbl/activity-entry-bg.png)
            no-repeat center;
          background-size: 856px 340px;

          .status {
            position: absolute;
            left: 0;
            top: 0;
            width: 72px;
            height: 32px;
            line-height: 32px;
            border-radius: 8px 0 8px 0;
            color: #fff;
            text-align: center;

            &.wait {
              background: #f94b4b;
            }
            &.start {
              background: #f3920d;
            }
            &.end {
              background: rgba(0, 0, 0, 0.3);
            }
          }
        }
      }
    }
  }
}

@media screen and (max-width: 768px) {
  .page {
    padding-bottom: 10vw;
    .page-top {
      width: 100%;
      height: 100vw;
      background: url(~assets/theme-images/asbl/h5-banner-activity.png)
        no-repeat center;
      background-size: auto 100vw;
    }

    .page-content {
      width: 85.6vw;
      margin: 0 auto;
      margin-top: 3.2vw;

      .content {
        min-height: 116.3vw;
        margin-top: 8vw;

        .title {
          font-size: 5vw;
          color: #333;
          height: 9vw;
          box-sizing: border-box;
          text-align: center;
          margin-bottom: 8vw;
          padding-top: 2.4vw;
          font-weight: bold;
          background: url(~assets/theme-images/asbl/h5_activity_title_01.png)
            no-repeat center;
          background-size: auto 9vw;
        }

        dl {
          dt {
            font-size: 4.8vw;
            text-align: center;
            margin-bottom: 4.8vw;

            div {
              line-height: 3.2vw;
              display: inline-block;
              border-bottom: 0.8vw;
              border-bottom-color: #ffd7c5;
              border-bottom-style: solid;
            }
          }
          dd {
            font-size: 3.4vw;
            color: #666666;
            text-align: center;
            line-height: 5.6vw;
            margin-bottom: 8.8vw;
          }
        }
      }

      .entry {
        margin-top: 15vw;
        .title {
          font-size: 5vw;
          color: #333;
          height: 9vw;
          box-sizing: border-box;
          text-align: center;
          margin-bottom: 8vw;
          padding-top: 2.4vw;
          font-weight: bold;
          background: url(~assets/theme-images/asbl/h5_activity_title_02.png)
            no-repeat center;
          background-size: auto 9vw;
        }

        .cover {
          position: relative;
          width: 85.6vw;
          height: 34vw;
          margin: 0 auto;
          // background: pink;
          cursor: pointer;
          background: url(~assets/theme-images/asbl/activity-entry-bg.png)
            no-repeat center;
          background-size: 85.6vw 34vw;

          .status {
            position: absolute;
            left: 0;
            top: 0;
            width: 12.8vw;
            height: 5.6vw;
            line-height: 5.6vw;
            border-radius: 0.8vw 0 0.8vw 0;
            color: #fff;
            text-align: center;
            font-size: 3vw;

            &.wait {
              background: #f94b4b;
            }
            &.start {
              background: #f3920d;
            }
            &.end {
              background: rgba(0, 0, 0, 0.3);
            }
          }
        }
      }
    }
  }
}
</style>
