Prechádzať zdrojové kódy

Merge branch 'master' of http://120.77.221.199:3000/public/JingTieXueTang.H5

yellowtaotao 4 rokov pred
rodič
commit
27629a3998

+ 1 - 1
.env.development

@@ -1 +1 @@
-VUE_APP_JTXT_URL = "http://120.77.221.199:7000"
+VUE_APP_JTXT_URL = "http://8.141.68.219:8080"

+ 1 - 1
.env.testing

@@ -1 +1 @@
-VUE_APP_JTXT_URL = "http://120.77.221.199:7000"
+VUE_APP_JTXT_URL = "http://8.141.68.219:8080"

+ 2 - 0
src/api/modules/user.js

@@ -2,6 +2,8 @@
 export default {
   basePath: process.env.VUE_APP_JTXT_URL,
   apiList: {
+    //  admin获取所有用户
+    JTXT_GET_USER_ADMIN_USERS: "admin/users",
     // 查询今日积分
     JTXT_GET_USER_DAIYL_POINTS: "user/{userName}/daily-points",
     // 查询总积分

+ 6 - 0
src/store/modules/favorite.js

@@ -9,6 +9,12 @@ const favorite = {
     },
     addFavoriteItemStore(state, { field, value }) {
       state[field].push(value);
+    },
+    deleteFavoriteItemStore(state, { field, value }) {
+      if (state[field].length > 0) {
+        let index = state[field].indexOf(value);
+        state[field].splice(index, 1);
+      }
     }
   },
   actions: {}

+ 9 - 13
src/views/home/answer/page-answer-recruit.vue

@@ -27,7 +27,7 @@
         <div class="exam-question-describe">
           {{
             examQuestionList[answerIndex].questionContent ||
-              examQuestionList[answerIndex].content
+            examQuestionList[answerIndex].content
           }}
         </div>
         <!-- 答题列表 -->
@@ -35,7 +35,7 @@
         <div
           v-if="
             examQuestionList[answerIndex].type === questionType.singleChoice ||
-              examQuestionList[answerIndex].type === questionType.multipleChoice
+            examQuestionList[answerIndex].type === questionType.multipleChoice
           "
           class="exam-question-options"
         >
@@ -46,7 +46,7 @@
               'exam-question-options-item': true,
               'exam-question-options-item-checked': answerValue.includes(item),
               'exam-question-options-false':
-                answerValue.includes(item) && answerStatus === 2
+                answerValue.includes(item) && answerStatus === 2,
             }"
             @click="handleExamQuestionOptionsItemFun(item)"
           >
@@ -161,12 +161,16 @@ export default {
         return;
       }
       this.$store.commit("toggleLoading", true);
