|
@@ -3,7 +3,9 @@
|
|
|
<view class="study-school-year" @click="clickGradeTerm">{{gradeTerm}}</view>
|
|
|
<view class="ezy-study-wrap">
|
|
|
<view class="chapter-box" @click="handleCheckCatalogue">{{options.numberStr}}</view>
|
|
|
- <view @click="handleCheckCatalogue" :class="getTitleClass(options.zhangName)">{{getZhangName(options.zhangName)}}</view>
|
|
|
+ <view @click="handleCheckCatalogue" :class="getTitleClass(options.zhangName)">
|
|
|
+ {{getZhangName(options.zhangName)}}
|
|
|
+ </view>
|
|
|
<view>
|
|
|
<!-- 小岛 -->
|
|
|
<view class="brand-item" v-for="(item, index) in options.jieList" :key="item.jieId"
|
|
@@ -14,22 +16,17 @@
|
|
|
<!-- 星星 -->
|
|
|
<view class="brand-finish-icon" v-if="item.studyFlag===1"></view>
|
|
|
<!-- 动物类型 -->
|
|
|
- <view v-if="item.daeFlag && growthType ==0" class="animal-img dan-img"></view>
|
|
|
- <view v-if="item.daeFlag && growthType ==1" class="animal-img xiao-e-img"></view>
|
|
|
- <view v-if="item.daeFlag && growthType ==2" class="animal-img zhong-e-img"></view>
|
|
|
- <view v-if="item.daeFlag && growthType ==3" class="animal-img da-e-img"></view>
|
|
|
+ <view v-if="item.daeFlag &&animalNum == index" :class="currentGrowth()"></view>
|
|
|
<!-- 节名称 -->
|
|
|
<view class="brand-content">{{ item.jieName }}</view>
|
|
|
</view>
|
|
|
<view v-if="isVip !== 'VIP'">
|
|
|
<!-- 序号或锁 -->
|
|
|
- <view v-if="options.number ==1" class="brand-icon">{{ item.number }}</view>
|
|
|
- <view v-if="options.number !=1" class="brand-lock"></view>
|
|
|
+ <view v-if="options.number ==1 && item.firstFlag ==1" class="brand-icon">{{ item.number }}
|
|
|
+ </view>
|
|
|
+ <view v-else class="brand-lock"></view>
|
|
|
<!-- 动物类型 -->
|
|
|
- <view v-if="item.daeFlag && growthType ==0" class="animal-img dan-img"></view>
|
|
|
- <view v-if="item.daeFlag && growthType ==1" class="animal-img xiao-e-img"></view>
|
|
|
- <view v-if="item.daeFlag && growthType ==2" class="animal-img zhong-e-img"></view>
|
|
|
- <view v-if="item.daeFlag && growthType ==3" class="animal-img da-e-img"></view>
|
|
|
+ <view v-if="item.daeFlag && animalNum == index" :class="currentGrowth()"></view>
|
|
|
<!-- 节名称 -->
|
|
|
<view class="brand-content"> {{ item.jieName }} </view>
|
|
|
</view>
|
|
@@ -45,23 +42,24 @@
|
|
|
ref,
|
|
|
watch,
|
|
|
getCurrentInstance,
|
|
|
- onMounted
|
|
|
+ onMounted,
|
|
|
+ nextTick
|
|
|
} from "vue";
|
|
|
import cacheManager from "@/utils/cacheManager.js";
|
|
|
import {
|
|
|
toast,
|
|
|
getUserIdentity
|
|
|
} from "@/utils/common";
|
|
|
- import {
|
|
|
- onShow
|
|
|
- } from '@dcloudio/uni-app';
|
|
|
- const growthType = ref(null);
|
|
|
- onShow(() => growthType.value = cacheManager.get('auth').growthType)
|
|
|
+ import {
|
|
|
+ onShow
|
|
|
+ } from '@dcloudio/uni-app';
|
|
|
+ const growthType = ref(null);
|
|
|
+ onShow(() => growthType.value = cacheManager.get('auth').growthType)
|
|
|
const $emit = defineEmits(['clickGradeTerm', 'onLeft', 'onRight', 'handleCheckCatalogue', 'listClick'])
|
|
|
const props = defineProps({
|
|
|
options: {
|
|
|
type: Object,
|
|
|
- },
|
|
|
+ },
|
|
|
gradeTerm: {
|
|
|
type: String,
|
|
|
},
|
|
@@ -85,78 +83,98 @@
|
|
|
let isSliding = ref(false);
|
|
|
let endX = ref(0);
|
|
|
let gradeTerm = ref('');
|
|
|
+ let animalNum = ref(0);
|
|
|
|
|
|
function clickGradeTerm() {
|
|
|
$emit('clickGradeTerm');
|
|
|
}
|
|
|
|
|
|
- function listClick(data) {
|
|
|
- $emit('listClick', data);
|
|
|
+ function listClick(data, index) {
|
|
|
+ data.daeFlag = true
|
|
|
+ nextTick(() => {
|
|
|
+ animalNum.value = index
|
|
|
+ })
|
|
|
+ setTimeout(() => {
|
|
|
+ $emit('listClick', data);
|
|
|
+ }, 1000)
|
|
|
+
|
|
|
}
|
|
|
// 获取章name
|
|
|
- function getZhangName(data){
|
|
|
- if(data.length <=9){
|
|
|
+ function getZhangName(data) {
|
|
|
+ if (data.length <= 9) {
|
|
|
return data
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return getZhangContent(data);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ function currentGrowth(data) {
|
|
|
+ if (growthType.value == 0) {
|
|
|
+ return 'animal-img dan-img'
|
|
|
+ } else if (growthType.value == 2) {
|
|
|
+ return 'animal-img xiao-e-img'
|
|
|
+ } else if (growthType.value == 3) {
|
|
|
+ return 'animal-img zhong-e-img'
|
|
|
+ } else {
|
|
|
+ return 'animal-img da-e-img'
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 章换行显示
|
|
|
- function getZhangContent(data){
|
|
|
+ function getZhangContent(data) {
|
|
|
|
|
|
let length = data.length;
|
|
|
// 初始将字符串平分成两半
|
|
|
- let halfLength = Math.floor(length / 2);
|
|
|
-
|
|
|
+ let halfLength = Math.floor(length / 2);
|
|
|
+
|
|
|
// 插入换行符
|
|
|
let firstLine = data.slice(0, halfLength);
|
|
|
let secondLine = data.slice(halfLength);
|
|
|
- console.log(firstLine + '\n' + secondLine,'firstLine + + secondLine');
|
|
|
+ //console.log(firstLine + '\n' + secondLine, 'firstLine + + secondLine');
|
|
|
return firstLine + '\n' + secondLine;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 章class
|
|
|
- function getTitleClass(data){
|
|
|
-
|
|
|
- if(data.length <=5){
|
|
|
+ function getTitleClass(data) {
|
|
|
+
|
|
|
+ if (data.length <= 5) {
|
|
|
return 'chapter-title-box chapter-small-title-box'
|
|
|
- }else if(data.length <=9){
|
|
|
+ } else if (data.length <= 9) {
|
|
|
return 'chapter-title-box chapter-middle-title-box'
|
|
|
- }else if(data.length >9){
|
|
|
+ } else if (data.length > 9) {
|
|
|
return 'chapter-title-box chapter-big-title-box'
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 获取节class
|
|
|
- function getClass (data,index,isVip){
|
|
|
+ function getClass(data, index, isVip) {
|
|
|
let brandActive = '';
|
|
|
- if(isVip==='VIP'){
|
|
|
+ if (isVip === 'VIP') {
|
|
|
brandActive = 'brand-active';
|
|
|
- }else if(data[index].firstFlag==1){
|
|
|
+ } else if (data[index].firstFlag == 1) {
|
|
|
brandActive = 'brand-active';
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
brandActive = '';
|
|
|
}
|
|
|
- let indexLast = data.length -1;
|
|
|
+ let indexLast = data.length - 1;
|
|
|
// 判断最后一个为名称是否为单元测试,是单元测试则返回ceshi-jie
|
|
|
- if(index===indexLast && data[data.length -1].jieName =='单元测试'){
|
|
|
- return 'ceshi-brand-item' +' '+ brandActive;
|
|
|
- }else{
|
|
|
- return getJieClass(data,index,brandActive)
|
|
|
+ if (index === indexLast && data[data.length - 1].jieName == '单元测试') {
|
|
|
+ return 'ceshi-brand-item' + ' ' + brandActive;
|
|
|
+ } else {
|
|
|
+ return getJieClass(data, index, brandActive)
|
|
|
}
|
|
|
}
|
|
|
// 根据获取节字数获取class
|
|
|
- function getJieClass(data,index,active){
|
|
|
+ function getJieClass(data, index, active) {
|
|
|
let itemJieName = data[index].jieName.length;
|
|
|
- if(itemJieName > 7){
|
|
|
- return 'big-brand-item' +' '+ active;
|
|
|
- }else{
|
|
|
- return 'small-brand-item' +' '+ active;
|
|
|
+ if (itemJieName > 7) {
|
|
|
+ return 'big-brand-item' + ' ' + active;
|
|
|
+ } else {
|
|
|
+ return 'small-brand-item' + ' ' + active;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
function handleCheckCatalogue() {
|
|
|
$emit('handleCheckCatalogue');
|
|
@@ -205,33 +223,43 @@
|
|
|
console.log('error');
|
|
|
}
|
|
|
}
|
|
|
- function dataRecom(data){
|
|
|
- if(data&&data.jieList.length>0){
|
|
|
- data.jieList.some(item => {
|
|
|
- if (item.studyFlag == 0) {
|
|
|
- item.daeFlag = true;
|
|
|
- return true; // 返回 true 以终止 some 循环
|
|
|
- }
|
|
|
- return false;
|
|
|
- });
|
|
|
+
|
|
|
+ function dataRecom(data) {
|
|
|
+
|
|
|
+ // if (data && data.jieList.length > 0) {
|
|
|
+ // data.jieList.some(item => {
|
|
|
+ // if (item.studyFlag == 0) {
|
|
|
+ // item.daeFlag = true;
|
|
|
+ // animalNum.value
|
|
|
+ // return true; // 返回 true 以终止 some 循环
|
|
|
+ // }
|
|
|
+ // return false;
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+
|
|
|
+ const index = data.jieList.findIndex(item => item.studyFlag == 0);
|
|
|
+
|
|
|
+ if (index !== -1) {
|
|
|
+ data.jieList[index].daeFlag = true;
|
|
|
+ animalNum.value = index
|
|
|
}
|
|
|
}
|
|
|
watch(() => props.options, (newVal, oldVal) => {
|
|
|
- // console.log('New options:', newVal);
|
|
|
- // console.log('Old options:', oldVal);
|
|
|
+ // console.log('New options:', newVal);
|
|
|
+ // console.log('Old options:', oldVal);
|
|
|
// 在这里可以根据新的 options 做一些操作,比如发起请求等
|
|
|
-
|
|
|
+
|
|
|
dataRecom(newVal)
|
|
|
}, {
|
|
|
deep: true,
|
|
|
immediate: true
|
|
|
});
|
|
|
watch(() => props.gradeTerm, (newVal, oldVal) => {
|
|
|
- // console.log('New options:', newVal);
|
|
|
- // console.log('Old options:', oldVal);
|
|
|
+ // console.log('New options:', newVal);
|
|
|
+ // console.log('Old options:', oldVal);
|
|
|
// 在这里可以根据新的 options 做一些操作,比如发起请求等
|
|
|
gradeTerm.value = newVal
|
|
|
-
|
|
|
+
|
|
|
}, {
|
|
|
deep: true,
|
|
|
immediate: true
|