index.vue 10.6 KB
<template>
  <div class="main">
    <van-tabs v-model="active" @click="tabClick" class="card-tab">
      <van-tab :title="item.name" v-for="(item,index) in tabStatus" :key="index"></van-tab>
    </van-tabs>
        <div class="card-list" v-if="cardList.length != 0">
          <div class="card-list-item" v-for="(item,index) in cardList" :key="index">
            <template v-if="item.appearance == 1">
              <div class="card-img">
                <div class="card-l-panel">
                  <div class="card-l-title">{{ item.brandName }}</div>
                  <div class="card-l-price">{{ item.officePrice }}元券</div>
                  <div class="card-l-number">X{{ item.goodsQuality }}</div>
                </div>
              </div>
              <div class="card-desc">
                <div class="card-num">¥{{ item.orderPrices }}</div>
                <div class="card-name">
                  <span>{{ item.productName }}</span>
                  <template v-for="(i,key) in cardStatus">
                    <span :class="`color-${key+1}`" v-if="i.value == item.orderStatus" :key="key">{{ i.name }}</span>
                  </template>
                </div>
                <div class="card-time">
                  保质期至{{item.warrantyDate}}
                </div>
                <div class="card-operation">
                  <span @click="jumpDetail(item.orderCode)" v-if="item.orderStatus != 6">查看卡券</span>
                  <span @click="handleConfirm(item.orderCode)" v-if="item.orderStatus == 3">确认收货</span>
                  <span @click="jumpSales(item)" v-if="item.orderStatus == 1 || item.orderStatus == 2">售后</span>
                  <span @click="jumpSalesDetail(item)" v-if="item.orderStatus == 3 || item.orderStatus ==  4 || item.orderStatus == 6">售后详情</span>
                </div>
              </div>
            </template>
            <template v-if="item.appearance == 2">
              <div class="card-img">
                <div class="card-l-panel">
                  <div class="card-l-title">{{ item.brandName }}</div>
                  <div class="card-l-price">{{ item.productName }}</div>
                  <div class="card-l-number">{{ item.denomination }}</div>
                </div>
              </div>
              <div class="card-desc">
                <div class="card-num">¥{{ item.orderPrices }}</div>
                <div class="card-name">
                  <span>{{ item.productName }}</span>
                  <template v-for="(i,key) in cardStatus">
                    <span :class="`color-${key}`" v-if="i.value == item.orderStatus" :key="key">{{ i.name }}</span>
                  </template>
                </div>
                <div class="card-time card-time-2" v-if="item.appearance == 2">
                  充值账号{{item.rechargeNumber}}
                </div>
                <div class="card-type" v-if="item.appearance == 2">
                  <p>购买日期 {{ item.orderDate }}</p>
                  <p>订单编号  {{item.orderCode}}</p>
                </div>
              </div>
            </template>
          </div>
        </div>
      <div class="van-empty" v-if="cardList.length == 0">
        <div class="van-empty__image">
          <img src="@a/images/Coupon.png">
        </div>
        <p class="van-empty-description">暂无可用优惠券</p>
      </div>
  </div>
</template>

