<template>
  <view>
    <view class="application-record" v-if="Object.values(list).length > 0">
      <view class="card-list" v-for="(item,index) in list" :key="index">
        <view class="card-top">
          <view class="title">{{item.winery_name}}</view>
          <view class="time">提交时间：{{item.create_time}}</view>
          <view v-if="item.reason && item.status == 2" class="reason">原因：{{item.reason}}</view>
        </view>
        <view class="line"></view>
        <view class="card-bottom">
          <view class="card-status">
            <image class="status-icon" v-if="item.status === 0" src="@/static/images/pending.png" mode=""></image>
            <image class="status-icon" v-else-if="item.status === 1" src="@/static/images/passed.png" mode=""></image>
            <image class="status-icon" v-else-if="item.status === 2" src="@/static/images/not-pass.png" mode=""></image>
            <text class="status-text">{{statusText(item.status)}}</text>
          </view>
          <view class="status-btn" v-if="item.status == 2" @click="jump(item)">修改</view>
        </view>
      </view>
    </view>
    <emptyPage v-else title="暂无记录～"></emptyPage>
  </view>
</template>

<script>
import {mapGetters} from "vuex";
import emptyPage from '@/components/emptyPage.vue';
import {supplierApplyRecord} from "@/api/supplier";

export default {
  components: {
    emptyPage,
  },
  data() {
    return {
      list: [],
      page: 1,
    }
  },
  computed: {
    ...mapGetters(['isLogin', 'userInfo', 'viewColor'])
  },
  onLoad() {
    this.getRecordList();
  },
  // 滚动到底部
  onReachBottom() {
    this.getRecordList();
  },
  methods: {
    // 记录
    getRecordList() {
      let _this = this;
      supplierApplyRecord({page: _this.page}).then(res => {
        let list = res.data.list || {};
        if (Object.values(list).length > 0) {
          _this.list = _this.$util.SplitArray(list, _this.list);
          _this.$set(_this, 'list', _this.list);
          _this.page++;
        }
      }).catch(err => {
        this.$util.Tips({
          title: err
        });
      });
    },
    //状态判断
    statusText(number) {
      let statusData = {
        0: "审核中",
        1: "已通过",
        2: "已驳回"
      };
      return statusData[number]
    },
    // 跳转逻辑
    jump(item) {
      uni.navigateTo({
        url: `/pages/supplier/apply/apply_join?apply_id=${item.id}`
      })
    },



  }
}
</script>

<style lang="scss" scoped>
.application-record {
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: #F5F5F5;
  padding: 20rpx 30rpx;
  .card-list {
    width: 100%;
    background-color: #fff;
    padding: 20rpx 24rpx;
    margin: 10rpx 20rpx;
    border-radius: 12rpx;
    .card-top {
      height: 140rpx;
      .title {
        font-size: 28rpx;
        font-weight: bold;
        color: #333333;
      }
      .time {
        color: #999999;
        font-size: 24rpx;
        padding: 5rpx 0;
      }
      .reason {
        color: #E93323;
        font-weight: bold;
        font-size: 24rpx;
      }
    }
    .line {
      height: 2rpx;
      margin: 20rpx 0 20rpx 0;
      background-color: #EEEEEE;
    }
    .card-bottom {
      display: flex;
      justify-content: space-between;
      align-items: center;
      color: #333;
      .card-status {
        display: flex;
        align-items: center;
        .status-icon {
          width: 30rpx;
          height: 30rpx;
          margin: 10rpx;
        }
        .status-text {
          font-size: 28rpx;
          font-weight: 500;
        }
      }
      .status-btn {
        font-size: 26rpx;
        color: #555;
        border: 1px solid #999999;
        padding: 8rpx 32rpx;
        border-radius: 40rpx;
      }
    }
  }
}
.no-shop {
  width: 100%;
  background-color: #fff;
  height: 100vh;
  .pictrue {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: $uni-nothing-text;
    image {
      width: 414rpx;
      height: 380rpx;
    }
  }
}
</style>
