saleSuccess.vue 6.43 KB
<template>
  <div class="sale">
    <div style="height: 3.75vw"></div>
      <div class="banner">
        <img :src="weChatUrl">
      </div>
    <div>
    <div class="success-block" >
      <p>恭喜领取成功!请尽快使用代金券哦~</p>
      <div class="text-content last" >
        <i class="line" ></i>
        剩余
        <span>{{h}}</span>:
        <span>{{m}}</span>:
        <span>{{s}}</span>
        到期
        <i class="line" ></i>
      </div>
    </div>
      <!--<div class="shop-block" v-for="data in user_goods_list" @click="goToBuy(data);buttonClick('去购买')">-->
        <!--<div class="shop">-->
          <!--<div class="img-block">-->
            <!--<img :src="data.goods_desc.img[0].url">-->
          <!--</div>-->
          <!--<div>-->
            <!--<div class="title">-->
              <!--{{data.name}}-->
            <!--</div>-->
            <!--<div class="content">-->
              <!--{{data.goods_desc.desc}}-->
            <!--</div>-->
            <!--<div class="price">-->
              <!--&gt;>立即购买<<-->
            <!--</div>-->
          <!--</div>-->
        <!--</div>-->
      <!--</div>-->
    </div>


  </div>
</template>

<script>
  import weChatUrl from '../../assets/shop/saleSuccess.png'
  import {getOrderDetailApi,getGoodsDetailApi,getGoodsListApi} from "../../service/api";
  export default {
    name: "saleSuccess",
    data(){
      return {
        invite_code:'',
        weChatUrl:weChatUrl,
        orderNo:this.$route.query.out_trade_no,
        goods_id:'',
        user_goods_list:[],
        h:'',
        m:'',
        s:'',
        deadline:''
      }
    },
    mounted(){
      this.initPage()
    },
    methods:{
      buttonClick(buttonName){
        this.$sa.track('buttonClick',{
          tabTitle:'商品',
          moduleTitle:'优惠券购买成功页',
          buttonType:'功能',
          buttonName:buttonName
        });
      },
      initPage(){
        getOrderDetailApi(this.orderNo).then(res=>{
          this.goods_id = res.goods_id;
          this.invite_code = `CC-${res.invite_type}-${res.invite_id}`;
          if(res.coupon_over_at){
            this.deadline = res.coupon_over_at
            this.leftTimer()
          }
          
          getGoodsDetailApi(this.goods_id).then(res=>{
            let user_goods_id = JSON.parse(res.desc).use_goods_ids;
            getGoodsListApi({goods_ids:user_goods_id}).then(res=>{
              this.user_goods_list = [];
              for(let i = 0; i < res.list.length ; i ++){
                res.list[i].desc = JSON.parse(res.list[i].desc);
                res.list[i].goods_desc = JSON.parse(res.list[i].goods_desc);
                res.list[i].share_desc = JSON.parse(res.list[i].share_desc)
                this.user_goods_list.push(res.list[i])
              }
            });
          })
        })
      },
      goToBuy(data){
        this.$router.push({name:'buyDetail',query:{shopId:data.id,invite_code:this.$route.query.invite_code}})
      },
      leftTimer() {
      let leftTime = new Date(this.deadline.replace(/\-/g, "/")) - new Date(); //计算剩余的毫秒数
      let hours = parseInt(leftTime / 1000 / 60 / 60, 10); //计算剩余的小时
      let minutes = parseInt((leftTime / 1000 / 60) % 60, 10); //计算剩余的分钟
      let seconds = parseInt((leftTime / 1000) % 60, 10); //计算剩余的秒数
      hours = this.checkTime(hours);
      minutes = this.checkTime(minutes);
      seconds = this.checkTime(seconds);
      this.h = hours > 0 ? hours : "00";
      this.m = minutes > 0 ? minutes : "00";
      this.s = seconds > 0 ? seconds : "00";
      window.setTimeout(this.leftTimer, 1000);
      },
      checkTime(i) {
        //将0-9的数字前面加上0,例1变为01
        if (i < 10) {
          i = "0" + i;
        }
        return i;
      }
    }
  }
</script>

<style scoped lang="less">
  @import "../../util/public";
  .sale{
    background: #eeeeee;
    .shop-block{
      background: white;
      .shop{
        padding: 20/7.5vw;
        border-bottom: 1px solid #d8d8d8;
        position: relative;
        &:after{
          content:'';
          display: block;
          clear: both;
        }
        .img-block{
          float: left;
          margin-right: 20/7.5vw;
          img{
            width: 250/7.5vw;
          }
          min-height: 120px;
        }

        .title{
          font-size: 18px;
          overflow: hidden;
          text-overflow:ellipsis;
          white-space: nowrap;
          color: #333333;
          margin-bottom: 5/7.5vw;
        }
        .content{
          font-size: 12px;
          line-height: 1.4em;
          color: #CCCCCC;
          height: 4.2em;
          overflow: hidden;
        }
        .price{
          font-size: 18px;
          color: #FF001F;
          position: absolute;
          right: 20/7.5vw;
          bottom: 20/7.5vw;
        }
      }
    }
    .banner{
      margin: 0 0 10 * @toVw 0;
      background: white;
      padding: 10 * @toVw;
      img{
        width: 100%;
      }
    }
    .success-block {
  // padding: 0 20 * @toVw;
  margin-bottom: 15 * @toVw;
  margin-top: 30 * @toVw;
  position: relative;
  text-align:center;
  // background: #f0f0f0;
  .suc-head {
    padding: 20 * @toVw 0;
    text-align: center;
    border-bottom: 1px solid #d0d0d0;
    .title {
      font-size: 16px;
      color: #333333;
      .red {
        color: #ff001f;
      }
    }
    img {
      width: 40 * @toVw;
      border-radius: 1000px;
      margin: 5 * @toVw;
    }
    .otherIcon {
      width: 40 * @toVw;
      height: 40 * @toVw;
      display: inline-block;
      border-radius: 1000px;
      margin: 5 * @toVw;
      background: #d0d0d0;
    }
  }
  .text-content {
    // position: absolute;
    // bottom: -8px;
    justify-content: center;
    height: 19 * @toVw;
    margin-top: 10 * @toVw;
    line-height: 19 * @toVw;
    background: #f0f0f0;
    display:flex;
    // width: 16em;
    // left: 50%;
    // margin-left: -8em;
    text-align: center;
    font-size: 16px;
    color: #333333;
    .line{
      display:inline-block;
      border-bottom: 1 * @toVw solid #CCCCCC;
      width: 80 * @toVw;
      margin: auto 16 * @toVw;
      }

    &.last {
      font-size: 12px;
      span {
        display: inline-block;
        background: #FF7171;
        width: 1.6em;
        height: 1.6em;
        line-height: 1.6em;
        border-radius: 3px;
        color: white;
        margin: 0 5px;
        font-size: 12px;
      }
    }
  }
}
  }

</style>