wupengfei
2 天以前 b9417fa80146902cfb44a0091869f9189b41509e
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<template>
  <!-- <ProTabs
    v-model="queryState.type"
    name="home-tab"
    :showPaneContent="false"
    class="home-tabs"
    isTransparent
    title-gutter="12"
    title-scroll
  >
    <ProTabPane :title="`全部`" :pane-key="0"></ProTabPane>
    <ProTabPane :title="`收入`" :pane-key="EnumUserWalletTransactionType.Income"></ProTabPane>
    <ProTabPane :title="`提现`" :pane-key="EnumUserWalletTransactionType.Withdraw"></ProTabPane>
  </ProTabs> -->
  <List>
    <IncomeDetailListItem
      :item="`收入:¥${toThousand(sumIncome)} 提现:¥${toThousand(sumWithdraw)}`"
    >
      <template #title>
        <div class="income-detail-time-picker">
          <ChooseInputWithDatePicker
            v-model="queryState.month"
            type="year-month"
            :max-date="nowDate"
            format="YYYY-MM"
          />
          <IconFont name="triangle-down" class="income-detail-time-picker-icon"></IconFont>
        </div>
      </template>
    </IncomeDetailListItem>
  </List>
  <InfiniteLoading
    scrollViewClassName="common-infinite-scroll-list home-list"
    v-bind="infiniteLoadingProps"
    :key="queryState.type"
  >
    <template #renderItem="{ item }">
      <IncomeDetailListItem
        :title="item.title"
        :funds="item.amount"
        :item="dayjs(item.createdTime).format('YYYY-MM-DD HH:mm:ss')"
        :value="`钱包余额:${toThousand(item.balance)}`"
        @click="goIncomeDetailInfo(item)"
      >
      </IncomeDetailListItem>
    </template>
  </InfiniteLoading>
</template>
 
<script setup lang="ts">
import {
  List,
  IncomeDetailListItem,
  ChooseInputWithDatePicker,
  ProTabs,
  ProTabPane,
} from '@12333/components';
import { useUserStore } from '@/stores/modules/user';
import { IconFont } from '@nutui/icons-vue-taro';
import Taro from '@tarojs/taro';
import dayjs from 'dayjs';
import { useInfiniteLoading } from '@12333/hooks';
import { EnumPagedListOrder, EnumUserWalletTransactionType } from '@12333/constants';
import { toThousand } from '@12333/utils';
import * as userServices from '@12333/services/apiV2/user';
 
defineOptions({
  name: 'InnerPage',
});
 
const userStore = useUserStore();
const nowDate = dayjs().toDate();
 
const queryState = reactive({
  month: dayjs().format('YYYY-MM'),
  type: 0 as any as EnumUserWalletTransactionType,
});
 
const sumIncome = computed(() => {
  return infiniteLoadingProps.value?.listData?.pages?.[0]?.objectData?.sumIncome ?? 0;
});
const sumWithdraw = computed(() => {
  return infiniteLoadingProps.value?.listData?.pages?.[0]?.objectData?.sumWithdraw ?? 0;
});
 
const { infiniteLoadingProps } = useInfiniteLoading(
  ({ pageParam }) => {
    let params: API.GetPersonalUserTransactionsQuery = {
      pageModel: {
        rows: 20,
        page: pageParam,
        orderInput: [{ property: 'id', order: EnumPagedListOrder.Desc }],
      },
      type: EnumUserWalletTransactionType.Income,
    };
    // if (Number(queryState.type)) {
    //   params.type = queryState.type;
    // }
    if (queryState.month) {
      params.createdTimeStart = dayjs(queryState.month).startOf('month').format('YYYY-MM-DD');
      params.createdTimeEnd = dayjs(queryState.month).endOf('month').format('YYYY-MM-DD');
    }
    return userServices.getPersonalUserTransactions(params, {
      showLoading: false,
    });
  },
  {
    queryKey: ['userServices/getPersonalUserTransactions', queryState],
  }
);
 
function goIncomeDetailInfo(row: API.GetPersonalUserTransactionsQueryResultItem) {
  Taro.navigateTo({
    url: `${RouterPath.incomeDetailInfo}?id=${row.id}`,
  });
  // Taro.navigateTo({
  //   url: `${RouterPath.withdrawDetailInfo}`,
  // });
}
</script>
 
<style lang="scss">
@import '@/styles/common.scss';
 
.incomeDetail-page-wrapper {
  .income-detail-time-picker {
    position: relative;
 
    .nut-input {
      border-bottom: none;
      padding: 0;
      width: 100%;
 
      .input-text {
        font-size: 20px;
        font-weight: 500;
        height: 28px;
      }
 
      .nut-input-right-box {
        display: none;
      }
    }
 
    .income-detail-time-picker-icon {
      position: absolute;
      top: 12px;
      left: 220px;
    }
  }
 
  .common-infinite-scroll-list {
    background-color: #ffffff;
  }
 
  .pro-list {
    background: transparent;
  }
 
  .nut-input {
    background: transparent;
  }
}
</style>