解决学习任务两个bug
This commit is contained in:
@@ -65,7 +65,6 @@
|
||||
};
|
||||
const searchText = ref('');
|
||||
const search = (value, state) => {
|
||||
console.log('value', value, state);
|
||||
total.value = -1;
|
||||
searchText.value = value;
|
||||
if (state) {
|
||||
@@ -76,6 +75,12 @@
|
||||
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);
|
||||
|
||||
@@ -88,7 +93,8 @@
|
||||
defineExpose({
|
||||
getData,
|
||||
search,
|
||||
updateData
|
||||
updateData,
|
||||
clear
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -213,17 +213,17 @@
|
||||
}
|
||||
};
|
||||
onLoad((e) => {
|
||||
collectId.value = e.collectId || '';
|
||||
const learning_tasks_details = getPageCache('learning_tasks_details');
|
||||
Object.assign(detailData, {
|
||||
...learning_tasks_details
|
||||
});
|
||||
collectId.value = learning_tasks_details.collectionId || '';
|
||||
getData();
|
||||
const updateFun = () => {
|
||||
setTimeout(() => {
|
||||
console.log('详情监听里面学习完成后更新任务历程');
|
||||
queryTraTaskInfoByTaskId({ taskId: detailData.taskId }).then(({ body }) => {
|
||||
uni.$emit('refresh_favorites_data', body);
|
||||
uni.$emit('refresh_tasks_data', body);
|
||||
Object.assign(detailData, {
|
||||
...body
|
||||
});
|
||||
@@ -255,6 +255,7 @@
|
||||
});
|
||||
} else if (prevPage.route === 'pages/learningTasks/index') {
|
||||
// 学习任务页跳入,更新外部列表否则下次列表数据还是老的
|
||||
console.log('学习任务页跳入,更新外部列表否则下次列表数据还是老的');
|
||||
uni.$emit('refresh_tasks_list', detailData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,11 +69,9 @@
|
||||
tabAct.value = item.detail.current;
|
||||
};
|
||||
const search = (value) => {
|
||||
|
||||
listItemRefs.value[0]?.search(value, tabAct.value === 0);
|
||||
listItemRefs.value[1]?.search(value, tabAct.value === 1);
|
||||
listItemRefs.value[2]?.search(value, tabAct.value === 2);
|
||||
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
@@ -91,14 +89,28 @@
|
||||
|
||||
onLoad(() => {
|
||||
uni.$on('refresh_tasks_list', (res) => {
|
||||
// 更新列表内单挑item数据
|
||||
if (typeof listItemRefs.value[tabAct.value]?.updateData === 'function') {
|
||||
listItemRefs.value[tabAct.value]?.updateData(res);
|
||||
console.log('refresh_tasks_list');
|
||||
listItemRefs.value[0]?.updateData(res);
|
||||
listItemRefs.value[1]?.updateData(res);
|
||||
listItemRefs.value[2]?.updateData(res);
|
||||
});
|
||||
// 完成任务后更新列表单条信息
|
||||
uni.$on('refresh_tasks_data', (res) => {
|
||||
console.log('refresh_tasks_data');
|
||||
listItemRefs.value[0]?.updateData(res);
|
||||
listItemRefs.value[1]?.clear();
|
||||
listItemRefs.value[2]?.clear();
|
||||
listItemRefs.value[tabAct.value]?.getData('first');
|
||||
if (tabAct.value === 0) {
|
||||
courseRef.value?.updateData(res);
|
||||
} else if (tabAct.value === 1) {
|
||||
taskRef.value?.updateData(res);
|
||||
}
|
||||
});
|
||||
});
|
||||
onUnload(() => {
|
||||
uni.$off('refresh_tasks_list');
|
||||
uni.$off('refresh_tasks_data');
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -92,10 +92,15 @@
|
||||
data_list.length = 0;
|
||||
}
|
||||
};
|
||||
|
||||
const clear = (state) => {
|
||||
total.value = -1;
|
||||
page.value = 1;
|
||||
data_list.length = 0;
|
||||
};
|
||||
defineExpose({
|
||||
getData,
|
||||
search
|
||||
search,
|
||||
clear
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user