|
@@ -6,7 +6,7 @@
|
|
|
</view>
|
|
|
<view>
|
|
|
<template v-for="item in data.wordList">
|
|
|
- <mainCardVue :active-word="activeWord" :active-words="activeWords" v-if="item.id == data.activeId"
|
|
|
+ <mainCardVue :active-word="data.activeWord" :active-words="activeWords" v-if="item.id == data.activeId"
|
|
|
:key="item.id">
|
|
|
</mainCardVue>
|
|
|
</template>
|
|
@@ -53,29 +53,22 @@
|
|
|
subjectId: null, // 学科ID
|
|
|
levelId: null, // 等级
|
|
|
jieName: '', // 节/单元名称
|
|
|
- count: 0, // 单词总数
|
|
|
title: '', // 版本+年级+学期
|
|
|
studyCount: 0, // 已学习总数
|
|
|
wordList: [], // 单词列表
|
|
|
arrayList: [], // 整合数据
|
|
|
- wordInfo: null, // 单词详情数据
|
|
|
+ activeWord: null, // 单词详情数据
|
|
|
+ collectFlag: 0, // 收藏状态
|
|
|
})
|
|
|
|
|
|
onLoad(({
|
|
|
- jieId,wordId
|
|
|
+ jieId,
|
|
|
+ wordId
|
|
|
}) => {
|
|
|
data.jieId = jieId;
|
|
|
- data.activeId = wordId;
|
|
|
+ data.activeId = wordId;
|
|
|
// 获取单词列表数据
|
|
|
- initWordInfo();
|
|
|
- })
|
|
|
-
|
|
|
- // 当前单词
|
|
|
- const activeWord = computed(() => {
|
|
|
- if (!data.activeId) {
|
|
|
- return null
|
|
|
- }
|
|
|
- return data.wordList.find(item => item.id == data.activeId)
|
|
|
+ initWordInfo();
|
|
|
})
|
|
|
|
|
|
// 是否是最后一题
|
|
@@ -83,7 +76,7 @@
|
|
|
if (!data.wordList.length) {
|
|
|
return false
|
|
|
}
|
|
|
- return data.activeId == data.wordList[data.count - 1].id;
|
|
|
+ return data.activeId == data.wordList[data.wordList.length - 1].id;
|
|
|
})
|
|
|
const isFirst = computed(() => {
|
|
|
if (!data.wordList.length) {
|
|
@@ -101,28 +94,30 @@
|
|
|
|
|
|
function nextWord() {
|
|
|
const index = data.wordList.findIndex(item => item.id == data.activeId);
|
|
|
- if (index < data.count - 1) {
|
|
|
- data.activeId = data.wordList[index + 1].id;
|
|
|
+ if (index < data.wordList.length - 1) {
|
|
|
+ uni.redirectTo({
|
|
|
+ url: `/pages/newEnglish/index?jieId=${data.jieId}&wordId=${data.wordList[index + 1].id }`
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function prevWord() {
|
|
|
const index = data.wordList.findIndex(item => item.id == data.activeId);
|
|
|
if (index > 0) {
|
|
|
- data.activeId = data.wordList[index - 1].id;
|
|
|
+ uni.redirectTo({
|
|
|
+ url: `/pages/newEnglish/index?jieId=${data.jieId}&wordId=${data.wordList[index - 1].id }`
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
function initWordInfo() {
|
|
|
httpApi.getWordInfo({
|
|
|
jieId: data.jieId,
|
|
|
wordId: data.activeId
|
|
|
}).then(res => {
|
|
|
- data.wordInfo = res.data;
|
|
|
- data.levelId = res.data.levelId;
|
|
|
- data.subjectId = res.data.subjectId;
|
|
|
- data.wordList = res.data.danciList;
|
|
|
+ data.activeWord = res.data;
|
|
|
+ data.wordList = res.data.danciList; // 单词组
|
|
|
+ data.collectFlag = res.data.collectFlag; // 收藏状态
|
|
|
if (data.wordList.length) {
|
|
|
data.arrayList = chunkArray(data.wordList, 5); // 将1维单词数组转换为2维数组
|
|
|
}
|