浏览代码

feat: 每日一练

xuqiaoying 3 年之前
父节点
当前提交
620ba81213

+ 11 - 0
pages.json

@@ -705,6 +705,17 @@
 						"bounce": "none"
 					}
 				}
+			},
+			{
+				"path": "dailyPractice/index",
+				"style": {
+					"navigationBarTitleText": "每日一练",
+					"navigationStyle": "custom", // 隐藏系统导航栏
+					"app-plus": {
+						"titleNView": false, //禁用原生导航栏 
+						"bounce": "none"
+					}
+				}
 			}
 		]
 		 

+ 8 - 2
pages/questionBank/index.vue

@@ -40,7 +40,7 @@
 				</view>
 
 				<template v-if="questionLists.length">
-					<view v-for="(item, indexq) in questionLists" :key="indexq" class="course_item">
+					<view v-for="(item, index) in questionLists" :key="index" class="course_item">
 						<view>
 							<view class="cou_titles">{{ item.goodsName }}</view>
 							<view v-if="item.serviceStartTime && item.serviceEndTime" class="learn_ranges">
@@ -71,7 +71,7 @@
 						</view>
 						<!-- 按钮 -->
 						<view class="study_btns">
-							<view class="exam_word intos">每日一练</view>
+							<view class="exam_word intos" @click.stop="toDailyPractice(item)">每日一练</view>
 							<view class="exam_word intos">随机联系</view>
 							<view class="exam_word intos" @click="studyques(item,index)">章节练习</view>
 						</view>
@@ -143,6 +143,12 @@ export default {
 				url:'/pages/course/index'
 			})
 		},
