瀏覽代碼

解决刷新token bug

liqk 4 年之前
父節點
當前提交
1d5fd33768

+ 6 - 4
TEAMModelOS/ClientApp/src/filters/http.js

@@ -30,10 +30,12 @@ axios.interceptors.request.use(
         // if (config.url != 'https://api2.teammodel.cn/oauth2/v2.1/token') {
         let flag = checkToken()
         if (flag) {
-            if (localStorage.getItem('access_token')) {
-                console.log('等待刷新....')
-                await refreshToken()
-                console.log('刷新完成....')
+            if (!refreshing) {
+                if (localStorage.getItem('access_token')) {
+                    console.log('等待刷新....')
+                    await refreshToken()
+                    console.log('刷新完成....')
+                }
             }
         }
         // }

+ 18 - 45
TEAMModelOS/ClientApp/src/view/selfstudy/ActivityInfo.vue

@@ -16,15 +16,15 @@
                     <p class="target-name">
                         {{item.classroomName}}
                         <span class="class-type-label" :title="item.code === $store.state.userInfo.schoolCode ? '校本班级':'私人班级'">{{item.code === $store.state.userInfo.schoolCode ? '校':'私'}}</span>
-                        <span class="activity-status" :style="{background: item.flag ? '#19be6b':'#ed4014'}">未分享</span>
+                        <span class="activity-status" :style="{background: item[id] ? '#19be6b':'#ed4014'}">{{item[id] ? '进行中':'未分享'}}</span>
                     </p>
                     <p style="margin-top:6px;">
                         <span class="info-label">活动类型:</span>
-                        <span class="info-value">{{item.flag ? item.flag:'-- --'}}</span>
+                        <span class="info-value">{{ !item[id] ? '-- --' : item[id].type == 1 ? '自主学习':'课前预习'}}</span>
                     </p>
-                    <p style="margin-top:6px;" v-if="item.publish == ''">
-                        <span class="info-label">开始时间:</span>
-                        <span class="info-value">{{item.startTime ? item.startTime:'-- --'}}</span>
+                    <p style="margin-top:6px;" v-if="item[id]">
+                        <span class="info-label">{{ item[id].type == 1 ? '开始时间:' : '结束时间:' }}</span>
+                        <span class="info-value">{{item[id].type == 1 ? $tools.formatTime(item[id].createTime,'yyyy-MM-dd') : $tools.formatTime(item[id].endTime)}}</span>
                     </p>
                     <p style="margin-top:6px;" v-else>
                         <span class="info-label">结束时间:</span>
@@ -51,10 +51,10 @@
                 </FormItem>
                 <FormItem label="闯关模式" prop="stage">
                     <RadioGroup v-model="activityInfo.stage" style="color:white;">
-                        <Radio label="1" style="width:82px;">
+                        <Radio :label="1" style="width:82px;">
                             <span>是</span>
                         </Radio>
-                        <Radio label="0">
+                        <Radio :label="0">
                             <span>否</span>
                         </Radio>
                     </RadioGroup>
@@ -87,6 +87,12 @@
             id: {
                 default: '',
                 type: String
+            },
+            classList: {
+                default: () => {
+                    return []
+                },
+                type: Array
             }
         },
         data() {
@@ -116,13 +122,12 @@
                         { required: true, type:'number', message: '请选择活动类型', trigger: 'change' }
                     ],
                     stage: [
-                        { required: true, type:'boolean',message: '请选择活动模式', trigger: 'change' }
+                        { required: true, type:'number',message: '请选择活动模式', trigger: 'change' }
                     ],
                     endTime: [
                         { required: true, type:'number',message: '请设置结束时间', trigger: 'change' }
                     ]
                 },
-                classList: [],
                 activityInfo: {
                     type: '',
                     endTime: undefined,
@@ -160,41 +165,6 @@
                 })
                 
             },
-            //查询学习任务
-            findTask() {
-
-            },
-            /**
-             * 查找教师课程下的教室(班级)
-             * */
-            findClassroom() {
-                if (this.classList.length == 0) {
-                    let requestData = this.$store.state.userInfo.TEAMModelId
-                    this.$api.learnActivity.FindClassroomByTeacherId(requestData).then(
-                        res => {
-                            if (res.error == null) {
-
-                                this.classList = res.result.data
-                                this.$api.learnActivity.findTask({
-                                    id: this.id
-                                }).then(
-                                    (taskRes) => {
-
-                                    },
-                                    (taskErr) => {
-
-                                    }
-                                )
-                            } else {
-                                this.$Message.error('API ERROR!')
-                            }
-                        },
-                        err => {
-
-                        }
-                    )
-                }
-            },
             selectActivity(index) {
                 this.curClassIndex = index
             },
