Sfoglia il codice sorgente

联考学生端总分科目标准分分析无数据不显示

DFRCYXY0023 6 mesi fa
parent
commit
18cf7eab40

+ 220 - 148
src/views/analysisReport/studentPage/scrolReport/transcript_total.vue

@@ -5,8 +5,16 @@
         <div class="title_left">成绩总览</div>
       </div>
       <div class="module_table">
-        <el-table :data="subjectData.tableData" v-loading="subjectLoading" :element-loading-text="loadingText"
-          element-loading-spinner="el-icon-loading" element-loading-background="#ffffff" border stripe align="left">
+        <el-table
+          :data="subjectData.tableData"
+          v-loading="subjectLoading"
+          :element-loading-text="loadingText"
+          element-loading-spinner="el-icon-loading"
+          element-loading-background="#ffffff"
+          border
+          stripe
+          align="left"
+        >
           <el-table-column v-for="title in subjectData.titleData" :key="title.prop" align="center" :label="title.name">
             <template slot-scope="scope">
               <template v-if="title.prop == 'score' || title.prop == 'scoreRate'">
@@ -18,14 +26,19 @@
                   <img v-else-if="scope.row?.[title.prop] == 0" src="@/assets/stuIcon/icon_error.png" />
                   <img v-else src="@/assets/stuIcon/icon_half_right.png" />
                 </template>
-                <template v-else>{{ scope.row?.[title.prop] || "-" }}</template>
+                <template v-else>{{ scope.row?.[title.prop] || '-' }}</template>
               </template>
               <template v-else-if="title.prop == 'imgUrlList'">
                 <!-- :disabled="!scope?.row?.imgUrlList || scope?.row?.imgUrlList == '-'" -->
-                <el-button v-if="scope.row.isTotal==0 && scope.row.subjectGroupType==0" type="text" @click="OpenStudentPaper(scope.row.subjectCode)">查看答题卡</el-button>
+                <el-button
+                  v-if="scope.row.isTotal == 0 && scope.row.subjectGroupType == 0"
+                  type="text"
+                  @click="OpenStudentPaper(scope.row.subjectCode)"
+                  >查看答题卡</el-button
+                >
                 <template v-else>-</template>
               </template>
-              <template v-else>{{ scope.row?.[title.prop] || "-" }}</template>
+              <template v-else>{{ scope.row?.[title.prop] || '-' }}</template>
             </template>
           </el-table-column>
         </el-table>
@@ -38,39 +51,56 @@
       </div>
       <div class="module_describe suggestion">
         <ExpandableText :isExpanded="false" :shouldShowButton="false">
-          {{ suggestionData?.studentName }}同学,本次考试{{ suggestionData?.studentOpenness == 1 ||
-            suggestionData?.studentOpenness == 2 ?'总分':'总分标准分为' }}<span style="color: #2E64FA;">{{ suggestionData?.fullScore
-            }}</span>{{ suggestionData?.studentOpenness == 1 || suggestionData?.studentOpenness == 2 ? '分' : '' }},整体处于{{
-              suggestionData?.summarySuggestionLevel }},<template v-if="suggestionData?.upSubjectData"><span
-              style="color: #3BA272;">{{
-                suggestionData?.upSubjectData }}</span>是你的优势学科,建议通过提分练习进行强化,继续保持这类学科的优势性{{ suggestionData?.downSubjectData
-                ? ';' :
-                '。'
-            }}</template><template v-if="suggestionData?.downSubjectData"><span style="color: #F56C6C;">{{
-              suggestionData?.downSubjectData
-              }}</span>是你的劣势学科,建议先加强学习,熟练掌握薄弱知识点的基础,然后通过提分练习进行巩固和强化,争取下次考试获得更优异的成绩!</template>
+          {{ suggestionData?.studentName }}同学,本次考试{{
+            suggestionData?.studentOpenness == 1 || suggestionData?.studentOpenness == 2 ? '总分' : '总分标准分为'
+          }}<span style="color: #2e64fa">{{ suggestionData?.fullScore }}</span
+          >{{ suggestionData?.studentOpenness == 1 || suggestionData?.studentOpenness == 2 ? '分' : '' }},整体处于{{
+            suggestionData?.summarySuggestionLevel
+          }},<template v-if="suggestionData?.upSubjectData"
+            ><span style="color: #3ba272">{{ suggestionData?.upSubjectData }}</span
+            >是你的优势学科,建议通过提分练习进行强化,继续保持这类学科的优势性{{
+              suggestionData?.downSubjectData ? ';' : '。'
+            }}</template
+          ><template v-if="suggestionData?.downSubjectData"
+            ><span style="color: #f56c6c">{{ suggestionData?.downSubjectData }}</span
+            >是你的劣势学科,建议先加强学习,熟练掌握薄弱知识点的基础,然后通过提分练习进行巩固和强化,争取下次考试获得更优异的成绩!</template
+          >
         </ExpandableText>
       </div>
     </div>
     <!-- 科目标准分分析 -->
