移动系统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
<template>
    <view>
        <u-toast ref="uToast" /><u-no-network></u-no-network>
        <u-navbar :title="'我的'+pointShowName" 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="integral-top coreshop-bg-red coreshop-flex coreshop-flex-direction-column coreshop-justify-center">
                <view class="coreshop-font-md text-white  coreshop-margin-bottom-10">
                    可用{{pointShowName}}
                </view>
                <view class="coreshop-font-xl coreshop-text-white coreshop-margin-bottom-10">
                    {{ pointList.length ? pointList[0].balance : 0}}
                </view>
                <view class="coreshop-font-xs coreshop-text-gray">
                    截止{{ nowDate }}可用{{pointShowName}}
                </view>
            </view>
        </u-sticky>
        <!-- 积分记录列表 -->
        <view v-if="pointList.length>0">
            <view class="coreshop-log-item coreshop-flex coreshop-justify-between" v-for="item in pointList" :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.remarks.replace(/积分/,pointShowName) }}</view>
                    </view>
                </view>
                <view class="item-right coreshop-flex coreshop-flex-direction coreshop-align-end">
                    <view class="log-num coreshop-text-red">{{ item.num > 0 ? '+' + item.num : item.num }}</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>
    </view>
</template>
<script>
    export default {
        data() {
            return {
                page: 1,
                limit: 10,
                pointList: [], // 积分记录
                status: 'loadmore',
                iconType: 'flower',
                loadText: {
                    loadmore: '轻轻上拉',
                    loading: '努力加载中',
                    nomore: '实在没有了'
                }
            }
        },
        onLoad() {
            this.userPointLog()
        },
        computed: {
            nowDate() {
                return this.$u.timeFormat(Math.round(new Date().getTime() / 1000))
            },
            pointShowName() { return this.$store.state.config.pointShowName },
        },
        methods: {
            userPointLog() {
                let _this = this
                let data = {
                    page: _this.page,
                    limit: _this.limit
                }
                _this.status = 'loading'
                _this.$u.api.pointLog(data).then(res => {
                    if (res.status) {
                        _this.pointList = [..._this.pointList, ...res.data]
                        // 判断数据是否加载完毕
                        if (_this.page < res.otherData.totalPages) {
                            _this.page++
                            _this.status = 'loadmore'
                        } else {
                            _this.status = 'nomore'
                        }
                    } else {
                        // 接口請求出錯
                        _this.$u.toast(res.msg)
                        _this.status = 'loadmore'
                    }
                })
            }
        },
        // 页面滚动到底部触发事件
        onReachBottom() {
            let _this = this
            if (_this.status === 'loadmore') {
                _this.userPointLog()
            }
        }
    }
</script>
<style lang="scss">
    @import "index.scss";
</style>