bug修复
This commit is contained in:
parent
95f097f8c9
commit
b67b581775
|
|
@ -68,24 +68,26 @@
|
|||
></skill-card>
|
||||
</view>
|
||||
|
||||
<view class="empty-state" v-else>
|
||||
<image class="empty-icon" src="https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/da814ede-1adc-4f90-8cdf-5357a12fab27.png"></image>
|
||||
<view v-else>
|
||||
<noData></noData>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view style="height: 60rpx;"></view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from "@/utils/request"
|
||||
import SkillCard from "@/pages/home/components/skill-card.vue"
|
||||
import noData from "@/components/noData/noData.vue";
|
||||
|
||||
// 数据模式开关:true=调用真实接口,false=使用模拟数据
|
||||
const USE_REAL_API = true
|
||||
|
||||
export default {
|
||||
components: { SkillCard },
|
||||
components: { SkillCard, noData },
|
||||
data() {
|
||||
return {
|
||||
navHeight: 0,
|
||||
|
|
@ -170,6 +172,7 @@ export default {
|
|||
this.fetchData(true);
|
||||
},
|
||||
|
||||
// 获取列表数据 (统一入口)
|
||||
// 获取列表数据 (统一入口)
|
||||
async fetchData(isReset = false) {
|
||||
if (isReset) {
|
||||
|
|
@ -181,12 +184,21 @@ export default {
|
|||
if (USE_REAL_API) {
|
||||
uni.showLoading({ title: '加载中...' })
|
||||
try {
|
||||
// 1. 初始化基础参数
|
||||
const params = {
|
||||
page: this.page,
|
||||
limit: this.limit,
|
||||
order_type: this.orderType
|
||||
limit: this.limit
|
||||
}
|
||||
|
||||
// 2. 仅当 orderType 不为 0 时,才将 order_type 传给后端,避免 500 报错
|
||||
if (this.orderType !== 0) {
|
||||
params.order_type = this.orderType
|
||||
}
|
||||
|
||||
// 3. 课程类型筛选
|
||||
if (this.linkType !== '') {
|
||||
params.link_type = this.linkType
|
||||
}
|
||||
if (this.linkType) params.link_type = this.linkType
|
||||
|
||||
const res = await request.post('/sj/skill/list', params)
|
||||
if ((res.code === 200 || res.state === 1) && res.data && res.data.list) {
|
||||
|
|
@ -210,18 +222,20 @@ export default {
|
|||
let list = [...this.mockDatabase]
|
||||
|
||||
// 1. 模拟筛选
|
||||
if (this.linkType) {
|
||||
if (this.linkType !== '') {
|
||||
list = list.filter(item => item.link_type === this.linkType)
|
||||
}
|
||||
|
||||
// 2. 模拟排序
|
||||
list.sort((a, b) => {
|
||||
if (this.orderType === 1) return b.timestamp - a.timestamp // 时间降序
|
||||
if (this.orderType === 2) return a.timestamp - b.timestamp // 时间升序
|
||||
if (this.orderType === 3) return b.views - a.views // 浏览量降序
|
||||
if (this.orderType === 4) return a.views - b.views // 浏览量升序
|
||||
return 0
|
||||
})
|
||||
// 2. 模拟排序 (仅当 orderType 不为 0 时才进行排序操作)
|
||||
if (this.orderType !== 0) {
|
||||
list.sort((a, b) => {
|
||||
if (this.orderType === 1) return b.timestamp - a.timestamp // 时间降序
|
||||
if (this.orderType === 2) return a.timestamp - b.timestamp // 时间升序
|
||||
if (this.orderType === 3) return b.views - a.views // 浏览量降序
|
||||
if (this.orderType === 4) return a.views - b.views // 浏览量升序
|
||||
return 0
|
||||
})
|
||||
}
|
||||
|
||||
// 3. 模拟分页
|
||||
const start = (this.page - 1) * this.limit
|
||||
|
|
|
|||
Loading…
Reference in New Issue