liaoxujun@qq.com
2024-03-05 f0ca9fb79a91544c037c55a291be00e8c469bf34
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<!-- 佣金明细 -->
<template>
    <view>
        <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="wallet-wrap">
                <view class="wallet-card coreshop-bg-red">
                    <view class="coreshop-margin-bottom-15 coreshop-flex coreshop-align-center">
                        <view class="coreshop-font-12 coreshop-text-white">总收益(元)</view>
                        <view class="coreshop-font-15 coreshop-text-white" @click="onEye">
                            <u-icon color="#fff" v-if="showMoney" name="eye-fill"></u-icon>
                            <u-icon color="#fff" v-else name="eye-off"></u-icon>
                        </view>
                    </view>
                    <view class="coreshop-font-20 coreshop-text-white coreshop-margin-bottom-15">{{ showMoney ? info.totalSettlementAmount || '0.00' : '***' }}</view>
                    <view class="card-bottom coreshop-flex coreshop-justify-between">
                        <view class="card-item coreshop-flex coreshop-flex-direction coreshop-align-start">
                            <view class="coreshop-font-12 coreshop-text-white coreshop-margin-bottom-5">待入账佣金</view>
                            <view class="coreshop-font-15">{{ showMoney ? info.freezeAmount || '0.00' : '***' }}</view>
                        </view>
                        <view class="card-item coreshop-flex coreshop-flex-direction coreshop-align-start">
                            <view class="coreshop-font-12 coreshop-text-white coreshop-margin-bottom-5">可提现佣金</view>
                            <view class="coreshop-font-15">{{ showMoney ? userInfo.balance || '0.00' : '***' }}</view>
                        </view>
                        <view class=""></view>
                    </view>
                    <button class="cu-btn draw-btn" @tap="goWithdraw">提现</button>
                </view>
            </view>
            <view class="coreshop-flex coreshop-flex-wrap coreshop-flex-direction-row coreshop-justify-between coreshop-padding-15 coreshop-bg-white">
                <u-icon name="arrow-down" size="13" :label="selDateText" @click="onFilterDate" labelSize="12"></u-icon>
                <view class="coreshop-font-12">收入¥{{ totalMoney || '0.00' }}</view>
            </view>
            <!-- 状态分类 -->
            <!--<view class="coreshop-flex coreshop-align-center nav-box">
                <view class="state-item flex-sub " v-for="(state, index) in statusList" :key="state.value" @tap="onTab(state.value)">
                    <text class="state-title" :class="{ 'title-active': stateCurrent === state.value }">{{ state.name }}</text>
                    <text class="underline" :class="{ 'underline-active': stateCurrent === state.value }"></text>
                </view>
            </view>-->
        </u-sticky>
        <!-- 佣金明细列表 -->
        <view v-if="list.length>0">
            <view class="coreshop-log-item coreshop-flex coreshop-justify-between" v-for="item in list" :key="item.id">
                <view class="item-left coreshop-flex coreshop-align-center">
                    <!--<image class="log-img" :src="item.buyer.avatar" mode=""></image>-->
                    <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.sourceId }}</view>
                    </view>
                </view>
                <view class="item-right coreshop-flex coreshop-flex-direction coreshop-align-end">
                    <view class="log-num  coreshop-text-red">+{{ item.money }}</view>
                    <view class="log-date  coreshop-text-grey">{{ $u.timeFormat(item.createTime, 'yyyy.mm.dd') }}</view>
                </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>
 
        <!-- 日期选择 -->
        <u-calendar :show="showCalendar"
                    :mode="mode"
                    :minDate="minDate"
                    :start-text="startText"
                    :end-text="endText"
                    :range-color="rangeColor"
                    :range-bg-color="rangeBgColor"
                    :active-bg-color="activeBgColor"
                    :monthNum="13"
                    btnType="success"
                    @close="showCalendar=false"
                    @confirm="selDate"></u-calendar>
    </view>
</template>
 
