修改考试中心下拉刷新
This commit is contained in:
@@ -75,14 +75,14 @@
|
||||
|
||||
const swipeActionClick = (click_item) => {
|
||||
const index = click_item['name'];
|
||||
const item = data_list[index];
|
||||
const item = data_list.value[index];
|
||||
console.log('item', item);
|
||||
common.show('提示', '确认删除吗?').then((res) => {
|
||||
if (!res) return;
|
||||
common.loading();
|
||||
deleteTraPersonalCollectionById({ collectId: item.collectionId })
|
||||
.then(() => {
|
||||
data_list.splice(index, 1); // 从列表移除
|
||||
total.value -= 1; // 更新下总数
|
||||
reload(true);
|
||||
})
|
||||
.finally(() => {
|
||||
common.hideLoading();
|
||||
@@ -115,7 +115,7 @@
|
||||
{ immediate: true }
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
const updateData = (item) => {
|
||||
// 这里是收藏记录,如果是取消收藏,那就得重新刷新列表
|
||||
if (item.collectionId === null) {
|
||||
|
||||
@@ -474,7 +474,7 @@
|
||||
break;
|
||||
case 'preview':
|
||||
// if (getPhoneEnvBool('AND')) {
|
||||
if (false) {
|
||||
if (true) {
|
||||
common.navigateTo('/pages/index/preview?fileId=' + info.docId);
|
||||
} else {
|
||||
const base_url = get_base_url('/traask/traFilePreview/');
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
<script>
|
||||
import { getToken } from '@/common/common.js'
|
||||
import common from '@/common/common'
|
||||
import {getPhoneEnvBool} from '@/common/common'
|
||||
import { downloadFile } from '@/api/common.js'
|
||||
import { get_base_url } from '@/api/request.js'
|
||||
var wv
|
||||
@@ -37,14 +38,16 @@ export default {
|
||||
this.fileId = params.fileId || ''
|
||||
},
|
||||
onShow() {
|
||||
console.log(getPhoneEnvBool('AND'),111)
|
||||
if (getPhoneEnvBool('AND')) {
|
||||
this.openPdfFn({
|
||||
fileId: this.fileId
|
||||
})
|
||||
}else{
|
||||
const base_url = get_base_url('/traask/traFilePreview/');
|
||||
let fileUrl = base_url + '/traask/traFilePreview/' + info.docId;
|
||||
this.showUrl = fileUrl
|
||||
let fileUrl = base_url + '/traask/traFilePreview/' + this.fileId;
|
||||
this.showUrl = 'https://aitstest.jlbank.com.cn:7002/traask/traFilePreview/d0c9e8cf-c862-44e7-bfa8-514a54d4baf2'//fileUrl
|
||||
console.log(this.showUrl,111)
|
||||
}
|
||||
},
|
||||
onReady() {
|
||||
@@ -52,6 +55,7 @@ export default {
|
||||
var currentWebview = this.$scope.$getAppWebview()
|
||||
setTimeout(() => {
|
||||
wv = currentWebview.children()[0]
|
||||
if(!wv) return
|
||||
wv.setStyle({
|
||||
top: 80
|
||||
})
|
||||
@@ -62,6 +66,7 @@ export default {
|
||||
methods: {
|
||||
setHeight(res){
|
||||
//#ifdef APP-PLUS
|
||||
if(!wv) return
|
||||
wv.setStyle({
|
||||
top: res.height + 20
|
||||
})
|
||||
|
||||
@@ -97,8 +97,6 @@
|
||||
}
|
||||
}
|
||||
.item {
|
||||
// background-color: red;
|
||||
// height: 170rpx;
|
||||
padding-top: 16rpx;
|
||||
padding-bottom: 16rpx;
|
||||
display: flex;
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
<template>
|
||||
<scroll-view
|
||||
<z-paging
|
||||
ref="pagingRef"
|
||||
v-model="data_list"
|
||||
@query="queryList"
|
||||
:fixed="false"
|
||||
class="scroll_div"
|
||||
:auto="false"
|
||||
empty-view-text="暂无考试任务"
|
||||
>
|
||||
<view class="scroll-Y">
|
||||
<!-- 如果当前页已经加载过数据或者当前切换到的tab是当前页,才展示当前页数据(懒加载) -->
|
||||
<itemVue :item="item" v-for="(item, index) in data_list"></itemVue>
|
||||
</view>
|
||||
</z-paging>
|
||||
<!-- <scroll-view
|
||||
ref="scrollRef"
|
||||
scroll-y="true"
|
||||
class="scroll-Y"
|
||||
@@ -7,106 +21,124 @@
|
||||
:show-scrollbar="false"
|
||||
@scrolltolower="scrolltolower"
|
||||
>
|
||||
<!-- 主体 -->
|
||||
<view class="content">
|
||||
<itemVue :item="item" v-for="item in data_list"></itemVue>
|
||||
<list-no-data v-if="total === 0 && status == 'nomore'">暂无考试任务</list-no-data>
|
||||
<uv-load-more v-if="total !== 0" :status="status" loadmore-text="轻轻上拉加载" :height="30"></uv-load-more>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</scroll-view> -->
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive} from 'vue';
|
||||
import { ref, reactive, computed, onMounted, watch } from 'vue';
|
||||
import { queryTraExamPapersPage } from '@/api/testingHall.js';
|
||||
import itemVue from './content-item.vue';
|
||||
const status = ref('loadmore'); // loadmore - 加载前,loading - 加载中,nomore - 没有数据
|
||||
const limit = 20;
|
||||
const total = ref(-1);
|
||||
const page = ref(0);
|
||||
const data_list = reactive([]);
|
||||
const scrollRef = ref(null);
|
||||
|
||||
import useZpaging from '@/composables/useZpaging.js';
|
||||
|
||||
const examStat = computed(() => ['', 'Y', 'N'][props.currentIndex]);
|
||||
const fetchFunction = (params) => queryTraExamPapersPage({ examStat: examStat.value, ...params });
|
||||
const { pagingRef, queryList, data_list, reload, search, total, clear } = useZpaging({
|
||||
fetchFunction,
|
||||
searchKey: 'papersName'
|
||||
});
|
||||
|
||||
const props = defineProps({
|
||||
index: {
|
||||
tabIndex: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
currentIndex: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
});
|
||||
|
||||
const getData = (from = '', _searchText = '') => {
|
||||
if (from === 'first') {
|
||||
if (total.value !== -1) return;
|
||||
status.value = 'loading';
|
||||
total.value = -1;
|
||||
page.value = 1;
|
||||
data_list.length = 0;
|
||||
} else {
|
||||
if (status.value !== 'loadmore' && status.value !== '') return;
|
||||
status.value = 'loading';
|
||||
page.value++;
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
let params = {
|
||||
papersName: _searchText || searchText.value,
|
||||
page: page.value,
|
||||
limit: limit
|
||||
};
|
||||
if (props.index === 1) {
|
||||
params.examStat = 'Y';
|
||||
} else if (props.index === 2) {
|
||||
params.examStat = 'N';
|
||||
}
|
||||
queryTraExamPapersPage(params)
|
||||
.then((res) => {
|
||||
total.value = res.total;
|
||||
data_list.push(...res.body);
|
||||
console.log('total.value', total.value);
|
||||
})
|
||||
.catch((res) => {
|
||||
console.log('resres', res);
|
||||
})
|
||||
.finally(() => {
|
||||
if (data_list.length >= total.value) {
|
||||
status.value = 'nomore';
|
||||
} else {
|
||||
status.value = 'loadmore';
|
||||
}
|
||||
|
||||
});
|
||||
}, 200);
|
||||
};
|
||||
const scrolltolower = () => {
|
||||
getData();
|
||||
};
|
||||
const searchText = ref('');
|
||||
const search = (value, state) => {
|
||||
console.log('value', value, state);
|
||||
total.value = -1;
|
||||
searchText.value = value;
|
||||
if (state) {
|
||||
getData('first', value);
|
||||
} else {
|
||||
total.value = -1;
|
||||
page.value = 1;
|
||||
data_list.length = 0;
|
||||
}
|
||||
};
|
||||
const clear = (state) => {
|
||||
total.value = -1;
|
||||
page.value = 1;
|
||||
data_list.length = 0;
|
||||
};
|
||||
const updateData = (item) => {
|
||||
// const index = data_list.findIndex((res) => res.taskId === item.taskId);
|
||||
|
||||
// console.log('updateData', index, item);
|
||||
// if (index !== -1) {
|
||||
// data_list[index] = item;
|
||||
// const getData = (from = '', _searchText = '') => {
|
||||
// if (from === 'first') {
|
||||
// if (total.value !== -1) return;
|
||||
// status.value = 'loading';
|
||||
// total.value = -1;
|
||||
// page.value = 1;
|
||||
// data_list.length = 0;
|
||||
// } else {
|
||||
// if (status.value !== 'loadmore' && status.value !== '') return;
|
||||
// status.value = 'loading';
|
||||
// page.value++;
|
||||
// }
|
||||
|
||||
// setTimeout(() => {
|
||||
// let params = {
|
||||
// papersName: _searchText || searchText.value,
|
||||
// page: page.value,
|
||||
// limit: limit
|
||||
// };
|
||||
// if (props.currentIndex === 1) {
|
||||
// params.examStat = 'Y';
|
||||
// } else if (props.currentIndex === 2) {
|
||||
// params.examStat = 'N';
|
||||
// }
|
||||
// queryTraExamPapersPage(params)
|
||||
// .then((res) => {
|
||||
// total.value = res.total;
|
||||
// data_list.push(...res.body);
|
||||
// console.log('total.value', total.value);
|
||||
// })
|
||||
// .catch((res) => {
|
||||
// console.log('resres', res);
|
||||
// })
|
||||
// .finally(() => {
|
||||
// if (data_list.length >= total.value) {
|
||||
// status.value = 'nomore';
|
||||
// } else {
|
||||
// status.value = 'loadmore';
|
||||
// }
|
||||
// });
|
||||
// }, 200);
|
||||
// };
|
||||
// const scrolltolower = () => {
|
||||
// getData();
|
||||
// };
|
||||
// const searchText = ref('');
|
||||
// const search = (value, state) => {
|
||||
// console.log('value', value, state);
|
||||
// total.value = -1;
|
||||
// searchText.value = value;
|
||||
// if (state) {
|
||||
// getData('first', value);
|
||||
// } else {
|
||||
// total.value = -1;
|
||||
// page.value = 1;
|
||||
// data_list.length = 0;
|
||||
// }
|
||||
// };
|
||||
// const clear = (state) => {
|
||||
// total.value = -1;
|
||||
// page.value = 1;
|
||||
// data_list.length = 0;
|
||||
// };
|
||||
const updateData = (item) => {
|
||||
// const index = data_list.findIndex((res) => res.taskId === item.taskId);
|
||||
// console.log('updateData', index, item);
|
||||
// if (index !== -1) {
|
||||
// data_list[index] = item;
|
||||
// }
|
||||
};
|
||||
onMounted(() => {
|
||||
watch(
|
||||
() => props.currentIndex,
|
||||
(newVal) => {
|
||||
if (newVal === props.tabIndex && total.value === -1) {
|
||||
reload();
|
||||
}
|
||||
},
|
||||
{
|
||||
immediate: true
|
||||
}
|
||||
);
|
||||
});
|
||||
defineExpose({
|
||||
getData,
|
||||
// getData,
|
||||
search,
|
||||
updateData,
|
||||
clear
|
||||
@@ -114,20 +146,26 @@
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.scroll-Y {
|
||||
height: calc(100vh - var(--status-bar-height) - 70rpx - 78rpx - 40rpx - 88rpx);
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
background-color: #f1f5fa;
|
||||
// .scroll-Y {
|
||||
// height: calc(100vh - var(--status-bar-height) - 70rpx - 78rpx - 40rpx - 88rpx);
|
||||
// position: relative;
|
||||
// overflow: hidden;
|
||||
// background-color: #f1f5fa;
|
||||
|
||||
.content {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 20rpx 20rpx 0 0;
|
||||
position: relative;
|
||||
padding-top: 22rpx;
|
||||
padding: 0 22rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
// .content {
|
||||
// width: 100%;
|
||||
// height: 100%;
|
||||
// border-radius: 20rpx 20rpx 0 0;
|
||||
// position: relative;
|
||||
// padding-top: 22rpx;
|
||||
// padding: 0 22rpx;
|
||||
// box-sizing: border-box;
|
||||
// }
|
||||
// }
|
||||
|
||||
.scroll-Y {
|
||||
background-color: #f1f5fa;
|
||||
border-radius: 16rpx;
|
||||
padding: 1rpx 12rpx 0 22rpx;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,106 +1,106 @@
|
||||
<template>
|
||||
<view class="main_div max_page">
|
||||
<view class="body-title">
|
||||
<view class="back_div" @click="common.navigateBack()">
|
||||
<view class="back-icon"></view>
|
||||
<z-paging-swiper>
|
||||
<template #top>
|
||||
<view class="main_div">
|
||||
<view class="body-title">
|
||||
<view class="back_div" @click="common.navigateBack()">
|
||||
<view class="back-icon"></view>
|
||||
</view>
|
||||
<view>考试中心</view>
|
||||
</view>
|
||||
<view class="input-view">
|
||||
<search-input placeholder="请输入考试名" @search="search"></search-input>
|
||||
</view>
|
||||
<view class="body-tab">
|
||||
<uv-tabs
|
||||
class="font_pf my_tabs"
|
||||
:current="tabAct"
|
||||
:list="tabList"
|
||||
@change="tabChange"
|
||||
:scrollable="false"
|
||||
line-color="#0066FF"
|
||||
:inactive-style="{ color: '#333333', fontSize: '30rpx', fontWeight: '600' }"
|
||||
:activeStyle="{ color: '#0066FF', fontSize: '30rpx', fontWeight: '600' }"
|
||||
:lineColor="`url(${LineBg}) 10% 10%`"
|
||||
></uv-tabs>
|
||||
</view>
|
||||
</view>
|
||||
<view>考试中心</view>
|
||||
</view>
|
||||
<view class="input-view">
|
||||
<search-input placeholder="请输入考试名" @search="search"></search-input>
|
||||
<!-- <view class="search_div" @click="search"></view> -->
|
||||
</view>
|
||||
<view class="body-tab">
|
||||
<uv-tabs class="font_pf my_tabs" :current="tabAct" :list="tabList" @change="tabChange" :scrollable="false"
|
||||
line-color="#0066FF" :inactive-style="{ color: '#333333', fontSize: '30rpx', fontWeight:'600'}"
|
||||
:activeStyle="{color:'#0066FF',fontSize:'30rpx', fontWeight:'600'}"
|
||||
:lineColor="`url(${LineBg}) 10% 10%`"></uv-tabs>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
<swiper class="swiper" :current="tabAct" :indicator-dots="false" @change="swiperChange">
|
||||
<swiper-item>
|
||||
<Content :ref="el => contentRefs[0] = el" :index="tabAct"
|
||||
@gotoDetails="gotoDetails"></Content>
|
||||
<Content :ref="(el) => (listItemRefs[0] = el)" :tabIndex="0" :currentIndex="tabAct" @gotoDetails="gotoDetails"></Content>
|
||||
</swiper-item>
|
||||
<swiper-item>
|
||||
<Content :ref="el => contentRefs[1] = el" :index="tabAct"
|
||||
@gotoDetails="gotoDetails"></Content>
|
||||
<Content :ref="(el) => (listItemRefs[1] = el)" :tabIndex="1" :currentIndex="tabAct" @gotoDetails="gotoDetails"></Content>
|
||||
</swiper-item>
|
||||
<swiper-item>
|
||||
<Content :ref="el => contentRefs[2] = el" :index="tabAct"
|
||||
@gotoDetails="gotoDetails"></Content>
|
||||
<Content :ref="(el) => (listItemRefs[2] = el)" :tabIndex="2" :currentIndex="tabAct" @gotoDetails="gotoDetails"></Content>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
</view>
|
||||
</z-paging-swiper>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
// 考试中心
|
||||
import Content from './components/content.vue'
|
||||
import {
|
||||
ref,
|
||||
reactive,
|
||||
watch,
|
||||
onMounted
|
||||
} from 'vue'
|
||||
import {
|
||||
onLoad,
|
||||
onUnload
|
||||
} from '@dcloudio/uni-app'
|
||||
import {
|
||||
setPageCache
|
||||
} from '@/common/common';
|
||||
|
||||
|
||||
import Content from './components/content.vue';
|
||||
import { ref, reactive, watch, onMounted } from 'vue';
|
||||
import { onLoad, onUnload } from '@dcloudio/uni-app';
|
||||
import { setPageCache } from '@/common/common';
|
||||
import common from '@/common/common';
|
||||
|
||||
import {
|
||||
LineBg
|
||||
} from '@/enum.js'
|
||||
const tabAct = ref(0);
|
||||
|
||||
const tabList = ref([{
|
||||
name: '全 部'
|
||||
}, {
|
||||
name: '已完成'
|
||||
}, {
|
||||
name: '未完成'
|
||||
}]);
|
||||
import { LineBg } from '@/enum.js';
|
||||
import useIndexList from '@/composables/useIndexList.js';
|
||||
const { tabAct, listItemRefs, tabChange, swiperChange, search } = useIndexList();
|
||||
|
||||
|
||||
|
||||
const tabList = ref([
|
||||
{
|
||||
name: '全 部'
|
||||
},
|
||||
{
|
||||
name: '已完成'
|
||||
},
|
||||
{
|
||||
name: '未完成'
|
||||
}
|
||||
]);
|
||||
|
||||
|
||||
const triggered = ref(false);
|
||||
|
||||
|
||||
// const search = (value) => {
|
||||
// contentRefs.value[0]?.search(value, tabAct.value === 0);
|
||||
// contentRefs.value[1]?.search(value, tabAct.value === 1);
|
||||
// contentRefs.value[2]?.search(value, tabAct.value === 2);
|
||||
// };
|
||||
|
||||
const contentRefs = ref([])
|
||||
const triggered = ref(false)
|
||||
const tabChange = (item) => {
|
||||
tabAct.value = item.index;
|
||||
};
|
||||
const swiperChange = (item) => {
|
||||
tabAct.value = item.detail.current;
|
||||
};
|
||||
|
||||
const search = (value) => {
|
||||
contentRefs.value[0]?.search(value, tabAct.value === 0);
|
||||
contentRefs.value[1]?.search(value, tabAct.value === 1);
|
||||
contentRefs.value[2]?.search(value, tabAct.value === 2);
|
||||
};
|
||||
|
||||
const gotoDetails = (item) => {
|
||||
setPageCache('testing_hall_details', item)
|
||||
setPageCache('testing_hall_details', item);
|
||||
common.navigateTo('/pages/testingHall/details');
|
||||
}
|
||||
onMounted(() => {
|
||||
triggered.value = true
|
||||
watch(tabAct, (newValue, oldValue) => {
|
||||
typeof contentRefs.value[newValue]?.getData === 'function' && contentRefs.value[newValue]
|
||||
?.getData('first')
|
||||
}, {
|
||||
immediate: true
|
||||
}) // 这里的immediate会在onMounted之后执行
|
||||
})
|
||||
|
||||
|
||||
};
|
||||
// onMounted(() => {
|
||||
// triggered.value = true;
|
||||
// watch(
|
||||
// tabAct,
|
||||
// (newValue, oldValue) => {
|
||||
// typeof contentRefs.value[newValue]?.getData === 'function' && contentRefs.value[newValue]?.getData('first');
|
||||
// },
|
||||
// {
|
||||
// immediate: true
|
||||
// }
|
||||
// ); // 这里的immediate会在onMounted之后执行
|
||||
// });
|
||||
|
||||
onLoad(() => {
|
||||
uni.$on('refresh_testing_hall_data', (res) => {
|
||||
// console.log('exam_completed');
|
||||
// contentRefs.value[0]?.updateData(res);
|
||||
// contentRefs.value[1]?.updateData(res);
|
||||
// contentRefs.value[2]?.updateData(res);
|
||||
// console.log('exam_completed');
|
||||
// contentRefs.value[0]?.updateData(res);
|
||||
// contentRefs.value[1]?.updateData(res);
|
||||
// contentRefs.value[2]?.updateData(res);
|
||||
});
|
||||
});
|
||||
onUnload(() => {
|
||||
@@ -114,7 +114,6 @@
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
.body-tab {
|
||||
height: 88rpx;
|
||||
// background-color: red;
|
||||
@@ -122,7 +121,6 @@
|
||||
}
|
||||
|
||||
.my_tabs {
|
||||
|
||||
// 解决这个圆角的图片,开穿透
|
||||
:deep(.uv-tabs__wrapper__nav__line) {
|
||||
height: 30rpx !important;
|
||||
@@ -130,7 +128,6 @@
|
||||
background-size: 24rpx !important;
|
||||
background-repeat: no-repeat !important;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.main_div {
|
||||
@@ -214,4 +211,4 @@
|
||||
// background-color: red;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user