-    <div class="report_module">
+    <div class="report_module" v-if="subjectData.standardScoreAnalysisStatus == 0">
       <div class="module_title" style="position: relative">
         <div class="title_left">科目标准分分析</div>
       </div>
       <div class="module_chart" v-if="subjectData.tableData.length > 0">
-        <DifferenceChart :datax="subjectData.datax" :tooltipData="subjectData.tooltipData" :datay="subjectData.datay"
-          :rate="0" :isClick="false"></DifferenceChart>
+        <DifferenceChart
+          :datax="subjectData.datax"
+          :tooltipData="subjectData.tooltipData"
+          :datay="subjectData.datay"
+          :rate="0"
+          :isClick="false"
+        ></DifferenceChart>
       </div>
-      <div class="module_chart no_content_data" v-loading="subjectLoading" :element-loading-text="loadingText"
-        element-loading-spinner="el-icon-loading" element-loading-background="#ffffff" v-else>
+      <div
+        class="module_chart no_content_data"
+        v-loading="subjectLoading"
+        :element-loading-text="loadingText"
+        element-loading-spinner="el-icon-loading"
+        element-loading-background="#ffffff"
+        v-else
+      >
         <span>暂无数据</span>
       </div>
       <div class="module_describe">
         <ExpandableText>
-          说明:从标准分情况来看,这次考试<template v-if="subjectData.maxSubject"><span style="color: #3BA272">{{ subjectData.maxSubject
-              }}</span>表现突出,请继续保持</template><template v-if="subjectData.minSubject">;<span style="color: #EE6666">{{
-                subjectData.minSubject
-              }}</span>标准分明显低于其他学科,可能会对总体排名造成影响,可结合错题梳理核心知识点,精准定位薄弱环节,制定针对性的提升计划,以实现各科均衡发展,进一步巩固整体成绩</template>。
+          说明:从标准分情况来看,这次考试<template v-if="subjectData.maxSubject"
+            ><span style="color: #3ba272">{{ subjectData.maxSubject }}</span
+            >表现突出,请继续保持</template
+          ><template v-if="subjectData.minSubject"
+            >;<span style="color: #ee6666">{{ subjectData.minSubject }}</span
+            >标准分明显低于其他学科,可能会对总体排名造成影响,可结合错题梳理核心知识点,精准定位薄弱环节,制定针对性的提升计划,以实现各科均衡发展,进一步巩固整体成绩</template
+          >。
         </ExpandableText>
       </div>
     </div>
@@ -79,41 +109,67 @@
         <div class="title_left">历次考试分析</div>
         <div class="title_right report_button">
           <div class="module_tab">
-            <div class="tab_item" v-for="item in historyExamData.selectNames"
-              :class="historyExamData.selectVal == item.prop ? 'tab_active' : ''" :key="item.prop"
-              @click="ChangeSelectVal(item.prop, item.name)">
+            <div
+              class="tab_item"
+              v-for="item in historyExamData.selectNames"
+              :class="historyExamData.selectVal == item.prop ? 'tab_active' : ''"
+              :key="item.prop"
+              @click="ChangeSelectVal(item.prop, item.name)"
+            >
               {{ item.name }}
             </div>
           </div>
         </div>
       </div>
       <div class="module_chart" v-if="historyExamData.chartData.length > 0">
