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