+      //   let params = {
+      //     type: "aaaaaaaa"
+      //   };
       this.$_http
         .post(
           this.$pathParams(this.$_API.POST_JTXT_GET_EXAMS_START, {
             examId: this.answerRecruitId
           }),
           this.userInfo
+        //   { params }
         )
         .then(res => {
           if (res.data) {
@@ -398,16 +402,8 @@ export default {
       let grades = this.getUserExamAllPointsFun(); // 方法:计算成绩
       let answers = this.getUserExamAllAnswersFun(); // 方法:获取当前用户所有题目作答的答案
       let params = {
-        user: this.userInfo,
-        exam: {
-          id: 0,
-          name: "",
-          description: "",
-          creator: this.userInfo,
-          duration: "",
-          deadline: "",
-          startTime: ""
-        },
+        userId: this.userInfo.id,
+        examId: this.answerRecruitId,
         points: grades, // 成绩:积分
         startTime: "", // this.answerTime.startTime,
         endTime: "", // this.answerTime.endTime

+ 14 - 19
src/views/home/exam/page-exam-item-doing.vue

@@ -14,7 +14,7 @@
         :class="{
           'exam-question-item': true,
           'exam-question-item-on': answerIndex === index,
-          'exam-question-item-down': examQuestionList[index].userAnswer.length
+          'exam-question-item-down': examQuestionList[index].userAnswer.length,
         }"
         v-for="(item, index) in examQuestionList"
         :key="index"
@@ -51,7 +51,7 @@
         <div v-if="examQuestionList.length" class="exam-question-describe">
           {{
             examQuestionList[answerIndex].questionContent ||
-              examQuestionList[answerIndex].content
+            examQuestionList[answerIndex].content
           }}
         </div>
         <!-- 答题列表 -->
@@ -59,10 +59,9 @@
         <div
           v-if="
             examQuestionList.length &&
-              (examQuestionList[answerIndex].type ===
-                questionType.singleChoice ||
-                examQuestionList[answerIndex].type ===
-                  questionType.multipleChoice)
+            (examQuestionList[answerIndex].type === questionType.singleChoice ||
+              examQuestionList[answerIndex].type ===
+                questionType.multipleChoice)
           "
           class="exam-question-options"
         >
@@ -71,7 +70,7 @@
             :key="index"
             :class="{
               'exam-question-options-item': true,
-              'exam-question-options-item-checked': answerValue.includes(item)
+              'exam-question-options-item-checked': answerValue.includes(item),
             }"
             @click="handleExamQuestionOptionsItemFun(item)"
           >
@@ -82,7 +81,7 @@
         <div
           v-if="
             examQuestionList.length &&
-              examQuestionList[answerIndex].type === questionType.gapFilling
+            examQuestionList[answerIndex].type === questionType.gapFilling
           "
           class="exam-question-gapFilling"
         >
@@ -125,7 +124,7 @@
       accept="image/*"
       capture="user"
       @change="startTakePhotoFUn"
-      style="display: none;"
+      style="display: none"
     />
   </div>
 </template>
@@ -206,12 +205,16 @@ export default {
     // 方法:开始考试
     examStartFun() {
       this.$store.commit("toggleLoading", true);
+      //   let params = {
+      //     type: "aaaaaaaa"
+      //   };
       this.$_http
         .post(
           this.$pathParams(this.$_API.POST_JTXT_GET_EXAMS_START, {
             examId: this.examItem.id
           }),
           this.userInfo
+          //   { params }
         )
         .then(res => {
           if (res.data) {
@@ -509,16 +512,8 @@ export default {
       let grades = this.getUserExamAllPointsFun(); // 方法:计算成绩
       let answers = this.getUserExamAllAnswersFun(); // 方法:获取当前用户所有题目作答的答案
       let params = {
-        user: this.userInfo,
-        exam: {
-          id: this.examItem.id,
-          name: this.examItem.name,
-          description: this.examItem.description,
-          creator: this.userInfo,
-          duration: this.examItem.duration,
-          deadline: this.examItem.deadline,
-          startTime: this.examItem.startTime
-        },
+        userId: this.userInfo.id,
+        examId: this.answerRecruitId,
         points: grades, // 成绩:分数
         startTime: this.answerTime.startTime,
         endTime: this.answerTime.endTime,

+ 19 - 20
src/views/home/index.vue

@@ -91,27 +91,25 @@ export default {
   },
   created() {
     this.initFun();
-    this.getCollection();
   },
   methods: {
     // 初始化
     initFun() {
-      this.$store.commit("updateUserItemStore", {
-        field: "userInfo",
-        value: {
-          id: "testuser-DHjjEuxXbN",
-          encodedPassword: "string",
-          userStatus: "suspended",
-          userName: "testuser-DHjjEuxXbN",
-          email: "test@gmail.com",
-          firstName: "一",
-          lastName: "张",
-          studyId: "U00000",
-          phone: "13060901234",
-          nickName: "小强",
-          group: "临时用户"
-        }
-      });
+      // 获取所有用户
+      this.$_http
+        .get(this.$_API.JTXT_GET_USER_ADMIN_USERS)
+        .then(res => {
+          console.log(res);
+          this.$store.commit("updateUserItemStore", {
+            field: "userInfo",
+            value: res.data[0]
+          });
+          // 获取所有收藏
+          this.getCollection();
+        })
+        .catch(() => {
+          this.$store.commit("toggleLoading", false);
+        });
       this.engineeringWorkList = [
         { text: "桥隧工", value: 1 },
         { text: "桥梁工", value: 2 },
@@ -145,14 +143,15 @@ export default {
         .get(this.$pathParams(this.$_API.JTXT_GET_USER_FAVORITES, path))
         .then(res => {
           if (res.data.materials) {
-            console.log(res.data.materials);
+            console.log("--已收藏--");
+            console.log(res.data);
             this.$store.commit("updateFavoriteItemStore", {
               field: "materials",
-              value: res.data.materials.materials
+              value: res.data.materials
             });
             this.$store.commit("updateFavoriteItemStore", {
               field: "titles",
-              value: res.data.materials.titles
+              value: res.data.titles
             });
           } else {
             this.$store.commit("toggleLoading", false);

+ 1 - 2
src/views/home/learn/page-learn-child.vue

@@ -3,8 +3,7 @@
     <van-tabs
       :active="active"
       type="line"
-      line-width="30px"
-      line-height="1px"
+      line-height="0px"
       @click="childChange"
     >
       <!-- 子目录 -->

+ 30 - 9
src/views/home/learn/page-learn-content.vue

@@ -1,7 +1,8 @@
 <template>
   <div class="page-learn-content-box">
     <van-nav-bar title="学习" left-arrow @click-left="onClickLeft" />
-    <div v-if="seconds > 0" class="learn-content-rest-time">
+    <div v-if="!isReadable" class="learn-content-rest-time">已学完</div>
+    <div v-else class="learn-content-rest-time">
       剩余学习时间: {{ getTimeHoursMinuteSecondsFun(seconds) }}
     </div>
     <!-- 内容 -->
@@ -120,18 +121,20 @@ export default {
       commentList: [], // 评论列表内容
       commentValue: "", // 即将评论的内容
       startStudyInterval: null,
-      isRead: false
+      isReadable: true
     };
   },
   computed: {
     ...mapState({
-      user: state => state.user
+      user: state => state.user,
+      favorite: state => state.favorite
     })
   },
   created() {},
   mounted() {
     this.getContent();
     this.checkReadMaterial();
+    this.checkCollection();
   },
   beforeDestroy() {
     clearInterval(this.startStudyInterval);
@@ -187,7 +190,8 @@ export default {
           this.seconds--;
         } else {
           Toast("学习完成");
-          if (this.isRead) {
+          if (this.isReadable) {
+            this.isReadable = false;
             this.ReadMaterial();
           }
           clearInterval(this.startStudyInterval);
@@ -209,6 +213,11 @@ export default {
         )
         .then(res => {
           this.isCollected = true;
+          //   新增收藏缓存
+          this.$store.commit("addFavoriteItemStore", {
+            field: "materials",
+            value: this.materialId
+          });
         })
         .catch(() => {
           this.$store.commit("toggleLoading", false);
@@ -234,6 +243,11 @@ export default {
         )
         .then(res => {
           this.isCollected = false;
+          //   删除收藏缓存
+          this.$store.commit("deleteFavoriteItemStore", {
+            field: "materials",
+            value: this.materialId
+          });
         })
         .catch(() => {
           this.$store.commit("toggleLoading", false);
@@ -287,11 +301,8 @@ export default {
           params
         })
         .then(res => {
-          this.isRead = res;
-          console.log(this.isRead);
-          if (this.isRead) {
-            this.ReadMaterial();
-          }
+          this.isReadable = res;
+          console.log(this.isReadable);
         })
         .catch(() => {
           this.$store.commit("toggleLoading", false);
@@ -315,6 +326,16 @@ export default {
         .catch(() => {
           this.$store.commit("toggleLoading", false);
         });
+    },
+    checkCollection() {
+      if (this.favorite.materials && this.favorite.materials.length > 0) {
+        console.log(this.favorite.materials);
+        console.log(this.materialId);
+        const item = this.favorite.materials.find(it => it === this.materialId);
+        if (item && item === this.materialId) {
+          this.isCollected = true;
+        }
+      }
     }
   }
 };

+ 1 - 1
src/views/home/learn/page-learn.vue

@@ -1,6 +1,6 @@
 <template>
   <div>
-    <van-tabs :active="active" @click="rootChange">
+    <van-tabs :active="active" @click="rootChange" line-width="10px">
       <!-- 根目录 -->
       <van-tab
         v-for="(item, index) in learnRootList"

+ 1 - 1
src/views/home/person/collection.vue

@@ -67,6 +67,7 @@ export default {
                 index + 1 === res.data.materials.length
               );
             });
+            this.finished = true;
           } else {
             this.$store.commit("toggleLoading", false);
           }
@@ -86,7 +87,6 @@ export default {
         .then(res => {
           this.favoritesList.push(res.data);
           if (isLast) {
-            this.finished = true;
             this.$store.commit("toggleLoading", false);
           }
         })

+ 2 - 2
src/views/home/person/exam-history.vue

@@ -28,7 +28,7 @@
                 'exam-point': true,
                 'exam-point-green': item.points >= 90,
                 'exam-point-yellow': item.points >= 60 && item.points < 90,
-                'exam-point-red': item.points < 60
+                'exam-point-red': item.points < 60,
               }"
             >
               {{ item.points }}
@@ -73,6 +73,7 @@ export default {
           res.data.forEach((item, index) => {
             this.getExamDetailFun(item, index, index + 1 === res.data.length);
           });
+          this.finished = true;
         })
         .catch(() => {
           this.$store.commit("toggleLoading", false);
@@ -89,7 +90,6 @@ export default {
         .then(res => {
           this.examHistoryList.push({ ...item, examName: res.data.name });
           if (isLast) {
-            this.finished = true;
             this.$store.commit("toggleLoading", false);
           }
         })

+ 1 - 1
src/views/home/person/page-person.vue

@@ -14,7 +14,7 @@
           />
           <div>
             <div class="userName">
-              {{ userInfo.userName }}
+              {{ userInfo.nickName }}
             </div>
             <div class="userGroup">组织:{{ userInfo.group }}</div>
           </div>