zengyicheng 2 سال پیش
والد
کامیت
b66ef3e8f1
3فایلهای تغییر یافته به همراه176 افزوده شده و 26 حذف شده
  1. 20 12
      src/components/courseDetail.vue
  2. 152 10
      src/components/study.vue
  3. 4 4
      src/config/config.js

+ 20 - 12
src/components/courseDetail.vue

@@ -36,15 +36,16 @@
                   {{ courseDetail.vcount != null ? courseDetail.vcount : 0 }}人
                 </div>
               </div>
-              <div class="cType">
+              <!-- <div class="cType">
                 <div
-                  v-for="(item, index) in courseType"
+                  class="all_choose"
+                  v-for="(item, index) in courseTypeJson"
                   :key="index"
-                  style="margin: 10px 10px 0 0"
                 >
                   <span>{{ item }}</span>
+                  <span v-for="(item2,index2) in courseTypeJosn[item]" :key="index2">{{ item2 }}</span>
                 </div>
-              </div>
+              </div> -->
               <div class="now_study" @click="dialogVisible = true">
                 立即学习
               </div>
@@ -162,6 +163,7 @@ export default {
       aStudentName: [],
       chapInfo: [],
       courseType: [],
+      courseTypeJson: {},
       mr: require("../assets/icon/wheel.png"),
     };
   },
@@ -240,14 +242,20 @@ export default {
           this.courseDetail = res.data[0][0];
           var a = res.data[0];
           var b = res.data[1];
-          for (var i = 0; i < a.length; i++) {
-            for (var j = 0; j < b.length; j++) {
-              if (a[i].pid == b[j].id) {
-                this.courseType.push(b[j].name + ":" + a[i].name);
-              }
-            }
-          }
-          console.log(this.courseType);
+          // for (var i = 0; i < b.length; i++) {
+          //   if (!this.id) {
+          //     this.courseType[b[i].id] = [];
+          //   }
+          //   for (var j = 0; j < a.length; j++) {
+          //     if (b[i].id == a[j].pid) {
+          //       if (!this.courseTypeJson[b[i].id]) {
+          //         this.courseTypeJson[b[i].name] = [];
+          //       }
+          //       this.courseTypeJson[b[i].name].push(a[j].name);
+          //     }
+          //   }
+          // }
+          // console.log(this.courseTypeJson);
           this.aStudentName = res.data[2];
           this.chapInfo = JSON.parse(this.courseDetail.chapters);
         })

+ 152 - 10
src/components/study.vue

@@ -196,7 +196,8 @@
               <div class="ediBottom">
                 <editor-bar
                   style="width: 75%; padding: 10px 0 20px 0px; margin: 0"
-                  v-model="question"
+                  v-model="questionAnswer"
+                  @change="change"
                 ></editor-bar>
                 <div
                   class="addEditor"
@@ -290,22 +291,46 @@
                     .toolChoose"
                   :key="indexTool"
                 >
-                  <div class="whiteBIcon" v-if="itemTool == 1">
+                  <div
+                    class="whiteBIcon"
+                    v-if="itemTool == 1"
+                    @click="addTools(itemTool)"
+                  >
                     <img src="../assets/icon/whiteBordIcon.png" alt="" />
                   </div>
-                  <div class="whiteBIcon" v-if="itemTool == 2">
+                  <div
+                    class="whiteBIcon"
+                    v-if="itemTool == 2"
+                    @click="addTools(itemTool)"
+                  >
                     <img src="../assets/icon/noteIcon.png" alt="" />
                   </div>
-                  <div class="whiteBIcon" v-if="itemTool == 3">
+                  <div
+                    class="whiteBIcon"
+                    v-if="itemTool == 3"
+                    @click="addTools(itemTool)"
+                  >
                     <img src="../assets/icon/mindIcon.png" alt="" />
                   </div>
-                  <div class="whiteBIcon" v-if="itemTool == 4">
+                  <div
+                    class="whiteBIcon"
+                    v-if="itemTool == 4"
+                    @click="addTools(itemTool)"
+                  >
                     <img src="../assets/icon/askIcon.png" alt="" />
                   </div>
-                  <div class="whiteBIcon" v-if="itemTool == 5">
+                  <div
+                    class="whiteBIcon"
+                    v-if="itemTool == 5"
+                    @click="addTools(itemTool)"
+                  >
                     <img src="../assets/icon/scoreIcon.png" alt="" />
                   </div>
-                  <div class="whiteBIcon" v-if="itemTool == 6">
+                  <div
+                    class="whiteBIcon"
+                    v-if="itemTool == 6"
+                    @click="addTools(itemTool)"
+                  >
                     <img src="../assets/icon/wordIcon.png" alt="" />
                   </div>
                 </div>
