<template>
  <div class="shadow" v-if="isFalse">
    <basicPopNew title="立即参与" @closeClick="clickShadow">
      <div class="backOver">
        <div class="waitEvaluationStyle">
          <img
            src="https://img10.360buyimg.com/imgzone/jfs/t1/97127/1/3243/41445/5dde5aa2E0da0f811/70a752086469a4b9.png"
            alt
            class="likeImg"
            v-if="speakShopList.length == 0"
          />
          <div v-else>
            <div class="myOrder">我的订单</div>
            <div
              v-for="(item, index) in speakShopList"
              :key="item.skuId"
              class="skuStyle"
            >
              <div class="skuImgBoxStyle">
                <img :src="item.imgUrl" alt class="skuImgStyle" />
                <div style="text-align: left">
                  <div class="skuNameStyle">{{ item.skuName }}</div>
                  <div class="shopError" v-if="item.status == 3">
                    您的评价不符合参与活动条件
                  </div>
                </div>
              </div>
              <div class="skuBtnStyle" @click="speakNow(item)">
                {{ speakText(item) }}
              </div>
            </div>
          </div>
          <!-- <div class="likeBtn" v-lz-click="'10'" @click="clickShadow">
            为喜欢的买家秀点赞
          </div>
          <div class="gotoShop" v-lz-click="'4'" @click="goToShop">进店逛逛></div> -->
        </div>
        <div class="infoShop">
          <img
            class="infoImg"
            src="https://img10.360buyimg.com/imgzone/jfs/t1/49115/38/16940/3812/5dde5487E24290892/25a440b256ea0b47.png"
            alt
          />
        </div>
        <div class="productList">
          <div
            class="productCont"
            v-for="(item, index) in shopList"
            :key="index"
            v-lz-click="'5'"
            @click="goToBuy(item.skuId)"
          >
            <img :src="item.skuImg" alt="" />
            <div class="shopText">{{ item.skuName }}</div>
            <span class="prize"> </span>
          </div>
        </div>
      </div>
    </basicPopNew>
  </div>
