移动系统liao
2025-02-17 557c2711a3e103ebc3d0492344eca9730d5e92b2
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
<template>
    <view>
        <u-toast ref="uToast" /><u-no-network></u-no-network>
        <u-navbar title="余额明细" safeAreaInsetTop fixed placeholder>
            <view class="coreshop-navbar-left-slot" slot="left">
                <u-icon name="arrow-left" size="19" @click="goNavigateBack"></u-icon>
                <u-line direction="column" :hairline="false" length="16" margin="0 8px"></u-line>
                <u-icon name="home" size="22" @click="goHome"></u-icon>
            </view>
            <view slot="right">
            </view>
        </u-navbar>
        <u-sticky customNavHeight="48">
            <view class="coreshop-flex coreshop-flex-nowrap coreshop-justify-between coreshop-padding-15 coreshop-bg-white">
                <view class="coreshop-font-15">类型筛选</view>
                <picker @change="changeState" :value="index" :range="objectType">
                    <view class="picker">
                        <u-icon name="arrow-right-double" margin-left="10px" class="coreshop-margin-left-10" :label="index>-1?objectType[index]:''" labelPos="left"></u-icon>
                    </view>
                </picker>
            </view>
        </u-sticky>
        <view class="coreshop-margin-top-15  coreshop-margin-left-15 coreshop-margin-right-15 radius">
            <view v-if="list.length>0">
                <view class="coreshop-log-item coreshop-margin-bottom-10" v-for="item in list" :key="item.id">
                    <view class="coreshop-flex coreshop-justify-between">
                        <view class="item-left coreshop-flex coreshop-align-center">
                            <view class="coreshop-flex coreshop-flex-direction coreshop-align-start">
                                <view class="log-name coreshop-text-black">{{ item.typeName }}</view>
                                <view class="log-notice coreshop-text-grey">余额:{{ item.balance }}</view>
                            </view>
                        </view>
                        <view class="item-right coreshop-flex coreshop-flex-direction coreshop-align-center coreshop-justify-center">
                            <view class="log-num coreshop-text-red">{{ item.money }}</view>
                            <view class="log-date coreshop-text-grey">{{ item.createTime }}</view>
                        </view>
                    </view>
                    <view class="coreshop-log-memo coreshop-text-grey">
                        说明:{{item.memo}}
                    </view>
                </view>
 
                <!-- 更多 -->
                <u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" margin-top="20" margin-bottom="20" />
            </view>
            <!-- 无数据时默认显示 -->
            <view class="coreshop-emptybox" v-else>
                <u-empty :icon="$globalConstVars.apiFilesUrl+'/static/images/empty/history.png'" icon-size="150" text="暂无余额明细" mode="list"></u-empty>
            </view>
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                objectType: ['全部', '消费', '退款', '充值', '提现', '佣金', '平台调整', '奖励'],
                index: 0,   // 默认选中的类型   索引
                page: 1,
                limit: 10,
                list: [],
                states: [0, 1, 2, 3, 4, 5, 6, 7], // 不同类型的状态
                status: 'loadmore',
                iconType: 'flower',
                loadText: {
                    loadmore: '轻轻上拉',
                    loading: '努力加载中',
                    nomore: '实在没有了'
                }
            }
        },
        onLoad(e) {
            if (e.status) {
                this.index = this.states.indexOf(parseInt(e.status));
            } else {
                this.balances()//修复多次加载问题
            }
        },
        onReachBottom() {
            if (this.status === 'loadmore') {
                this.balances()
            }
        },
        methods: {
            // 切换类型
            changeState(e) {
                if (this.index !== e.target.value) {
                    this.index = e.target.value;
                    this.page = 1
                    this.list = []
                }
            },
            // 获取余额明细
            balances() {
                let data = {
                    id: this.states[this.index],
                    page: this.page,
                    limit: this.limit
                }
 
                this.status = 'loading'
 
                this.$u.api.getBalanceList(data).then(res => {
                    if (res.status) {
                        if (this.page >= res.otherData.totalPages) {
                            // 没有数据了
                            this.status = 'nomore'
                        } else {
                            // 未加载完毕
                            this.status = 'loadmore'
                            this.page++
                        }
                        this.list = [...this.list, ...res.data]
                    } else {
                        this.$u.toast(res.msg)
                    }
                })
            }
        },
        watch: {
            index() {
                this.balances();
            }
        }
    }
</script>
 
<style lang="scss">
</style>