-        <LineChart :extraText="false" :showCheckBox="false" :showMarkPoint="false" :showBackground="false"
-          :markNumber="historyExamData.markNumber" :datax="historyExamData.datax" :datay="historyExamData.datay"
-          :title="historyExamData.title" :legendList="historyExamData.title"
-          :yInverse="historyExamData.selectVal == 'examRank' || historyExamData.selectVal == 'schoolRank'? true : false" :tooltipData="historyExamData.tooltipData"
-          :gridRight="40"></LineChart>
+        <LineChart
+          :extraText="false"
+          :showCheckBox="false"
+          :showMarkPoint="false"
+          :showBackground="false"
+          :markNumber="historyExamData.markNumber"
+          :datax="historyExamData.datax"
+          :datay="historyExamData.datay"
+          :title="historyExamData.title"
+          :legendList="historyExamData.title"
+          :yInverse="
+            historyExamData.selectVal == 'examRank' || historyExamData.selectVal == 'schoolRank' ? true : false
+          "
+          :tooltipData="historyExamData.tooltipData"
+          :gridRight="40"
+        ></LineChart>
       </div>
-      <div class="module_chart no_content_data" v-loading="historyExamLoading" :element-loading-text="loadingText"
-        element-loading-spinner="el-icon-loading" element-loading-background="#ffffff" v-else>
+      <div
+        class="module_chart no_content_data"
+        v-loading="historyExamLoading"
+        :element-loading-text="loadingText"
+        element-loading-spinner="el-icon-loading"
+        element-loading-background="#ffffff"
+        v-else
+      >
         <span>暂无数据</span>
       </div>
       <div class="page_jg_20"></div>
     </div>
     <GotoTop></GotoTop>
     <!-- 学生答题卡预览组件 -->
-    <StudentPaper v-model="showStudentPaperDialog" :paperInfo="paperInfo" :currentPageIndex="currentPageIndex" :pageTitle="paperTitle"></StudentPaper>
+    <StudentPaper
+      v-model="showStudentPaperDialog"
+      :paperInfo="paperInfo"
+      :currentPageIndex="currentPageIndex"
+      :pageTitle="paperTitle"
+    ></StudentPaper>
   </div>
 </template>
 <script>
-import DifferenceChart from "@/views/analysisReport/components/dCharts/differenceChart"; //率差图
-import ExpandableText from "@/views/analysisReport/components/ExpandableText"; //文本内容展开收缩组件
-import LineChart from "@/views/analysisReport/components/dCharts/lineChart"; //折线图
-import GotoTop from "@/views/analysisReport/components/GotoTop"; //分析报告页面底部回到顶部组件
-import StudentPaper from '@/components/StudentPaper.vue';//学生答题卡预览组件
-import { mapGetters } from "vuex";
+import DifferenceChart from '@/views/analysisReport/components/dCharts/differenceChart' //率差图
+import ExpandableText from '@/views/analysisReport/components/ExpandableText' //文本内容展开收缩组件
+import LineChart from '@/views/analysisReport/components/dCharts/lineChart' //折线图
+import GotoTop from '@/views/analysisReport/components/GotoTop' //分析报告页面底部回到顶部组件
+import StudentPaper from '@/components/StudentPaper.vue' //学生答题卡预览组件
+import { mapGetters } from 'vuex'
 export default {
-  name: "subjectQuality",
+  name: 'subjectQuality',
   props: {},
   components: {
     DifferenceChart,
@@ -125,8 +181,9 @@ export default {
   data() {
     return {
       subjectData: {
+        standardScoreAnalysisStatus: 0,
         titleData: [],
-        studentOpenness: '',//学生信息
+        studentOpenness: '', //学生信息
         tableData: [],
         datax: [], //图数据
         datay: [], //图数据
@@ -136,97 +193,105 @@ export default {
       },
       subjectLoading: false, //加载状态
       historyExamLoading: false,
-      loadingText: "加载中,请稍后……",
+      loadingText: '加载中,请稍后……',
       historyExamData: {
         chartData: [],
         datax: [],
         datay: [],
         title: [],
-        colors: ["#5470C6"],
+        colors: ['#5470C6'],
         markNumber: [],
         selectNames: [],
         selectVal: 'standardScore'
       }, //线面积图
       suggestionData: null,
-      showStudentPaperDialog:false,//显示答题卡弹框
-      paperInfo:{},
-      paperTitle:'',//答题卡弹框标题
-      currentPageIndex:0,//当前选中的答题卡第几页
-    };
+      showStudentPaperDialog: false, //显示答题卡弹框
+      paperInfo: {},
+      paperTitle: '', //答题卡弹框标题
+      currentPageIndex: 0 //当前选中的答题卡第几页
+    }
   },
   watch: {
     reportParam() {
-      this.PageInit();//初始加载数据
-    },//监听筛选数据变化
+      this.PageInit() //初始加载数据
+    } //监听筛选数据变化
   },
   computed: {
-    ...mapGetters(["userInfo"]),
+    ...mapGetters(['userInfo']),
     pageName() {
       return this.$store.state.report.examSelectItem.examName
-    },//考试名称
+    }, //考试名称
     reportParam() {
       return {
         examLevel: this.$store.state.report.filterObject.examLevel, //1-联考 2-单校
         contrastExamIds: this.$store.state.report.filterObject.contrastExamIds, //多次考试任务对比ID,不包含当前任务ID
         examId: this.$store.state.report.filterObject.examId, //考试id
         subjectCode: this.$store.state.report.filterObject.subjectCode, //科目code
-        subjectGroupType:
-          this.$store.state.report.filterObject.subjectGroupType, //是否为组合科目 1为组合科目 0为非组合科目
-        isTotal: this.$store.state.report.filterObject.isTotal, //是否为总分科目 1为总分 0为非总分
-      };
+        subjectGroupType: this.$store.state.report.filterObject.subjectGroupType, //是否为组合科目 1为组合科目 0为非组合科目
+        isTotal: this.$store.state.report.filterObject.isTotal //是否为总分科目 1为总分 0为非总分
+      }
     }, //分析报告公共参数变量
-    getSubjectName(){
-        return this.$store.state.report.filterObject.subjectName
-    },
+    getSubjectName() {
+      return this.$store.state.report.filterObject.subjectName
+    }
   },
