<template>
  <van-overlay :show="value" :duration="0.1">
    <div class="repeat-modal modal" @click.stop>
      <!-- <img src="../assets/img/close.png" class="close" @click="$emit('change', false)" /> -->
      <div class="text-box">您已订购，请不要重复订购哦～</div>
      <div class="text-box">
        {{ repeatText }}
      </div>
      <div class="text-box">不要错过！</div>
      <div class="btn-box">
        <div class="btn left" @click="$emit('change', false)">确定</div>
        <div class="btn right" @click="getStrategy">
          去看看
        </div>
      </div>
    </div>
  </van-overlay>
</template>
<script>
import {
  strategyGetID,
  detMainProduct,
  strategytemplate
} from "../api";
export default {
  data () {
    return {
      repeatText: ""
    }
  },
  model: {
    prop: "value",
    event: "change"
  },
  props: {
    value: Boolean
  },
  computed: {
    pageData () {
      return this.$store.state.pageData;
    },
  },
  async created () {
    if (this.pageData.remarks.orderRepeat && this.pageData.remarks.orderRepeat !== null && this.pageData
      .remarks.orderRepeat !== '') {
      if (this.pageData.channl.edition !== 1) {
        let productId = await strategyGetID({
          id: this.pageData.remarks.orderRepeat,
        });
        let res = await detMainProduct({
          productId: productId.data.primaryProductId,
        });
        this.repeatText = res.data.productName
      } else {
        let productId = await strategytemplate(this.pageData.remarks.orderRepeat);
        let res = await detMainProduct({
          productId: productId.data.primaryProductId,
        });
        this.repeatText = res.data.productName
      }

    }

  },
  methods: {
    getStrategy () {
      this.$emit('repeat', this.pageData.remarks.orderRepeat)
    }
  }
};
</script>
<style lang="scss" scoped>
.repeat-modal {
  top: 412px;
  padding: 60px 51px;
  font-size: 30px;
  font-family: Source Han Sans CN;
  font-weight: 400;
  color: #222222;

  .text-box {
    line-height: 48px;
    text-align: center;
  }

  .btn-box {
    display: flex;
    justify-content: space-between;

    .btn {
      width: 190px;
      margin-top: 60px;
      height: 80px;
      line-height: 80px;
      border-radius: 40px;
      font-size: 34px;
      font-weight: bold;
      text-align: center;
    }

    .left {
      border: 2px #fdc51b solid;
      color: #fdc51b;
      background-color: #ffffff;
    }

    .right {
      color: #0d0d0d;
      background: #fdc51b;
    }
  }
}

.modal {
  box-sizing: border-box;
  position: absolute;
  left: 50%;
  top: 333px;
  transform: translateX(-50%);
  width: 520px;
  background-color: #fff;
  border-radius: 8px;
}
</style>