| | |
| | | |
| | | // 切换选项卡 |
| | | switchTab(e) { |
| | | const index = e.currentTarget.dataset.index |
| | | const index = parseInt(e.currentTarget.dataset.index) // 将字符串转换为数字 |
| | | if (index === this.data.currentTab) return |
| | | |
| | | this.setData({ |
| | |
| | | } |
| | | |
| | | // 根据当前选项卡构建不同的查询 |
| | | switch (currentTab) { |
| | | switch (parseInt(currentTab)) { // 确保currentTab是数字 |
| | | case 0: // 我未评审 |
| | | query = ` |
| | | query GetUnReviewedProjects($page: Int!, $pageSize: Int!, $searchKeyword: String) { |
| | |
| | | } |
| | | ` |
| | | break |
| | | default: |
| | | console.error('无效的选项卡索引:', currentTab) |
| | | query = ` |
| | | query GetUnReviewedProjects($page: Int!, $pageSize: Int!, $searchKeyword: String) { |
| | | unReviewedProjects(page: $page, pageSize: $pageSize, searchKeyword: $searchKeyword) { |
| | | items { |
| | | id |
| | | projectName |
| | | activityName |
| | | stageName |
| | | studentName |
| | | submitTime |
| | | status |
| | | } |
| | | total |
| | | hasMore |
| | | } |
| | | } |
| | | ` |
| | | break |
| | | } |
| | | |
| | | // 检查query是否为空 |
| | | if (!query || query.trim() === '') { |
| | | console.error('GraphQL查询为空,无法执行请求') |
| | | return |
| | | } |
| | | |
| | | const result = await graphqlRequest(query, variables) |
| | | |
| | | if (result) { |
| | | const dataKey = currentTab === 0 ? 'unReviewedProjects' : |
| | | currentTab === 1 ? 'reviewedProjects' : |
| | | const dataKey = parseInt(currentTab) === 0 ? 'unReviewedProjects' : |
| | | parseInt(currentTab) === 1 ? 'reviewedProjects' : |
| | | 'studentUnReviewedProjects' |
| | | |
| | | const data = result[dataKey] |