<template>
  <div class="myOrders">
    <van-tabs v-model="active" :before-change="beforeTabChange">
      <van-tab title="待评价">
        <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoadCareer()">
          <div class="showBoxDPJ" v-for="(item,index) in datalist" :key="index">
            <div class="topLine">
              <div class="topLineL">订单编号:{{item.orderpaynum}}</div>
              <div class="topLineR" @click="evaluate(item)">去评价 ></div>
            </div>
            <div class="top" @click="toEdit(item)">
              <div class="pic">
                <img :src="item.coverUrl ? item.coverUrl : require('@/assets/service/defCoure.jpg')" alt="" style="width:100%;height:100%">
              </div>
              <div class="basefont">
                <div class="titlefont">{{item.baseName}}</div>
                <div class="tcfont">套餐名称:{{item.courseName}}</div>
                <div class="tcfont">数量*{{item.orderCount}}</div>
              </div>
              <div class="priceRight">¥{{item.paymoney}}</div>
            </div>
            <div class="detailsBox">
              <div class="detailsBoxOne">
                <div>订单创建时间</div>
                <div>{{item.intime.replace(/T/,' ')}}</div>
              </div>
            </div>
          </div>
        </van-list>
      </van-tab>
      <van-tab title="已评价">
        <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad()">
          <div class="showBoxDPJ showBoxYPJ" v-for="(item,index) in list" :key="index">
            <div class="top">
              <div class="pic">
                <img :src="item.coverUrl ? item.coverUrl : require('@/assets/service/defCoure.jpg')" alt="" style="width:100%;height:100%">
              </div>
              <div class="basefont">
                <div class="titlefont">{{item.baseName}}</div>
                <div class="tcfont">套餐名称:{{item.courseName}}</div>
                <div class="tcfont">数量*{{item.orderCount}}</div>
              </div>
              <div class="priceRight">¥{{item.paymoney}}</div>
            </div>
            <div class="boxdf">
              <div class="title">课程评分</div>
              <div class="fr">
                <van-rate v-model="item.courseScore" void-icon="star" void-color="#eee" color="#FFCC00" :size="16" readonly />
                <span class="rate">{{item.courseScore}}.0</span>
              </div>
            </div>
            <div class="boxdf">
              <div class="title">基地评分</div>
              <div class="fr">
                <van-rate v-model="item.baseScore" void-icon="star" void-color="#eee" color="#FFCC00" :size="16" readonly />
                <span class="rate">{{item.baseScore}}.0</span>
              </div>
            </div>
            <p class="evaluation"><span>评价:</span>{{item.evaluation}}</p>
            <div class="evaluation_img_box">
              <img class="evaluation_img" v-for="(imgItem,index) in item.imageList" :key="index" :src="imgItem.imgUrl" alt="" @click="previewImg(imgItem.imgUrl)">
            </div>
            <!-- <p class="evaluation_time">评价于2020-12-21</p> -->
          </div>
        </van-list>
      </van-tab>
    </van-tabs>

    <van-popup v-model="showPreview" round get-container="body">
      <img class="preview_img" :src="previewUrl" alt="">
    </van-popup>
  </div>
</template>

<script>
export default {
  name: 'ServiceOrder',
  data () {
    return {
      userInfo: '',
      active: 1,
      list: [],  //所有
      datalist: [],  //未评价
      loading: false,
      finished: false,
      pageCareerIndex: 0,
      codeData: {},
      imgUrl: '',
      previewUrl: '',//图片预览
      showPreview: false,
    }
  },
  computed: {
    nicknameUser () {
      return localStorage.getItem('nicknameUser')
    }
  },
  mounted () {
    let userInfo = localStorage.getItem('userInfo');
    if (userInfo) {
      this.userInfo = JSON.parse(userInfo);
    }
    // 进入页面进到第几个tab
    if (this.$route.query.active || this.$route.query.active == 0) {
      this.active = this.$route.query.active
    }
  },
  methods: {
    beforeTabChange (item) {
      console.log(item)
      this.list = [];
      this.datalist = [];
      if (item == 0) {
        this.onLoadCareer()
      } else if (item == 1) {
        this.onLoad()
      }
      return true;
    },
    //获取待评价
    onLoadCareer () {
      this.mgop({
        api: 'mgop.sz.hswsy.GetOrderPayList', // 必须
        host: 'https://mapi.zjzwfw.gov.cn/',
        dataType: 'JSON',
        type: 'GET',
        appKey: 'fuxgnukl+2001895516+edccpx', // 必须
        headers: {
          //   'isTestUrl': '1'
        },
        data: {
          "userId": localStorage.getItem('centerNo'),
          "type": 3,
          "page": 1,
          "pageSize": 999
        },
        onSuccess: res => {
          console.log('待评价:', res)
          if (res.data.status == 1) {
            this.datalist = res.data.data.list;
            this.loading = false;
            this.finished = true;
          } else {
            this.$toast.fail(res.data.message);
          }
        },
        onFail: err => {
          console.log('err', err)
        }
      });
    },
    //获取已评价
    onLoad () {
      this.mgop({
        api: 'mgop.sz.hswsy.GetOrderPayList', // 必须
        host: 'https://mapi.zjzwfw.gov.cn/',
        dataType: 'JSON',
        type: 'GET',
        appKey: 'fuxgnukl+2001895516+edccpx', // 必须
        headers: {
          //   'isTestUrl': '1'
        },
        data: {
          "userId": localStorage.getItem('centerNo'),
          "type": 4,
          "page": 1,
          "pageSize": 999
        },
        onSuccess: res => {
          console.log('已评价:', res)
          if (res.data.status == 1) {
            this.list = res.data.data.list;
            this.loading = false;
            this.finished = true;
          } else {
            this.$toast.fail(res.data.message);
          }
        },
        onFail: err => {
          console.log('err', err)
        }
      });
    },
    //评价
    evaluate (item) {
      window.localStorage.setItem('courseInfo', JSON.stringify(item))
      this.$router.push({ name: 'evaluateCourse' })
    },
    //跳转
    toEdit (item) {
      this.$router.push({ path: 'abroad_detail', query: { courseId: item.courseId } })
    },
    // 预览图片
    previewImg (url) {
      this.previewUrl = url;
      this.showPreview = true
    }
  },
  components: {
  }
}
</script>

