123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725 |
- <template>
- <!-- style="margin: 20rpx 0" -->
- <view>
- <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> -->
- <u-icon name="arrow-down" color="#999" size="24" v-if="!down"></u-icon>
- <u-icon name="arrow-right" color="#999" size="24" v-if="down"></u-icon>
- <text class="menu_name">{{ menuItem.name }}</text>
- </view>
- <view v-show="!down">
- <view v-for="(itemM, indexM) in list" :key="indexM">
- <view v-if="itemM.type != 2">
- <courseSection
- ref="ChapterSection"
- :isLive="isLive"
- :orderGoodsId="orderGoodsId"
- :sectionMaxNum="sectionMaxNum"
- :preItem="list[indexM - 1] || preItem"
- :learningOrder="learningOrder"
- :courseId="courseId"
- @playEnd="refreshList($event)"
- :goodsId="goodsId"
- :isBuy="isBuy"
- :nextMenuItem="findNextSection(indexM)"
- :isRebuild="isRebuild"
- :gradeId="gradeId"
- :menuItem="itemM"
- :levelId="levelId + '-' + itemM.sectionId"
- :testType="2"
- :sectionExam='sectionExam'
- @togoBack='togoBack()'
- ></courseSection>
- <u-line v-if="indexM < list.length - 1"></u-line>
- </view>
- <view v-if="itemM.type == 2">
- <u-line></u-line>
- <view
- class="examBox"
- @click="
- toDo(
- itemM.typeId,
- goodsId,
- itemM.moduleId,
- itemM.chapterId,
- itemM,
- indexM
- )
- "
- >
- <view class="exam">
- <view class="eTag">{{
- itemM.doType == 1 ? "练习" : "考试"
- }}</view>
- <view style="margin-left: 15rpx; flex: 1">{{ itemM.name }}</view>
- </view>
- <view v-if="isRebuild || itemM.rebuild > 0" class="tagRe"
- >待重修</view
- >
- <view v-else>
- <view
- :class="{
- tagGreen: itemM.learning == 1,
- tagRe: itemM.learning == 0 || itemM.rebuild > 0,
- }"
- >
- <text v-if="itemM.rebuild > 0">待重测</text>
- <text v-else-if="itemM.learning == 1">合格</text>
- <text v-else-if="itemM.learning == 0">不合格</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import { mapGetters, mapMutations } from "vuex";
- import courseSection from "@/components/course/courseSection.vue";
- export default {
- name: "courseChapter",
- props: {
- isLive: false,
- orderGoodsId: {
- default: 0,
- },
- preItem: {
- default: undefined,
- },
- learningOrder: {
- //是否设置学习顺序 1 章节顺序 0不设置 2从头学到尾顺序
- type: Number,
- default: 0,
- },
- needOpen: {
- //是否默认展开
- type: Boolean,
- default: false,
- },
- 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,
- },
- sectionMaxNum: {
- default: undefined,
- },
- // 商品类型 1视频2题库 3补考 4前培 5虚拟赠送题库 6直播
- goodsType: {
- type: [Number, String],
- default: 0,
- },
- },
- components: {
- courseSection,
- },
- data() {
- return {
- down: true,
- list: [],
- examList: {},
- canLearn: false, //是否全部视频看完才可以练习、测试
- sectionExam: [],
- };
- },
- onLoad() {},
- created() {},
- mounted() {
- if (this.needOpen && this.chapterOpen) {
- this.updateChapterOpen(false);
- this.openChapter(this.menuItem);
- }
- },
- onPageShow() {
- if (this.isBuy) {
- this.refreshList({ isRebuild: this.isRebuild });
- }
- },
- methods: {
- ...mapMutations(["updateChapterOpen"]),
- togoBack(value) {
- console.log('章的节', value , this.$refs.ChapterSection)
- this.$refs.ChapterSection[0].ChapterExam()
- },
- goodsTodayStudySectionNum() {
- return new Promise((resolve) => {
- this.$api
- .goodsTodayStudySectionNum({
- goodsId: this.goodsId,
- gradeId: this.gradeId,
- })
- .then((res) => {
- if (res.data.code == 200) {
- resolve(res.data.data);
- }
- });
- });
- },
- refreshList(isRebuild) {
- console.log(9999);
- let moduleId = this.menuItem.moduleId ? this.menuItem.moduleId : 0;
- if (this.isRebuild) {
- this.getReSectionList(
- this.menuItem.id,
- this.menuItem.courseId,
- moduleId
- );
- } else {
- this.getBuySectionList(
- this.menuItem.id,
- this.menuItem.courseId,
- moduleId
- );
- // this.getMenuExamList(item.id,item.courseId,moduleId)
- }
- this.$emit("playEnd", { isRebuild: isRebuild.isRebuild });
- console.log(10000);
- // let moduleId = this.menuItem.moduleId?this.menuItem.moduleId:0
- // this.getBuySectionList(this.menuItem.id,this.menuItem.courseId,moduleId)
- },
- findNextSection(index) {
- for (let i = index + 1; i < this.list.length; i++) {
- return this.list[i];
- }
- return {};
- },
- studyRecordMenuAllList() {
- return new Promise((resolve) => {
- this.$api
- .studyRecordMenuAllList({
- courseId: this.courseId,
- gradeId: this.gradeId,
- goodsId: this.goodsId,
- })
- .then((res) => {
- if (res.data.code == 200) {
- resolve(res.data.data);
- }
- });
- });
- },
- gradeCheckGoodsStudy(id) {
- let moduleId = this.menuItem.moduleId || 0;
- let chapterId = this.menuItem.chapterId || 0;
- let sectionId = this.menuItem.sectionId || this.menuItem.menuId;
- return new Promise((resolve) => {
- this.$api
- .gradeCheckGoodsStudy({
- goodsId: this.goodsId,
- gradeId: this.gradeId,
- moduleId: this.menuItem.moduleId || 0,
- chapterId: this.menuItem.chapterId || 0,
- examId: id,
- })
- .then((res) => {
- resolve(res.data.data);
- });
- });
- },
- // 新增用户视频学习日志
- studyLog() {
- this.$http({
- url: '/user/study/log',
- method: 'post',
- data: {
- goodsId: this.goodsId,
- courseId: this.courseId,
- moduleId: this.menuItem.moduleId || 0,
- chapterId: this.menuItem.chapterId || 0,
- sectionId: this.menuItem.sectionId || this.menuItem.menuId,
- fromPlat: 1, //来源平台 1小程序 2PC网站
- goodsType: this.goodsType, // 商品类型 1视频2题库 3补考 4前培 5虚拟赠送题库 6直播
- orderGoodsId: this.orderGoodsId,
- }
- }).then((res) => {
- console.log('考试的用户学习日志:', res)
- })
- },
- /**
- * 去做题
- */
- async toDo(id, goodsId = 0, moduleId = 0, chapterId = 0, item, index) {
- let learnNum = await this.goodsTodayStudySectionNum();
- let hasLearn = await this.gradeCheckGoodsStudy(id);
- if (this.sectionMaxNum > 0) {
- if (learnNum >= this.sectionMaxNum && !hasLearn) {
- uni.showToast({
- icon: "none",
- title: `每天最多学习${this.sectionMaxNum}节`,
- });
- return;
- }
- }
- console.log(this.learningOrder, "this.learningOrder");
- if (this.learningOrder == 1) {
- if (this.canLearn) {
- let num = await this.bankRecordDoNum(item.typeId);
- //有次数限制
- if (item.answerNum - num > 0 && item.answerNum > 0) {
- // this.$set(this.list[index],'doNum',(item.doNum+1))
- console.log(this.list[index]);
- uni.navigateTo({
- url:
- "/pages2/class/questionBank?courseId=" +
- this.courseId +
- "&gradeId=" +
- this.gradeId +
- "&isFromVideo=1&id=" +
- id +
- "&goodsid=" +
- goodsId +
- "&moduleId=" +
- moduleId +
- "&chapterId=" +
- chapterId +
- "&orderGoodsId=" +
- this.orderGoodsId,
- });
- this.studyLog()
- //没有答题次数限制
- } else if (item.answerNum == 0) {
- uni.navigateTo({
- url:
- "/pages2/class/questionBank?courseId=" +
- this.courseId +
- "&gradeId=" +
- this.gradeId +
- "&isFromVideo=1&id=" +
- id +
- "&goodsid=" +
- goodsId +
- "&moduleId=" +
- moduleId +
- "&chapterId=" +
- chapterId +
- "&orderGoodsId=" +
- this.orderGoodsId,
- });
- this.studyLog()
- } else {
- uni.showToast({
- icon: "none",
- title: "该试卷只能答题" + item.answerNum + "次",
- });
- return;
- }
- } else {
- uni.showToast({
- icon: "none",
- title: "请按顺序学完视频课程再进行练习和测试",
- });
- }
- } else if (this.learningOrder == 2 && !item.rebuild) {
- let canLearn = this.list[index - 1].learning == 1;
- let rows = await this.studyRecordMenuAllList();
- let isStop = false;
- let newRows = [];
- for (let i = 0; i < rows.length; i++) {
- let moduleTrue = rows[i].moduleId == moduleId;
- let chapterTrue = rows[i].chapterId == chapterId;
- if (moduleTrue && chapterTrue) {
- isStop = true;
- if (rows[i].sectionType != 2) {
- //忽略直播
- newRows.push(rows[i]);
- }
- } else {
- if (!isStop) {
- if (rows[i].sectionType != 2) {
- //忽略直播
- newRows.push(rows[i]);
- }
- } else {
- break;
- }
- }
- }
- console.log(newRows);
- let isAllLearn = newRows.every((item) => {
- return item.studyStatus == 1;
- });
- if (isAllLearn) {
- //之前的都学完了
- // if(canLearn) { //视频的上一节学完
- let num = await this.bankRecordDoNum(item.typeId);
- //有次数限制
- if (item.answerNum - num > 0 && item.answerNum > 0) {
- // this.$set(this.list[index],'doNum',(item.doNum+1))
- console.log(this.list[index]);
- uni.navigateTo({
- url:
- "/pages2/class/questionBank?courseId=" +
- this.courseId +
- "&gradeId=" +
- this.gradeId +
- "&isFromVideo=1&id=" +
- id +
- "&goodsid=" +
- goodsId +
- "&moduleId=" +
- moduleId +
- "&chapterId=" +
- chapterId +
- "&orderGoodsId=" +
- this.orderGoodsId,
- });
- this.studyLog()
- //没有答题次数限制
- } else if (item.answerNum == 0) {
- uni.navigateTo({
- url:
- "/pages2/class/questionBank?courseId=" +
- this.courseId +
- "&gradeId=" +
- this.gradeId +
- "&isFromVideo=1&id=" +
- id +
- "&goodsid=" +
- goodsId +
- "&moduleId=" +
- moduleId +
- "&chapterId=" +
- chapterId +
- "&orderGoodsId=" +
- this.orderGoodsId,
- });
- this.studyLog()
- } else {
- uni.showToast({
- icon: "none",
- title: "该试卷只能答题" + item.answerNum + "次",
- });
- return;
- }
- } else {
- uni.showToast({
- icon: "none",
- title: "请学完视频课程再进行练习和测试",
- });
- }
- } else {
- let num = await this.bankRecordDoNum(item.typeId);
- //有次数限制
- if (item.answerNum - item.doNum > 0 && item.answerNum > 0) {
- // this.$set(this.list[index],'doNum',(item.doNum+1))
- console.log(this.list[index]);
- uni.navigateTo({
- url:
- "/pages2/class/questionBank?courseId=" +
- this.courseId +
- "&gradeId=" +
- this.gradeId +
- "&isFromVideo=1&id=" +
- id +
- "&goodsid=" +
- goodsId +
- "&moduleId=" +
- moduleId +
- "&chapterId=" +
- chapterId +
- "&orderGoodsId=" +
- this.orderGoodsId,
- });
- this.studyLog()
- //没有答题次数限制
- } else if (item.answerNum == 0) {
- uni.navigateTo({
- url:
- "/pages2/class/questionBank?courseId=" +
- this.courseId +
- "&gradeId=" +
- this.gradeId +
- "&isFromVideo=1&id=" +
- id +
- "&goodsid=" +
- goodsId +
- "&moduleId=" +
- moduleId +
- "&chapterId=" +
- chapterId +
- "&orderGoodsId=" +
- this.orderGoodsId,
- });
- this.studyLog()
- } else {
- uni.showToast({
- icon: "none",
- title: "该试卷只能答题" + item.answerNum + "次",
- });
- return;
- }
- }
- },
- bankRecordDoNum(examId) {
- return new Promise((resolve) => {
- this.$api
- .bankRecordDoNum({
- goodsId: this.goodsId,
- gradeId: this.gradeId,
- chapterId: this.menuItem.id,
- courseId: this.courseId,
- moduleId: 0,
- examId: examId,
- })
- .then((res) => {
- resolve(res.data.data);
- });
- });
- },
- async openChapter(item) {
- console.log('---zhang',this.menuItem, this.down,this.list, item.id, item.courseId, item.moduleId);
- this.down = !this.down;
- if (!this.down && this.list.length == 0) {
- console.log(item.id, 69);
- //获取所有节试卷列表
- await this.$api.reSectionExamList({
- chapterId: item.chapterId || item.menuId,
- courseId: item.courseId,
- gradeId: item.gradeId
- }).then((res) => {
- if (res.data.code == 200) {
- this.sectionExam = res.data.data || []
- }
- })
- 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) {
- console.log('=============2', 'chapterId:', chapterId)
- let self = this;
- // url: '/app/common/course/sectionList/'+data,
- 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.menuType = 3;
- //判断是否试听
- item.tryListen = false;
- if (self.goodsAuditionConfigIdList.indexOf(item.id) !== -1) {
- item.tryListen = true;
- }
- }
- let newArr = res.data.data.filter((item) => {
- console.log(item);
- return item.type != 2;
- });
- this.canLearn = newArr.every((item) => {
- console.log(item);
- if (item.learning == 1) {
- return true;
- } else {
- return false;
- }
- });
- self.list = res.data.data;
- console.log('=============2', self.list)
- }
- });
- },
- getReSectionList(chapterId, courseId, moduleId) {
- console.log('=============3', 'chapterId:', chapterId, 'courseId:', courseId, 'moduleId:', 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.menuType = 3;
- //判断是否试听
- item.tryListen = false;
- if (self.goodsAuditionConfigIdList.indexOf(item.id) !== -1) {
- item.tryListen = true;
- }
- }
- let newArr = res.data.data.filter((item) => {
- console.log(item);
- return item.type != 2;
- });
- this.canLearn = newArr.every((item) => {
- console.log(item);
- if (item.learning == 1) {
- return true;
- } else {
- return false;
- }
- });
- self.list = res.data.data;
- console.log('=============3', self.list)
- }
- });
- },
- getBuySectionList(chapterId, courseId, moduleId) {
- console.log('=============1', 'chapterId:', chapterId, 'courseId:', courseId, 'moduleId:', 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.menuType = 3;
- //判断是否试听
- item.tryListen = false;
- if (self.goodsAuditionConfigIdList.indexOf(item.id) !== -1) {
- item.tryListen = true;
- }
- }
- let newArr = res.data.data.filter((item) => {
- return item.type != 2;
- });
- this.canLearn = newArr.every((item) => {
- console.log(item);
- if (item.learning == 1) {
- return true;
- } else {
- return false;
- }
- });
- self.list = res.data.data;
- console.log('=============1', self.list)
- }
- });
- },
- },
- computed: { ...mapGetters(["goodsAuditionConfigIdList", "chapterOpen"]) },
- };
- </script>
- <style lang="scss" scoped>
- .tagRe {
- width: 80rpx;
- height: 28rpx;
- background: #ff3b30;
- border-radius: 8rpx;
- font-size: 20rpx;
- color: #ffffff;
- text-align: center;
- }
- .tagGreen {
- width: 80rpx;
- height: 28rpx;
- background: #34c759;
- border-radius: 8rpx;
- font-size: 20rpx;
- color: #ffffff;
- text-align: center;
- }
- .eTag {
- width: 56rpx;
- height: 42rpx;
- text-align: center;
- line-height: 42rpx;
- font-size: 20rpx;
- background: #007aff;
- border-radius: 8rpx;
- color: #ffffff;
- }
- .examBox {
- display: flex;
- align-items: center;
- justify-content: space-between;
- }
- .exam {
- font-size: 30rpx;
- display: flex;
- align-items: center;
- margin: 20rpx 0;
- }
- .icon_up {
- width: 24rpx;
- height: 24rpx;
- }
- .title {
- // margin-bottom: 30rpx;
- height: 78rpx;
- display: flex;
- align-items: center;
- border-bottom: 1rpx solid #EEEEEE;
- .menu_name {
- font-size: 24rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #333;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- margin-left: 8rpx;
- }
- }
- </style>
|