<template>
  <div>
    <div class="container">
      <div
        class="list-content"
        v-for="(piece, i) in nftList"
        @click="showTip(piece)"
        :key="i"
      >
        <!-- <div class="no-sale">
          <img
            width="205px"
            src="../../../assets/market/hero/no-sale.png"
            alt=""
          />
        </div> -->
        <div class="chip-bg">
          <img
            v-if="piece.c_id"
            width="125px"
            :src="require('@/assets/market/piece/' + piece.c_id + '.png')"
            alt=""
          />
          <img
            v-else
            width="125px"
            :src="
              require('@/assets/market/piece/' + piece.detail.item_id + '.png')
            "
            alt=""
          />
          <span class="amount"
            >Amount：{{
              piece.balance ? piece.balance : piece.detail.balance
            }}</span
          >
        </div>
        <div class="level-content">
          <!-- <div class="level-lv">
          Lv <span class="level-number">{{ piece.level }}</span>
        </div> -->
          <div class="tree-guard">
            {{ piece.c_name ? piece.c_name : "Tree guard" }}
          </div>
        </div>
        <div class="lease-listing" v-if="isType == 'mynft'">
          <div class="rent"></div>
          <div class="sell">Sell</div>
        </div>
        <div class="price-content" v-else>
          <div class="price-left">
            <div>
              <img
                width="32px"
                src="../../../assets/market/chip/t-icon.png"
                alt=""
              />
            </div>

            <div class="price">{{ piece.s_price ? piece.s_price : " " }}</div>
          </div>
          <div class="buy">
            <img
              width="78px"
              src="../../../assets/market/chip/buy.png"
              alt=""
            />
          </div>
        </div>
      </div>
    </div>
    <Piecedialog
      ref="dialog"
      @closeTip="closeTip"
      @showTip="showTip"
      :isType="isType"
      :isShow="isShow"
      :isPiecePut="isPiecePut"
      :isBuy="isBuy"
      @handBuyShow="handBuyShow"
      @handBuyHide="handBuyHide"
      @handPutShow="handPutShow"
      @handPutHide="handPutHide"
    ></Piecedialog>
    <TheSell
      :type="type"
      :isPiecePut="isPiecePut"
      @handMessage="handMessage"
      @handPutShow="handPutShow"
      @handPutHide="handPutHide"
    />
    <!-- <TheBuy
      :type="type"
      :isBuy="isBuy"
      @handBuyShow="handBuyShow"
      @handBuyHide="handBuyHide"
    >
    </TheBuy> -->
    <!-- <WeaponBuyDialog
      :type="type"
      :isBuy="isBuy"
      @handBuyShow="handBuyShow"
      @handBuyHide="handBuyHide"
    ></WeaponBuyDialog> -->
    <ChipBuyDialog
      :type="type"
      :isBuy="isBuy"
      @handBuyShow="handBuyShow"
      @handBuyHide="handBuyHide"
    ></ChipBuyDialog>
    <MessageBox ref="message"></MessageBox>
  </div>
</template>