<script>
    const d = new Date()
    const year = d.getFullYear()
    let month = d.getMonth() + 1
    month = month < 10 ? `0${month}` : month
    const date = d.getDate();
    export default {
 
        data() {
            return {
                showMoney: false, //是否显示金额
                info: {}, //经销商信息
                userInfo: {}, // 用户信息
                //日期选择
                showCalendar: false,
                minDate: `${year - 1}-${month}-${date}`,
                //maxDate: `${year}-${month}-${date}`,
                mode: 'range',
                result: '请选择日期',
                startText: '开始',
                endText: '结束',
                rangeColor: '#4CB89D',
                rangeBgColor: 'rgba(76,184,157,0.13)',
                activeBgColor: '#4CB89D',
                selDateText: '',
                list: [], //佣金记录
                propsDate: '', //日期参数
                totalMoney: 0, //收入
                page: 1,
                lastPage: 1,
                limit: 10,
                status: 'loadmore',
                iconType: 'flower',
                loadText: {
                    loadmore: '轻轻上拉',
                    loading: '努力加载中',
                    nomore: '实在没有了'
                },
                stateCurrent: 'all', //默认
                statusList: [
                    {
                        name: '全部',
                        value: 'all'
                    },
                    {
                        name: '待入账',
                        value: 'waiting'
                    },
                    {
                        name: '已入账',
                        value: 'entry'
                    },
                    {
                        name: '已退回',
                        value: 'back'
                    }
                ],
                viewHeight: 0,
            }
        },
        onShow() {
            var _this = this;
            _this.$u.api.getDistributionInfo().then(res => {
                if (res.status) {
                    _this.info = res.data;
                } else {
                    //报错了
                    _this.$u.toast(res.msg);
                }
            });
        },
        onLoad() {
            this.initData()
            this.getToday();
            this.getCommissionLog();
        },
        onReachBottom() {
            if (this.status === 'loadmore') {
                this.getCommissionLog()
            }
        },
        methods: {
            //触底加载数据
            bottomOut() {
                if (this.status == 'nomore') {
                    return;
                }
                if (this.status == 'loadmore') {
                    this.getCommissionLog();//调用数据请求
                }
            },
            navigateToHandle(pageUrl) {
                this.$u.route(pageUrl)
            },
            // 切换分类
            onTab(state) {
                this.list = [];
                this.page = 1;
                this.stateCurrent = state;
                this.$u.debounce(this.getCommissionLog);
            },
            // 点击日期选择
            onFilterDate() {
                this.showCalendar = true;
            },
            // 是否显示金额
            onEye() {
                this.showMoney = !this.showMoney;
            },
            //  今日
            getToday() {
                let now = new Date();
                this.selDateText = `${now.getFullYear()}.${now.getMonth() + 1}.${now.getDate()}`;
                let dateText = `${now.getFullYear()}/${now.getMonth() + 1}/${now.getDate()}`;
                this.propsDate = `${dateText}-${dateText}`;
            },
 
            // 选择日期
            selDate(e) {
                this.list = [];
                this.page = 1;
                this.selDateText = `${e[0]}至${e[e.length - 1]}`;
                this.propsDate = this.selDateText;
                this.getCommissionLog();
                this.showCalendar = false;
            },
            //去提现
            goWithdraw() {
                this.$u.route('/pages/member/balance/withdrawCash/withdrawCash')
            },
            initData() {
                // 获取用户信息
                var _this = this
                this.$u.api.userInfo().then(res => {
                    if (res.status) {
                        _this.userInfo = res.data
                    }
                })
            },
            // 获取余额明细
            getCommissionLog() {
                let data = {
                    id: 5,
                    page: this.page,
                    limit: this.limit,
                    propsDate: this.propsDate
                }
                this.status = 'loading'
                this.$u.api.getBalanceList(data).then(res => {
                    if (res.status) {
                        this.totalMoney = res.otherData.sunMoney;
                        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)
                    }
                })
            }
        },
    }
</script>
 
<style lang="scss">
    @import "commissionDetails.scss";
</style>