Skip to content

Commit

Permalink
feat(ansker): 新增问问同学逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
eleliauk committed Dec 12, 2024
1 parent 204302e commit c8c0db8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 42 deletions.
9 changes: 0 additions & 9 deletions src/common/components/AnswerToStudent/index.scss

This file was deleted.

18 changes: 8 additions & 10 deletions src/common/components/AnswerToStudent/index.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import { Image, View } from '@tarojs/components';

import './index.scss';

// eslint-disable-next-line import/first
import Ask from '@/common/assets/img/publishQuestion/img.png';
// eslint-disable-next-line import/first
import { Answerv1Answer } from '@/common/types/userTypes';

interface Question {
content: string;
preview_answers: Array<Answerv1Answer>;
}

const AnswerToStudent: React.FC<Question> = (props) => {
const { content, preview_answers } = props;
return (
<View className="question-container">
{/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment */}
<Image src={Ask} className="img"></Image>
<View>{content}</View>
<View>{preview_answers.length}个回答</View>
<View className="flex h-[4vh] w-[90vw] items-center justify-center gap-2">
<Image src={Ask as string} className="h-6 w-6" />
<View className="text-base font-medium text-gray-800">{content}</View>
<View className="ml-auto text-sm text-gray-500">
{preview_answers.length} 个回答
</View>
</View>
);
};

export default AnswerToStudent;
45 changes: 23 additions & 22 deletions src/pages/classInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default function Index() {
const getCommentData = async () => {
try {
void get(
`/evaluations/list/courses/${courseId}?cur_evaluation_id=0&limit=100`
`/evaluations/list/courses/${courseId}?cur_evaluation_id=${0}&limit=${100}`
).then((res) => {
console.log(res);
setComments(res.data as CommentInfoType[]);
Expand Down Expand Up @@ -117,14 +117,22 @@ export default function Index() {
console.error(e);
}
};
const fetchAnswer = async () => {
const fetchAnswer = () => {
try {
await get(
`/questions/list?biz=Course&biz_id=${courseId}&cur_question_id=&limit=`
void get(
`/questions/list?biz=Course&biz_id=${courseId}&cur_question_id=${0}&limit=${100}`
).then((res) => {
console.log(res);

console.log('questionlist1', res.data);
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-return
const questionsWithAnswers = res.data.map((item) => ({
...item,
preview_answers: item.preview_answers || [],
}));
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
setQuestionlist(res.data);
setQuestionlist(questionsWithAnswers);
console.log('questionlist', questionsWithAnswers);
});
} catch (e) {
console.error('Failed to fetch course data:', e);
Expand Down Expand Up @@ -209,23 +217,16 @@ export default function Index() {
/>
))}
</>
{questionlist.length > 0 && (
<View
onClick={() => {
void Taro.navigateTo({
url: `/pages/questionList/index?course_id=${courseId}`,
});
}}
className="text-right"
>
全部&gt;
</View>
)}
{questionlist.length === 0 && (
<Text className="mb-2 mr-auto mt-2 flex items-center justify-center">
暂无内容敬请期待
</Text>
)}
<View
onClick={() => {
void Taro.navigateTo({
url: `/pages/questionList/index?course_id=${courseId}`,
});
}}
className="text-right"
>
全部&gt;
</View>
</View>
<View>
<View className="line-container pt-5 text-center text-xl">最新评论</View>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/publishQuestion/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export default function Index() {
const postQuestion = () => {
const questionobj = {
biz: 'Course',
biz_id: courseId,
biz_id: Number(courseId),
content: question,
};
post(`/questions/publish`, questionobj)
Expand Down

0 comments on commit c8c0db8

Please sign in to comment.