<template>
  <view class="pintuandetaillist">
    <view class="list" v-for="(item,j) in pintuanlist" :key="j">
      <view class="left">
        <img :src="item.avatar_url" alt class="user" />
        <view class="username">{{item.uname}}</view>
      </view>
      <view class="right">
        <view class="xq">
          <view class="cha">
            还差
            <text class="number">{{item.hcrs_num}}人</text>拼成
          </view>
         <view class="djs">
            剩余
            <countdown :hour="shijian(item.dqtime)[0] " :minute="shijian(item.dqtime)[1]" :second="shijian(item.dqtime)[2]"></countdown>
          </view>
        </view>
        <view class="btn" @click="cantuan" :data-ptorderid="item.pt_order_id">去参团</view>
      </view>
    </view>
    <!-- <view class="list">
      <view class="left">
        <img src="../../static/img/pintuanuser.png" alt class="user" />
        <view class="username">Awen</view>
      </view>
      <view class="right">
        <view class="xq">
          <view class="cha">
            还差
            <text class="number">3人</text>拼成
          </view>
          <view class="djs">
            剩余
            <countdown hour="1" minute="12" second="40"></countdown>
          </view>
        </view>
        <view class="btn">去参团</view>
      </view>
    </view> -->
  </view>
</template>

<script>
import countdown from "../seckill/countdown";
export default {
  name: "pintuandetaillist",
  components: {
    countdown
  },
  data(){
    return {
      time1:[]
    }
  },
  props:{
    pintuanlist:{
      type:Array
    }
  },
methods:{
     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;
    },
    cantuan(e){
      console.log(e)
      this.$emit("cantuan",true)
      this.$emit("getorderid",e.currentTarget.dataset.ptorderid)
    }
},
  mounted(){
    console.log(this.pintuanlist,7946)
    // for()
  }
};
</script>

<style lang="scss">
.pintuandetaillist {
  // height: 347upx;
  width: 100%;
  background-color: white;
  .list {
    width: 693upx;
    height: 65upx;
    display: flex;
    justify-content: space-between;
    margin: 0 auto;
    margin-bottom: 43upx; 
    .left {
      .user {
        width: 60upx;
        height: 60upx;
        float: left;
      }
      .username {
        color: #999999;
        font-size: 28upx;
        float: left;
        line-height: 45upx;
        text-indent: 18upx;
      }
    }
    .right {
      // width: 327upx;
      height: 65upx;
      display: flex;
      .xq {
        .cha {
          color: #333333;
          font-size: 28upx;
          .number {
            color: #dd3447;
          }
        }
        .djs {
          color: #333333;
          font-size: 22upx;
          display:flex;
        }
      }
      .btn {
        width: 150upx;
        height: 65upx;
        background-color: #db3446;
        color: white;
        line-height: 65upx;
        text-align: center;
        font-size: 28upx;
        margin-left: 25upx;
      }
    }
  }
}
</style>