<script>
import Piecedialog from "../Piecedialog.vue";
import TheSell from "../TheSellDialog.vue";
import ChipBuyDialog from "../ChipBuyDialog.vue";
import MessageBox from "../MessageBox.vue";
import WeaponBuyDialog from "../WeaponBuyDialog.vue";
export default {
  props: ["isType", "nftList"],
  components: {
    Piecedialog,
    TheSell,
    WeaponBuyDialog,
    ChipBuyDialog,
    MessageBox,
  },
  data() {
    return {
      isShow: false,
      type: "piece",
      isPiecePut: false,
      isBuy: false,
      pieceList: [
        {
          chipid: "01",
          price: 9999,
        },
        {
          chipid: "02",
          price: 9999,
        },
        {
          chipid: "03",
          price: 9999,
        },
        {
          chipid: "04",
          price: 9999,
        },
        {
          chipid: "05",
          price: 9999,
        },
        {
          chipid: "06",
          price: 9999,
        },
      ],
    };
  },
  methods: {
    closeTip(hide) {
      this.isShow = hide;
    },
    showTip(data) {
      this.isShow = true;
      console.log("=-=-=-=-fsdfdsfsdf", this.isShow);
      this.$nextTick(() => {
        //这里的dialog与上面dialog-component组件里面的ref属性值是一致的
        //init调用的是dialog-component组件里面的init方法
        //data是传递给弹窗页面的值
        this.$refs.dialog.init(data);
      });
    },
    handPutShow() {
      this.isPiecePut = true;
      console.log("");
    },

    handPutHide() {
      this.isPiecePut = false;
    },
    handBuyShow() {
      this.isBuy = true;
    },
    handBuyHide() {
      this.isBuy = false;
    },
    handMessage() {
      this.$nextTick(() => {
        //这里的dialog与上面dialog-component组件里面的ref属性值是一致的
        //init调用的是dialog-component组件里面的init方法
        //data是传递给弹窗页面的值
        this.$refs.message.open(1);
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.container {
  display: flex;
  width: 1406px;
  cursor: pointer;
  flex-direction: row;
  margin-top: 43px;
  margin-left: 54px;
  align-items: center;
  flex-wrap: wrap;
}
.list-content {
  display: flex;
  flex-direction: column;
  position: relative;
  margin-right: 23px;
  width: 216px;
  padding-top: 23px;
  padding-left: 17px;
  padding-right: 17px;
  margin-bottom: 20px;
  height: 277px;
  background: url("../../../assets/market/piece/bg.png") no-repeat;
  .no-sale {
    position: absolute;
    left: 0;
    top: 0;
    width: 242px;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 292px;
    background: #3c3c3c;
    border: 4px solid #cdd8fd;
    opacity: 0.8;
    border-radius: 16px;
  }
}
.price-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-right: 32px;
}
.level-number {
  font-size: 29px;
  // font-family: 'MEurostile';
  font-weight: 400;
  font-style: italic;
  color: #454545;
}
.level-lv {
  font-size: 25px;
  // font-family: 'MEurostile';
  font-weight: 400;
  font-style: italic;
  color: #454545;
}
.price {
  font-size: 26px;
  font-family: "Arciform";
  font-weight: 400;
  margin-left: 7px;
  color: #454545;
}
.price-left {
  display: flex;
}
.buy {
  cursor: pointer;
  margin-left: 13px;
}

.level-content {
  display: flex;
  justify-content: center;
  margin-top: 5px;

  .level-img {
    display: flex;
  }

  .level-levelList {
    display: flex;
    margin-left: 14px;
  }
  .item-Image {
    margin-left: 6px;
    display: flex;
  }
}
.chip-bg {
  width: 216px;
  height: 182px;
  display: flex;
  position: relative;
  justify-content: center;
  align-items: center;
  line-height: 182px;
  background: url("../../../assets/market/piece/bg-there.png") no-repeat;
  background-size: 100% 100%;
  .amount {
    position: absolute;
    right: 11px;
    bottom: -78px;
  }
}
.tree-guard {
  font-size: 21px;
  font-family: "OPPOSans";
  margin-bottom: 10px;
  font-weight: normal;
  color: #454545;
}
.lease-listing {
  display: flex;
  justify-content: center;
  align-items: center;
  // margin-top: 11px;
  font-size: 24px;
  .rent {
    width: 97px;
    height: 40px;
    // text-align: center;
    // line-height: 40px;
    // color: #fff;
    // background: url("../../../assets/market/hero/rent-btn.png") no-repeat;
    // background-size: contain;
  }
  .sell {
    width: 97px;
    height: 40px;
    color: #fff;
    text-align: center;
    margin-left: 14px;
    line-height: 40px;
    background: url("../../../assets/market/hero/sell-btn.png") no-repeat;
    background-size: contain;
  }
}
</style>
<style></style>