+		toDailyPractice(item) {
+			console.log('item', item);
+			uni.navigateTo({
+				url: '/pages2/dailyPractice/index?goodsId=' + item.goodsId + '&orderGoodsId=' + item.orderGoodsId
+			})
+		},
 		// 进入练习
 		studyques(item,index){
 			let sysTime = this.$method.timest()

+ 28 - 3
pages2/bank/questionBank.vue

@@ -919,9 +919,11 @@ export default {
       orderGoodsId: "",
       cgType: 0, //对应设计稿弹窗编码
       courseId: '',
+      entryType: '', // 进入做题页面的入口类型,daily-每日一练进来,其他的-题库做题进入
     };
   },
   async onLoad(option) {
+    this.entryType = option.entryType || ''
     this.courseId = option.courseId
     this.orderGoodsId = option.orderGoodsId || 0;
     this.current = +option.current || 0;
@@ -1320,6 +1322,7 @@ export default {
         .then((res) => {
           this.isSubmit = true;
           if (res.data.code == 200) {
+            this.entryType == 'daily' && this.dailyExam()
           }
         });
 
@@ -1458,7 +1461,11 @@ export default {
             doQuestionNum: doQuestionNum,
             historyExamJson: JSON.stringify(this.questionList),
           })
-          .then((res) => {});
+          .then((res) => {
+            if (res.data.code == 200) {
+              this.entryType == 'daily' && this.dailyExam()
+            }
+          });
       }
     },
     /**
@@ -2165,6 +2172,7 @@ export default {
         .then((res) => {
           this.isSubmit = true;
           if (res.data.code == 200) {
+            this.entryType == 'daily' && this.dailyExam()
             uni.showToast({
               title: "交卷成功",
               duration: 1000,
@@ -2185,7 +2193,7 @@ export default {
                   "&id=" +
                   this.recordId +
                   "&orderGoodsId=" +
-                  this.orderGoodsId,
+                  this.orderGoodsId + '&entryType=daily',
               });
             }, 1000);
           }
@@ -2203,7 +2211,24 @@ export default {
         })
         .then((res) => {});
     },
-
+    // 每日一练试卷打卡
+    dailyExam() {
+      const dateStamp = parseInt(new Date(new Date().toLocaleDateString()).getTime()/1000)
+      this.$http({
+        url: '/bank/question/special/exam/record',
+        method: 'post',
+        data: {
+          examId: this.id,
+          chapterExamId: this.chapterId, // 章卷ID
+          moduleExamId: this.moduleId, //模块卷ID	
+          goodsId: this.goodsId,
+          recordTime: dateStamp, // 传当天0点时间戳(秒)
+        }
+      }).then((res) => {
+        if (res.data.code == 200) {
+        }
+    })
+  },
     /**
      * @param {Object} state
      * @param {Object} index

+ 1 - 1
pages2/bank/question_detail.vue

@@ -101,7 +101,7 @@
 								<view class="flex_auto">{{ article.examName }}</view>
 								<view class="btn" @click="toDo(article.examId, goodsData.goodsId, 0, item1.majorId)" v-if="article.recordStatus == -1">做题</view>
 								<view class="btn" @click="continueDo(article.recordId,article.examId, goodsData.goodsId, 0, item1.majorId)" v-if="article.recordStatus == 0 && article.doType == 1">继续</view>
-								<view class="btn" :class="{disabled:(article.answerNum > 0 && article.doNum >= article.answerNum)}" @click="doRepeat(article.recordId,article.examId, goodsData.goodsId, item1.majorId,0)" v-if="article.recordStatus == 1 || (article.recordStatus == 0 && article.doType == 2)">重做</view>
+								<view class="btn" :class="{disabled:(article.answerNum > 0 && article.doNum >= article.answerNum)}" @click="(article.recordId,article.examId, goodsData.goodsId, item1.majorId,0)" v-if="article.recordStatus == 1 || (article.recordStatus == 0 && article.doType == 2)">重做</view>
 							</view>
 						</view>
 					</template>

+ 4 - 2
pages2/bank/question_report.vue

@@ -78,8 +78,8 @@
 				>
 					<view class="btnACs">全部解析</view>
 				</navigator>
-				<view class="btnACs" @click="doRepeat(reportdata.examId, reportdata.goodsId, reportdata.moduleExamId, reportdata.chapterExamId)">重新做题</view>
-				<view class="btnACs" v-if="nextExamId" @click="backBank">继续做题</view>
+				<view class="btnACs" v-if="entryType != 'daily'" @click="doRepeat(reportdata.examId, reportdata.goodsId, reportdata.moduleExamId, reportdata.chapterExamId)">重新做题</view>
+				<view class="btnACs" v-if="entryType != 'daily' && nextExamId" @click="backBank">继续做题</view>
 			</view>
 		</view>
 		<view class="bottom">
@@ -168,6 +168,7 @@ export default {
 			pageNum: 1,
 			pageSize: 10,
 			total: 0,
+			entryType: '', // 进入做题页面的入口类型,daily-每日一练进来,其他的-题库做题进入
 		};
 	},
 	onUnload() {},
@@ -181,6 +182,7 @@ export default {
 		
 	async onLoad(option) {
 		console.log(option)
+		this.entryType = option.entryType
 		this.orderGoodsId = option.orderGoodsId
 		this.recordId = option.id;
 		this.examId = option.examId;

+ 192 - 0
pages2/dailyPractice/index.vue

@@ -0,0 +1,192 @@
+<template>
+    <view class="daily_practice">
+        <nav-bar title="每日一练"></nav-bar>
+        <view class="contents">
+            <view class="remind">
+                <view>订阅</view>
+            </view>
+            <view class="insist">
+                <view>坚持打卡{{ dayExamDetail.recordCount }} 天</view>
+            </view>
+            <view class="names">
+                <view class="name_title">{{ dayExamDetail.examName || ''}}</view>
+                <view class="percentage">
+                    <text v-if=" dayExamDetail.examRecord == 1">恭喜你,今天的打卡已完成~</text>
+                    <text v-else>打卡进度超过了{{ dayExamDetail.recordPercentage || '0%' }}的学员,快来打卡呀~</text>
+                </view>
+            </view>
+            <view class="toPractice" @click="goPractice()">
+                {{ dayExamDetail.examRecord == 1 ? '今日已完成' : '快来做题' }}
+            </view>
+            <view class="punch_calendar">
+                <view class="card_box">
+                    {{ curMonth + '月'}}
+                </view>
+                <u-line color="#EEEEEE" />
+                <view class="weeks">
+                    <view v-for="(item, index) in weekLists" :key="index" class="card_date">{{ item }}</view>
+                </view>
+                <view class="day_dailys">
+                    <view v-for="(item, index) in date_num" :key="index" class="date_num">
+                        <view class="items">
+                            {{ item.date }}
+                        </view>
+                    </view>
+                </view>
+            </view>
+        </view>
+    </view>
+</template>
+
+<script>
+export default {
+    data() {
+        return {
+            weekLists: ['日','一','二','三','四','五','六'],
+			date_num: [],
+            curMonth: 0, // 当前月份
+            goodsId: '',
+            orderGoodsId: '',
+            dayExamDetail: {}, // 每日一练当天信息试卷
+            dayRecordList: [], // 每日一练试卷打卡记录
+        }
+    },
+    onLoad(option) {
+        this.goodsId = option.goodsId
+        this.orderGoodsId = option.orderGoodsId
+        this.initCalendar()
+        this.getToDayExam()
+    },
+    methods: {
+        // 初始化当月日历
+        initCalendar() {
+            let date = new Date()
+			let year = date.getFullYear() //获取当前年份
+			this.curMonth = date.getMonth() + 1 //获取当前月份
+			let dd = new Date(year, this.curMonth, 0) //获取当月总天数
+			let current_month = []
+			let weekList = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
+			for (let i = 1; i <= dd.getDate(); i++) {
+				current_month.push({
+					date: i,
+					week: new Date(date.setDate(i)).getDay(),//获取对应日期的星期
+				});
+			}
+			if (current_month[0].week != 0) {
+				for (let index = 0; index < 2; index++) {
+					let item = {
+						date: '',
+						week: index
+					}
+					current_month.splice(index, 0, item)
+				}
+			}
+			// console.log('====:', current_month);
+			this.date_num = current_month
+        },
+        // 获取每日一练当天的试卷信息
+        getToDayExam() {
+            // ${this.goodsId || 990}
+            this.$http({
+				url: `/bank/question/getToDayExam/${this.goodsId}`,
+				method: 'get',
+			}).then((res) => {
+                if (res.data.code == 200) {
+                    this.dayExamDetail = res.data.data || {}
+                    if (Object.keys(this.dayExamDetail).length) {
+                        this.getDailyRecord()
+                    }
+                }
+            })
+        },
+        // 获取每日一练试卷打卡记录
+        getDailyRecord() {
+            this.$http({
+                url: '/bank/question/get/special/record',
+                method: 'get',
+                data: {
+                    goodsId: this.goodsId,
+                    chapterExamId: this.dayExamDetail.chapterExamId || 0,
+                    moduleExamId: this.dayExamDetail.moduleExamId || 0,
+                    examId: this.dayExamDetail.examId,
+                }
+            }).then((res) => {
+                if (res.data.code == 200) {
+                    console.log('--res-', res)
+                }
+            })
+        },
+        goPractice() {
+            const { examId, moduleExamId = 0, chapterExamId = 0 } = this.dayExamDetail
+            uni.navigateTo({
+                url:'/pages2/bank/questionBank?orderGoodsId='+ this.orderGoodsId + '&id=' + examId + '&goodsid=' + this.goodsId 
+                +'&moduleId=' + moduleExamId + '&chapterId=' + chapterExamId + '&entryType=daily'
+            })
+        },
+        
+    },
+}
+</script>
+
+<style lang="scss">
+.daily_practice {
+    width: 100%;
+    padding: 32rpx;
+}
+.contents {
+    .toPractice {
+        width: 600rpx;
+        height: 100rpx;
+        line-height: 100rpx;
+        text-align: center;
+        font-size: 32rpx;
+        color: #222;
+        border: 2rpx solid #666;
+    }
+}
+.punch_calendar {
+    width: 100%;
+    background: #ffffff;
+	box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(47, 67, 121, 0.1);
+	border-radius: 22rpx;
+	margin-top: 16rpx;
+	padding-bottom: 15rpx;
+    .card_box {
+        height: 60rpx;
+        line-height: 60rpx;
+        // margin-left: 20rpx;
+        text-align: center;
+    }
+    .t1 {
+        color: #007AFF;
+        font-size: 24rpx;
+    }
+    .weeks {
+        width: 100%;
+        display: flex;
+        justify-content:center;
+        margin-top: 20rpx;
+    }
+    .card_date {
+        width: 14%;
+        text-align: center;
+        color: #7f8caf;
+    }
+    .day_dailys {
+        width: 100%;
+        display: flex;
+        margin-top: 40rpx;
+        flex-wrap: wrap;
+    }
+    .date_num {
+        width: 14%;
+        text-align: center;
+        position: relative;
+        display: inline-block;
+        margin-top: 20rpx;
+        .items {
+            width: 100%;
+        }
+    }
+}
+</style>