<style lang="scss" scoped>
.myOrders {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: auto;
  background: #f6f7fa;


  .list {
    padding: 20px;
    box-sizing: border-box;

    li:not(:last-child) {
      border-bottom: 1px dashed #eee;
    }

    li {
      margin-bottom: 10px;
      padding-bottom: 10px;

      .baseName {
        padding-left: 50px;
        font-size: 30px;
        background: url("../../assets/service/hoom.png") no-repeat left top;
        background-size: contain;
        margin: 10px 0;
      }
      .career_type {
        font-size: 30px;
        margin: 0;
        margin-top: 10px;
      }
      .career_create {
        color: #ccc;
        font-size: 30px;
        margin: 0;
        margin-top: 10px;
      }
      .course {
        min-height: 60px;

        img {
          object-fit: cover;
          width: 200px;
          float: left;
          margin-right: 10px;
        }

        .courseCont {
          h5 {
            word-break: break-all;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
            overflow: hidden;
            font-size: 30px;
            margin: 0;
          }

          p {
            color: #ccc;
            font-size: 30px;
            margin: 0;
            margin-top: 10px;
          }
        }
      }

      .orderCont {
        padding: 40px 0;
        font-size: 28px;

        span {
          color: red;
        }

        .pj {
          float: right;
        }
      }

      .codeBtn {
        text-align: right;
        margin-top: 15px;
      }
    }
  }
  //待审核
  .showBox {
    width: 702px;
    background: #fff;
    border-radius: 16px;
    margin: 30px auto;
    padding: 34px 24px;
    box-sizing: border-box;

    .top {
      display: flex;

      .pic {
        width: 124px;
        height: 124px;
        flex-shrink: 0;
      }
      .basefont {
        padding: 0 20px;
        box-sizing: border-box;
        .titlefont {
          color: #333333;
          font-size: 28px;
          margin-bottom: 18px;
        }
        .tcfont {
          color: #535353;
          font-size: 24px;
        }
      }
      .priceRight {
        width: 110px;
        font-size: 28px;
        color: #f64c37;
        line-height: 200px;
      }
    }
    .groupTime {
      font-size: 28px;
      line-height: 60px;
      height: 60px;
      margin-bottom: 20px;
      // background-color: #f5f6fa;
      padding-left: 10px;
      box-sizing: border-box;

      .grey {
        color: #999999;
      }
    }
    .btnBox {
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    .detailsBox {
      color: #999999;
      font-size: 28px;
      margin-top: 60px;

      .detailsBoxOne {
        margin-top: 20px;
        display: flex;
        justify-content: space-between;
      }
    }
  }
  //待评价
  .showBoxDPJ {
    width: 702px;
    // height: 330px;
    margin: 30px auto;
    padding: 34px 24px;
    box-sizing: border-box;
    background: #fff;
    border-radius: 16px;
    .topLine {
      height: 60px;
      display: flex;
      justify-content: space-between;
      .topLineL {
        font-size: 23px;
        color: #999999;
      }
      .topLineR {
        font-size: 23px;
      }
    }
    .top {
      display: flex;

      .pic {
        width: 124px;
        height: 124px;
        flex-shrink: 0;
      }
      .basefont {
        padding: 0 20px;
        box-sizing: border-box;
        .titlefont {
          margin-bottom: 18px;
          color: #333333;
          font-weight: bold;
          font-size: 28px;
        }
        .tcfont {
          color: #535353;
          font-size: 24px;
        }
      }
      .priceRight {
        width: 110px;
        font-size: 28px;
        color: #f64c37;
        line-height: 200px;
      }
    }
    .detailsBox {
      color: #999999;
      font-size: 28px;

      .detailsBoxOne {
        margin-top: 20px;
        display: flex;
        justify-content: space-between;
      }
    }
  }
  // 已评价
  .showBoxYPJ {
    .boxdf {
      padding: 10px 0;
      font-size: 5vw;
      display: flex;
      .title {
        font-size: 28px;
        margin-right: 10px;
      }
      .rate {
        color: #ffcc00;
        font-size: 30px;
        margin-left: 10px;
      }
    }
    .evaluation {
      font-size: 30px;
      span {
        font-weight: bold;
      }
    }
    .evaluation_img_box {
      margin-top: 22px;
      .evaluation_img {
        width: 212px;
        height: 212px;
        margin-right: 9px;
        margin-bottom: 9px;
        &:nth-of-type(3n) {
          margin-right: 0;
        }
      }
    }
    .evaluation_time {
      margin-top: 18px;
      text-align: right;
      color: #999999;
      font-size: 28px;
    }
  }

  .pintuan_about {
    width: 592px;
    box-sizing: border-box;
    padding: 0 50px;
    .about_img {
      width: 112px;
      margin: 0 auto;
      margin-top: 30px;
      display: block;
    }
    .about_title {
      font-size: 34px;
      font-weight: bold;
      text-align: center;
    }
    .about_content {
      font-size: 30px;
      margin-top: 20px;
    }
    .about_know {
      font-size: 32px;
      text-align: center;
      color: #3385ff;
      margin-top: 60px;
      margin-bottom: 44px;
    }
  }
}
.codeCss {
  width: 700px;
  height: 850px;
  position: relative;

  .showBox {
    width: 702px;
    // height: 500px;
    // background-color: aquamarine;
    margin: 30px auto;
    padding: 34px 24px;
    box-sizing: border-box;

    .top {
      display: flex;

      .pic {
        width: 124px;
        height: 124px;
        flex-shrink: 0;
      }
      .basefont {
        padding: 0 20px;
        box-sizing: border-box;
        .titlefont {
          color: #333333;
          font-size: 28px;
          margin-bottom: 18px;
        }
        .tcfont {
          color: #535353;
          font-size: 24px;
        }
      }
      .priceRight {
        width: 110px;
        font-size: 28px;
        color: #f64c37;
        line-height: 200px;
      }
    }
    .groupTime {
      font-size: 28px;
      line-height: 60px;
      height: 60px;
      margin-bottom: 20px;
      background-color: #f5f6fa;
      padding-left: 10px;
      box-sizing: border-box;

      .grey {
        color: #999999;
      }
    }
    .numShow {
      width: 100%;
      font-size: 28px;
      text-align: center;
      color: #999999;
    }
    .fontBottom {
      width: 100%;
      font-weight: bold;
      font-size: 28px;
      text-align: center;
    }
  }
}
.preview_img {
  width: 100vw;
}
</style>
<style lang="scss">
.elder {
  .myOrders {
    .showBoxDPJ {
      .topLine {
        .topLineL,
        .topLineR {
          font-size: 40px;
        }
      }
      .top {
        .basefont {
          .titlefont {
            font-size: 40px;
          }
          .tcfont {
            font-size: 36px;
          }
        }
        .priceRight {
          font-size: 40px;
        }
      }
      .detailsBox {
        font-size: 40px;
        .detailsBoxOne {
          display: block;
        }
      }
    }
    .showBox {
      .top {
        .basefont {
          .titlefont {
            font-size: 40px;
          }
          .tcfont {
            font-size: 36px;
          }
        }
        .priceRight {
          font-size: 40px;
        }
      }
      .detailsBox {
        font-size: 40px;
        .detailsBoxOne {
          display: block;
        }
      }
      .groupTime {
        font-size: 36px;
      }
      .btnBox {
        .btn {
          font-size: 36px;
        }
      }
    }
    .showBoxYPJ {
      .boxdf .title {
        font-size: 36px;
      }
      .evaluation {
        font-size: 36px;
      }
    }
    .pintuan_about {
      .about_title {
        font-size: 44px;
      }
      .about_box {
        height: 600px;
        overflow: auto;
      }
      .about_content {
        font-size: 36px;
      }
      .about_know {
        font-size: 40px;
      }
    }
  }
}
</style>