-  created() { },
+  created() {},
   mounted() {
-    this.PageInit(); //页面初始加载数据
+    this.PageInit() //页面初始加载数据
   },
   methods: {
     PageInit() {
-      this.QueryMultiSubjectData();//多科成绩总览-科目标准分分析
-      this.QueryHistoryExamData();//学生端查询总分,多科历次信息
-      this.QuerySuggestionData();//学生端查询总分,多科总结建议信息
+      this.QueryMultiSubjectData() //多科成绩总览-科目标准分分析
+      this.QueryHistoryExamData() //学生端查询总分,多科历次信息
+      this.QuerySuggestionData() //学生端查询总分,多科总结建议信息
     },
     //多科成绩总览-科目标准分分析
     QueryMultiSubjectData() {
       //  获取表格数据
-      this.subjectLoading = true;
+      this.subjectLoading = true
       this.$api.reportStudent
         .queryMultiSubjectData(this.reportParam)
-        .then((res) => {
+        .then(res => {
           if (res.code == 200 && res.data) {
-            this.subjectData.tableData = res.data.tableData || [];
-            this.subjectData.studentOpenness = res.data.studentOpenness ?? '';
-            this.subjectData.titleData = res.data.titleData || [];
-            this.subjectData.datax = [];
-            this.subjectData.datay = [];
-            this.subjectData.tooltipData = [];
+            this.subjectData.tableData = res.data.tableData || []
+            this.subjectData.studentOpenness = res.data.studentOpenness ?? ''
+            this.subjectData.titleData = res.data.titleData || []
+            this.subjectData.datax = []
+            this.subjectData.datay = []
+            this.subjectData.tooltipData = []
+            this.subjectData.standardScoreAnalysisStatus = res.data.standardScoreAnalysisStatus
             //总分
-            const totalScore = this.subjectData.tableData.filter(item => item.isTotal == 1);
+            const totalScore = this.subjectData.tableData.filter(item => item.isTotal == 1)
             //组合
-            const subjectGroup = this.subjectData.tableData.filter(item => item.isTotal == 0 && item.subjectGroupType == 1);
+            const subjectGroup = this.subjectData.tableData.filter(
+              item => item.isTotal == 0 && item.subjectGroupType == 1
+            )
             //单科
-            const singleSubject = this.subjectData.tableData.filter(item => item.isTotal == 0 && item.subjectGroupType == 0);
-            const chartData = [...totalScore,...subjectGroup,...singleSubject];
-            let datax = [],datay = [];
-            chartData.forEach(item=>{
+            const singleSubject = this.subjectData.tableData.filter(
+              item => item.isTotal == 0 && item.subjectGroupType == 0
+            )
+            const chartData = [...totalScore, ...subjectGroup, ...singleSubject]
+            let datax = [],
+              datay = []
+            chartData.forEach(item => {
               this.subjectData.datax.push(item?.subjectName ?? '-')
-              this.subjectData.datay.push(!item?.standardScore || item?.standardScore =='-' ? 0 : item?.standardScore)
-              if(item.isTotal == 0 && item.subjectGroupType == 0){
+              this.subjectData.datay.push(!item?.standardScore || item?.standardScore == '-' ? 0 : item?.standardScore)
+              if (item.isTotal == 0 && item.subjectGroupType == 0) {
                 datax.push(item?.subjectName ?? '')
                 datay.push(item?.standardScore ?? 0)
               }
               this.subjectData.tooltipData.push({
-                list: [{
-                  name: '标准分',
-                  value: item.standardScore ?? '-',
-                }],
-                name: item.subjectName,
+                list: [
+                  {
+                    name: '标准分',
+                    value: item.standardScore ?? '-'
+                  }
+                ],
+                name: item.subjectName
               })
             })
-            let maxSubject = [], minSubject = [];
+            let maxSubject = [],
+              minSubject = []
             datay.forEach((item, k) => {
               if (Number(item) > 0) {
                 maxSubject.push(datax[k])
@@ -234,41 +299,45 @@ export default {
               if (Number(item) < 0) {
                 minSubject.push(datax[k])
               }
-            });
-            this.subjectData.maxSubject = maxSubject.join('、');
-            this.subjectData.minSubject = minSubject.join('、');
+            })
+            this.subjectData.maxSubject = maxSubject.join('、')
+            this.subjectData.minSubject = minSubject.join('、')
           } else {
-            this.subjectData.tableData = [];
-            this.subjectData.studentOpenness = '';
-            this.subjectData.titleData = [];
-            this.subjectData.datax = [];
-            this.subjectData.datay = [];
-            this.subjectData.tooltipData = [];
-            this.subjectData.maxSubject = '';
-            this.subjectData.minSubject = '';
+            this.subjectData.tableData = []
+            this.subjectData.studentOpenness = ''
+            this.subjectData.titleData = []
+            this.subjectData.datax = []
+            this.subjectData.datay = []
+            this.subjectData.tooltipData = []
+            this.subjectData.maxSubject = ''
+            this.subjectData.minSubject = ''
           }
         })
         .finally(() => {
-          this.subjectLoading = false;
-        });
+          this.subjectLoading = false
+        })
     },
     //学生端查询总分,多科历次信息
     QueryHistoryExamData() {
-      this.historyExamLoading = true;
+      this.historyExamLoading = true
       let param = {
         ...this.reportParam
       }
-      if(this.reportParam.subjectGroupType==1 && this.reportParam.isTotal==0){//学生端查询总分,多科历次信息,组合科目时,一定要传组合科目的名称,组合科目的历次是按照组合科目名称来查询
+      if (this.reportParam.subjectGroupType == 1 && this.reportParam.isTotal == 0) {
+        //学生端查询总分,多科历次信息,组合科目时,一定要传组合科目的名称,组合科目的历次是按照组合科目名称来查询
         param.subjectName = this.getSubjectName
       }
-      this.$api.reportStudent.queryHistoryExamData({...param}).then((res) => {
+      this.$api.reportStudent
+        .queryHistoryExamData({ ...param })
+        .then(res => {
           if (res.code == 200 && res.data) {
-            const detailData = (res.data?.detailData || []).reverse();
-            this.historyExamData.chartData = detailData;
-            this.historyExamData.selectNames = res.data.selectNames || [];
-            this.historyExamData.selectVal = this.historyExamData?.selectNames?.[0]?.prop ?? '';
-            this.historyExamData.datax = [];
-            let datay = [], tooltipData = [];
+            const detailData = (res.data?.detailData || []).reverse()
+            this.historyExamData.chartData = detailData
+            this.historyExamData.selectNames = res.data.selectNames || []
+            this.historyExamData.selectVal = this.historyExamData?.selectNames?.[0]?.prop ?? ''
+            this.historyExamData.datax = []
+            let datay = [],
+              tooltipData = []
             detailData.forEach(item => {
               this.historyExamData.datax.push(item.examName)
               datay.push(item[this.historyExamData.selectVal])
@@ -276,70 +345,73 @@ export default {
                 name: this.historyExamData?.selectNames?.[0]?.name ?? '',
                 value: item[this.historyExamData.selectVal]
               })
-            });
-            this.historyExamData.datay = [datay];
-            this.historyExamData.tooltipData = [tooltipData];
+            })
+            this.historyExamData.datay = [datay]
+            this.historyExamData.tooltipData = [tooltipData]
           } else {
-            this.historyExamData.chartData = [];
-            this.historyExamData.datax = [];
-            this.historyExamData.datay = [];
-            this.historyExamData.selectNames = [];
-            this.historyExamData.tooltipData = [];
-            this.historyExamData.selectVal = '';
+            this.historyExamData.chartData = []
+            this.historyExamData.datax = []
+            this.historyExamData.datay = []
+            this.historyExamData.selectNames = []
+            this.historyExamData.tooltipData = []
+            this.historyExamData.selectVal = ''
           }
         })
         .finally(() => {
-          this.historyExamLoading = false;
-        });
+          this.historyExamLoading = false
+        })
     },
     ChangeSelectVal(prop, name) {
-      this.historyExamData.selectVal = prop;
-      let datay = [], tooltipData = [];
+      this.historyExamData.selectVal = prop
+      let datay = [],
+        tooltipData = []
       this.historyExamData.chartData.forEach(item => {
         datay.push(item[prop])
         tooltipData.push({
           name: name,
           value: item[prop]
         })
-      });
-      this.historyExamData.datay = [datay];
-      this.historyExamData.tooltipData = [tooltipData];
+      })
+      this.historyExamData.datay = [datay]
+      this.historyExamData.tooltipData = [tooltipData]
     },
     //学生端查询总分,多科总结建议信息
     QuerySuggestionData() {
-      this.$api.reportStudent
-        .querySuggestionData(this.reportParam)
-        .then((res) => {
-          if (res.code == 200 && res.data) {
-            const data = res.data;
-            this.suggestionData = data;
-            this.suggestionData.upSubjectData = data.upSubjectData.map(item => {
+      this.$api.reportStudent.querySuggestionData(this.reportParam).then(res => {
+        if (res.code == 200 && res.data) {
+          const data = res.data
+          this.suggestionData = data
+          this.suggestionData.upSubjectData = data.upSubjectData
+            .map(item => {
               if (data.studentOpenness == 1 || data.studentOpenness == 2) {
                 return `${item.subjectName}(得分${item.score})`
               } else {
                 return `${item.subjectName}(${item.score})`
               }
-            }).join('、')
-            this.suggestionData.downSubjectData = data.downSubjectData.map(item => {
+            })
+            .join('、')
+          this.suggestionData.downSubjectData = data.downSubjectData
+            .map(item => {
               if (data.studentOpenness == 1 || data.studentOpenness == 2) {
                 return `${item.subjectName}(得分${item.score})`
               } else {
                 return `${item.subjectName}(${item.score})`
               }
-            }).join('、')
-          } else {
-            this.suggestionData = null
-          }
-        });
+            })
+            .join('、')
+        } else {
+          this.suggestionData = null
+        }
+      })
     },
     //答题卡预览
