hookehuyr

fix: 统一API响应码检查为严格等于1

......@@ -63,7 +63,7 @@ const unread_msg_count = ref(0)
async function load_unread_msg_count() {
try {
const { code, data } = await getUserInfoAPI()
if (code) {
if (code === 1) {
unread_msg_count.value = +data.unread_msg_count || 0
} else {
unread_msg_count.value = 0
......
......@@ -192,7 +192,7 @@ const confirm_delete_comment = async () => {
}
const { code } = await delGroupCommentAPI({ i: comment_id })
if (code) {
if (code === 1) {
showToast('评论删除成功')
emit('commentDeleted', comment_id)
}
......
......@@ -212,7 +212,7 @@ const handle_submit = async () => {
submitting.value = true
try {
const { code } = await checkinTaskAPI({ subtask_id: selected_item.value.checkin_subtask_id })
if (code) {
if (code === 1) {
emit('submit-success')
showToast('打卡成功')
selected_item.value = null
......
......@@ -53,7 +53,7 @@ const minor_group_option = ref([])
// 获取筛选选项列表
const getFilterList = async (group_id = null, team_id = null) => {
const { code, data } = await getTeacherGradeClassListAPI({ group_id, team_id });
if (code) {
if (code === 1) {
// 处理数据
course_option.value = data.group_list?.map(item => {
return {
......
......@@ -329,7 +329,7 @@ export function useCheckin() {
result = await addUploadTaskAPI(submitData)
}
if (result.code) {
if (result.code === 1) {
showToast('提交成功')
// 设置刷新标记,用于列表页更新数据
......@@ -400,7 +400,7 @@ export function useCheckin() {
if (route.query.status === 'edit') {
try {
const { code, data } = await getUploadTaskInfoAPI({ i: route.query.post_id })
if (code) {
if (code === 1) {
message.value = data?.note || ''
activeType.value = data?.file_type || 'text'
// 小作业ID
......
......@@ -28,7 +28,7 @@ export const useStudyComments = (course) => {
group_id: course.value.group_id,
schedule_id: course.value.id
});
if (comment.code) {
if (comment.code === 1) {
commentList.value = comment.data.comment_list;
commentCount.value = comment.data.comment_count;
}
......@@ -38,13 +38,13 @@ export const useStudyComments = (course) => {
try {
if (!comment.is_like) {
const { code } = await addGroupCommentLikeAPI({ i: comment.id });
if (code) {
if (code === 1) {
comment.is_like = true;
comment.like_count += 1;
}
} else {
const { code } = await delGroupCommentLikeAPI({ i: comment.id });
if (code) {
if (code === 1) {
comment.is_like = false;
comment.like_count -= 1;
}
......@@ -65,7 +65,7 @@ export const useStudyComments = (course) => {
note: newComment.value
});
if (code) {
if (code === 1) {
await refreshComments();
newComment.value = '';
}
......@@ -88,7 +88,7 @@ export const useStudyComments = (course) => {
limit: popupLimit.value,
page: nextPage
});
if (res.code) {
if (res.code === 1) {
const newComments = res.data.comment_list;
const existingIds = new Set(popupCommentList.value.map(item => item.id));
const uniqueNewComments = newComments.filter(item => !existingIds.has(item.id));
......@@ -113,7 +113,7 @@ export const useStudyComments = (course) => {
note: popupComment.value
});
if (code) {
if (code === 1) {
popupCommentList.value = [];
popupPage.value = 0;
popupFinished.value = false;
......
......@@ -65,7 +65,7 @@ export function provideAuth() {
// }
// 从服务器获取用户信息并更新本地存储
const { code, data } = await getUserInfoAPI();
if (code) {
if (code === 1) {
currentUser.value = { ...data.user, ...data.checkin }
localStorage.setItem('currentUser', JSON.stringify(currentUser.value))
// 重新设置认证头
......@@ -78,7 +78,7 @@ export function provideAuth() {
}
} else {
const { code, data } = await getAuthInfoAPI();
if(code) {
if (code === 1) {
// 如果接口返回了 user_info,先保存
if (data.user_info) {
applyUserInfoAuth(data.user_info, { set_auth_headers: setAuthHeaders })
......@@ -95,7 +95,7 @@ export function provideAuth() {
// 获取完整用户信息(包含打卡统计数据)
try {
const userRes = await getUserInfoAPI();
if (userRes.code) {
if (userRes.code === 1) {
currentUser.value = { ...userRes.data.user, ...userRes.data.checkin }
} else {
currentUser.value = { ...data.user, ...data.checkin }
......@@ -140,7 +140,7 @@ export function provideAuth() {
const logout = async () => {
try {
const { code } = await logoutAPI()
if (code) {
if (code === 1) {
// 清空当前用户状态
currentUser.value = null
// 清理本地存储的用户信息和登录时间戳
......
......@@ -162,7 +162,7 @@ const sendVerificationCode = async () => {
try {
// TAG: 调用发送验证码API
const { code } = await smsAPI({ mobile: formData.phone })
if (code) {
if (code === 1) {
showToast('验证码已发送')
startCountdown()
return
......@@ -190,7 +190,7 @@ const handleSubmit = async () => {
password: formData.password
})
if (code) {
if (code === 1) {
showToast('密码重置成功')
// 重置成功后跳转到登录页
router.push('/login')
......
......@@ -278,7 +278,7 @@ const sendVerificationCode = async () => {
try {
const { code } = await smsAPI({ mobile: mobile.value });
if (code) {
if (code === 1) {
showToast('验证码已发送');
startCountdown();
return;
......@@ -315,7 +315,7 @@ const handleSubmit = async () => {
}
const { code, data } = await getUserInfoAPI();
if (code) {
if (code === 1) {
// 登录成功,更新auth状态,传递完整的用户信息包括打卡信息
const success = login({ ...data.user, ...data.checkin });
......
......@@ -245,7 +245,7 @@ const sendVerificationCode = async () => {
try {
// TAG: 调用发送验证码API
const { code } = await smsAPI({ mobile: formData.phone })
if (code) {
if (code === 1) {
showToast('验证码已发送')
startCountdown()
return
......@@ -288,7 +288,7 @@ const handleSubmit = async () => {
sms_code: formData.verificationCode,
password: formData.password,
})
if (code) {
if (code === 1) {
// 使用auth.js中的login函数
const success = login({
name: formData.name,
......
......@@ -229,7 +229,7 @@ const lastUsedTargetList = ref([])
const fetchTargetList = async (subtask_id) => {
const { code, data } = await reuseGratitudeFormAPI({ subtask_id })
if (code) {
if (code === 1) {
targetList.value = data.gratitude_form_list || []
lastUsedTargetList.value = data.last_used_list || []
......@@ -440,7 +440,7 @@ const handleTargetEdit = (item) => {
*/
const handleTargetDelete = async (item) => {
const { code } = await gratitudeDeleteAPI({ id: item.id })
if (code) {
if (code === 1) {
// 删除成功,更新本地列表
const targetIndex = targetList.value.findIndex(t => t.id === item.id)
if (targetIndex > -1) {
......@@ -601,7 +601,7 @@ const getUploadTips = () => {
*/
const getTaskDetail = async (month) => {
const { code, data } = await getTaskDetailAPI({ i: route.query.task_id, month })
if (code) {
if (code === 1) {
taskDetail.value = data
}
}
......
......@@ -481,14 +481,14 @@ const goToCheckinDetailPage = () => {
const handLike = async (post) => {
if (!post.is_liked) {
const { code, data } = await likeUploadTaskInfoAPI({ checkin_id: post.id, })
if (code) {
if (code === 1) {
showSuccessToast('点赞成功')
post.likes++;
post.is_liked = true;
}
} else {
const { code, data } = await dislikeUploadTaskInfoAPI({ checkin_id: post.id, })
if (code) {
if (code === 1) {
showSuccessToast('取消点赞成功')
post.likes--;
post.is_liked = false;
......@@ -520,7 +520,7 @@ const delCheckin = (post) => {
.then(async () => {
// 调用接口
const { code, data } = await delUploadTaskInfoAPI({ i: post.id });
if (code) {
if (code === 1) {
// 删除成功后,刷新页面
showSuccessToast('删除成功');
......@@ -565,7 +565,7 @@ const myTotalGratitudeCount = ref(0);
const getTaskDetail = async (month) => {
const { code, data } = await getTaskDetailAPI({ i: route.query.id, month, subtask_id: selectedSubtaskId.value });
if (code) {
if (code === 1) {
taskDetail.value = data;
progress1.value = ((data.checkin_number/data.target_number)*100).toFixed(1); // 计算进度条百分比
showProgress.value = !isNaN(progress1.value); // 如果是NaN,就不显示进度条
......@@ -599,7 +599,7 @@ const onLoad = async (date) => {
subtask_id: selectedSubtaskId.value,
date: current_date
});
if (res.code) {
if (res.code === 1) {
// 整理数据结构
const newItems = formatData(res.data);
// 去重合并
......@@ -653,7 +653,7 @@ onMounted(async () => {
// 获取作品类型数据
try {
const { code, data } = await getTeacherFindSettingsAPI();
if (code && data.task_attachment_type) {
if (code === 1 && data.task_attachment_type) {
attachmentTypeOptions.value = Object.entries(data.task_attachment_type).map(([key, value]) => ({
key,
value
......@@ -778,7 +778,7 @@ onActivated(async () => {
try {
// 获取最新的打卡信息
const { code, data } = await getUploadTaskInfoAPI({ i: refreshId })
if (code && data) {
if (code === 1 && data) {
// 构造伪造的 data 对象以适配 formatData
const mockData = { checkin_list: [data] }
const formattedList = formatData(mockData)
......
......@@ -138,7 +138,7 @@ const task_detail = ref({})
const load_task_detail = async () => {
try {
const { code, data } = await getTaskDetailAPI({ i: target_checkin_id.value })
if (code) {
if (code === 1) {
task_detail.value = data || {}
}
} catch (error) {
......
......@@ -284,7 +284,7 @@ const onSubmit = async () => {
meta_id: fileList.value.map(item => item.meta_id),
file_type: route.query.type,
});
if (code) {
if (code === 1) {
showToast('提交成功')
router.back()
}
......@@ -296,7 +296,7 @@ const onSubmit = async () => {
meta_id: fileList.value.map(item => item.meta_id),
file_type: route.query.type,
});
if (code) {
if (code === 1) {
showToast('提交成功')
router.back()
}
......@@ -312,7 +312,7 @@ const onSubmit = async () => {
onMounted(async () => {
if (route.query.status === 'edit') {
const { code, data } = await getUploadTaskInfoAPI({ i: route.query.post_id });
if (code) {
if (code === 1) {
fileList.value = data.files.map(item => ({
name: item.name,
url: item.value,
......
......@@ -280,7 +280,7 @@ const onSubmit = async () => {
meta_id: fileList.value.map(item => item.meta_id),
file_type: route.query.type,
});
if (code) {
if (code === 1) {
showToast('提交成功')
router.back()
}
......@@ -292,7 +292,7 @@ const onSubmit = async () => {
meta_id: fileList.value.map(item => item.meta_id),
file_type: route.query.type,
});
if (code) {
if (code === 1) {
showToast('提交成功')
router.back()
}
......@@ -308,7 +308,7 @@ const onSubmit = async () => {
onMounted(async () => {
if (route.query.status === 'edit') {
const { code, data } = await getUploadTaskInfoAPI({ i: route.query.post_id });
if (code) {
if (code === 1) {
fileList.value = data.files.map(item => ({
url: item.value,
status: 'done',
......
......@@ -79,7 +79,7 @@ const onSubmit = async () => {
meta_id: [], // 文本类型不需要文件
file_type: route.query.type,
});
if (code) {
if (code === 1) {
showToast('提交成功')
router.back()
}
......@@ -91,7 +91,7 @@ const onSubmit = async () => {
meta_id: [], // 文本类型不需要文件
file_type: route.query.type,
});
if (code) {
if (code === 1) {
showToast('提交成功')
router.back()
}
......@@ -109,7 +109,7 @@ const onSubmit = async () => {
onMounted(async () => {
if (route.query.status === 'edit') {
const { code, data } = await getUploadTaskInfoAPI({ i: route.query.post_id });
if (code) {
if (code === 1) {
message.value = data.note
}
}
......
......@@ -284,7 +284,7 @@ const onSubmit = async () => {
meta_id: fileList.value.map(item => item.meta_id),
file_type: route.query.type,
});
if (code) {
if (code === 1) {
showToast('提交成功')
router.back()
}
......@@ -296,7 +296,7 @@ const onSubmit = async () => {
meta_id: fileList.value.map(item => item.meta_id),
file_type: route.query.type,
});
if (code) {
if (code === 1) {
showToast('提交成功')
router.back()
}
......@@ -312,7 +312,7 @@ const onSubmit = async () => {
onMounted(async () => {
if (route.query.status === 'edit') {
const { code, data } = await getUploadTaskInfoAPI({ i: route.query.post_id });
if (code) {
if (code === 1) {
fileList.value = data.files.map(item => ({
url: item.value,
status: 'done',
......
......@@ -570,7 +570,7 @@ const toggleFavorite = async () => {
group_id: course.value.id
})
const code = resp && typeof resp === 'object' ? resp.code : 0
if (code) {
if (code === 1) {
isFavorite.value = !isFavorite.value
showToast('取消收藏')
} else {
......@@ -582,7 +582,7 @@ const toggleFavorite = async () => {
group_id: course.value.id
})
const code = resp && typeof resp === 'object' ? resp.code : 0
if (code) {
if (code === 1) {
isFavorite.value = !isFavorite.value
showToast('收藏成功')
} else {
......@@ -698,7 +698,7 @@ const handleReviewSubmit = async (review) => {
note: review.note,
score: review.rating
})
if (code) {
if (code === 1) {
showToast('评论提交成功')
isReviewed.value = true
await fetchCommentList()
......@@ -716,7 +716,7 @@ const fetchCommentList = async () => {
page: 0,
limit: 5
})
if (code) {
if (code === 1) {
commentList.value = data.comment_list
commentScore.value = data.comment_score || 0
commentTotal.value = data.comment_count || 0
......@@ -728,7 +728,7 @@ onMounted(async () => {
const id = route.params.id
// 调用接口获取课程详情
const { code, data } = await getCourseDetailAPI({ i: id });
if (code) {
if (code === 1) {
const foundCourse = data;
if (foundCourse) {
course.value = foundCourse;
......
......@@ -84,7 +84,7 @@ const fetchComments = async () => {
page: page.value,
limit: limit.value
})
if (code) {
if (code === 1) {
if (page.value === 0) {
reviews.value = data.comment_list
overallRating.value = data.comment_score || 0
......@@ -126,7 +126,7 @@ const handleReviewEdit = async ({ score, note }) => {
score,
note
})
if (code) {
if (code === 1) {
showToast('评论修改成功')
page.value = 0
await fetchComments()
......@@ -137,7 +137,7 @@ const handleReviewDelete = async () => {
const { code } = await delGroupCommentAPI({
i: currentReview.value.id
})
if (code) {
if (code === 1) {
showToast('评论删除成功')
page.value = 0
await fetchComments()
......
......@@ -112,11 +112,11 @@ const bannerList = ref([]);
onMounted(async () => {
const res = await getCourseListAPI({ limit: 4 });
if (res.code) {
if (res.code === 1) {
courses.value = res.data;
}
const bannerRes = await getCourseBannerAPI();
if (bannerRes.code) {
if (bannerRes.code === 1) {
bannerList.value = bannerRes.list;
}
})
......
......@@ -139,7 +139,7 @@ const onLoad = async () => {
limit: limit.value,
page: nextPage,
});
if (code) {
if (code === 1) {
data.forEach((item) => {
item.record_progress = Math.floor((item?.study_count/item?.count)*100);
});
......
......@@ -47,7 +47,7 @@ const message = ref({
onMounted(async () => {
// 调用接口获取消息详情
const { code, data } = await getNewsInfoAPI({ i: route.params.id });
if (code) {
if (code === 1) {
message.value = data;
// 更新消息已读状态
message.value.status = 'read';
......
......@@ -334,7 +334,7 @@ const handlePaymentProcessing = () => {
const handleViewDetail = async (order) => {
try {
const { code, data } = await getOrderInfoAPI({ i: order.id });
if (code) {
if (code === 1) {
orderDetail.value = data;
showDetailDialog.value = true;
}
......@@ -354,7 +354,7 @@ const handleCancel = async (order) => {
.then(async() => {
try {
const { code } = await cancelOrderAPI({ i: order.id });
if (code) {
if (code === 1) {
const index = orders.value.findIndex((item) => item.id === order.id);
// 更新订单状态为已取消
orders.value[index].status = 'CANCEL';
......
......@@ -159,7 +159,7 @@ const formatCheckInCount = (count) => {
onMounted(async () => {
const { code, data } = await getUserInfoAPI();
if (code) {
if (code === 1) {
profile.value = data.user;
checkIns.value = data.checkin;
checkIns.value.total_days = data.checkin.total_days || 0
......
......@@ -264,7 +264,7 @@ onMounted(async () => {
const courseId = router.currentRoute.value.params.id;
// 调用接口获取课程详情
const { code, data } = await getCourseDetailAPI({ i: courseId });
if (code) {
if (code === 1) {
course.value = data;
task_list.value = [];
timeout_task_list.value = [];
......
......@@ -153,7 +153,7 @@ const sendVerificationCode = async () => {
try {
// 调用发送验证码API
const { code } = await smsAPI({ mobile: formData.value.phone });
if (code) {
if (code === 1) {
showToast('验证码已发送');
// 开始倒计时
countdown.value = 60;
......@@ -196,7 +196,7 @@ const handlePhoneChange = async () => {
sms_code: formData.value.verificationCode
});
if (code) {
if (code === 1) {
// 更新auth上下文中的用户信息
currentUser.value = {
...currentUser.value,
......
......@@ -77,7 +77,7 @@ const handleUsernameChange = async () => {
try {
const { code, data } = await updateUserInfoAPI({ name: username.value });
if (code) {
if (code === 1) {
// 更新auth上下文中的用户信息
currentUser.value = {
...currentUser.value,
......
......@@ -138,7 +138,7 @@ const handleCollectCoins = async () => {
idcard: userInfo.idCard || '',
old_activity_data: activityInfo.value
})
if (res.code) {
if (res.code === 1) {
showToast({
message: '收集星球币成功',
icon: 'success'
......@@ -254,7 +254,7 @@ onMounted(async () => {
// 获取用户信息
const userInfoRes = await userInfoAPI()
if (userInfoRes.code) {
if (userInfoRes.code === 1) {
userInfo.value = userInfoRes.data.user || {};
}
})
......
......@@ -153,7 +153,7 @@ const totalPoints = ref(0);
onMounted(async () => {
const res = await getPointsListAPI()
if (res.code) {
if (res.code === 1) {
// 需要格式化一下, 变成千分号显示
totalPoints.value = Number(res.data?.balance || 0).toLocaleString();
}
......
......@@ -185,7 +185,7 @@ onMounted(async () => {
campaign_id: campaign_id.value
})
if (code) {
if (code === 1) {
posterBg.value = data.background_image ? data.background_image + '?imageMogr2/thumbnail/800x/strip/quality/80' : defaultBg
qrCodeUrl.value = data?.qrcode || ''
isReady.value = true
......
......@@ -136,7 +136,7 @@ const handleSendCode = async () => {
try {
const { code } = await smsAPI({ mobile: phone.value })
if (code) {
if (code === 1) {
showToast('验证码已发送')
// Start countdown
......@@ -174,11 +174,11 @@ const handleLogin = async () => {
try {
const res = await loginAPI({ mobile: phone.value, sms_code: code.value, entry: entry.value, referrer_user_id: referrer_user_id.value })
if (res.code) {
if (res.code === 1) {
applyUserInfoAuth(res, { set_auth_headers: setAuthHeaders, storage: localStorage })
const userInfo = await userInfoAPI()
// 登录之后需要判断是否有完善个人信息
if (userInfo.code) {
if (userInfo.code === 1) {
const info = userInfo.data.user || '';
if (!info.has_idcard) { // 如果【查询我的信息】没有填写过身份证(has_idcard 为 false),则进入完善个人信息页
$router.push('/recall/boot')
......
......@@ -177,7 +177,7 @@ onMounted(async () => {
mobile: userInfo.value.phone,
idcard: userInfo.value.idCard
})
if (res.code) {
if (res.code === 1) {
activityCount.value = res.data?.jh_payment_qty || 0
volunteerCount.value = res.data?.jh_volunteers_qty || 0
recordDate.value = res.data?.record_date || ''
......@@ -187,7 +187,7 @@ onMounted(async () => {
} else {
// 如果是收集完成没有缓存字段的情况, 直接查接口
const res = await searchOldActivityAPI()
if (res.code) {
if (res.code === 1) {
activityCount.value = res.data?.jh_payment_qty || 0
volunteerCount.value = res.data?.jh_volunteers_qty || 0
recordDate.value = res.data?.record_date || ''
......@@ -195,7 +195,7 @@ onMounted(async () => {
}
const resUserInfo = await userInfoAPI()
// 登录之后需要判断是否有完善个人信息
if (resUserInfo.code) {
if (resUserInfo.code === 1) {
userInfo.value = resUserInfo.data?.user || {}
}
}
......
......@@ -433,7 +433,7 @@ const handleLessonClick = async (lesson) => {
// 重新获取课程数据
const { code, data } = await getScheduleCourseAPI({ i: lesson.id });
if (code) {
if (code === 1) {
course.value = data;
courseFile.value = data.file;
......@@ -678,7 +678,7 @@ onMounted(async () => {
if (courseId.value) {
const { code, data } = await getScheduleCourseAPI({ i: courseId.value });
if (code) {
if (code === 1) {
course.value = data;
courseFile.value = data.file;
......@@ -695,7 +695,7 @@ onMounted(async () => {
// 获取课程目录
const detail = await getCourseDetailAPI({ i: course.value.group_id });
if (detail.code) {
if (detail.code === 1) {
course_lessons.value = detail.data.schedule || [];
task_list.value = [];
timeout_task_list.value = [];
......
......@@ -473,14 +473,14 @@ const onPanelChange = ({ date }) => {
const handLike = async (post) => {
if (!post.is_liked) {
const { code, data } = await likeUploadTaskInfoAPI({ checkin_id: post.id, })
if (code) {
if (code === 1) {
showSuccessToast('点赞成功')
post.likes++;
post.is_liked = true;
}
} else {
const { code, data } = await dislikeUploadTaskInfoAPI({ checkin_id: post.id, })
if (code) {
if (code === 1) {
showSuccessToast('取消点赞成功')
post.likes--;
post.is_liked = false;
......@@ -573,7 +573,7 @@ const showProgress = ref(true);
const getTaskDetail = async (month) => {
const { code, data } = await getTaskDetailAPI({ i: route.query.id, month });
if (code) {
if (code === 1) {
taskDetail.value = data;
progress1.value = ((data.checkin_number/data.target_number)*100).toFixed(1); // 计算进度条百分比
showProgress.value = !isNaN(progress1.value); // 如果是NaN,就不显示进度条
......@@ -594,7 +594,7 @@ const getCheckedDates = async (month) => {
subtask_id: selected_subtask_id.value,
month
});
if (checkedDatesResult.code) {
if (checkedDatesResult.code === 1) {
myCheckinDates.value = checkedDatesResult.data.my_checkin_dates;
// 把['2025-06-06'] 转化为 [6] 只取日期去掉0
// myCheckinDates.value = myCheckinDates.value.map(date => {
......@@ -625,7 +625,7 @@ const onLoad = async (date) => {
task_id: selected_task_id.value,
subtask_id: selected_subtask_id.value,
});
if (res.code) {
if (res.code === 1) {
// 整理数据结构
checkinDataList.value = [...checkinDataList.value, ...formatData(res.data)];
finished.value = res.data.checkin_list.length < limit.value;
......@@ -640,7 +640,7 @@ const courseList = ref([]);
const getFilterList = async (grade_id=null, class_id=null) => {
const { code, data } = await getTeacherGradeClassListAPI({ grade_id, class_id });
if (code) {
if (code === 1) {
// 处理数据
gradeOption.value = data.grade_list?.map(item => {
return {
......
......@@ -943,7 +943,7 @@ const handleSubmit = async (values) => {
// 这里可以调用API提交数据
console.log('提交的表单数据:', submitData);
const { code, data } = await setTeacherTaskAPI(submitData);
if (code) {
if (code === 1) {
showToast('保存成功');
$router.back();
}
......@@ -962,7 +962,7 @@ const handleSubmit = async (values) => {
onMounted(async () => {
// 这里可以调用API获取课程、活动、年级、班级、小组等数据
const { code, data } = await getTeacherFindSettingsAPI();
if (code) {
if (code === 1) {
cycleOptions.value = Object.entries(data.task_cycle).map(([value, text]) => ({
text,
value: String(value) // 确保值为字符串类型
......
......@@ -443,7 +443,7 @@ const onLoad = async () => {
keyword: searchKeyword.value,
});
if (res.code) {
if (res.code === 1) {
// 整理数据结构
studentList.value = [...studentList.value, ...res.data.user_list];
finished.value = res.data.user_list.length < limit.value;
......@@ -468,7 +468,7 @@ const courseList = ref([]);
const getFilterList = async (grade_id=null, class_id=null) => {
const { code, data } = await getTeacherGradeClassListAPI({ grade_id, class_id });
if (code) {
if (code === 1) {
// 处理数据
gradeOption.value = data.grade_list?.map(item => {
return {
......
......@@ -482,7 +482,7 @@ const submitComment = async () => {
// 这里应该调用API提交点评
const { code, data } = await addCheckinFeedbackAPI(commentForm.value)
if (code) {
if (code === 1) {
commentForm.value.feedback_id = data.id
// 更新本地数据
currentCommentPost.value.is_feedback = true
......@@ -615,7 +615,7 @@ const onRecordLoad = async () => {
// task_id: filterTaskId.value,
// subtask_id: filterSubtaskId.value
});
if (res.code) {
if (res.code === 1) {
// 整理数据结构
records.value = [...records.value, ...res.data];
recordFinished.value = res.data.length < recordLimit.value;
......@@ -638,7 +638,7 @@ const onEvaluationLoad = async () => {
task_id: filterTaskId.value,
subtask_id: filterSubtaskId.value
});
if (res.code) {
if (res.code === 1) {
// 整理数据结构
evaluationList.value = [...evaluationList.value, ...res.data];
evaluationFinished.value = res.data.length < evaluationLimit.value;
......@@ -664,7 +664,7 @@ const confirmDelete = async () => {
const { code } = await delCheckinFeedbackAPI({
i: currentDeleteId.value
})
if (code) {
if (code === 1) {
const index = evaluationList.value.findIndex(item => item.id === currentDeleteId.value)
if (index !== -1) {
evaluationList.value.splice(index, 1)
......@@ -714,7 +714,7 @@ onMounted(async () => {
*/
const loadStudentData = async (studentId) => {
const { code, data } = await getStudentDetailAPI({ i: studentId })
if (code) {
if (code === 1) {
studentInfo.value = data;
studentInfo.value?.lesson_list.sort((a, b) => a.title.length - b.title.length)
selectedCourses.value = [studentInfo.value.lesson_list[0] || '']
......@@ -795,14 +795,14 @@ const handleAudioPlay = (id) => {
const handLike = async (post) => {
if (!post.is_liked) {
const { code, data } = await likeUploadTaskInfoAPI({ checkin_id: post.id, })
if (code) {
if (code === 1) {
showSuccessToast('点赞成功')
post.likes++;
post.is_liked = true;
}
} else {
const { code, data } = await dislikeUploadTaskInfoAPI({ checkin_id: post.id, })
if (code) {
if (code === 1) {
showSuccessToast('取消点赞成功')
post.likes--;
post.is_liked = false;
......@@ -826,7 +826,7 @@ const onLoad = async (date) => {
task_id: filterTaskId.value,
subtask_id: filterSubtaskId.value
});
if (res.code) {
if (res.code === 1) {
// 整理数据结构
checkinDataList.value = [...checkinDataList.value, ...formatData(res.data)];
finished.value = res.data.length < limit.value;
......@@ -945,7 +945,7 @@ const getStatList = async () => {
subtask_id: filterSubtaskId.value
})
if (code) {
if (code === 1) {
checkinCount.value = data.real_checkin_count/data.need_checkin_count * 100;
uploadCount.value = data.real_upload_count/data.need_upload_count * 100;
}
......
......@@ -119,14 +119,14 @@ const commentForm = ref({
async function handLike(post) {
if (!post.is_liked) {
const { code } = await likeUploadTaskInfoAPI({ checkin_id: post.id })
if (code) {
if (code === 1) {
showSuccessToast('点赞成功')
post.likes++
post.is_liked = true
}
} else {
const { code } = await dislikeUploadTaskInfoAPI({ checkin_id: post.id })
if (code) {
if (code === 1) {
showSuccessToast('取消点赞成功')
post.likes--
post.is_liked = false
......@@ -181,7 +181,7 @@ async function submitComment() {
try {
showLoadingToast('提交中...')
const { code, data } = await addCheckinFeedbackAPI(commentForm.value)
if (code) {
if (code === 1) {
commentForm.value.feedback_id = data.id
currentCommentPost.value.is_feedback = true
checkinDataList.value.forEach(item => {
......@@ -254,7 +254,7 @@ async function onLoad() {
created_by: $route.query.created_by,
date: $route.query.date,
})
if (res.code) {
if (res.code === 1) {
checkinDataList.value = [...checkinDataList.value, ...formatData(res.data.checkin_list)]
finished.value = res.data.checkin_list.length < limit.value
page.value = nextPage + 1
......