@@ -516,10 +541,18 @@ export default {
       noneBtnImg: false,
       proVisible: false,
       progress: 0,
-      question: "",
+      questionAnswer: "",
+      wbCount: 0,
+      wordCount: 0,
+      mindCount: 0,
+      askCount: 0,
+      noteCount: 0,
     };
   },
   methods: {
+    change(val) {
+      console.log(val);
+    },
     goTo(path) {
       this.$router.push(path);
     },
@@ -694,7 +727,7 @@ export default {
           cid: this.id,
           // chid: this.chapInfoList[this.courseType - 0].chapterInfo[0].chapterid,
           chid: this.courseType,
-          t: this.question,
+          t: this.questionAnswer,
           uid: this.userid,
         },
       ];
@@ -705,7 +738,7 @@ export default {
             message: "提交成功",
             type: "success",
           });
-          this.question = "";
+          this.questionAnswer = "";
         })
         .catch((err) => {
           this.$message.error("提交失败");
@@ -852,9 +885,118 @@ export default {
           console.error(err);
         });
     },
+    selectCount() {
+      let params = {
+        cid: this.id,
+        chid: this.courseType,
+        uid: this.userid,
+      };
+      this.ajax
+        .get(this.$store.state.api + "selectToolsCount", params)
+        .then((res) => {
+          for (var i = 0; i < res.data[0].length; i++) {
+            if (res.data[0][i].tools == 1) {
+              this.wbCount = res.data[0][i].count;
+            } else if (res.data[0][i].tools == 2) {
+              this.wordCount = res.data[0][i].count;
+            } else if (res.data[0][i].tools == 3) {
+              this.mindCount = res.data[0][i].count;
+            } else if (res.data[0][i].tools == 4) {
+              this.askCount = res.data[0][i].count;
+            } else {
+              this.noteCount = res.data[0][i].count;
+            }
+          }
+        })
+        .catch((err) => {
+          console.error(err);
+        });
+    },
+    addTools(t) {
+      var a = 0;
+      if (t == 1) {
+        if (this.wbCount > 0) {
+          this.updateCount(this.wbCount, t);
+        } else {
+          this.wbCount++;
+          a = this.wbCount;
+          this.toolsCount(a,t);
+        }
+      } else if (t == 2) {
+        if (this.wordCount > 0) {
+          this.updateCount(this.wordCount, t);
+        } else {
+          this.wordCount++;
+          a = this.wordCount;
+          this.toolsCount(a,t);
+        }
+      } else if (t == 3) {
+        if (this.mindCount > 0) {
+          this.updateCount(this.mindCount, t);
+        } else {
+          this.mindCount++;
+          a = this.mindCount;
+          this.toolsCount(a,t);
+        }
+      } else if (t == 4) {
+        if (this.askCount > 0) {
+          this.updateCount(this.askCount, t);
+        } else {
+          this.askCount++;
+          a = this.askCount;
+          this.toolsCount(a,t);
+        }
+      } else {
+        if (this.noteCount > 0) {
+          this.updateCount(this.noteCount, t);
+        } else {
+          this.noteCount++;
+          a = this.noteCount;
+          this.toolsCount(a,t);
+        }
+      }
+    },
+    toolsCount(a,t) {
+      let params = {
+        cid: this.id,
+        chid: this.courseType,
+        uid: this.userid,
+        tid: t,
+        count: a,
+      };
+      this.ajax
+        .get(this.$store.state.api + "insertToolsCount", params)
+        .then((res) => {
+          this.selectCount();
+          console.log(res);
+        })
+        .catch((err) => {
+          console.error(err);
+        });
+    },
+    updateCount(c, t) {
+      c++;
+      let params = {
+        cid: this.id,
+        chid: this.courseType,
+        uid: this.userid,
+        tid: t,
+        count: c,
+      };
+      this.ajax
+        .get(this.$store.state.api + "updateToolsCount", params)
+        .then((res) => {
+          this.selectCount();
+          console.log(res);
+        })
+        .catch((err) => {
+          console.error(err);
+        });
+    },
   },
   created() {
     this.getCourseDetail();
+    this.selectCount();
     document.scrollingElement.scrollTop = 0;
   },
 };

+ 4 - 4
src/config/config.js

@@ -6,11 +6,11 @@ Vue.use(Vuex)
 const store = new Vuex.Store({
     state: {
         isLogin: false,
-        luyou:1,
+        luyou: 1,
         userInfo: {},
-        nCount:0,
-        api: 'https://pbl.cocorobo.cn/api/pbl/',
-        // api: 'http://localhost:7003/api/pbl/',
+        nCount: 0,
+        // api: 'https://pbl.cocorobo.cn/api/pbl/',
+        api: 'http://localhost:7003/api/pbl/',
     },
 
     mutations: {