-    OpenStudentPaper(subjectCode){
-      this.paperTitle = `${this.pageName}_${this.userInfo.userName}【${this.userInfo.registrationCode}】`;
-      this.paperInfo = {examId:this.reportParam.examId,subjectCode:subjectCode};
-      this.showStudentPaperDialog = true;
-    },
-  },
-};
+    OpenStudentPaper(subjectCode) {
+      this.paperTitle = `${this.pageName}_${this.userInfo.userName}【${this.userInfo.registrationCode}】`
+      this.paperInfo = { examId: this.reportParam.examId, subjectCode: subjectCode }
+      this.showStudentPaperDialog = true
+    }
+  }
+}
 </script>
 <style lang="scss" scoped>
 .module_tab {

+ 76 - 93
src/views/login/login.vue

@@ -1,16 +1,13 @@
-<template>
-
-</template>
+<template></template>
 <script>
-import user from "@/http/api/user";
-import { setToken } from "@/utils/auth";
+import user from '@/http/api/user'
+import { setToken } from '@/utils/auth'
 // import { getToken} from '@/utils/auth';
-import { encrypt } from "@/utils/jsencrypt";
-import base from "@/http/common/base";
+import { encrypt } from '@/utils/jsencrypt'
+import base from '@/http/common/base'
 export default {
   data() {
-    return {
-    }
+    return {}
   },
   mounted() {
     // if(getToken()){
@@ -18,119 +15,105 @@ export default {
     //   this.$router.push({ path: directUrl });
     //   return false
     // }else{
-      
+
     // }
     // this.SubmitLogin();
-    this.GetUserInfo();
+    this.GetUserInfo()
   },
   methods: {
     //登录提交
     SubmitLogin() {
-      const code = this.$route.query.code || '';
-      const pw = this.$route.query.pw || '';
-      const type = this.$route.query.type || '1';//1:单校 2:联校
-      if(!code && !pw){
-        window.location.href = base.STUDENT_LOGIN;//跳转到教师端登录页面
+      const code = this.$route.query.code || ''
+      const pw = this.$route.query.pw || ''
+      const type = this.$route.query.type || '1' //1:单校 2:联校
+      if (!code && !pw) {
+        window.location.href = base.STUDENT_LOGIN //跳转到教师端登录页面
       }
-      sessionStorage.setItem('schoolType', type);//1:单校 2:联校
+      sessionStorage.setItem('schoolType', type) //1:单校 2:联校
       const params = {
-        "password": decodeURI(pw),//解密 encrypt(decodeURI(pw))
-        "username": code
-      };
-      user.loginEmailPass(params).then((res) => {
+        password: decodeURI(pw), //解密 encrypt(decodeURI(pw))
+        username: code
+      }
+      user.loginEmailPass(params).then(res => {
         if (res.code === 200) {
-          this.$store.dispatch("user/CLEAR_LOCAL_STORAGE");//清空本地存储
-          setToken(res.data.tokenValue);
+          this.$store.dispatch('user/CLEAR_LOCAL_STORAGE') //清空本地存储
+          setToken(res.data.tokenValue)
 
-          this.$store.dispatch("user/SET_TOKEN", res.data.tokenValue);
-          this.$store.dispatch("user/SET_SCHOOL_LOGO", res.data.schoolLogoUrl);//设置学校logo
-          this.$store.dispatch("user/SET_SCHOOL_WEB_SITE_ID",res.data.cloudMonitorSiteId || '');//设置学校网站id
-          this.$store.dispatch("user/getUserInfoByToken");//获取用户登录信息
+          this.$store.dispatch('user/SET_TOKEN', res.data.tokenValue)
+          this.$store.dispatch('user/SET_SCHOOL_LOGO', res.data.schoolLogoUrl) //设置学校logo
+          this.$store.dispatch('user/SET_SCHOOL_WEB_SITE_ID', res.data.cloudMonitorSiteId || '') //设置学校网站id
+          this.$store.dispatch('user/getUserInfoByToken') //获取用户登录信息
 
-          const directUrl = "/studentAnalysisReport/list";
-          this.$router.push({ path: directUrl });
-        }else{
+          const directUrl = '/studentAnalysisReport/list'
+          this.$router.push({ path: directUrl })
+        } else {
           this.$message({
             message: res.msg,
             type: 'warning',
-            offset:100
-          });
+            offset: 100
+          })
         }
-      });
+      })
     },
 
     //获取用户信息
-    GetUserInfo()
-    {
-      const messageHandler=(event)=>{
-        console.log("打印父窗口传来的数据",event.data);
-        console.log("打印父窗口的源",event.origin);
-        console.log("打印当前窗口的源",window.location.origin);
+    GetUserInfo() {
+      const messageHandler = event => {
+        console.log('打印父窗口传来的数据', event.data)
+        console.log('打印父窗口的源', event.origin)
+        console.log('打印当前窗口的源', window.location.origin)
         //安全检查 验证消息来源
-        if(event.origin!== window.location.origin)
-        {
-          return;
+        if (event.origin !== window.location.origin) {
+          return
         }
 
-        if(event.data.type === "STU_TOKEN")
-        {
-          const userInfo = event.data.userInfo;
-          console.log("打印用户信息",userInfo);
-          this.$store.dispatch("user/CLEAR_LOCAL_STORAGE");//清空本地存储
-          setToken(userInfo.tokenValue);
-          sessionStorage.setItem('schoolType', 1);//1:单校 2:联校// 暂时写死单校
-          this.$store.dispatch("user/SET_TOKEN", userInfo.tokenValue);
-          this.$store.dispatch("user/SET_SCHOOL_LOGO",userInfo.schoolLogoUrl);//设置学校logo
-          this.$store.dispatch("user/SET_SCHOOL_WEB_SITE_ID",userInfo.cloudMonitorSiteId || '');//设置学校网站id
-       
-          this.$store.dispatch("user/getUserInfoByToken").then((user)=>{
-               console.log("获取用户信息成功",this.$store.state.user.userInfo);
-               let userInfos = this.$store.state.user.userInfo;
-               // 移除事件监听器,避免重复处理
-               window.removeEventListener('message', messageHandler);
-               if(userInfos.phone)
-               {
-                const directUrl = "/studentAnalysisReport/list";
-               
-                this.$router.push({ path: directUrl });
-               }
-               else
-               {
+        if (event.data.type === 'STU_TOKEN') {
+          const userInfo = event.data.userInfo
+          console.log('打印用户信息', userInfo)
+          this.$store.dispatch('user/CLEAR_LOCAL_STORAGE') //清空本地存储
+          setToken(userInfo.tokenValue)
+          sessionStorage.setItem('schoolType', 2) //1:单校 2:联校// 暂时写死单校
+          this.$store.dispatch('user/SET_TOKEN', userInfo.tokenValue)
+          this.$store.dispatch('user/SET_SCHOOL_LOGO', userInfo.schoolLogoUrl) //设置学校logo
+          this.$store.dispatch('user/SET_SCHOOL_WEB_SITE_ID', userInfo.cloudMonitorSiteId || '') //设置学校网站id
 
-                this.$router.push({ path: '/userInfo/personInfo' });
-                // // 使用 this.$confirm 替代
-                // this.$confirm('为了方便找回密码,我们建议您绑定手机号!', '', {
-                //   confirmButtonText: '确定',
-                //   cancelButtonText: '取消',
-                //   customClass:"page_dialog",
-                //   type: 'warning'
-                // }).then(() => {
-                //   // 用户点击立即绑定,跳转到个人资料页面
-                  
-                // }).catch(() => {
-                //   // 用户点击稍后绑定,直接进入首页
-                //   const directUrl = "/studentAnalysisReport/list";
-                //   this.$router.push({ path: directUrl });
-                // });
-              }
-               
+          this.$store.dispatch('user/getUserInfoByToken').then(user => {
+            console.log('获取用户信息成功', this.$store.state.user.userInfo)
+            let userInfos = this.$store.state.user.userInfo
+            // 移除事件监听器,避免重复处理
+            window.removeEventListener('message', messageHandler)
+            if (userInfos.phone) {
+              const directUrl = '/studentAnalysisReport/list'
 
-          });//获取用户登录信息
-          
-        }
+              this.$router.push({ path: directUrl })
+            } else {
+              this.$router.push({ path: '/userInfo/personInfo' })
+              // // 使用 this.$confirm 替代
+              // this.$confirm('为了方便找回密码,我们建议您绑定手机号!', '', {
+              //   confirmButtonText: '确定',
+              //   cancelButtonText: '取消',
+              //   customClass:"page_dialog",
+              //   type: 'warning'
+              // }).then(() => {
+              //   // 用户点击立即绑定,跳转到个人资料页面
 
-      };
+              // }).catch(() => {
+              //   // 用户点击稍后绑定,直接进入首页
+              //   const directUrl = "/studentAnalysisReport/list";
+              //   this.$router.push({ path: directUrl });
+              // });
+            }
+          }) //获取用户登录信息
+        }
+      }
 
       // 添加消息监听器
-      window.addEventListener('message', messageHandler);
-
-
-    },
+      window.addEventListener('message', messageHandler)
+    }
   }
-
 }
 </script>
 
 <style lang="scss">
-@use "@/styles/login.scss";
+@use '@/styles/login.scss';
 </style>