</template>
<script>
import apis1 from "../../../util/apis1.js";
import {
  getJdPingJia,
  goToShopPage,
  goToSkuPage,
} from "../../../util/tools.js";
import {
  PrizeResultPopComService,
  NoPrizeResultPopComService,
} from "../../../util/comCreate";
import basicPopNew from "./basicPopNew.vue";
import bus from "../../../util/bus.js";
let { getGoods, buyersGetMyOrder, buyersDraw } = apis1;
export default {
  props: ["styleData", "keyData", "datas", "isTemplate"],
  components: {
    basicPopNew,
  },
  data() {
    return {
      shopList: [],
      speakShopList: [],
      shopId: 0,
      isFalse: true,
      rotaryShow: true,
      prizeListData: [
        {
          position: 1,
          showImg: "",
          angle: 0,
          prizeName: "谢谢参与",
        },
        {
          position: 2,
          showImg: "",
          angle: 0,
          prizeName: "谢谢参与",
        },
        {
          position: 3,
          showImg: "",
          angle: 0,
          prizeName: "谢谢参与",
        },
        {
          position: 4,
          showImg: "",
          angle: 0,
          prizeName: "谢谢参与",
        },
        {
          position: 5,
          showImg: "",
          angle: 0,
          prizeName: "谢谢参与",
        },
        {
          position: 6,
          showImg: "",
          angle: 0,
          prizeName: "谢谢参与",
        },
        {
          position: 7,
          showImg: "",
          angle: 0,
          prizeName: "谢谢参与",
        },
        {
          position: 8,
          showImg: "",
          angle: 0,
          prizeName: "谢谢参与",
        },
      ],
      prizeResultData: {
        styleData: {},
        datas: {},
        keyData: {
          prizeUrl: "showImg",
          prizeName: "prizeName",
          prizeType: "prizeType",
          priceInfo: "priceInfo",
          discountType: "discountType",
          couponType: "couponType",
        },
      },
    };
  },
  created() {
    this.initData();
    bus.$on("isShow", (content) => {
      console.log(content, 2222222222222);
      this.isFalse = content;
    });
  },
  mounted() {},
  methods: {
    initData() {
      if (this.isTemplate) {
        return;
      } else {
        bus.$on("shopId", (content) => {
          this.shopId = content;
          console.log(content, "shopID");
        });
        document.body.style.overflowY = "hidden";
        var taskType = "11";
        getGoods(taskType, (initdatas) => {
          if (initdatas.data) {
            this.shopList = initdatas.data;
          }
        });
        buyersGetMyOrder((content) => {
          this.speakShopList = content.data;
        });
      }
    },
    goToShop() {
      goToShopPage(this.$store.state.shopId);
    },
    goToBuy(sku) {
      goToSkuPage(sku);
    },
    clickShadow() {
      document.body.style.overflowY = "auto";
      this.isFalse = !this.isFalse;
      this.$emit("isShadow", this.isFalse);
    },
    speakNow(item) {
      console.log(item);
      if (item.status == 0) {
        getJdPingJia();
      } else if (item.status == 2) {
        buyersDraw(item.resultId, (content) => {
          console.log(content);
          if (content.data) {
            this.prizeResultData.datas = content.data;
            PrizeResultPopComService.create(
              this.prizeResultData,
              content.data,
              (submit) => {
                PrizeResultPopComService.close();
                item.status = 1;
              }
            );
          } else {
            console.log("hahha", NoPrizeResultPopComService);
            NoPrizeResultPopComService.create(
              "非常遗憾，您与大奖擦肩而过~",
              "//img10.360buyimg.com/imgzone/jfs/t1/136745/32/20121/48059/5fd996feE56314a28/b952f0e6f3fe811f.png",
              (submit) => {
                NoPrizeResultPopComService.close();
                item.status = 1;
              }
            );
          }
        });
      } else if (item.status == 3) {
        this.toluckDrawPage();
      }
    },
    speakText(item) {
      if (item.status == 0) {
        return "评价";
      } else if (item.status == 1) {
        return "已领奖";
      } else if (item.status == 2) {
        return "点击领奖";
      } else if (item.status == 3) {
        return "查看规则";
      }
    },
    toluckDrawPage() {
      if (this.isTemplate) {
        this.$toast("活动预览，仅供查看");
        return;
      }
      (this.rotaryShow = false), this.publicData.$emit("pingjiaPopFn", true);
    },
  },
};
</script>
<style lang="scss" scoped>
.backOver {
  height: 9rem;
  overflow-y: auto;
}
.hide {
  display: none;
}
.waitEvaluationStyle {
  background: #fff;
  margin: 0.2rem 0.3rem 0;
  padding-bottom: 0.4rem;
  box-sizing: border-box;
  box-sizing: border-box;
  border-radius: 0.2rem;
}
.myOrder {
  height: 0.8rem;
  line-height: 0.8rem;
  font-weight: bolder;
  background: #f2f2f2;
}
.likeBtn {
  width: 6.7rem;
  height: 1rem;
  background: #fd4314;
  font-size: 0.36rem;
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 40px;
  margin: 0.2rem auto 0;
}
.likeImg {
  width: 2.99rem;
  height: 3.3rem;
  display: block;
  margin: 0px auto;
}
.gotoShop {
  font-size: 0.3rem;
  color: rgb(255, 51, 51);
  text-align: center;
  margin: 0.5rem auto 0px;
}
.infoShop {
  width: 100%;
  padding-top: 0.3rem;
  box-sizing: border-box;
  position: relative;
}
.infoImg {
  width: 3.5rem;
  height: 0.31rem;
  display: block;
  margin: 0px auto;
}
.shopError {
  font-size: 0.24rem;
  color: red;
  margin-top: 0.3rem;
  margin-left: 0.3rem;
}
.shopContainer {
  margin-top: 0.2rem;
  display: flex;
  height: 6.2rem;
  overflow-y: scroll;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}
.shopLi {
  width: 49%;
  background: #fff;
  margin-top: 0.15rem;
  text-align: left;
}
.shopText {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 0.24rem;
  color: #333;
  text-align: justify;
  margin: 0.2rem;
}
.itemskuImg {
  width: 100%;
}
.moneytext {
  font-size: 0.36rem;
  color: #f23c3c;
  margin-top: 0.1rem;
  margin-left: 0.1rem;
}
.skuStyle {
  width: 90%;
  height: 2rem;
  margin-left: 0.4rem;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dashed #ccc;
  padding-top: 0.15rem;
}
.skuStyle:nth-last-child(1) {
  border-bottom: none;
}
.skuImgStyle {
  width: 1.5rem;
  height: 1.5rem;
}
.skuImgBoxStyle {
  display: flex;
}
.skuNameStyle {
  font-size: 0.3rem;
  margin-left: 0.3rem;
  margin-top: 0.1rem;
  width: 3rem;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.skuBtnStyle {
  padding: 0 0.2rem;
  text-align: center;
  height: 0.5rem;
  line-height: 0.5rem;
  margin-top: 0.55rem;
  font-size: 0.3rem;
  background: red;
  border-radius: 20px;
  color: white;
}

.productList {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  margin: 0.33rem 0.3rem 0.2rem;
  .productCont {
    width: 3.4rem;
    background: #fff;
    border-radius: 0.2rem;
    overflow: hidden;
    margin-bottom: 0.1rem;
    img{
      max-width: 100% !important;
    }
  }
}
</style>
