course.vue
3.82 KB
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
<template>
<view>
<view class="search-area">
<uni-easyinput prefixIcon="search" v-model="query.courseName" placeholder="搜索课程名称"
@change="getList" @clear="getList">
</uni-easyinput>
</view>
<view class="imageFlowBox">
<view class="imageFlow">
<view v-for="(b,index) in clist" :key="b.courseId" @click="goDetail(b)">
<image mode="aspectFill" :src="config.baseUrl_api+b.coursePic" class="cover"></image>
<!-- <div class="info">
<h3 class="name esp">{{b.paperName}}</h3>
<p class="esp_2">{{b.description}}</p>
<view class="timeblock">预计用时 {{b.evalTime}}分钟
</view>
</div> -->
</view>
</view>
</view>
<view class="tbar">
全部课程
</view>
<view class="list">
<view class="kcitem" v-for="n in list" :key="n.courseId" @click="goDetail(n)">
<image :src="config.baseUrl_api+n.coursePic" mode="aspectFill"></image>
<view class="info">
<view class="tt esp_2">{{n.courseName}}</view>
<!-- <view class="pp"><uni-icons type="chatboxes" size="12" />209w 学习</view> -->
<view class="text-warning" v-if="n.isFree==0">免费</view>
<view class="text-warning" v-else>金币{{n.allGold}}/积分{{n.allScore}}</view>
</view>
</view>
</view>
<view class="nodata" v-if="list.length==0">
<image mode="aspectFit" src="/static/nodata.png"></image>
</view>
</view>
</template>
<script setup>
import {
onLoad,
onShow
} from '@dcloudio/uni-app';
import config from '@/config.js';
import {
ref,
getCurrentInstance
} from 'vue';
import * as api from '@/common/api.js';
const list = ref([])
const clist = ref([])
const kindList = ref([])
const kindId = ref('')
const query = ref({
courseName:''
})
const system = uni.getStorageSync('systemType');
onShow(() => {
init()
})
function init() {
getList()
getHot()
}
function getHot(){
uni.showLoading({
title:`加载中`
})
api.getHomePageHotCourse().then(res => {
clist.value = res.data
uni.hideLoading()
})
}
function getList() {
uni.showLoading({
title:`加载中`
})
api.getCourseList(query.value).then(res => {
list.value = res.rows
uni.hideLoading()
})
}
function goDetail(item) {
let path = `/course/courseDetail?id=${item.courseId}`;
uni.navigateTo({
url: path
});
}
</script>
<style lang="scss" scoped>
.imageFlowBox {
position: relative;
height: 300rpx;
overflow: auto;
}
.imageFlow {
display: flex;
position: absolute;
left: 0;
padding: 0 10rpx;
&>view { border-radius: 10px;
overflow: hidden;
width: 630rpx;
height: 300rpx;
margin: 0 10rpx;
position: relative;
}
image {
width: 630rpx;
height: 300rpx;
}
.info {
position: absolute;
color: #fff;
top: 0;
width: 100%;
height: 100%;
padding: 30rpx 40rpx;
overflow: hidden;
box-sizing: border-box;
.name {
font-size: 34rpx;
color: #fff;
padding-bottom: 20rpx;
margin-bottom: 20rpx;
border-bottom: 1px solid RGBA(255, 255, 255, 0.7);
}
}
.esp_2 {
font-size: 28rpx;
margin-bottom: 26rpx;
}
.timeblock {
background: rgba(27, 27, 27, 0.1);
border-radius: 25rpx;
font-size: 22rpx;
padding: 12rpx 17rpx;
display: inline-flex;
align-items: center;
image {
width: 28rpx;
height: 28rpx;
margin-left: 22rpx;
}
}
}
.list {
padding: 24rpx 0 0 24rpx;
overflow: hidden;
}
.item {
border-radius: 15rpx;
background: #fff;
width: 338rpx;
float: left;
margin: 0 24rpx 24rpx 0;
image {
height: 180rpx;
width: 100%;
}
.info {
padding: 20rpx 26rpx;
height: 100rpx;
box-sizing: border-box;
.tt {
font-size: 28rpx;
line-height: 36rpx;
}
}
}
</style>