Prechádzať zdrojové kódy

修改答题、考试逻辑,新增vuex用户信息

yellowtaotao 4 rokov pred
rodič
commit
3986daa623

+ 8 - 5
src/views/home/index.vue

@@ -71,12 +71,15 @@ export default {
       field: "userInfo",
       value: {
         id: "testuser-ztdxxDGdNj",
-        username: "testuser-ztdxxDGdNj",
-        firstName: "string",
-        lastName: "string",
-        email: "string",
         encodedPassword: "string",
-        userStatus: "suspended"
+        userStatus: "suspended",
+        userName: "testuser-ztdxxDGdNj",
+        email: "test@gmail.com",
+        firstName: "一",
+        lastName: "张",
+        studyId: "U00000",
+        phone: "13060901234",
+        nickName: "小强"
       }
     });
     this.activeTabName = 0;

+ 8 - 3
src/views/home/learn/page-learn-content.vue

@@ -102,6 +102,7 @@
 
 <script>
 import { Toast } from "vant";
+import { mapState } from "vuex";
 export default {
   name: "page-learn-content",
   props: {
@@ -119,7 +120,11 @@ export default {
       commentValue: "" // 即将评论的内容
     };
   },
-  computed: {},
+  computed: {
+    ...mapState({
+      user: state => state.user
+    })
+  },
   created() {},
   mounted() {
     this.getContent();
@@ -182,7 +187,7 @@ export default {
     // 操作:收藏
     clickCollection() {
       let path = {
-        userName: "testuser-ztdxxDGdNj"
+        userName: this.user.userName
       };
       let params = {
         id: this.materialId
@@ -202,7 +207,7 @@ export default {
     // 操作:移除收藏
     clickRemoveCollection() {
       let path = {
-        userName: "testuser-ztdxxDGdNj"
+        userName: this.user.userName
       };
       let params = {
         id: this.materialId

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

@@ -29,6 +29,7 @@
 </template>
 
 <script>
+import { mapState } from "vuex";
 export default {
   name: "collection",
   components: {},
@@ -43,10 +44,15 @@ export default {
     console.log("--收藏--");
     this.getFavorites();
   },
+  computed: {
+    ...mapState({
+      user: state => state.user
+    })
+  },
   methods: {
     getFavorites() {
       let path = {
-        userName: "testuser-zirKBELIlg"
+        userName: this.user.userName
       };
       this.$_http
         .get(this.$pathParams(this.$_API.JTXT_GET_USER_FAVORITES, path))

+ 7 - 1
src/views/home/person/exam-history.vue

@@ -32,6 +32,7 @@
 </template>
 
 <script>
+import { mapState } from "vuex";
 export default {
   name: "exam-history",
   components: {},
@@ -52,10 +53,15 @@ export default {
   mounted() {
     this.getExamHistory();
   },
+  computed: {
+    ...mapState({
+      user: state => state.user
+    })
+  },
   methods: {
     getExamHistory() {
       let params = {
-        user: "testuser-ztdxxDGdNj"
+        user: this.user.userName
       };
       this.$_http
         .get(this.$_API.JTXT_GET_USER_EXAMS_HISTORY, { params })

+ 8 - 3
src/views/home/person/page-person.vue

@@ -52,6 +52,7 @@
 
 <script>
 import maleAvatar from "@/assets/image/maleAvatar.jpg";
+import { mapState } from "vuex";
 export default {
   name: "page-personal",
   components: {},
@@ -68,7 +69,6 @@ export default {
         "margin-right": "0.2rem"
       },
       faceUrl: "",
-      userName: "test@test.com",
       menus: [
         { title: "考试成绩", icon: "photo-o", to: "exam-history" },
         { title: "收藏", icon: "photo-o", to: "collection" },
@@ -78,6 +78,11 @@ export default {
       ]
     };
   },
+  computed: {
+    ...mapState({
+      user: state => state.user
+    })
+  },
   mounted() {
     this.getDailyPoints();
     this.getAllPoints();
@@ -86,7 +91,7 @@ export default {
     //   获取今日分数
     getDailyPoints() {
       let path = {
-        userName: "testuser-zirKBELIlg"
+        userName: this.user.userName
       };
       this.$_http
         .get(this.$pathParams(this.$_API.JTXT_GET_USER_DAIYL_POINTS, path))
@@ -101,7 +106,7 @@ export default {
     //   查询总积分
     getAllPoints() {
       let path = {
-        userName: "testuser-zirKBELIlg"
+        userName: this.user.userName
       };
       this.$_http
         .get(this.$pathParams(this.$_API.JTXT_GET_USER_ALL_POINTS, path))

+ 7 - 1
src/views/home/person/rank.vue

@@ -39,6 +39,7 @@
 
 <script>
 import maleAvatar from "@/assets/image/maleAvatar.jpg";
+import { mapState } from "vuex";
 export default {
   name: "collection",
   components: {},
@@ -55,10 +56,15 @@ export default {
     console.log("--收藏--");
     this.getFavorites();
   },
+  computed: {
+    ...mapState({
+      user: state => state.user
+    })
+  },
   methods: {
     getFavorites() {
       let path = {
-        userName: "testuser-zirKBELIlg"
+        userName: this.user.userName
       };
       this.$_http
         .get(this.$pathParams(this.$_API.JTXT_GET_USER_FAVORITES, path))