<template>
  <view class="seckill">
    <view class="top">
      <seckillTop :list="list" :cutime="cupage"></seckillTop>
    </view>

    <swiper
      class="swiper"
      :indicator-dots="indicatorDots"
      :autoplay="autoplay"
      :interval="interval"
      :duration="duration"
      @change="aa"
    >
      <swiper-item class="item" v-for="(i,j) in list" :key="j">
        <view class="ads">
          <view class="ad" @click="toaddetail">
            <seckillAd :picurl="ad1"></seckillAd>
          </view>
          <view class="ad" @click="toaddetail1">
            <seckillAd :picurl="ad2"></seckillAd>
          </view>
        </view>
        <view class="tittle">
          <seckillTittle :show="j" :date="i.jieshushijian"></seckillTittle>
        </view>
        <view class="shop" v-for="(i,k) in i.goods_list" :key="k" @click="todetail" :data-id="i.goods_ms_id">
          <seckillShop
            :imgurl="i.imgpaththumb"
            :shopname="i.goods_name"
            :shopdesc="goods_ms"
            tag=""
            :price="i.price"
            :huaxian="i.price_y"
            :sale="i.yp_kp_bfb"
            :show="j"
          ></seckillShop>
        </view>
      </swiper-item>

      <!-- <swiper-item class="item">
        <view class="ads">
          <view class="ad">
            <seckillAd picurl="../../static/img/seckillad1.png"></seckillAd>
          </view>
          <view class="ad">
            <seckillAd picurl="../../static/img/seckillad2.png"></seckillAd>
          </view>
        </view>
        <view class="tittle">
          <seckillTittle></seckillTittle>
        </view>
        <view class="shop">
          <seckillShop
            imgurl="../../static/img/seckillshop.png"
            shopname="【小米生态链】70迈智能胎压检测仪···"
            shopdesc="小米生态链新成员 太阳能无线 胎压胎温同显"
            tag="包安装"
            price="465.23"
            huaxian="652.45"
            sale="40%"
          ></seckillShop>
          <seckillShop
            imgurl="../../static/img/seckillshop.png"
            shopname="【小米生态链】70迈智能胎压检测仪···"
            shopdesc="小米生态链新成员 太阳能无线 胎压胎温同显"
            tag="包安装"
            price="465.23"
            huaxian="652.45"
            sale="40%"
          ></seckillShop>
        </view>
      </swiper-item>-->
    </swiper>
  </view>
</template>

<script>
import seckillceshi from "../../components/seckill/seckillceshi";
import seckillTop from "../../components/seckill/seckillTop";
import seckillAd from "../../components/seckill/seckillad";
import seckillTittle from "../../components/seckill/seckilltittle";
import seckillShop from "../../components/seckill/seckillshop";
import {requestP} from "../../static/js/request"
export default {
  data() {
    return {
      cupage: 0,
      list:[],
      ad1:"",
      ad2:"",
      adid:0,
      adid1:0
    };
  },
  components: {
    seckillceshi,
    seckillTop,
    seckillAd,
    seckillTittle,
    seckillShop
  },
  methods: {
    toaddetail(e){
      console.log(this.adid)
      uni.navigateTo({
        url:"/pages/seckilldetail/seckilldetail?msid="+this.adid
      })
    },
      toaddetail1(e){
      console.log(this.adid1)
      uni.navigateTo({
        url:"/pages/seckilldetail/seckilldetail?msid="+this.adid
      })
    },
    aa(e) {
      console.log(e);
      this.cupage = e.detail.current;
    },
    todetail(e){
      console.log(e.currentTarget.dataset.id)
      uni.navigateTo({
        url:"/pages/seckilldetail/seckilldetail?msid="+e.currentTarget.dataset.id
      })
    },
    shijian(completeTime) {
      console.log(completeTime)
          var stime = Date.parse(new Date());
          var etime = Date.parse(new Date(completeTime));
          console.log(stime,etime)
          // 两个时间戳相差的毫秒数
          var usedTime = etime - stime;
          // 计算相差的天数  
          // var days = Math.floor(usedTime / (24 * 3600 * 1000));
          // 计算天数后剩余的毫秒数
          var leave1 = usedTime % (24 * 3600 * 1000);  
          // 计算出小时数  
          var hours = Math.floor(usedTime / (3600 * 1000));
          // 计算小时数后剩余的毫秒数
          var leave2 = leave1 % (3600 * 1000);        
          // 计算相差分钟数
          var minutes = Math.floor(leave2 / (60 * 1000));
          var leave3 = leave2 % (60 * 1000)
           var s = Math.floor(leave3 / (1000));
          var time = [hours,minutes,s];
          console.log(time)
          return time;
    }
  },
  onLoad(){
    requestP({
      url:"Miaosha/get_list_miaosha"
    }).then((res)=>{
      // for(let i in res.data.data){
        res.data.data[0].jieshushijian = this.shijian(res.data.data[0].ms_endtime)
      // }
      console.log(res.data.data)
      this.list = res.data.data
      this.adlist=res.data
      this.ad1=res.data.guanggao_img1[0].imgpath
      this.ad2=res.data.guanggao_img2[0].imgpath
      this.adid=res.data.guanggao_img1[0].ms_goods_id
      this.adid1=res.data.guanggao_img2[0].ms_goods_id
      console.log(res.data.guanggao_img1[0].ms_goods_id,"loijhnkolsdhvb")
    })
  }
};
</script>

<style lang="scss">
.seckill {
  width: 750upx;
  .top {
    width: 100%;
    position: absolute;
    z-index: -1;
  }
  .ads {
    display: flex;
    justify-content: center;
    position: absolute;
    top: 15upx;
    left: 23upx;
    z-index: 999;
    .ad {
      margin-right: 14upx;
      height: 165upx;
    }
  }
  .tittle {
    position: relative;
    bottom: -218upx;
    left: 25upx;
  }

  .swiper {
    position: relative;
    top: 155upx;
    height: 100vh;
    .item {
      position: absolute;
      z-index: 999;
      .shop {
        position: relative;
        z-index: 999;
        top: 223upx;
      }
    }
  }
}
</style>