<style>
  .demandlist {
    padding: 30px 20px;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
  }

  .order-header {
    display: flex;
    align-items: flex-start;
    margin: 20px 0;
  }

  .order-header .order_title {
    margin-right: 20px;
    font-size: 25px;
    color: #666;
    font-weight: 400;
  }

  .order-header .type-item {
    margin: 0 15px;
    cursor: pointer;
  }

  .order-header .type-item a {
    font-size: 16px;
    padding: 0 2px 12px;
    text-decoration: none;
  }

  .type-item .is-acted {
    color: #00afff;
    border-bottom: 2px solid #00afff;
  }

  .type-bar {
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
  }

  .type-bar li {
    list-style-type: none;
  }

  .order_link {
    display: block;
    padding: 20px 25px;
  }
  .order-list{
    padding:0;
  }

  .order-list li {
    margin-bottom: 15px;
    font-size: 0;
    background-color: #fff;
    box-shadow: 0 2px 4px 0 rgba(10, 8, 8, .5);
    transition: transform .2s ease, box-shadow .2s ease;
    cursor: pointer;
  }

  .order_link .order_tour {
    font-size: 16px;
    padding-right: 10px;
    width: calc(100% - 90px);
    display: inline-block;
    vertical-align: middle;
  }

  .tour-name {
    margin-bottom: 5px;
    color: #333;
  }

  .order_link .order-status {
    font-size: 15px;
    display: inline-block;
    vertical-align: middle;
    color: #999;
  }

  .order-list li .order-status:not(:last-child) {
    margin-right: 20px;
  }

  .order-status-ch {
    width: 90px;
    color: #333;
    text-align: center;
    display: inline-block;
    vertical-align: middle;
  }
  .text-my{
    color:#00afff;
  }

  .order-status-tag {
    padding: 2px 12px;
    background-color: #e2f0fb;
    color: #00afff;
    border-radius: 50px;
    background-clip: padding-box;
    display: inline-block;
    vertical-align: middle;
    font-size: 13px;
  }

  @media only screen and (min-width: 768px) {
    .order-list li:hover {
      -webkit-transform: translate(0, -4px);
      -moz-transform: translate(0, -4px);
      -ms-transform: translate(0, -4px);
      -o-transform: translate(0, -4px);
      transform: translate(0, -4px);
      -webkit-box-shadow: 0 4px 25px 0 rgba(0, 0, 0, .2), 0 0 0 0 rgba(0, 0, 0, .1);
      -moz-box-shadow: 0 4px 25px 0 rgba(0, 0, 0, .2), 0 0 0 0 rgba(0, 0, 0, .1);
      box-shadow: 0 4px 25px 0 rgba(0, 0, 0, .2), 0 0 0 0 rgba(0, 0, 0, .1);
    }
  }

  @media only screen and (max-width: 1200px) {
    .order_tour {
      width: 100%!important;
      padding-right:0!important;
    }
  }

</style>
<template>
  <q-page>
    <div class="demandlist">
      <template v-if="!$q.screen.xs">
        <div class="order-header">
          <div class="order_title">我的需求單</div>
          <q-tabs
            v-model="tab"
            inline-label
            class="text-my"
          >
            <q-tab :name="item.Type" :label="item.Type" v-for="(item,index) in TitList" @click="clickItem(item.ID)" :key="index" />
          </q-tabs>
        </div>
      </template>
      <template v-if="$q.screen.xs">
        <div>
          <div class="order_titleMobile">我的需求單</div>
          <q-tabs
            v-model="tab"
            inline-label
            class="text-my"
          >
            <q-tab :name="item.Type" :label="item.Type" v-for="(item,index) in TitList" @click="clickItem(item.ID)" :key="index" />
          </q-tabs>
        </div>
      </template>
      <ul class="order-list">
        <li v-for="(item,index) in DataList" :key="index" @click="CommonJump('/demandinfo/'+item.Id,{})">
          <a class="order_link">
            <div class="order_tour">
              <div class="tour-name">
                {{item.TripTitle}}
              </div>
              <div class="order-status">
                訂購日期：{{item.CreateDateStr}}
              </div>
              <div class="order-status">
                需求單編號：{{item.Id}}
              </div>
              <div class="order-status" style="margin-top:10px;" v-if="$q.screen.xs">
                <div class="order-status-tag">{{item.DemandStatusStr}}</div>
              </div>
            </div>
            <div class="order-status-ch" v-if="!$q.screen.xs">
              <div class="order-status-tag">{{item.DemandStatusStr}}</div>
            </div>
          </a>
        </li>
        <q-pagination v-if="pageCount>1" v-model="qMsg.PageIndex" :max="pageCount" @input="getdemandList()"
          :direction-links="true">
        </q-pagination>
      </ul>
    </div>
  </q-page>
</template>
<script>
  export default {
    props: [],
    data() {
      return {
        tab:'待處理',
        qMsg: {
          PageIndex: 1,
          PageSize: 10,
          CreateBy: 0,
          DemandStatus: 0,
        },
        DataList: [],
        pageCount: 0,
        TitList: [{
            Type: "待處理",
            ID: 0
          },
          {
            Type: "處理中",
            ID: 1
          },
          {
            Type: "已完成",
            ID: 2
          },
          {
            Type: "已取消",
            ID: 4
          }
        ],
      };
    },
    created() {

    },
    mounted() {
      if (localStorage.b2bUser) {
        var b2bUser = JSON.parse(window.localStorage.getItem('b2bUser'))
        if (b2bUser) {
          this.qMsg.CreateBy = b2bUser.customerId;
          this.getdemandList();
        }
      }
    },
    methods: {
      clickItem(index) {
        this.qMsg.DemandStatus = index;
        this.getdemandList()
      },
      getdemandList() {
        this.$q.loading.show()
        this.DataList = [];
        this.apipost(
          "ws_get_GetServicePageList", this.qMsg,
          res => {
            this.$q.loading.hide()
            if (res.data.resultCode == 1) {
              this.DataList = res.data.data.pageData;
              this.pageCount = res.data.data.pageCount;
            }
            else if (res.data.resultCode == 10000 || res.data.resultCode == 10001) {
              localStorage.removeItem("b2bUser");
              this.CommonJump('/login', {})
            }
          },
          err => {}
        );
      }
    },
  };

</script>
