hookehuyr

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

...@@ -63,7 +63,7 @@ const unread_msg_count = ref(0) ...@@ -63,7 +63,7 @@ const unread_msg_count = ref(0)
63 async function load_unread_msg_count() { 63 async function load_unread_msg_count() {
64 try { 64 try {
65 const { code, data } = await getUserInfoAPI() 65 const { code, data } = await getUserInfoAPI()
66 - if (code) { 66 + if (code === 1) {
67 unread_msg_count.value = +data.unread_msg_count || 0 67 unread_msg_count.value = +data.unread_msg_count || 0
68 } else { 68 } else {
69 unread_msg_count.value = 0 69 unread_msg_count.value = 0
......
...@@ -192,7 +192,7 @@ const confirm_delete_comment = async () => { ...@@ -192,7 +192,7 @@ const confirm_delete_comment = async () => {
192 } 192 }
193 193
194 const { code } = await delGroupCommentAPI({ i: comment_id }) 194 const { code } = await delGroupCommentAPI({ i: comment_id })
195 - if (code) { 195 + if (code === 1) {
196 showToast('评论删除成功') 196 showToast('评论删除成功')
197 emit('commentDeleted', comment_id) 197 emit('commentDeleted', comment_id)
198 } 198 }
......
...@@ -212,7 +212,7 @@ const handle_submit = async () => { ...@@ -212,7 +212,7 @@ const handle_submit = async () => {
212 submitting.value = true 212 submitting.value = true
213 try { 213 try {
214 const { code } = await checkinTaskAPI({ subtask_id: selected_item.value.checkin_subtask_id }) 214 const { code } = await checkinTaskAPI({ subtask_id: selected_item.value.checkin_subtask_id })
215 - if (code) { 215 + if (code === 1) {
216 emit('submit-success') 216 emit('submit-success')
217 showToast('打卡成功') 217 showToast('打卡成功')
218 selected_item.value = null 218 selected_item.value = null
......
...@@ -53,7 +53,7 @@ const minor_group_option = ref([]) ...@@ -53,7 +53,7 @@ const minor_group_option = ref([])
53 // 获取筛选选项列表 53 // 获取筛选选项列表
54 const getFilterList = async (group_id = null, team_id = null) => { 54 const getFilterList = async (group_id = null, team_id = null) => {
55 const { code, data } = await getTeacherGradeClassListAPI({ group_id, team_id }); 55 const { code, data } = await getTeacherGradeClassListAPI({ group_id, team_id });
56 - if (code) { 56 + if (code === 1) {
57 // 处理数据 57 // 处理数据
58 course_option.value = data.group_list?.map(item => { 58 course_option.value = data.group_list?.map(item => {
59 return { 59 return {
......
...@@ -329,7 +329,7 @@ export function useCheckin() { ...@@ -329,7 +329,7 @@ export function useCheckin() {
329 result = await addUploadTaskAPI(submitData) 329 result = await addUploadTaskAPI(submitData)
330 } 330 }
331 331
332 - if (result.code) { 332 + if (result.code === 1) {
333 showToast('提交成功') 333 showToast('提交成功')
334 334
335 // 设置刷新标记,用于列表页更新数据 335 // 设置刷新标记,用于列表页更新数据
...@@ -400,7 +400,7 @@ export function useCheckin() { ...@@ -400,7 +400,7 @@ export function useCheckin() {
400 if (route.query.status === 'edit') { 400 if (route.query.status === 'edit') {
401 try { 401 try {
402 const { code, data } = await getUploadTaskInfoAPI({ i: route.query.post_id }) 402 const { code, data } = await getUploadTaskInfoAPI({ i: route.query.post_id })
403 - if (code) { 403 + if (code === 1) {
404 message.value = data?.note || '' 404 message.value = data?.note || ''
405 activeType.value = data?.file_type || 'text' 405 activeType.value = data?.file_type || 'text'
406 // 小作业ID 406 // 小作业ID
......
...@@ -28,7 +28,7 @@ export const useStudyComments = (course) => { ...@@ -28,7 +28,7 @@ export const useStudyComments = (course) => {
28 group_id: course.value.group_id, 28 group_id: course.value.group_id,
29 schedule_id: course.value.id 29 schedule_id: course.value.id
30 }); 30 });
31 - if (comment.code) { 31 + if (comment.code === 1) {
32 commentList.value = comment.data.comment_list; 32 commentList.value = comment.data.comment_list;
33 commentCount.value = comment.data.comment_count; 33 commentCount.value = comment.data.comment_count;
34 } 34 }
...@@ -38,13 +38,13 @@ export const useStudyComments = (course) => { ...@@ -38,13 +38,13 @@ export const useStudyComments = (course) => {
38 try { 38 try {
39 if (!comment.is_like) { 39 if (!comment.is_like) {
40 const { code } = await addGroupCommentLikeAPI({ i: comment.id }); 40 const { code } = await addGroupCommentLikeAPI({ i: comment.id });
41 - if (code) { 41 + if (code === 1) {
42 comment.is_like = true; 42 comment.is_like = true;
43 comment.like_count += 1; 43 comment.like_count += 1;
44 } 44 }
45 } else { 45 } else {
46 const { code } = await delGroupCommentLikeAPI({ i: comment.id }); 46 const { code } = await delGroupCommentLikeAPI({ i: comment.id });
47 - if (code) { 47 + if (code === 1) {
48 comment.is_like = false; 48 comment.is_like = false;
49 comment.like_count -= 1; 49 comment.like_count -= 1;
50 } 50 }
...@@ -65,7 +65,7 @@ export const useStudyComments = (course) => { ...@@ -65,7 +65,7 @@ export const useStudyComments = (course) => {
65 note: newComment.value 65 note: newComment.value
66 }); 66 });
67 67
68 - if (code) { 68 + if (code === 1) {
69 await refreshComments(); 69 await refreshComments();
70 newComment.value = ''; 70 newComment.value = '';
71 } 71 }
...@@ -88,7 +88,7 @@ export const useStudyComments = (course) => { ...@@ -88,7 +88,7 @@ export const useStudyComments = (course) => {
88 limit: popupLimit.value, 88 limit: popupLimit.value,
89 page: nextPage 89 page: nextPage
90 }); 90 });
91 - if (res.code) { 91 + if (res.code === 1) {
92 const newComments = res.data.comment_list; 92 const newComments = res.data.comment_list;
93 const existingIds = new Set(popupCommentList.value.map(item => item.id)); 93 const existingIds = new Set(popupCommentList.value.map(item => item.id));
94 const uniqueNewComments = newComments.filter(item => !existingIds.has(item.id)); 94 const uniqueNewComments = newComments.filter(item => !existingIds.has(item.id));
...@@ -113,7 +113,7 @@ export const useStudyComments = (course) => { ...@@ -113,7 +113,7 @@ export const useStudyComments = (course) => {
113 note: popupComment.value 113 note: popupComment.value
114 }); 114 });
115 115
116 - if (code) { 116 + if (code === 1) {
117 popupCommentList.value = []; 117 popupCommentList.value = [];
118 popupPage.value = 0; 118 popupPage.value = 0;
119 popupFinished.value = false; 119 popupFinished.value = false;
......
...@@ -65,7 +65,7 @@ export function provideAuth() { ...@@ -65,7 +65,7 @@ export function provideAuth() {
65 // } 65 // }
66 // 从服务器获取用户信息并更新本地存储 66 // 从服务器获取用户信息并更新本地存储
67 const { code, data } = await getUserInfoAPI(); 67 const { code, data } = await getUserInfoAPI();
68 - if (code) { 68 + if (code === 1) {
69 currentUser.value = { ...data.user, ...data.checkin } 69 currentUser.value = { ...data.user, ...data.checkin }
70 localStorage.setItem('currentUser', JSON.stringify(currentUser.value)) 70 localStorage.setItem('currentUser', JSON.stringify(currentUser.value))
71 // 重新设置认证头 71 // 重新设置认证头
...@@ -78,7 +78,7 @@ export function provideAuth() { ...@@ -78,7 +78,7 @@ export function provideAuth() {
78 } 78 }
79 } else { 79 } else {
80 const { code, data } = await getAuthInfoAPI(); 80 const { code, data } = await getAuthInfoAPI();
81 - if(code) { 81 + if (code === 1) {
82 // 如果接口返回了 user_info,先保存 82 // 如果接口返回了 user_info,先保存
83 if (data.user_info) { 83 if (data.user_info) {
84 applyUserInfoAuth(data.user_info, { set_auth_headers: setAuthHeaders }) 84 applyUserInfoAuth(data.user_info, { set_auth_headers: setAuthHeaders })
...@@ -95,7 +95,7 @@ export function provideAuth() { ...@@ -95,7 +95,7 @@ export function provideAuth() {
95 // 获取完整用户信息(包含打卡统计数据) 95 // 获取完整用户信息(包含打卡统计数据)
96 try { 96 try {
97 const userRes = await getUserInfoAPI(); 97 const userRes = await getUserInfoAPI();
98 - if (userRes.code) { 98 + if (userRes.code === 1) {
99 currentUser.value = { ...userRes.data.user, ...userRes.data.checkin } 99 currentUser.value = { ...userRes.data.user, ...userRes.data.checkin }
100 } else { 100 } else {
101 currentUser.value = { ...data.user, ...data.checkin } 101 currentUser.value = { ...data.user, ...data.checkin }
...@@ -140,7 +140,7 @@ export function provideAuth() { ...@@ -140,7 +140,7 @@ export function provideAuth() {
140 const logout = async () => { 140 const logout = async () => {
141 try { 141 try {
142 const { code } = await logoutAPI() 142 const { code } = await logoutAPI()
143 - if (code) { 143 + if (code === 1) {
144 // 清空当前用户状态 144 // 清空当前用户状态
145 currentUser.value = null 145 currentUser.value = null
146 // 清理本地存储的用户信息和登录时间戳 146 // 清理本地存储的用户信息和登录时间戳
......
...@@ -162,7 +162,7 @@ const sendVerificationCode = async () => { ...@@ -162,7 +162,7 @@ const sendVerificationCode = async () => {
162 try { 162 try {
163 // TAG: 调用发送验证码API 163 // TAG: 调用发送验证码API
164 const { code } = await smsAPI({ mobile: formData.phone }) 164 const { code } = await smsAPI({ mobile: formData.phone })
165 - if (code) { 165 + if (code === 1) {
166 showToast('验证码已发送') 166 showToast('验证码已发送')
167 startCountdown() 167 startCountdown()
168 return 168 return
...@@ -190,7 +190,7 @@ const handleSubmit = async () => { ...@@ -190,7 +190,7 @@ const handleSubmit = async () => {
190 password: formData.password 190 password: formData.password
191 }) 191 })
192 192
193 - if (code) { 193 + if (code === 1) {
194 showToast('密码重置成功') 194 showToast('密码重置成功')
195 // 重置成功后跳转到登录页 195 // 重置成功后跳转到登录页
196 router.push('/login') 196 router.push('/login')
......
...@@ -278,7 +278,7 @@ const sendVerificationCode = async () => { ...@@ -278,7 +278,7 @@ const sendVerificationCode = async () => {
278 278
279 try { 279 try {
280 const { code } = await smsAPI({ mobile: mobile.value }); 280 const { code } = await smsAPI({ mobile: mobile.value });
281 - if (code) { 281 + if (code === 1) {
282 showToast('验证码已发送'); 282 showToast('验证码已发送');
283 startCountdown(); 283 startCountdown();
284 return; 284 return;
...@@ -315,7 +315,7 @@ const handleSubmit = async () => { ...@@ -315,7 +315,7 @@ const handleSubmit = async () => {
315 } 315 }
316 316
317 const { code, data } = await getUserInfoAPI(); 317 const { code, data } = await getUserInfoAPI();
318 - if (code) { 318 + if (code === 1) {
319 // 登录成功,更新auth状态,传递完整的用户信息包括打卡信息 319 // 登录成功,更新auth状态,传递完整的用户信息包括打卡信息
320 const success = login({ ...data.user, ...data.checkin }); 320 const success = login({ ...data.user, ...data.checkin });
321 321
......
...@@ -245,7 +245,7 @@ const sendVerificationCode = async () => { ...@@ -245,7 +245,7 @@ const sendVerificationCode = async () => {
245 try { 245 try {
246 // TAG: 调用发送验证码API 246 // TAG: 调用发送验证码API
247 const { code } = await smsAPI({ mobile: formData.phone }) 247 const { code } = await smsAPI({ mobile: formData.phone })
248 - if (code) { 248 + if (code === 1) {
249 showToast('验证码已发送') 249 showToast('验证码已发送')
250 startCountdown() 250 startCountdown()
251 return 251 return
...@@ -288,7 +288,7 @@ const handleSubmit = async () => { ...@@ -288,7 +288,7 @@ const handleSubmit = async () => {
288 sms_code: formData.verificationCode, 288 sms_code: formData.verificationCode,
289 password: formData.password, 289 password: formData.password,
290 }) 290 })
291 - if (code) { 291 + if (code === 1) {
292 // 使用auth.js中的login函数 292 // 使用auth.js中的login函数
293 const success = login({ 293 const success = login({
294 name: formData.name, 294 name: formData.name,
......
...@@ -229,7 +229,7 @@ const lastUsedTargetList = ref([]) ...@@ -229,7 +229,7 @@ const lastUsedTargetList = ref([])
229 229
230 const fetchTargetList = async (subtask_id) => { 230 const fetchTargetList = async (subtask_id) => {
231 const { code, data } = await reuseGratitudeFormAPI({ subtask_id }) 231 const { code, data } = await reuseGratitudeFormAPI({ subtask_id })
232 - if (code) { 232 + if (code === 1) {
233 targetList.value = data.gratitude_form_list || [] 233 targetList.value = data.gratitude_form_list || []
234 lastUsedTargetList.value = data.last_used_list || [] 234 lastUsedTargetList.value = data.last_used_list || []
235 235
...@@ -440,7 +440,7 @@ const handleTargetEdit = (item) => { ...@@ -440,7 +440,7 @@ const handleTargetEdit = (item) => {
440 */ 440 */
441 const handleTargetDelete = async (item) => { 441 const handleTargetDelete = async (item) => {
442 const { code } = await gratitudeDeleteAPI({ id: item.id }) 442 const { code } = await gratitudeDeleteAPI({ id: item.id })
443 - if (code) { 443 + if (code === 1) {
444 // 删除成功,更新本地列表 444 // 删除成功,更新本地列表
445 const targetIndex = targetList.value.findIndex(t => t.id === item.id) 445 const targetIndex = targetList.value.findIndex(t => t.id === item.id)
446 if (targetIndex > -1) { 446 if (targetIndex > -1) {
...@@ -601,7 +601,7 @@ const getUploadTips = () => { ...@@ -601,7 +601,7 @@ const getUploadTips = () => {
601 */ 601 */
602 const getTaskDetail = async (month) => { 602 const getTaskDetail = async (month) => {
603 const { code, data } = await getTaskDetailAPI({ i: route.query.task_id, month }) 603 const { code, data } = await getTaskDetailAPI({ i: route.query.task_id, month })
604 - if (code) { 604 + if (code === 1) {
605 taskDetail.value = data 605 taskDetail.value = data
606 } 606 }
607 } 607 }
......
...@@ -481,14 +481,14 @@ const goToCheckinDetailPage = () => { ...@@ -481,14 +481,14 @@ const goToCheckinDetailPage = () => {
481 const handLike = async (post) => { 481 const handLike = async (post) => {
482 if (!post.is_liked) { 482 if (!post.is_liked) {
483 const { code, data } = await likeUploadTaskInfoAPI({ checkin_id: post.id, }) 483 const { code, data } = await likeUploadTaskInfoAPI({ checkin_id: post.id, })
484 - if (code) { 484 + if (code === 1) {
485 showSuccessToast('点赞成功') 485 showSuccessToast('点赞成功')
486 post.likes++; 486 post.likes++;
487 post.is_liked = true; 487 post.is_liked = true;
488 } 488 }
489 } else { 489 } else {
490 const { code, data } = await dislikeUploadTaskInfoAPI({ checkin_id: post.id, }) 490 const { code, data } = await dislikeUploadTaskInfoAPI({ checkin_id: post.id, })
491 - if (code) { 491 + if (code === 1) {
492 showSuccessToast('取消点赞成功') 492 showSuccessToast('取消点赞成功')
493 post.likes--; 493 post.likes--;
494 post.is_liked = false; 494 post.is_liked = false;
...@@ -520,7 +520,7 @@ const delCheckin = (post) => { ...@@ -520,7 +520,7 @@ const delCheckin = (post) => {
520 .then(async () => { 520 .then(async () => {
521 // 调用接口 521 // 调用接口
522 const { code, data } = await delUploadTaskInfoAPI({ i: post.id }); 522 const { code, data } = await delUploadTaskInfoAPI({ i: post.id });
523 - if (code) { 523 + if (code === 1) {
524 // 删除成功后,刷新页面 524 // 删除成功后,刷新页面
525 showSuccessToast('删除成功'); 525 showSuccessToast('删除成功');
526 526
...@@ -565,7 +565,7 @@ const myTotalGratitudeCount = ref(0); ...@@ -565,7 +565,7 @@ const myTotalGratitudeCount = ref(0);
565 565
566 const getTaskDetail = async (month) => { 566 const getTaskDetail = async (month) => {
567 const { code, data } = await getTaskDetailAPI({ i: route.query.id, month, subtask_id: selectedSubtaskId.value }); 567 const { code, data } = await getTaskDetailAPI({ i: route.query.id, month, subtask_id: selectedSubtaskId.value });
568 - if (code) { 568 + if (code === 1) {
569 taskDetail.value = data; 569 taskDetail.value = data;
570 progress1.value = ((data.checkin_number/data.target_number)*100).toFixed(1); // 计算进度条百分比 570 progress1.value = ((data.checkin_number/data.target_number)*100).toFixed(1); // 计算进度条百分比
571 showProgress.value = !isNaN(progress1.value); // 如果是NaN,就不显示进度条 571 showProgress.value = !isNaN(progress1.value); // 如果是NaN,就不显示进度条
...@@ -599,7 +599,7 @@ const onLoad = async (date) => { ...@@ -599,7 +599,7 @@ const onLoad = async (date) => {
599 subtask_id: selectedSubtaskId.value, 599 subtask_id: selectedSubtaskId.value,
600 date: current_date 600 date: current_date
601 }); 601 });
602 - if (res.code) { 602 + if (res.code === 1) {
603 // 整理数据结构 603 // 整理数据结构
604 const newItems = formatData(res.data); 604 const newItems = formatData(res.data);
605 // 去重合并 605 // 去重合并
...@@ -653,7 +653,7 @@ onMounted(async () => { ...@@ -653,7 +653,7 @@ onMounted(async () => {
653 // 获取作品类型数据 653 // 获取作品类型数据
654 try { 654 try {
655 const { code, data } = await getTeacherFindSettingsAPI(); 655 const { code, data } = await getTeacherFindSettingsAPI();
656 - if (code && data.task_attachment_type) { 656 + if (code === 1 && data.task_attachment_type) {
657 attachmentTypeOptions.value = Object.entries(data.task_attachment_type).map(([key, value]) => ({ 657 attachmentTypeOptions.value = Object.entries(data.task_attachment_type).map(([key, value]) => ({
658 key, 658 key,
659 value 659 value
...@@ -778,7 +778,7 @@ onActivated(async () => { ...@@ -778,7 +778,7 @@ onActivated(async () => {
778 try { 778 try {
779 // 获取最新的打卡信息 779 // 获取最新的打卡信息
780 const { code, data } = await getUploadTaskInfoAPI({ i: refreshId }) 780 const { code, data } = await getUploadTaskInfoAPI({ i: refreshId })
781 - if (code && data) { 781 + if (code === 1 && data) {
782 // 构造伪造的 data 对象以适配 formatData 782 // 构造伪造的 data 对象以适配 formatData
783 const mockData = { checkin_list: [data] } 783 const mockData = { checkin_list: [data] }
784 const formattedList = formatData(mockData) 784 const formattedList = formatData(mockData)
......
...@@ -138,7 +138,7 @@ const task_detail = ref({}) ...@@ -138,7 +138,7 @@ const task_detail = ref({})
138 const load_task_detail = async () => { 138 const load_task_detail = async () => {
139 try { 139 try {
140 const { code, data } = await getTaskDetailAPI({ i: target_checkin_id.value }) 140 const { code, data } = await getTaskDetailAPI({ i: target_checkin_id.value })
141 - if (code) { 141 + if (code === 1) {
142 task_detail.value = data || {} 142 task_detail.value = data || {}
143 } 143 }
144 } catch (error) { 144 } catch (error) {
......
...@@ -284,7 +284,7 @@ const onSubmit = async () => { ...@@ -284,7 +284,7 @@ const onSubmit = async () => {
284 meta_id: fileList.value.map(item => item.meta_id), 284 meta_id: fileList.value.map(item => item.meta_id),
285 file_type: route.query.type, 285 file_type: route.query.type,
286 }); 286 });
287 - if (code) { 287 + if (code === 1) {
288 showToast('提交成功') 288 showToast('提交成功')
289 router.back() 289 router.back()
290 } 290 }
...@@ -296,7 +296,7 @@ const onSubmit = async () => { ...@@ -296,7 +296,7 @@ const onSubmit = async () => {
296 meta_id: fileList.value.map(item => item.meta_id), 296 meta_id: fileList.value.map(item => item.meta_id),
297 file_type: route.query.type, 297 file_type: route.query.type,
298 }); 298 });
299 - if (code) { 299 + if (code === 1) {
300 showToast('提交成功') 300 showToast('提交成功')
301 router.back() 301 router.back()
302 } 302 }
...@@ -312,7 +312,7 @@ const onSubmit = async () => { ...@@ -312,7 +312,7 @@ const onSubmit = async () => {
312 onMounted(async () => { 312 onMounted(async () => {
313 if (route.query.status === 'edit') { 313 if (route.query.status === 'edit') {
314 const { code, data } = await getUploadTaskInfoAPI({ i: route.query.post_id }); 314 const { code, data } = await getUploadTaskInfoAPI({ i: route.query.post_id });
315 - if (code) { 315 + if (code === 1) {
316 fileList.value = data.files.map(item => ({ 316 fileList.value = data.files.map(item => ({
317 name: item.name, 317 name: item.name,
318 url: item.value, 318 url: item.value,
......
...@@ -280,7 +280,7 @@ const onSubmit = async () => { ...@@ -280,7 +280,7 @@ const onSubmit = async () => {
280 meta_id: fileList.value.map(item => item.meta_id), 280 meta_id: fileList.value.map(item => item.meta_id),
281 file_type: route.query.type, 281 file_type: route.query.type,
282 }); 282 });
283 - if (code) { 283 + if (code === 1) {
284 showToast('提交成功') 284 showToast('提交成功')
285 router.back() 285 router.back()
286 } 286 }
...@@ -292,7 +292,7 @@ const onSubmit = async () => { ...@@ -292,7 +292,7 @@ const onSubmit = async () => {
292 meta_id: fileList.value.map(item => item.meta_id), 292 meta_id: fileList.value.map(item => item.meta_id),
293 file_type: route.query.type, 293 file_type: route.query.type,
294 }); 294 });
295 - if (code) { 295 + if (code === 1) {
296 showToast('提交成功') 296 showToast('提交成功')
297 router.back() 297 router.back()
298 } 298 }
...@@ -308,7 +308,7 @@ const onSubmit = async () => { ...@@ -308,7 +308,7 @@ const onSubmit = async () => {
308 onMounted(async () => { 308 onMounted(async () => {
309 if (route.query.status === 'edit') { 309 if (route.query.status === 'edit') {
310 const { code, data } = await getUploadTaskInfoAPI({ i: route.query.post_id }); 310 const { code, data } = await getUploadTaskInfoAPI({ i: route.query.post_id });
311 - if (code) { 311 + if (code === 1) {
312 fileList.value = data.files.map(item => ({ 312 fileList.value = data.files.map(item => ({
313 url: item.value, 313 url: item.value,
314 status: 'done', 314 status: 'done',
......
...@@ -79,7 +79,7 @@ const onSubmit = async () => { ...@@ -79,7 +79,7 @@ const onSubmit = async () => {
79 meta_id: [], // 文本类型不需要文件 79 meta_id: [], // 文本类型不需要文件
80 file_type: route.query.type, 80 file_type: route.query.type,
81 }); 81 });
82 - if (code) { 82 + if (code === 1) {
83 showToast('提交成功') 83 showToast('提交成功')
84 router.back() 84 router.back()
85 } 85 }
...@@ -91,7 +91,7 @@ const onSubmit = async () => { ...@@ -91,7 +91,7 @@ const onSubmit = async () => {
91 meta_id: [], // 文本类型不需要文件 91 meta_id: [], // 文本类型不需要文件
92 file_type: route.query.type, 92 file_type: route.query.type,
93 }); 93 });
94 - if (code) { 94 + if (code === 1) {
95 showToast('提交成功') 95 showToast('提交成功')
96 router.back() 96 router.back()
97 } 97 }
...@@ -109,7 +109,7 @@ const onSubmit = async () => { ...@@ -109,7 +109,7 @@ const onSubmit = async () => {
109 onMounted(async () => { 109 onMounted(async () => {
110 if (route.query.status === 'edit') { 110 if (route.query.status === 'edit') {
111 const { code, data } = await getUploadTaskInfoAPI({ i: route.query.post_id }); 111 const { code, data } = await getUploadTaskInfoAPI({ i: route.query.post_id });
112 - if (code) { 112 + if (code === 1) {
113 message.value = data.note 113 message.value = data.note
114 } 114 }
115 } 115 }
......
...@@ -284,7 +284,7 @@ const onSubmit = async () => { ...@@ -284,7 +284,7 @@ const onSubmit = async () => {
284 meta_id: fileList.value.map(item => item.meta_id), 284 meta_id: fileList.value.map(item => item.meta_id),
285 file_type: route.query.type, 285 file_type: route.query.type,
286 }); 286 });
287 - if (code) { 287 + if (code === 1) {
288 showToast('提交成功') 288 showToast('提交成功')
289 router.back() 289 router.back()
290 } 290 }
...@@ -296,7 +296,7 @@ const onSubmit = async () => { ...@@ -296,7 +296,7 @@ const onSubmit = async () => {
296 meta_id: fileList.value.map(item => item.meta_id), 296 meta_id: fileList.value.map(item => item.meta_id),
297 file_type: route.query.type, 297 file_type: route.query.type,
298 }); 298 });
299 - if (code) { 299 + if (code === 1) {
300 showToast('提交成功') 300 showToast('提交成功')
301 router.back() 301 router.back()
302 } 302 }
...@@ -312,7 +312,7 @@ const onSubmit = async () => { ...@@ -312,7 +312,7 @@ const onSubmit = async () => {
312 onMounted(async () => { 312 onMounted(async () => {
313 if (route.query.status === 'edit') { 313 if (route.query.status === 'edit') {
314 const { code, data } = await getUploadTaskInfoAPI({ i: route.query.post_id }); 314 const { code, data } = await getUploadTaskInfoAPI({ i: route.query.post_id });
315 - if (code) { 315 + if (code === 1) {
316 fileList.value = data.files.map(item => ({ 316 fileList.value = data.files.map(item => ({
317 url: item.value, 317 url: item.value,
318 status: 'done', 318 status: 'done',
......
...@@ -570,7 +570,7 @@ const toggleFavorite = async () => { ...@@ -570,7 +570,7 @@ const toggleFavorite = async () => {
570 group_id: course.value.id 570 group_id: course.value.id
571 }) 571 })
572 const code = resp && typeof resp === 'object' ? resp.code : 0 572 const code = resp && typeof resp === 'object' ? resp.code : 0
573 - if (code) { 573 + if (code === 1) {
574 isFavorite.value = !isFavorite.value 574 isFavorite.value = !isFavorite.value
575 showToast('取消收藏') 575 showToast('取消收藏')
576 } else { 576 } else {
...@@ -582,7 +582,7 @@ const toggleFavorite = async () => { ...@@ -582,7 +582,7 @@ const toggleFavorite = async () => {
582 group_id: course.value.id 582 group_id: course.value.id
583 }) 583 })
584 const code = resp && typeof resp === 'object' ? resp.code : 0 584 const code = resp && typeof resp === 'object' ? resp.code : 0
585 - if (code) { 585 + if (code === 1) {
586 isFavorite.value = !isFavorite.value 586 isFavorite.value = !isFavorite.value
587 showToast('收藏成功') 587 showToast('收藏成功')
588 } else { 588 } else {
...@@ -698,7 +698,7 @@ const handleReviewSubmit = async (review) => { ...@@ -698,7 +698,7 @@ const handleReviewSubmit = async (review) => {
698 note: review.note, 698 note: review.note,
699 score: review.rating 699 score: review.rating
700 }) 700 })
701 - if (code) { 701 + if (code === 1) {
702 showToast('评论提交成功') 702 showToast('评论提交成功')
703 isReviewed.value = true 703 isReviewed.value = true
704 await fetchCommentList() 704 await fetchCommentList()
...@@ -716,7 +716,7 @@ const fetchCommentList = async () => { ...@@ -716,7 +716,7 @@ const fetchCommentList = async () => {
716 page: 0, 716 page: 0,
717 limit: 5 717 limit: 5
718 }) 718 })
719 - if (code) { 719 + if (code === 1) {
720 commentList.value = data.comment_list 720 commentList.value = data.comment_list
721 commentScore.value = data.comment_score || 0 721 commentScore.value = data.comment_score || 0
722 commentTotal.value = data.comment_count || 0 722 commentTotal.value = data.comment_count || 0
...@@ -728,7 +728,7 @@ onMounted(async () => { ...@@ -728,7 +728,7 @@ onMounted(async () => {
728 const id = route.params.id 728 const id = route.params.id
729 // 调用接口获取课程详情 729 // 调用接口获取课程详情
730 const { code, data } = await getCourseDetailAPI({ i: id }); 730 const { code, data } = await getCourseDetailAPI({ i: id });
731 - if (code) { 731 + if (code === 1) {
732 const foundCourse = data; 732 const foundCourse = data;
733 if (foundCourse) { 733 if (foundCourse) {
734 course.value = foundCourse; 734 course.value = foundCourse;
......
...@@ -84,7 +84,7 @@ const fetchComments = async () => { ...@@ -84,7 +84,7 @@ const fetchComments = async () => {
84 page: page.value, 84 page: page.value,
85 limit: limit.value 85 limit: limit.value
86 }) 86 })
87 - if (code) { 87 + if (code === 1) {
88 if (page.value === 0) { 88 if (page.value === 0) {
89 reviews.value = data.comment_list 89 reviews.value = data.comment_list
90 overallRating.value = data.comment_score || 0 90 overallRating.value = data.comment_score || 0
...@@ -126,7 +126,7 @@ const handleReviewEdit = async ({ score, note }) => { ...@@ -126,7 +126,7 @@ const handleReviewEdit = async ({ score, note }) => {
126 score, 126 score,
127 note 127 note
128 }) 128 })
129 - if (code) { 129 + if (code === 1) {
130 showToast('评论修改成功') 130 showToast('评论修改成功')
131 page.value = 0 131 page.value = 0
132 await fetchComments() 132 await fetchComments()
...@@ -137,7 +137,7 @@ const handleReviewDelete = async () => { ...@@ -137,7 +137,7 @@ const handleReviewDelete = async () => {
137 const { code } = await delGroupCommentAPI({ 137 const { code } = await delGroupCommentAPI({
138 i: currentReview.value.id 138 i: currentReview.value.id
139 }) 139 })
140 - if (code) { 140 + if (code === 1) {
141 showToast('评论删除成功') 141 showToast('评论删除成功')
142 page.value = 0 142 page.value = 0
143 await fetchComments() 143 await fetchComments()
......
...@@ -112,11 +112,11 @@ const bannerList = ref([]); ...@@ -112,11 +112,11 @@ const bannerList = ref([]);
112 112
113 onMounted(async () => { 113 onMounted(async () => {
114 const res = await getCourseListAPI({ limit: 4 }); 114 const res = await getCourseListAPI({ limit: 4 });
115 - if (res.code) { 115 + if (res.code === 1) {
116 courses.value = res.data; 116 courses.value = res.data;
117 } 117 }
118 const bannerRes = await getCourseBannerAPI(); 118 const bannerRes = await getCourseBannerAPI();
119 - if (bannerRes.code) { 119 + if (bannerRes.code === 1) {
120 bannerList.value = bannerRes.list; 120 bannerList.value = bannerRes.list;
121 } 121 }
122 }) 122 })
......
...@@ -139,7 +139,7 @@ const onLoad = async () => { ...@@ -139,7 +139,7 @@ const onLoad = async () => {
139 limit: limit.value, 139 limit: limit.value,
140 page: nextPage, 140 page: nextPage,
141 }); 141 });
142 - if (code) { 142 + if (code === 1) {
143 data.forEach((item) => { 143 data.forEach((item) => {
144 item.record_progress = Math.floor((item?.study_count/item?.count)*100); 144 item.record_progress = Math.floor((item?.study_count/item?.count)*100);
145 }); 145 });
......
...@@ -47,7 +47,7 @@ const message = ref({ ...@@ -47,7 +47,7 @@ const message = ref({
47 onMounted(async () => { 47 onMounted(async () => {
48 // 调用接口获取消息详情 48 // 调用接口获取消息详情
49 const { code, data } = await getNewsInfoAPI({ i: route.params.id }); 49 const { code, data } = await getNewsInfoAPI({ i: route.params.id });
50 - if (code) { 50 + if (code === 1) {
51 message.value = data; 51 message.value = data;
52 // 更新消息已读状态 52 // 更新消息已读状态
53 message.value.status = 'read'; 53 message.value.status = 'read';
......
...@@ -334,7 +334,7 @@ const handlePaymentProcessing = () => { ...@@ -334,7 +334,7 @@ const handlePaymentProcessing = () => {
334 const handleViewDetail = async (order) => { 334 const handleViewDetail = async (order) => {
335 try { 335 try {
336 const { code, data } = await getOrderInfoAPI({ i: order.id }); 336 const { code, data } = await getOrderInfoAPI({ i: order.id });
337 - if (code) { 337 + if (code === 1) {
338 orderDetail.value = data; 338 orderDetail.value = data;
339 showDetailDialog.value = true; 339 showDetailDialog.value = true;
340 } 340 }
...@@ -354,7 +354,7 @@ const handleCancel = async (order) => { ...@@ -354,7 +354,7 @@ const handleCancel = async (order) => {
354 .then(async() => { 354 .then(async() => {
355 try { 355 try {
356 const { code } = await cancelOrderAPI({ i: order.id }); 356 const { code } = await cancelOrderAPI({ i: order.id });
357 - if (code) { 357 + if (code === 1) {
358 const index = orders.value.findIndex((item) => item.id === order.id); 358 const index = orders.value.findIndex((item) => item.id === order.id);
359 // 更新订单状态为已取消 359 // 更新订单状态为已取消
360 orders.value[index].status = 'CANCEL'; 360 orders.value[index].status = 'CANCEL';
......
...@@ -159,7 +159,7 @@ const formatCheckInCount = (count) => { ...@@ -159,7 +159,7 @@ const formatCheckInCount = (count) => {
159 159
160 onMounted(async () => { 160 onMounted(async () => {
161 const { code, data } = await getUserInfoAPI(); 161 const { code, data } = await getUserInfoAPI();
162 - if (code) { 162 + if (code === 1) {
163 profile.value = data.user; 163 profile.value = data.user;
164 checkIns.value = data.checkin; 164 checkIns.value = data.checkin;
165 checkIns.value.total_days = data.checkin.total_days || 0 165 checkIns.value.total_days = data.checkin.total_days || 0
......
...@@ -264,7 +264,7 @@ onMounted(async () => { ...@@ -264,7 +264,7 @@ onMounted(async () => {
264 const courseId = router.currentRoute.value.params.id; 264 const courseId = router.currentRoute.value.params.id;
265 // 调用接口获取课程详情 265 // 调用接口获取课程详情
266 const { code, data } = await getCourseDetailAPI({ i: courseId }); 266 const { code, data } = await getCourseDetailAPI({ i: courseId });
267 - if (code) { 267 + if (code === 1) {
268 course.value = data; 268 course.value = data;
269 task_list.value = []; 269 task_list.value = [];
270 timeout_task_list.value = []; 270 timeout_task_list.value = [];
......
...@@ -153,7 +153,7 @@ const sendVerificationCode = async () => { ...@@ -153,7 +153,7 @@ const sendVerificationCode = async () => {
153 try { 153 try {
154 // 调用发送验证码API 154 // 调用发送验证码API
155 const { code } = await smsAPI({ mobile: formData.value.phone }); 155 const { code } = await smsAPI({ mobile: formData.value.phone });
156 - if (code) { 156 + if (code === 1) {
157 showToast('验证码已发送'); 157 showToast('验证码已发送');
158 // 开始倒计时 158 // 开始倒计时
159 countdown.value = 60; 159 countdown.value = 60;
...@@ -196,7 +196,7 @@ const handlePhoneChange = async () => { ...@@ -196,7 +196,7 @@ const handlePhoneChange = async () => {
196 sms_code: formData.value.verificationCode 196 sms_code: formData.value.verificationCode
197 }); 197 });
198 198
199 - if (code) { 199 + if (code === 1) {
200 // 更新auth上下文中的用户信息 200 // 更新auth上下文中的用户信息
201 currentUser.value = { 201 currentUser.value = {
202 ...currentUser.value, 202 ...currentUser.value,
......
...@@ -77,7 +77,7 @@ const handleUsernameChange = async () => { ...@@ -77,7 +77,7 @@ const handleUsernameChange = async () => {
77 77
78 try { 78 try {
79 const { code, data } = await updateUserInfoAPI({ name: username.value }); 79 const { code, data } = await updateUserInfoAPI({ name: username.value });
80 - if (code) { 80 + if (code === 1) {
81 // 更新auth上下文中的用户信息 81 // 更新auth上下文中的用户信息
82 currentUser.value = { 82 currentUser.value = {
83 ...currentUser.value, 83 ...currentUser.value,
......
...@@ -138,7 +138,7 @@ const handleCollectCoins = async () => { ...@@ -138,7 +138,7 @@ const handleCollectCoins = async () => {
138 idcard: userInfo.idCard || '', 138 idcard: userInfo.idCard || '',
139 old_activity_data: activityInfo.value 139 old_activity_data: activityInfo.value
140 }) 140 })
141 - if (res.code) { 141 + if (res.code === 1) {
142 showToast({ 142 showToast({
143 message: '收集星球币成功', 143 message: '收集星球币成功',
144 icon: 'success' 144 icon: 'success'
...@@ -254,7 +254,7 @@ onMounted(async () => { ...@@ -254,7 +254,7 @@ onMounted(async () => {
254 254
255 // 获取用户信息 255 // 获取用户信息
256 const userInfoRes = await userInfoAPI() 256 const userInfoRes = await userInfoAPI()
257 - if (userInfoRes.code) { 257 + if (userInfoRes.code === 1) {
258 userInfo.value = userInfoRes.data.user || {}; 258 userInfo.value = userInfoRes.data.user || {};
259 } 259 }
260 }) 260 })
......
...@@ -153,7 +153,7 @@ const totalPoints = ref(0); ...@@ -153,7 +153,7 @@ const totalPoints = ref(0);
153 153
154 onMounted(async () => { 154 onMounted(async () => {
155 const res = await getPointsListAPI() 155 const res = await getPointsListAPI()
156 - if (res.code) { 156 + if (res.code === 1) {
157 // 需要格式化一下, 变成千分号显示 157 // 需要格式化一下, 变成千分号显示
158 totalPoints.value = Number(res.data?.balance || 0).toLocaleString(); 158 totalPoints.value = Number(res.data?.balance || 0).toLocaleString();
159 } 159 }
......
...@@ -185,7 +185,7 @@ onMounted(async () => { ...@@ -185,7 +185,7 @@ onMounted(async () => {
185 campaign_id: campaign_id.value 185 campaign_id: campaign_id.value
186 }) 186 })
187 187
188 - if (code) { 188 + if (code === 1) {
189 posterBg.value = data.background_image ? data.background_image + '?imageMogr2/thumbnail/800x/strip/quality/80' : defaultBg 189 posterBg.value = data.background_image ? data.background_image + '?imageMogr2/thumbnail/800x/strip/quality/80' : defaultBg
190 qrCodeUrl.value = data?.qrcode || '' 190 qrCodeUrl.value = data?.qrcode || ''
191 isReady.value = true 191 isReady.value = true
......
...@@ -136,7 +136,7 @@ const handleSendCode = async () => { ...@@ -136,7 +136,7 @@ const handleSendCode = async () => {
136 136
137 try { 137 try {
138 const { code } = await smsAPI({ mobile: phone.value }) 138 const { code } = await smsAPI({ mobile: phone.value })
139 - if (code) { 139 + if (code === 1) {
140 showToast('验证码已发送') 140 showToast('验证码已发送')
141 141
142 // Start countdown 142 // Start countdown
...@@ -174,11 +174,11 @@ const handleLogin = async () => { ...@@ -174,11 +174,11 @@ const handleLogin = async () => {
174 174
175 try { 175 try {
176 const res = await loginAPI({ mobile: phone.value, sms_code: code.value, entry: entry.value, referrer_user_id: referrer_user_id.value }) 176 const res = await loginAPI({ mobile: phone.value, sms_code: code.value, entry: entry.value, referrer_user_id: referrer_user_id.value })
177 - if (res.code) { 177 + if (res.code === 1) {
178 applyUserInfoAuth(res, { set_auth_headers: setAuthHeaders, storage: localStorage }) 178 applyUserInfoAuth(res, { set_auth_headers: setAuthHeaders, storage: localStorage })
179 const userInfo = await userInfoAPI() 179 const userInfo = await userInfoAPI()
180 // 登录之后需要判断是否有完善个人信息 180 // 登录之后需要判断是否有完善个人信息
181 - if (userInfo.code) { 181 + if (userInfo.code === 1) {
182 const info = userInfo.data.user || ''; 182 const info = userInfo.data.user || '';
183 if (!info.has_idcard) { // 如果【查询我的信息】没有填写过身份证(has_idcard 为 false),则进入完善个人信息页 183 if (!info.has_idcard) { // 如果【查询我的信息】没有填写过身份证(has_idcard 为 false),则进入完善个人信息页
184 $router.push('/recall/boot') 184 $router.push('/recall/boot')
......
...@@ -177,7 +177,7 @@ onMounted(async () => { ...@@ -177,7 +177,7 @@ onMounted(async () => {
177 mobile: userInfo.value.phone, 177 mobile: userInfo.value.phone,
178 idcard: userInfo.value.idCard 178 idcard: userInfo.value.idCard
179 }) 179 })
180 - if (res.code) { 180 + if (res.code === 1) {
181 activityCount.value = res.data?.jh_payment_qty || 0 181 activityCount.value = res.data?.jh_payment_qty || 0
182 volunteerCount.value = res.data?.jh_volunteers_qty || 0 182 volunteerCount.value = res.data?.jh_volunteers_qty || 0
183 recordDate.value = res.data?.record_date || '' 183 recordDate.value = res.data?.record_date || ''
...@@ -187,7 +187,7 @@ onMounted(async () => { ...@@ -187,7 +187,7 @@ onMounted(async () => {
187 } else { 187 } else {
188 // 如果是收集完成没有缓存字段的情况, 直接查接口 188 // 如果是收集完成没有缓存字段的情况, 直接查接口
189 const res = await searchOldActivityAPI() 189 const res = await searchOldActivityAPI()
190 - if (res.code) { 190 + if (res.code === 1) {
191 activityCount.value = res.data?.jh_payment_qty || 0 191 activityCount.value = res.data?.jh_payment_qty || 0
192 volunteerCount.value = res.data?.jh_volunteers_qty || 0 192 volunteerCount.value = res.data?.jh_volunteers_qty || 0
193 recordDate.value = res.data?.record_date || '' 193 recordDate.value = res.data?.record_date || ''
...@@ -195,7 +195,7 @@ onMounted(async () => { ...@@ -195,7 +195,7 @@ onMounted(async () => {
195 } 195 }
196 const resUserInfo = await userInfoAPI() 196 const resUserInfo = await userInfoAPI()
197 // 登录之后需要判断是否有完善个人信息 197 // 登录之后需要判断是否有完善个人信息
198 - if (resUserInfo.code) { 198 + if (resUserInfo.code === 1) {
199 userInfo.value = resUserInfo.data?.user || {} 199 userInfo.value = resUserInfo.data?.user || {}
200 } 200 }
201 } 201 }
......
...@@ -433,7 +433,7 @@ const handleLessonClick = async (lesson) => { ...@@ -433,7 +433,7 @@ const handleLessonClick = async (lesson) => {
433 433
434 // 重新获取课程数据 434 // 重新获取课程数据
435 const { code, data } = await getScheduleCourseAPI({ i: lesson.id }); 435 const { code, data } = await getScheduleCourseAPI({ i: lesson.id });
436 - if (code) { 436 + if (code === 1) {
437 course.value = data; 437 course.value = data;
438 courseFile.value = data.file; 438 courseFile.value = data.file;
439 439
...@@ -678,7 +678,7 @@ onMounted(async () => { ...@@ -678,7 +678,7 @@ onMounted(async () => {
678 678
679 if (courseId.value) { 679 if (courseId.value) {
680 const { code, data } = await getScheduleCourseAPI({ i: courseId.value }); 680 const { code, data } = await getScheduleCourseAPI({ i: courseId.value });
681 - if (code) { 681 + if (code === 1) {
682 course.value = data; 682 course.value = data;
683 courseFile.value = data.file; 683 courseFile.value = data.file;
684 684
...@@ -695,7 +695,7 @@ onMounted(async () => { ...@@ -695,7 +695,7 @@ onMounted(async () => {
695 695
696 // 获取课程目录 696 // 获取课程目录
697 const detail = await getCourseDetailAPI({ i: course.value.group_id }); 697 const detail = await getCourseDetailAPI({ i: course.value.group_id });
698 - if (detail.code) { 698 + if (detail.code === 1) {
699 course_lessons.value = detail.data.schedule || []; 699 course_lessons.value = detail.data.schedule || [];
700 task_list.value = []; 700 task_list.value = [];
701 timeout_task_list.value = []; 701 timeout_task_list.value = [];
......
...@@ -473,14 +473,14 @@ const onPanelChange = ({ date }) => { ...@@ -473,14 +473,14 @@ const onPanelChange = ({ date }) => {
473 const handLike = async (post) => { 473 const handLike = async (post) => {
474 if (!post.is_liked) { 474 if (!post.is_liked) {
475 const { code, data } = await likeUploadTaskInfoAPI({ checkin_id: post.id, }) 475 const { code, data } = await likeUploadTaskInfoAPI({ checkin_id: post.id, })
476 - if (code) { 476 + if (code === 1) {
477 showSuccessToast('点赞成功') 477 showSuccessToast('点赞成功')
478 post.likes++; 478 post.likes++;
479 post.is_liked = true; 479 post.is_liked = true;
480 } 480 }
481 } else { 481 } else {
482 const { code, data } = await dislikeUploadTaskInfoAPI({ checkin_id: post.id, }) 482 const { code, data } = await dislikeUploadTaskInfoAPI({ checkin_id: post.id, })
483 - if (code) { 483 + if (code === 1) {
484 showSuccessToast('取消点赞成功') 484 showSuccessToast('取消点赞成功')
485 post.likes--; 485 post.likes--;
486 post.is_liked = false; 486 post.is_liked = false;
...@@ -573,7 +573,7 @@ const showProgress = ref(true); ...@@ -573,7 +573,7 @@ const showProgress = ref(true);
573 573
574 const getTaskDetail = async (month) => { 574 const getTaskDetail = async (month) => {
575 const { code, data } = await getTaskDetailAPI({ i: route.query.id, month }); 575 const { code, data } = await getTaskDetailAPI({ i: route.query.id, month });
576 - if (code) { 576 + if (code === 1) {
577 taskDetail.value = data; 577 taskDetail.value = data;
578 progress1.value = ((data.checkin_number/data.target_number)*100).toFixed(1); // 计算进度条百分比 578 progress1.value = ((data.checkin_number/data.target_number)*100).toFixed(1); // 计算进度条百分比
579 showProgress.value = !isNaN(progress1.value); // 如果是NaN,就不显示进度条 579 showProgress.value = !isNaN(progress1.value); // 如果是NaN,就不显示进度条
...@@ -594,7 +594,7 @@ const getCheckedDates = async (month) => { ...@@ -594,7 +594,7 @@ const getCheckedDates = async (month) => {
594 subtask_id: selected_subtask_id.value, 594 subtask_id: selected_subtask_id.value,
595 month 595 month
596 }); 596 });
597 - if (checkedDatesResult.code) { 597 + if (checkedDatesResult.code === 1) {
598 myCheckinDates.value = checkedDatesResult.data.my_checkin_dates; 598 myCheckinDates.value = checkedDatesResult.data.my_checkin_dates;
599 // 把['2025-06-06'] 转化为 [6] 只取日期去掉0 599 // 把['2025-06-06'] 转化为 [6] 只取日期去掉0
600 // myCheckinDates.value = myCheckinDates.value.map(date => { 600 // myCheckinDates.value = myCheckinDates.value.map(date => {
...@@ -625,7 +625,7 @@ const onLoad = async (date) => { ...@@ -625,7 +625,7 @@ const onLoad = async (date) => {
625 task_id: selected_task_id.value, 625 task_id: selected_task_id.value,
626 subtask_id: selected_subtask_id.value, 626 subtask_id: selected_subtask_id.value,
627 }); 627 });
628 - if (res.code) { 628 + if (res.code === 1) {
629 // 整理数据结构 629 // 整理数据结构
630 checkinDataList.value = [...checkinDataList.value, ...formatData(res.data)]; 630 checkinDataList.value = [...checkinDataList.value, ...formatData(res.data)];
631 finished.value = res.data.checkin_list.length < limit.value; 631 finished.value = res.data.checkin_list.length < limit.value;
...@@ -640,7 +640,7 @@ const courseList = ref([]); ...@@ -640,7 +640,7 @@ const courseList = ref([]);
640 640
641 const getFilterList = async (grade_id=null, class_id=null) => { 641 const getFilterList = async (grade_id=null, class_id=null) => {
642 const { code, data } = await getTeacherGradeClassListAPI({ grade_id, class_id }); 642 const { code, data } = await getTeacherGradeClassListAPI({ grade_id, class_id });
643 - if (code) { 643 + if (code === 1) {
644 // 处理数据 644 // 处理数据
645 gradeOption.value = data.grade_list?.map(item => { 645 gradeOption.value = data.grade_list?.map(item => {
646 return { 646 return {
......
...@@ -943,7 +943,7 @@ const handleSubmit = async (values) => { ...@@ -943,7 +943,7 @@ const handleSubmit = async (values) => {
943 // 这里可以调用API提交数据 943 // 这里可以调用API提交数据
944 console.log('提交的表单数据:', submitData); 944 console.log('提交的表单数据:', submitData);
945 const { code, data } = await setTeacherTaskAPI(submitData); 945 const { code, data } = await setTeacherTaskAPI(submitData);
946 - if (code) { 946 + if (code === 1) {
947 showToast('保存成功'); 947 showToast('保存成功');
948 $router.back(); 948 $router.back();
949 } 949 }
...@@ -962,7 +962,7 @@ const handleSubmit = async (values) => { ...@@ -962,7 +962,7 @@ const handleSubmit = async (values) => {
962 onMounted(async () => { 962 onMounted(async () => {
963 // 这里可以调用API获取课程、活动、年级、班级、小组等数据 963 // 这里可以调用API获取课程、活动、年级、班级、小组等数据
964 const { code, data } = await getTeacherFindSettingsAPI(); 964 const { code, data } = await getTeacherFindSettingsAPI();
965 - if (code) { 965 + if (code === 1) {
966 cycleOptions.value = Object.entries(data.task_cycle).map(([value, text]) => ({ 966 cycleOptions.value = Object.entries(data.task_cycle).map(([value, text]) => ({
967 text, 967 text,
968 value: String(value) // 确保值为字符串类型 968 value: String(value) // 确保值为字符串类型
......
...@@ -443,7 +443,7 @@ const onLoad = async () => { ...@@ -443,7 +443,7 @@ const onLoad = async () => {
443 keyword: searchKeyword.value, 443 keyword: searchKeyword.value,
444 }); 444 });
445 445
446 - if (res.code) { 446 + if (res.code === 1) {
447 // 整理数据结构 447 // 整理数据结构
448 studentList.value = [...studentList.value, ...res.data.user_list]; 448 studentList.value = [...studentList.value, ...res.data.user_list];
449 finished.value = res.data.user_list.length < limit.value; 449 finished.value = res.data.user_list.length < limit.value;
...@@ -468,7 +468,7 @@ const courseList = ref([]); ...@@ -468,7 +468,7 @@ const courseList = ref([]);
468 468
469 const getFilterList = async (grade_id=null, class_id=null) => { 469 const getFilterList = async (grade_id=null, class_id=null) => {
470 const { code, data } = await getTeacherGradeClassListAPI({ grade_id, class_id }); 470 const { code, data } = await getTeacherGradeClassListAPI({ grade_id, class_id });
471 - if (code) { 471 + if (code === 1) {
472 // 处理数据 472 // 处理数据
473 gradeOption.value = data.grade_list?.map(item => { 473 gradeOption.value = data.grade_list?.map(item => {
474 return { 474 return {
......
...@@ -482,7 +482,7 @@ const submitComment = async () => { ...@@ -482,7 +482,7 @@ const submitComment = async () => {
482 482
483 // 这里应该调用API提交点评 483 // 这里应该调用API提交点评
484 const { code, data } = await addCheckinFeedbackAPI(commentForm.value) 484 const { code, data } = await addCheckinFeedbackAPI(commentForm.value)
485 - if (code) { 485 + if (code === 1) {
486 commentForm.value.feedback_id = data.id 486 commentForm.value.feedback_id = data.id
487 // 更新本地数据 487 // 更新本地数据
488 currentCommentPost.value.is_feedback = true 488 currentCommentPost.value.is_feedback = true
...@@ -615,7 +615,7 @@ const onRecordLoad = async () => { ...@@ -615,7 +615,7 @@ const onRecordLoad = async () => {
615 // task_id: filterTaskId.value, 615 // task_id: filterTaskId.value,
616 // subtask_id: filterSubtaskId.value 616 // subtask_id: filterSubtaskId.value
617 }); 617 });
618 - if (res.code) { 618 + if (res.code === 1) {
619 // 整理数据结构 619 // 整理数据结构
620 records.value = [...records.value, ...res.data]; 620 records.value = [...records.value, ...res.data];
621 recordFinished.value = res.data.length < recordLimit.value; 621 recordFinished.value = res.data.length < recordLimit.value;
...@@ -638,7 +638,7 @@ const onEvaluationLoad = async () => { ...@@ -638,7 +638,7 @@ const onEvaluationLoad = async () => {
638 task_id: filterTaskId.value, 638 task_id: filterTaskId.value,
639 subtask_id: filterSubtaskId.value 639 subtask_id: filterSubtaskId.value
640 }); 640 });
641 - if (res.code) { 641 + if (res.code === 1) {
642 // 整理数据结构 642 // 整理数据结构
643 evaluationList.value = [...evaluationList.value, ...res.data]; 643 evaluationList.value = [...evaluationList.value, ...res.data];
644 evaluationFinished.value = res.data.length < evaluationLimit.value; 644 evaluationFinished.value = res.data.length < evaluationLimit.value;
...@@ -664,7 +664,7 @@ const confirmDelete = async () => { ...@@ -664,7 +664,7 @@ const confirmDelete = async () => {
664 const { code } = await delCheckinFeedbackAPI({ 664 const { code } = await delCheckinFeedbackAPI({
665 i: currentDeleteId.value 665 i: currentDeleteId.value
666 }) 666 })
667 - if (code) { 667 + if (code === 1) {
668 const index = evaluationList.value.findIndex(item => item.id === currentDeleteId.value) 668 const index = evaluationList.value.findIndex(item => item.id === currentDeleteId.value)
669 if (index !== -1) { 669 if (index !== -1) {
670 evaluationList.value.splice(index, 1) 670 evaluationList.value.splice(index, 1)
...@@ -714,7 +714,7 @@ onMounted(async () => { ...@@ -714,7 +714,7 @@ onMounted(async () => {
714 */ 714 */
715 const loadStudentData = async (studentId) => { 715 const loadStudentData = async (studentId) => {
716 const { code, data } = await getStudentDetailAPI({ i: studentId }) 716 const { code, data } = await getStudentDetailAPI({ i: studentId })
717 - if (code) { 717 + if (code === 1) {
718 studentInfo.value = data; 718 studentInfo.value = data;
719 studentInfo.value?.lesson_list.sort((a, b) => a.title.length - b.title.length) 719 studentInfo.value?.lesson_list.sort((a, b) => a.title.length - b.title.length)
720 selectedCourses.value = [studentInfo.value.lesson_list[0] || ''] 720 selectedCourses.value = [studentInfo.value.lesson_list[0] || '']
...@@ -795,14 +795,14 @@ const handleAudioPlay = (id) => { ...@@ -795,14 +795,14 @@ const handleAudioPlay = (id) => {
795 const handLike = async (post) => { 795 const handLike = async (post) => {
796 if (!post.is_liked) { 796 if (!post.is_liked) {
797 const { code, data } = await likeUploadTaskInfoAPI({ checkin_id: post.id, }) 797 const { code, data } = await likeUploadTaskInfoAPI({ checkin_id: post.id, })
798 - if (code) { 798 + if (code === 1) {
799 showSuccessToast('点赞成功') 799 showSuccessToast('点赞成功')
800 post.likes++; 800 post.likes++;
801 post.is_liked = true; 801 post.is_liked = true;
802 } 802 }
803 } else { 803 } else {
804 const { code, data } = await dislikeUploadTaskInfoAPI({ checkin_id: post.id, }) 804 const { code, data } = await dislikeUploadTaskInfoAPI({ checkin_id: post.id, })
805 - if (code) { 805 + if (code === 1) {
806 showSuccessToast('取消点赞成功') 806 showSuccessToast('取消点赞成功')
807 post.likes--; 807 post.likes--;
808 post.is_liked = false; 808 post.is_liked = false;
...@@ -826,7 +826,7 @@ const onLoad = async (date) => { ...@@ -826,7 +826,7 @@ const onLoad = async (date) => {
826 task_id: filterTaskId.value, 826 task_id: filterTaskId.value,
827 subtask_id: filterSubtaskId.value 827 subtask_id: filterSubtaskId.value
828 }); 828 });
829 - if (res.code) { 829 + if (res.code === 1) {
830 // 整理数据结构 830 // 整理数据结构
831 checkinDataList.value = [...checkinDataList.value, ...formatData(res.data)]; 831 checkinDataList.value = [...checkinDataList.value, ...formatData(res.data)];
832 finished.value = res.data.length < limit.value; 832 finished.value = res.data.length < limit.value;
...@@ -945,7 +945,7 @@ const getStatList = async () => { ...@@ -945,7 +945,7 @@ const getStatList = async () => {
945 subtask_id: filterSubtaskId.value 945 subtask_id: filterSubtaskId.value
946 }) 946 })
947 947
948 - if (code) { 948 + if (code === 1) {
949 checkinCount.value = data.real_checkin_count/data.need_checkin_count * 100; 949 checkinCount.value = data.real_checkin_count/data.need_checkin_count * 100;
950 uploadCount.value = data.real_upload_count/data.need_upload_count * 100; 950 uploadCount.value = data.real_upload_count/data.need_upload_count * 100;
951 } 951 }
......
...@@ -119,14 +119,14 @@ const commentForm = ref({ ...@@ -119,14 +119,14 @@ const commentForm = ref({
119 async function handLike(post) { 119 async function handLike(post) {
120 if (!post.is_liked) { 120 if (!post.is_liked) {
121 const { code } = await likeUploadTaskInfoAPI({ checkin_id: post.id }) 121 const { code } = await likeUploadTaskInfoAPI({ checkin_id: post.id })
122 - if (code) { 122 + if (code === 1) {
123 showSuccessToast('点赞成功') 123 showSuccessToast('点赞成功')
124 post.likes++ 124 post.likes++
125 post.is_liked = true 125 post.is_liked = true
126 } 126 }
127 } else { 127 } else {
128 const { code } = await dislikeUploadTaskInfoAPI({ checkin_id: post.id }) 128 const { code } = await dislikeUploadTaskInfoAPI({ checkin_id: post.id })
129 - if (code) { 129 + if (code === 1) {
130 showSuccessToast('取消点赞成功') 130 showSuccessToast('取消点赞成功')
131 post.likes-- 131 post.likes--
132 post.is_liked = false 132 post.is_liked = false
...@@ -181,7 +181,7 @@ async function submitComment() { ...@@ -181,7 +181,7 @@ async function submitComment() {
181 try { 181 try {
182 showLoadingToast('提交中...') 182 showLoadingToast('提交中...')
183 const { code, data } = await addCheckinFeedbackAPI(commentForm.value) 183 const { code, data } = await addCheckinFeedbackAPI(commentForm.value)
184 - if (code) { 184 + if (code === 1) {
185 commentForm.value.feedback_id = data.id 185 commentForm.value.feedback_id = data.id
186 currentCommentPost.value.is_feedback = true 186 currentCommentPost.value.is_feedback = true
187 checkinDataList.value.forEach(item => { 187 checkinDataList.value.forEach(item => {
...@@ -254,7 +254,7 @@ async function onLoad() { ...@@ -254,7 +254,7 @@ async function onLoad() {
254 created_by: $route.query.created_by, 254 created_by: $route.query.created_by,
255 date: $route.query.date, 255 date: $route.query.date,
256 }) 256 })
257 - if (res.code) { 257 + if (res.code === 1) {
258 checkinDataList.value = [...checkinDataList.value, ...formatData(res.data.checkin_list)] 258 checkinDataList.value = [...checkinDataList.value, ...formatData(res.data.checkin_list)]
259 finished.value = res.data.checkin_list.length < limit.value 259 finished.value = res.data.checkin_list.length < limit.value
260 page.value = nextPage + 1 260 page.value = nextPage + 1
......