<template>
  <layout
    bgImgName="second-reward-img"
    bgColor="#f64d5d"
    bgHeight="188"
    @goBack="goBack"
  >
    <div class="second-reward">
      <div class="second-reward-title">
        请搜索您希望在云机内运行的应用为您安装至云机
      </div>
      <div v-if="!isSelectBool">
        <div class="application">
          <div
            v-for="item in applicationList"
            :key="item"
            @click="toDetails(item)"
          >
            {{ item }}
          </div>
        </div>
      </div>
      <div v-else class="details">
        <img
          :src="`${IMG_URL}/installApps_${+this.imgName + 1}.png`"
          alt=""
          class="details-img"
        />
        <img
          src="@/assets/image/claimCloudPhone/claim-mobile-phone-btn.png"
          class="details-btn"
          @click="toPurchase"
        />
      </div>
    </div>
  </layout>
</template>

<script>
import layout from './components/layout';
export default {
  auth: false,
  name: 'secondReward',
  head: {
    title: '0元购机，尽情享受',
  },
  data() {
    return {
      applicationList: [
        '飞书',
        '钉钉',
        '企业微信',
        '梦幻西游',
        '闲鱼之王',
        '寻道大千',
        '部落冲突',
        '传奇',
        '倩女幽魂',
      ], //  应用数组
      adaptedModels: [1], // 适配机型
      isSelectBool: false,
      imgName: '',
      IMG_URL: process.env.IMG_URL,
    };
  },
  components: { layout },
  methods: {
    toDetails(applicationName) {
      // 埋点
      this.$axios
        .$post('public/v5/User/selects/addApplication', { applicationName })
        .then((res) => {});
      this.imgName = this.applicationList.indexOf(applicationName);
      console.log(this.imgName);
      this.isSelectBool = true;
    },
    goBack() {
      if (this.isSelectBool) return (this.isSelectBool = false);
      this.$router.go(-1);
    },
    toPurchase() {
      localStorage.removeItem('activityPurchaseVisible');
      this.$router.push('/claimCloudPhone/purchase');
    },
  },
};
</script>

<style lang="less" scoped>
.second-reward {
  height: 100%;
  box-sizing: border-box;
  padding-top: 188px;
  .second-reward-title {
    font-family: AlibabaPuHuiTi, AlibabaPuHuiTi;
    font-weight: bold;
    font-size: 15px;
    color: #fefefe;
    line-height: 18px;
    text-align: center;
    font-style: normal;
  }

  .application {
    padding: 0 16px;
    margin-top: 24px;
    display: grid;
    grid-gap: 16px;
    grid-template-columns: repeat(3, 1fr);
    & > div {
      font-family: PingFangSC, PingFang SC;
      font-weight: 400;
      font-size: 14px;
      color: #742428;
      line-height: 20px;
      text-align: center;
      font-style: normal;
      background: #fff1e1;
      border-radius: 14px;
      padding: 11px 0;
    }
  }

  .details {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    .details-img {
      height: 130px;
      width: 100%;
    }

    .details-btn {
      margin-top: 32px;
      height: 56px;
    }
  }
}
//   height: 100%;
//   box-sizing: border-box;
//   background: #f64d5d;
//   .second-reward-container {
//     padding: 12.2666666667vw 0 16px;
//     height: 100%;
//     box-sizing: border-box;
//     background: url('~/assets/image/claimCloudPhone/second-reward-img.png')
//       no-repeat;
//     background-size: 100% 210px;
//     background-position: 0px 12.2666666667vw;
//     & > div {
//       padding-top: 224px;
//       .second-reward-container_title {
//         font-family: AlibabaPuHuiTi, AlibabaPuHuiTi;
//         font-weight: bold;
//         font-size: 16px;
//         color: #fefefe;
//         line-height: 18px;
//         text-align: center;
//         font-style: normal;
//       }

//       .second-reward-container_main {
//         padding: 0 16px;
//         .application {
//           margin-top: 24px;
//           display: grid;
//           grid-gap: 16px;
//           grid-template-columns: repeat(3, 1fr);
//           & > div {
//             font-family: PingFangSC, PingFang SC;
//             font-weight: 400;
//             font-size: 14px;
//             color: #742428;
//             line-height: 20px;
//             text-align: center;
//             font-style: normal;
//             background: #fff1e1;
//             border-radius: 14px;
//             padding: 11px 0;
//           }
//         }

//         .adapted-models {
//           margin-top: 16px;
//           font-family: AlibabaPuHuiTi, AlibabaPuHuiTi;
//           font-size: 14px;
//           color: #891c04;
//           & > div {
//             height: 64px;
//             padding: 16px;
//             box-sizing: border-box;
//             &:first-of-type {
//               background: #fff1e1;
//               border-radius: 12px 12px 0 0;
//               font-weight: bold;
//               line-height: 32px;
//               display: flex;
//               align-items: center;
//               & > img {
//                 height: 32px;
//                 width: 32px;
//                 margin-right: 8px;
//               }
//             }
//             &:last-of-type {
//               background: #fedec0;
//               border-radius: 0 0 12px 12px;
//               font-weight: 400;
//               font-size: 14px;
//               font-style: normal;
//               line-height: 15px;
//             }
//           }
//         }

//         &>img{
//           height: 56px;
//           width: 281px;
//           display: block;
//           margin: 0 auto;
//           margin-top: 32px;
//         }
//       }
//     }
//   }
// }
// ::v-deep .van-nav-bar__arrow {
//   color: #000000;
//   font-size: 24px;
// }

// ::v-deep .van-nav-bar__title {
//   font-weight: bold !important;
//   font-size: 17px !important;
//   color: #0a132b !important;
//   line-height: 24px !important;
// }
</style>