@@ -204,9 +174,12 @@
             closeAnswerDetail() {
                 this.showAnswer = false
             }
+        },
+        mounted() {
+            
         },
         created() {
-            this.findClassroom()
+          
         }
     }
 </script>

+ 71 - 4
TEAMModelOS/ClientApp/src/view/selfstudy/SelfLearn.vue

@@ -29,11 +29,11 @@
             </div>
             <div class="order-learn-main-body dark-iview-split" v-if="listType == 'order' && orderLearnList[currentLearnIndex]">
                 <OrderLearnInfo v-if="currentTabIndex == 0" :orderLearnInfo="orderLearnList[currentLearnIndex]"></OrderLearnInfo>
-                <ActivityInfo v-else :id="orderLearnList[currentLearnIndex].id"></ActivityInfo>
+                <ActivityInfo v-else :id="id" :classList="classList"></ActivityInfo>
             </div>
             <div class="order-learn-main-body dark-iview-split" v-else-if="listType == 'unit' && unitList[currentUnitIndex]">
                 <UnitInfo v-if="currentTabIndex == 0"  :unitInfo="unitList[currentUnitIndex]"></UnitInfo>
-                <ActivityInfo v-else :id="unitList[currentUnitIndex].id"></ActivityInfo>
+                <ActivityInfo v-else :id="id" :classList="classList"></ActivityInfo>
             </div>
         </div>
         <Modal v-model="editStatus"
@@ -59,6 +59,7 @@
     import OrderLearnInfo from './OrderLearnInfo.vue'
     import UnitInfo from './UnitInfo.vue'
     import ActivityInfo from './ActivityInfo.vue'
+import { faTruck } from '@fortawesome/free-solid-svg-icons'
     
     export default {
         components: {
@@ -66,7 +67,8 @@
         },
         data() {
             return {
-                
+                requestIds:[],
+                classList: [],
                 currentTabIndex: 1,
                 listType: 'order',//order: 编序式教材 unit:学习单元
                 isLoading: false,
@@ -94,6 +96,24 @@
                         return false
                     }
                 }
+            },
+            id() {
+                if (this.listType == 'order') {
+
+                    return this.orderLearnList[this.currentLearnIndex].id
+                } else {
+                    return this.unitList[this.currentUnitIndex].id
+                }
+            }
+        },
+        watch: {
+            id: {
+                handler(n, o) {
+                    if (this.requestIds.indexOf(this.id) == -1) {
+                        this.findTask()
+                    }
+                },
+                deep: true
             }
         },
         methods: {
@@ -188,7 +208,32 @@
                     this.findUnit()
                 }
             },
-            
+            //查询学习任务
+            findTask() {
+                this.$api.learnActivity.findTask({
+                    id: this.id
+                }).then(
+                    (res) => {
+                        if (res.error == null) {
+                            let resData = res.result.data
+                            for (let index in resData) {
+                                for (let i in this.classList) {
+                                    if (this.classList[i].classroomCode == resData[index].code) {
+                                        this.classList[i][resData[index].id] = resData[index]
+                                        break
+                                    }
+                                }
+                            }
+                            console.log(this.classList)
+                        } else {
+                            this.$Message.error('API error!')
+                        }
+                    },
+                    (err) => {
+                        this.$Message.error('API error!')
+                    }
+                )
+            },
             goToCreate() {
                 if (this.listType == 'order') {
                     this.$router.push({
@@ -201,6 +246,27 @@
                 }
 
             },
+            /**
+             * 查找教师课程下的教室(班级)
+             * */
+            findClassroom() {
+                if (this.classList.length == 0) {
+                    let requestData = this.$store.state.userInfo.TEAMModelId
+                    this.$api.learnActivity.FindClassroomByTeacherId(requestData).then(
+                        res => {
+                            if (res.error == null) {
+                                this.classList = res.result.data
+                                //this.findTask()
+                            } else {
+                                this.$Message.error('API ERROR!')
+                            }
+                        },
+                        err => {
+
+                        }
+                    )
+                }
+            },
             downloadFile(item) {
                 window.location.href = item.blobUrl + this.sasString
             },
@@ -286,6 +352,7 @@
         },
         created() {
             this.findOrderLearn()
+            this.findClassroom()
         }
     }
 </script>