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
<template>
    <z-paging ref="paging" class="z_pag" v-model="reCourses" @query="getCourses"
        :hide-loading-more-when-no-more-by-limit="5">
        <view class="list-item flex-row" :key="item._id" v-for="item in reCourses" @click="openCourse(item._id)">
            <u-image :src="item.thumb" :lazy-load="true" class="image_11" mode="aspectFill">
            </u-image>
            <view class="right-group flex-col">
                <text class="text_11">{{ item.title }}</text>
                <view class="center-group flex-row">
                    <view class="left-text-wrapper" :key="dynamicTag" v-for="dynamicTag in item.dynamicTags">
                        {{dynamicTag}}
                    </view>
                </view>
                <view class="justify-between">
                    <text class="text_17">{{item.user_count}}人已购</text>
                    <text class="text_19">¥{{item.charge / 100}}</text>
                </view>
            </view>
        </view>
    </z-paging>
</template>
 
<script>
    var that; // 当前页面对象
    var vk; // vk依赖
    export default {
        data() {
            // 页面数据变量
            return {
                cid: '',
                text: '',
                reCourses: []
            }
        },
        // 监听 - 页面每次【加载时】执行(如:前进)
        onLoad(options = {}) {
            that = this;
            vk = that.vk;
            that.init(options)
        },
        // 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快,会在页面进入动画完成前触发
        onReady() {},
        // 监听 - 页面每次【显示时】执行(如:前进和返回) (页面每次出现在屏幕上都触发,包括从下级页面点返回露出当前页面)
        onShow() {},
        // 监听 - 页面每次【隐藏时】执行(如:返回)
        onHide() {},
        // 函数
        methods: {
            // 页面数据初始化函数
            init(options) {
                this.text = options.text
                let category_info = vk.getStorageSync('category_info')
                if (category_info) this.cid = category_info.id
            },
            getCourses(pageIndex, pageSize) {
                vk.callFunction({
                    url: 'client/course/pub/search-result',
                    title: '请求中...',
                    data: {
                        pageIndex,
                        pageSize,
                        category_id: that.cid,
                        keyword: that.text
                    },
                    success: function(data) {
                        that.$refs.paging.complete(data.rows);
                    }
                });
            },
            // 推荐课程详情
            openCourse(id) {
                uni.vk.navigateTo('/uni_modules/uce-course/pages/detail/class-detail?_id=' + id, false);
            }
        },
    }
</script>
 
<style lang="scss" scoped>
    .list-item {
        padding: 20rpx 20rpx 40rpx;
        border-bottom: 1px solid #F0F0F0;
 
        &:not(:first-of-type) {
            margin-top: 40rpx;
        }
 
        .image_11 {
            border-radius: 8rpx;
            width: 284rpx !important;
            height: 182rpx !important;
        }
 
        .right-group {
            margin-left: 26rpx;
            flex: 1 1 auto;
 
            .text_11 {
                color: rgb(51, 51, 51);
                font-size: 30rpx;
                line-height: 35rpx;
                text-align: left;
            }
 
            .center-group {
                margin-top: 33rpx;
                color: rgb(255, 150, 12);
                font-size: 20rpx;
                line-height: 28rpx;
                white-space: nowrap;
 
                .left-text-wrapper {
                    background-repeat: no-repeat;
                    padding: 4rpx 14rpx;
                    margin-right: 20rpx;
                    background: rgba(255, 150, 12, 0.12);
                    border: 1rpx solid #FF960C;
                    border-radius: 16rpx;
                }
            }
 
            .text_17 {
                margin-top: 19rpx;
                color: rgb(153, 153, 153);
                font-size: 20rpx;
                line-height: 24rpx;
                white-space: nowrap;
            }
 
            .text_19 {
                color: rgb(246, 21, 21);
                font-size: 36rpx;
                margin-top: 4rpx;
                white-space: nowrap;
            }
        }
    }
</style>