liaoxujun@qq.com
2024-02-28 9f8e542b9b74fe18a6a4e0a00fef4b50e3e62581
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
<!-- 分享记录 -->
<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>
        <!-- 分类tab -->
        <view class="tab-box coreshop-flex coreshop-justify-between coreshop-padding-left-10 coreshop-padding-right-10">
            <view class="tab-item flex-sub " v-for="(tab, index) in tabsList" :key="tab.value" @tap="onTab(tab.value)">
                <text class="tab-title" :class="{ 'title-active': tabCurrent === tab.value }">{{ tab.name }}</text>
                <text class="underline" :class="{ 'underline-active': tabCurrent === tab.value }"></text>
            </view>
        </view>
 
        <view class="content_box">
            <scroll-view scroll-y="true" @scrolltolower="loadMore" class="scroll-box">
                <!-- 分享记录列表 -->
                <view class="log-list coreshop-flex coreshop-align-center" v-for="item in shareLogList" :key="item.id">
                    <view class="log-avatar-wrap"><image class="log-avatar" :src="item.user.avatar" mode=""></image></view>
 
                    <view class="item-right">
                        <view class="name">{{ item.user.nickname }}</view>
                        <view class="content coreshop-flex coreshop-align-center" v-if="item.type_data">
                            <view class="content-img-wrap"><image class="content-img" :src="item.type_data.image" mode=""></image></view>
 
                            <view class="content-text">通过{{ typeObj[item.type] }}访问了商品“{{ item.type_data.title }}”, 进入商城</view>
                        </view>
                        <view class="item-bottom coreshop-flex coreshop-justify-between">
                            <view class="time">{{ $u.timeFormat(item.createtime, 'yyyy年mm月dd日 hh:MM') }}</view>
                            <view class="from-text">来自{{ typeObj[item.type] }}分享</view>
                        </view>
                    </view>
                </view>
                <!-- 无数据时默认显示 -->
                <view class="coreshop-emptybox" v-if="shareLogList.length<=0">
                    <u-empty :icon="$globalConstVars.apiFilesUrl+'/static/images/empty/history.png'" icon-size="150" text="暂无分享记录" mode="list"></u-empty>
                </view>
                <!-- 更多 -->
                <u-loadmore v-if="shareLogList.length" :status="loadStatus" :icon-type="iconType" :load-text="loadText" margin-top="20" margin-bottom="20" />
            </scroll-view>
        </view>
        <view class="foot_box"></view>
    </view>
</template>
 
<script>
    export default {
        components: {},
        data() {
            return {
                shareLogList: [], //分享记录
                tabCurrent: 'all', //默认
                tabsList: [
                    {
                        name: '全部',
                        value: 'all'
                    },
                    {
                        name: '名片',
                        value: 'index'
                    },
                    {
                        name: '商品',
                        value: 'goods'
                    },
                    {
                        name: '拼团',
                        value: 'groupon'
                    }
                ],
                typeObj: {
                    index: '名片',
                    goods: '商品',
                    groupon: '拼团'
                },
                loadStatus: 'loadmore', //loadmore-加载前的状态,loading-加载中的状态,nomore-没有更多的状态
                iconType: 'flower',
                loadText: {
                    loadmore: '轻轻上拉',
                    loading: '努力加载中',
                    nomore: '实在没有了'
                },
                currentPage: 1,
                lastPage: 1,
            };
        },
        computed: {},
        onLoad() {
            this.getShareLog();
        },
        methods: {
            // 切换分类
            onTab(type) {
                this.tabCurrent = type;
                this.currentPage = 1;
                this.lastPage = 1;
                this.shareLogList = [];
                this.$u.debounce(this.getShareLog);
            },
 
            // 分享记录数据
            getShareLog() {
                let that = this;
                that.loadStatus = 'loading';
                //that.$api('commission.share', {
                //    type: that.tabCurrent,
                //    page: that.currentPage
                //}).then(res => {
                //    if (res.code === 1) {
                //        that.shareLogList = [...that.shareLogList, ...res.data.data];
                //        that.lastPage = res.data.last_page;
                //        if (that.currentPage < res.data.last_page) {
                //            that.loadStatus = 'loadmore';
                //        } else {
                //            that.loadStatus = 'nomore';
                //        }
                //    }
                //});
            },
 
            // 加载更多
            loadMore() {
                if (this.currentPage < this.lastPage) {
                    this.currentPage += 1;
                    this.getShareLog();
                }
            }
        }
    };
</script>
 
<style lang="scss" scoped>
    @import "shareLog.scss";
</style>