jhzh
2025-04-03 db12897dc68c68d40c557aa59ad78022e2b30ac2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<template>
  <div class="fn-sm p-x-md">
    <table class="w-max">
      <thead>
        <tr class="fn-10">
          <th class="fn-left p-l-md p-y-xs">{{$t('option.a0')}}</th>
          <th class="fn-left">{{$t('option.e3')}}</th>
          <th class="fn-right p-r-md">{{$t('option.d1')}}</th>
        </tr>
      </thead>
      <tbody class="color-light trade-list">
        <tr @click="_router.push({path:'/pages/option/delivery-detail',query:{order_id:item.order_id}})" v-for="item in list" :key="item.order_no" class="link-active">
          <td class="fn-left p-l-md p-y-xs rounded-bl-xs rounded-tl-xs">
            <div>{{item.pair_name}}·{{item.time_name}}</div>
            <div class="fn-sm color-default">{{item.created_at}}</div>
          </td>
          <td class="fn-left" :class="getColor(item.up_down)">
            {{getStatusText(item.up_down)}}
            {{item.up_down==3?'±':'≥'}}
            {{item.range}}%
          </td>
          <td class="fn-right p-r-md rounded-br-xs rounded-tr-xs">
            {{item.delivery_amount}} ({{item.bet_coin_name}})
            <van-icon class="color-default" name="arrow" />
          </td>
        </tr>
        <tr>
          <td
            class="fn-center color-default bg-panel-2 p-y-md link-active"
            @click="more"
            colspan="3"
            v-if="loadMore"
          >{{$t('option.d3')}}</td>
        </tr>
      </tbody>
    </table>
  </div>
</template>
<script>
import Option from "@/api/option";
export default {
  props: ["query"],
  data() {
    return {
      list: [],
      page: 1,
      loadMore: true,
    };
  },
  watch: {
    query() {
      this.reset();
    },
  },
  methods: {
    getColor(status) {
      if (status == 1) return "color-buy";
      if (status == 2) return "color-sell";
      if (status == 3) return "";
    },
    getStatusText(status) {
      if (status == 1) return this.$t('option.b8');
      if (status == 2) return this.$t('option.c0');
      if (status == 3) return this.$t('option.b9');
    },
    reset() {
      this.page = 1;
      this.loadMore = true;
      this.getOptionHistoryOrders();
    },
    more() {
      this.page++;
      this.getOptionHistoryOrders();
    },
    getOptionHistoryOrders() {
      let data = {
        status: 2,
        page: this.page,
        pair_id: this.query.pair_id,
        time_id: this.query.time_id,
      };
      Option.getOptionHistoryOrders(data).then((res) => {
        if (res.data.current_page == 1) this.list = [];
        this.list = [...this.list, ...res.data.data];
        if (res.data.data.length < res.data.per_page) {
          this.loadMore = false;
        }
      });
    },
  },
  created() {
    this.getOptionHistoryOrders();
  },
};
</script>
<style lang="scss" scoped>
.trade-list{
  tr:nth-of-type(2n-1){
    td{
      background: $panel-3;
    }
  }
}
</style>