123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- <template>
- <view style="margin: 20rpx 0;">
- <view class="title" @click="openChapter(menuItem)">
- <image src="/static/icon/up1.png" class="icon_up" v-if="down"></image>
- <image src="/static/icon/down1.png" class="icon_up" v-if="!down"></image>
- <text style="margin-left: 30rpx;">{{menuItem.name}}</text>
- </view>
- <view v-if="!down">
- <view v-for="(itemM,indexM) in list" >
- <courseSection :courseId="courseId" :goodsId="goodsId" :isBuy="isBuy" :isRebuild="isRebuild" :gradeId="gradeId" :menuItem="itemM" :levelId="levelId+'-'+itemM.sectionId"></courseSection>
- <u-line v-if="indexM<list.length-1"></u-line>
- </view>
- <u-line v-if="examList.length>0"></u-line>
- <view class="exam" v-for="(exam,index) in examList" :key="index" @click="toDo(exam.examId,goodsId,exam.moduleId,exam.chapterId)">
- <view class="eTag">{{exam.doType==1?'练习':'考试'}}</view>
- <view style="margin-left: 15rpx;">{{exam.examName}}</view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import { mapGetters } from 'vuex';
- import courseSection from '@/components/course/courseSection.vue';
- export default {
- name: 'courseChapter',
- props: {
- menuItem: {
- type: Object,
- default: {}
- },
- isBuy: {
- type: Boolean,
- default: false
- },
- levelId: {
- type: String,
- default: ""
- },
- goodsId: {
- type: Number,
- default: 0
- },
- courseId: {
- type: Number,
- default: 0
- },
- isRebuild: {
- type: Boolean,
- default: false
- },
- gradeId: {
- type: Number,
- default: 0
- }
- },
- components: {
- courseSection
- },
- data() {
- return {
- down:true,
- list:[],
- examList:{}
-
-
- };
- },
- onLoad() {},
- created() {
-
- },
- mounted() {
- },
- methods: {
- /**
- * 去做题
- */
- async toDo(id,goodsId =0,moduleId = 0, chapterId = 0) {
-
- uni.navigateTo({
- url:'/pages2/class/questionBank?courseId='+this.courseId+'&gradeId='+this.gradeId+'&isFromVideo=1&id='+id+'&goodsid='+goodsId+'&moduleId='+moduleId+'&chapterId='+chapterId+''
- })
- },
- openChapter(item){
- this.down = !this.down
- if(!this.down&&this.list.length==0){
- console.log(item.id,69)
- if(this.isBuy){
- let moduleId = item.moduleId?item.moduleId:0
- if(this.isRebuild){
- this.getReSectionList(item.id,item.courseId,moduleId)
- }else{
- this.getBuySectionList(item.id,item.courseId,moduleId)
- this.getMenuExamList(item.id,item.courseId,moduleId)
- }
- }else{
- this.getSectionList(item.id)
- }
-
- }
- },
- getMenuExamList(chapterId,courseId,moduleId) {
- let self = this
- this.$api.menuExamList({chapterId:chapterId,courseId:courseId,moduleId:moduleId}).then(res => {
- if(res.data.code==200){
- self.examList = res.data.rows
- }
- });
- },
- getSectionList(chapterId) {
- let self = this
- this.$api.sectionList(chapterId).then(res => {
- if(res.data.code==200){
- for(let i=0;i<res.data.data.length;i++){
- let item = res.data.data[i]
- item.id = item.sectionId
- //判断是否试听
- item.tryListen = false
- if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
- item.tryListen = true
- }
- }
- self.list = res.data.data
- }
- });
- },
- getReSectionList(chapterId,courseId,moduleId) {
- let self = this
- this.$api.reSectionList({chapterId:chapterId,gradeId:this.gradeId,courseId:courseId,rebuild:1,moduleId:moduleId}).then(res => {
- if(res.data.code==200){
- for(let i=0;i<res.data.data.length;i++){
- let item = res.data.data[i]
- item.id = item.sectionId
- //判断是否试听
- item.tryListen = false
- if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
- item.tryListen = true
- }
- }
- self.list = res.data.data
- }
- });
- },
- getBuySectionList(chapterId,courseId,moduleId) {
- let self = this
- this.$api.reSectionList({chapterId:chapterId,gradeId:this.gradeId,courseId:courseId,moduleId:moduleId}).then(res => {
- if(res.data.code==200){
- for(let i=0;i<res.data.data.length;i++){
- let item = res.data.data[i]
- item.id = item.sectionId
- //判断是否试听
- item.tryListen = false
- if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
- item.tryListen = true
- }
- }
- self.list = res.data.data
- }
- });
- },
- },computed: { ...mapGetters(['goodsAuditionConfigIdList']) },
- };
- </script>
- <style scoped>
- .eTag{
- width: 56rpx;
- height: 28rpx;
- background: #007AFF;
- border-radius: 8rpx;
- color: #FFFFFF;
- font-size: 20rpx;
- text-align: center;
- line-height: 20rpx;
- }
- .exam{
- display: flex;
- align-items: center;
- margin: 20rpx 0;
- }
- .icon_up{
- width: 24rpx;
- height: 24rpx;
- }
- .title{
- font-size: 24rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #666666;
- white-space:nowrap;
- overflow:hidden;
- text-overflow:ellipsis;
- }
- </style>
|