<script type='text/ecmascript-6'>
import {cardRoll} from "@r/api";
const cardStatus =  [{
  value: 0,
  name: '未支付',
},{
  value: 1,
  name: '已支付'
},{
  value: 2,
  name: '已发货'
},{
  value: 3,
  name: '已完成'
},{
  value: 4,
  name: '售后中'
},{
  value: 5,
  name: '退款失败'
},{
  value: 6,
  name: '已退款'
}]
const tabStatus =  [{
  value: 0,
  name: '全部',
},{
  value: 1,
  name: '待收货'
},{
  value: 2,
  name: '已完成'
},{
  value: 3,
  name: '已退款'
},{
  value: 4,
  name: '售后'
}]
export default {
  name: "index",
  data() {
    return {
      pageIndex: 1,
      statusIndex: 0,
      status: false,
      cardList: [],
      cardListStart: [],
      active: 0,
      list: [],
      loading: false,
      finished: false,
      isLoading: false,
      immediateCheck: false,
      finishedText: '没有更多了...',
      offset: 280,
      tabStatus,
      sessionId: JSON.parse(sessionStorage.getItem('GL_EQUITY_USER_INFO')),
      cardStatus
    }
  },
  mounted() {
    this.getCardList();
  },
  methods: {
    getCardList(e) {
      let {appearance} = this.$route.query;
      let {sessionId} = JSON.parse(sessionStorage.getItem('GL_EQUITY_USER_INFO'));
      this.showLoading();
      let para = {
        sessionId,
        appearance,
        ...e
      };
      cardRoll.getCardList(para).then(res => {
        this.hideLoading()
        let { code, data, message } = res
        if (code == 0) {
          this.cardList = data?data:[];
        } else {
          this.showToast(message)
        }
      })
    },
    //切换tab
    tabClick(name) {
      let params = {};
      switch(name)
      {
        case 0:
          params = {}
          break;
        case 1:
          params = {
            'statusList[0]': 1,
            'statusList[1]': 2,
          }
          break
        case 2:
          params = {
            'statusList[0]': 2,
            'statusList[1]': 3,
            'statusList[2]': 4,
          }
          break;
        case 3:
          params = {
            'statusList[0]': 5,
            'statusList[1]': 6,
          }
          break;
        case 4:
          params = {
            'statusList[0]': 4,
          }
          break;
      }
      this.getCardList(params)
    },
    //确认收货
    handleConfirm(val) {
      this.dialog({
        title: '提示',
        message: '是否确认收货',
        })
        .then(() => {
          this.showLoading();
          let para = {
            sessionId: this.sessionId,
            orderCode: val
          };
          cardRoll.getCardConfirm(para).then(res => {
            this.hideLoading()
            let { code, message } = res
            if (code == 0) {
              this.getCardList();
            } else {
              this.showToast(message)
            }
          })
        })
        .catch(() => {
          this.showToast('取消成功')
        });
    },
    //刷新
    onRefresh() {
      setTimeout(() => {
        this.showToast('刷新成功');
        this.isLoading = false;
      }, 1000);
    },
    //查看卡券
    jumpDetail(orderCode) {
      window.vm.$router.push({ name: 'cardRoll.detail',query:{orderCode} })
    },
    jumpSales(val) {
      if(val.openRefund) {
        window.vm.$router.push({ name: 'cardRoll.salesApply' ,query:{
            orderCode:val.orderCode,
            orderPrices: val.orderPrices
          }
        })
      }else {
        this.alert({
          message: '该卡券无法发起售后,如有其它疑问,请联系购券页面的在线客服进行咨询!',
        })
      }
    },
    jumpSalesDetail(val) {
      window.vm.$router.push({ name: 'cardRoll.salesDetail' ,query:{
          orderCode:val.orderCode
        }
      })
    },
    onLoad () {
        // 异步更新数据
        // setTimeout(() => {
        //   for (let i = 0; i < 10; i++) {
        //     this.cardList.push(this.cardList.length + 1);
        //   }
        //
        //   // 加载状态结束
        //   this.loading = false;
        //
        //   // 数据全部加载完成
        //   if (this.cardList.length >= 40) {
        //     this.finished = true;
        //   }
        // }, 1000);
    },
  },
}
</script>

<style scoped lang='scss'>
.color-2,.color-3,.color-4,.color-5 {
  color: #248B20;
}
.color-1,.color-4 {
  color: #F10016;
}
  .main {
    background: #F4F4F4;
    position: absolute;
    min-height: 100%;
    width: 100%;
    .card-tab {
      /deep/ .van-tab--active {
        color: #008FFF;
      }
      /deep/ .van-tabs__line {
        background: rgba(0,143,255,0.1);
        width: 57px;
        height: 24px;
        border-radius: 12px;
        bottom: 25px;
      }
    }
    .van-empty {
      img {
        width: 160px;
        height: 160px;
      }
      .van-empty-description {
        font-size: 14px;
        font-weight: 400;
        color: #999999;
        line-height: 20px;
      }
    }
    .card-list {
      padding: 10px;
      min-height: calc(100vh - 70px);
      &-item {
        margin-bottom: 10px;
        height: 100px;
        box-sizing: border-box;
        padding: 15px;
        background: #FFFFFF;
        border-radius: 6px;
        display: flex;
        position: relative;
        >.card-img {
          width: 70px;
          height: 70px;
          background-image: url('~@a/images/cardRoll.png');
          background-size: 100% 100%;
          .card-l-panel {
            width: 70px;
            height: 70px;
            text-align: center;
            color: #FFFFFF;
            padding: 9px 0px;
            box-sizing: border-box;
            .card-l-title,card-l-num {
              font-size: 12px;
              line-height: 17px;
            }
            .card-l-price {
              font-size: 14px;
              line-height: 20px;
            }
          }
        }
        >.card-desc {
          margin-left: 16px;
          flex: 1;
          >div {
            height: 23.3px;
          }
          >.card-num {
            position: absolute;
            top: 37px;
            right: 15px;
            font-size: 18px;
            font-weight: 800;
            color: #FF9900;
            line-height: 25px;
          }
          >.card-name {
            display: flex;
            justify-content: space-between;
            font-size: 14px;
            font-weight: 800;
            color: #333333;
            line-height: 20px;
            >span {
              &:last-child {
                font-size: 12px;
                font-weight: 500;
                color: #248B20;
              }
            }
          }
          >.card-time {
            font-size: 10px;
            font-weight: 500;
            color: #FF9900;
            line-height: 24px;
            &.card-time-2 {
              line-height: 18px;
            }
          }
          >.card-type {
            >p {
              font-size: 10px;
              font-weight: 500;
              color: #999999;
              line-height: 14px;
            }
          }
          >.card-operation {
            span {
              margin-right: 10px;
              display: inline-block;
              padding: 2px 8px;
              background: rgba(255,153,0,0.1);
              border-radius: 16px;
              font-size: 10px;
              font-weight: 400;
              color: #FF9900;
            }
          }
        }
       }
    }
  }
</style>