cash-out-record.vue 3.03 KB
Newer Older
1 2 3
<template>
  <div class="cash-out-record">
    <div id="top-month">
leiqingsong's avatar
leiqingsong committed
4
      <span style="margin-right: 5px">{{ selected }}</span>
5 6 7 8 9
      <van-icon name="arrow-down" @click="show = true" />
    </div>
    <div class="record-list">
      <base-refresh-scroll @downLoad="onDownLoad" @upRefresh="onUpRefresh">
        <div slot="content">
leiqingsong's avatar
leiqingsong committed
10 11
          <div v-for="(item, index) in recordList" :key="'record' + index">
            <record-item :record-item="item" />
12 13 14 15 16 17 18 19 20
          </div>
        </div>
      </base-refresh-scroll>
    </div>

    <van-popup v-model="show" get-container="#top-month">
      <van-datetime-picker
        v-model="currentDate"
        type="year-month"
leiqingsong's avatar
leiqingsong committed
21
        :min-date="minDate"
leiqingsong's avatar
leiqingsong committed
22
        :max-date="maxDate"
23 24 25 26 27 28 29 30 31
        @cancel="onPickerCancle"
        @confirm="onPickerConfirm"
      >
      </van-datetime-picker>
    </van-popup>
  </div>
</template>

<script>
leiqingsong's avatar
leiqingsong committed
32
import { getWithdrawalRecord } from "@/api/wallet";
33 34 35 36 37 38 39 40 41 42
import RecordItem from "./components/recordItem.vue";
import BaseRefreshScroll from "../../components/BaseRefreshScroll.vue";
export default {
  components: {
    BaseRefreshScroll,
    RecordItem
  },
  name: "CashOutRecord",
  data() {
    return {
leiqingsong's avatar
leiqingsong committed
43
      minDate: "",
leiqingsong's avatar
leiqingsong committed
44
      maxDate: "",
45 46 47
      show: false,
      options: [{ text: "2021年3月", value: 0 }],
      selected: "",
leiqingsong's avatar
leiqingsong committed
48 49
      currentDate: new Date(),
      recordList: []
50 51 52
    };
  },
  mounted() {
leiqingsong's avatar
leiqingsong committed
53 54 55
    this.maxDate = new Date();
    this.minDate = new Date(this.currentDate.getFullYear(), 0);
    this.selected = `${this.currentDate.getFullYear()}${this.currentDate.getMonth() +
leiqingsong's avatar
leiqingsong committed
56
      1}月`;
leiqingsong's avatar
leiqingsong committed
57
    const time = this.currentDate.toLocaleDateString().replace(/\//g, "-");
leiqingsong's avatar
leiqingsong committed
58
    this.getRecordList(time);
59 60 61 62 63 64 65
  },
  methods: {
    onUpRefresh() {
      console.log("上拉刷新");
    },
    onDownLoad() {
      console.log("下拉加载");
leiqingsong's avatar
leiqingsong committed
66
      const time = this.currentDate.toLocaleDateString().replace(/\//g, "-");
leiqingsong's avatar
leiqingsong committed
67
      this.getRecordList(time);
68 69 70 71 72 73 74
    },
    onPickerCancle() {
      this.show = false;
    },
    onPickerConfirm(val) {
      this.selected = `${val.getFullYear()}${val.getMonth() + 1}月`;
      this.show = false;
leiqingsong's avatar
leiqingsong committed
75
      const time = val.toLocaleDateString().replace(/\//g, "-");
leiqingsong's avatar
leiqingsong committed
76 77 78 79
      this.getRecordList(time);
    },
    getRecordList(yearMonth) {
      const params = {
leiqingsong's avatar
leiqingsong committed
80
        userId: JSON.parse(localStorage.getItem("user")).userId,
leiqingsong's avatar
leiqingsong committed
81 82 83 84 85 86 87
        yearMonth: yearMonth
      };
      getWithdrawalRecord(params).then(res => {
        if (res.code === 0) {
          this.recordList = res.data;
        }
      });
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
    }
  }
};
</script>

<style lang="scss" scoped>
#top-month {
  position: relative;
  display: flex;
  align-items: center;
  height: 44px;
  margin-bottom: 10px;
  padding-left: 15px;
  font-size: 16px;
  font-weight: bold;
  background-color: #ffffff;
  .van-popup {
    position: absolute;
    top: 145px;
    left: 100px;
    width: 200px;
    max-height: 200px;
    .van-picker {
      height: 200px;
      overflow: hidden;
    }
  }
  ::v-deep .van-picker__frame {
    border: 1px solid;
  }
}
.record-list {
  position: relative;
  height: calc(100vh - 100px);
}
</style>