cshenfu
2024-06-27 58aa6e282bb343503be3cb198948328ea3ed7b79
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
<template>
    <view>
        <u-toast ref="uToast" />
        <view class="sticky-nav">
            <!-- #ifdef APP-PLUS -->
            <view class="status_bar">
                <view class="top_view"></view>
            </view>
            <!-- #endif -->
            <view class="top-nav">
                <view class="nav-slot-wrap-title nav-slot-wrap-title-black">
                    我的课程
                </view>
                <view class="q_bank" @click="open_q_bank">
                    在线刷题
                    <u-icon name="play-right-fill" color="rgba(49,117,255,.5)" size="28"></u-icon>
                </view>
            </view>
            <filter-box :categories1="scenes" :categories2="categories" :cid1="pagination.scene" :cid2="pagination.cid"
                @change="filterChange"></filter-box>
        </view>
 
        <view class="section-box" v-if="list&&list.length>0">
            <block v-for="(item,index) in list">
                <course-item v-if="item.goods_type=='course'" :key="index" :item="item.courseInfo" :hasBuy="true">
                </course-item>
                <pay-article-item v-if="item.goods_type=='pay-article'" :key="index" :item="item.articleInfo">
                </pay-article-item>
            </block>
        </view>
        <empty v-else :loading="loading"></empty>
 
        <view class="loadmore" v-if="list&&list.length>0">
            <u-loadmore @loadmore="getData(true)" :status="loadStatus" />
        </view>
    </view>
</template>
 
<script>
    var that; // 当前页面对象
    var vk; // vk依赖
    export default {
        data() {
            return {
                background: {
                    backgroundColor: "rgba(0,0,0,0)"
                },
                // {
                //         id: "default",
                //         name: "全部",
                //     },
                scenes: [{
                        id: "course",
                        name: "点播",
                    },
                    {
                        id: "pay-article",
                        name: "图文",
                    },
                ],
                list: [],
                pagination: {
                    pageIndex: 1,
                    pageSize: 10,
                    scene: "course",
                    cid: 0,
                    need_user_info: true
                },
                categories: [],
                over: false,
                loading: false,
            };
        },
        computed: {
            loadStatus() {
                if (this.over) {
                    return "nomore";
                }
                if (this.loading) {
                    return "loading";
                }
                return "loadmore";
            },
        },
        onLoad(options) {
            that = this;
            vk = that.vk;
            this.pagination.scene = options.scene ?? 'course'
            this.pagination.cid = options.cid ?? 0
 
            this.getData();
        },
        onReachBottom() {
            this.getData(true);
        },
        onPullDownRefresh() {
            this.resetData();
            this.getData();
            setTimeout(() => {
                uni.stopPullDownRefresh()
            }, 500);
        },
        methods: {
            open_q_bank(){
                uni.vk.navigateTo("/uni_modules/uce-q-bank/pages/index/index")
            },
            filterChange(scene, cid) {
                this.pagination.scene = scene;
                this.pagination.cid = cid;
                this.resetData();
                this.getData();
            },
            resetData() {
                this.list = [];
                this.pagination.pageIndex = 1;
                this.over = false;
            },
            getData(more = false) {
                if (this.loading) {
                    return;
                }
                if (more) {
                    this.pagination.pageIndex++;
                }
                this.loading = true;
 
                vk.callFunction({
                    url: 'client/learn/pub/my_goods',
                    data: that.pagination,
                    success(data) {
                        let list = data.rows;
                        if (list.length > 0) {
                            that.list.push(...list);
                        }
                        setTimeout(() => {
                            that.loading = false;
                            if (list.length < that.pagination.pageSize) {
                                that.over = true;
                            }
                        }, 200);
                    },
                    fail(e) {
                        that.loading = false;
                        that.$refs.uToast.show({
                            title: e.msg
                        })
                    }
                });
            },
        }
    }
</script>
 
<style lang="scss">
    .top-nav {
        padding-top: 15rpx;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .q_bank{
        margin: 0 20rpx;
        font-size: 30rpx;
        letter-spacing: 2rpx;
        padding: 0rpx 30rpx;
        height: 50rpx;
        line-height: 50rpx;
        border-radius: 25rpx;
        background: #efefef;
    }
 
    .sticky-nav {
        position: sticky;
        z-index: 999;
        top: 0;
        width: 100%;
        background-image: linear-gradient(164deg, rgba(114,160,255,.2) 0%, #ffffff 38%, #ffffff 78%, #ffffff 100%);
 
        // background: #FFFFFF;
    }
 
    .section-box {
        position: relative;
        display: flex;
        flex-direction: column;
        background: #FFFFFF;
    }
</style>