Browse Source

增加微信授权登陆

TheLittlePrince 6 years ago
parent
commit
ba0e727d1e
4 changed files with 149 additions and 146 deletions
  1. 22 22
      src/pages/Login.vue
  2. 29 31
      src/pages/aikmt/Redirect_uri.vue
  3. 77 9
      src/pages/home/SchoolManager.vue
  4. 21 84
      src/store/modules/user.js

+ 22 - 22
src/pages/Login.vue

@@ -25,34 +25,34 @@ export default {
   data() {
     return {};
   },
-   watch:{
-  },
+  watch: {},
   created() {
-    // this.getTKByUnionid()
+    this.getTKByUnionid()
   },
   methods: {
     WxLoginCtl() {
-      // console.log(this.$router)
-      // this.$router.push({ path: '/aikmt/Redirect_uri' });
-      // console.log(123, this.$router.push)
-      // window.location.src = '/aikmt/Redirect_uri'
-      // this.$router.push('/aikmt/Redirect_uri')
-      // this.history.push('/aikmt/Redirect_uri')
       // this.$util.messageMethod("success", "前去微信登陆扫码授权");
-       this.$router.push({path: '/aikmt/Redirect_uri', query: {unionid: "oPHg8wbCbIuZwq6NKEdEUPh6DQFM",prince: "6666666666666"}});
+      this.$router.push({
+        path: "/aikmt/Redirect_uri",
+        query: {
+          unionid: "oPHg8wbCbIuZwq6NKEdEUPh6DQFM",
+          prince: "6666666666666"
+        }
+      });
     },
-      async getTKByUnionid(){
-    //  if (window.location.href.indexOf('unionid') >= 0) {
-    //     // 如果url中包含code,则保存到store中
-    //     let unionid = window.location.href.split("?")[1];
-    //     unionid = unionid.substring(8, code.indexOf('&'));
-    //     let WxCode = unionid
-    //     this.WxCode = WxCode
-    //   }
-           this.$store.dispatch('UnionidLogin', {
-             unionid: "oPHg8wbCbIuZwq6NKEdEUPh6DQFM"
-        });
-	}
+    async getTKByUnionid() {
+      if (window.location.href.indexOf("unionid") >= 0) {
+        // 如果url中包含code,则保存到store中
+        let unionid = window.location.href.split("?")[1];
+        unionid = unionid.substring(8, code.indexOf("&"));
+        let WxCode = unionid;
+        this.WxCode = WxCode;
+        this.$store.dispatch("UnionidLogin", {
+         unionid: this.WxCode
+      });
+      }
+     return
+    }
   },
   mounted() {
     var obj = new WxLogin({

+ 29 - 31
src/pages/aikmt/Redirect_uri.vue

@@ -24,46 +24,44 @@ export default {
   name: "login",
   data() {
     return {
-      WxCode:"",
+      WxCode: "",
       accessToken: sessionStorage.getItem("accessToken")
     };
   },
   created() {
-    this.getTKByUnionid()
+    this.getTKByUnionid();
     // debugger
   },
-   computed: {
-    ...mapGetters([
-      "token"
-    ])
+  computed: {
+    ...mapGetters(["token"])
   },
   methods: {
-       async getTKByUnionid(){
-          if (window.location.href.indexOf('unionid') >= 0) {
-            //  debugger
-              // 如果url中包含code,则保存到store中
-              let unionid = window.location.href.split("?")[1];
-              unionid = unionid.substring(8, unionid.indexOf('&'));
-              let WxCode = unionid
-              this.WxCode = WxCode
-            }
-           this.$store.dispatch('UnionidLogin', {
-             unionid: this.WxCode
+    async getTKByUnionid() {
+      if (window.location.href.indexOf("unionid") >= 0) {
+        //  debugger
+        // 如果url中包含code,则保存到store中
+        let unionid = window.location.href.split("?")[1];
+        unionid = unionid.substring(8, unionid.indexOf("&"));
+        let WxCode = unionid;
+        this.WxCode = WxCode;
+        this.$store.dispatch("UnionidLogin", {
+          unionid: this.WxCode
         });
-        // debugger
-	}
-	// async getTKByCode(){
-  //    if (window.location.href.indexOf('code') >= 0) {
-  //       // 如果url中包含code,则保存到store中
-  //       let code = window.location.href.split("?")[1];
-  //       code = code.substring(5, code.indexOf('&'));
-  //       let WxCode = code
-  //       this.WxCode = WxCode
-  //     }
-  //          this.$store.dispatch('GET_TOKEN', {
-  //            code: this.WxCode
-  //       });
-	// }
+      }
+      return
+    }
+    // async getTKByCode(){
+    //    if (window.location.href.indexOf('code') >= 0) {
+    //       // 如果url中包含code,则保存到store中
+    //       let code = window.location.href.split("?")[1];
+    //       code = code.substring(5, code.indexOf('&'));
+    //       let WxCode = code
+    //       this.WxCode = WxCode
+    //     }
+    //          this.$store.dispatch('GET_TOKEN', {
+    //            code: this.WxCode
+    //       });
+    // }
   },
   mounted() {}
 };

+ 77 - 9
src/pages/home/SchoolManager.vue

@@ -83,7 +83,8 @@
                 <div>状态</div>
               </div>
               <div class="tr" v-for="(v, k) of monitorTeacherList.list" :key="k">
-                <div class="tr-first">
+                <!-- 在线 -->
+                <div v-if="v.status == '在线'" class="tr-first">
                   <div>
                     <i
                       :class="[isDown && isDownindex === k?'el-icon-caret-bottom':'el-icon-caret-top']"
@@ -98,6 +99,38 @@
                   <div>{{v.respSpeed}}/份</div>
                   <div>{{v.status}}</div>
                 </div>
+                <!-- 离线 -->
+                 <div v-if="v.status == '离线'" style="color:#BEBEBE" class="tr-first">
+                  <div>
+                    <i
+                      :class="[isDown && isDownindex === k?'el-icon-caret-bottom':'el-icon-caret-top']"
+                      @click="dropDown(v,k)"
+                    ></i>
+                    <img :src="BASE_URL + v.imgUrl" alt class="table-img"  @click="isShow(v,3)">
+                  </div>
+                  <div>{{v.name}}</div>
+                  <div>{{v.waitCount}}份</div>
+                  <div>{{v.maxWaitTime}}</div>
+                  <div>{{v.totalCorrectTime}}</div>
+                  <div>{{v.respSpeed}}/份</div>
+                  <div>{{v.status}}</div>
+                </div>
+                <!-- 封号 -->
+                 <div v-if="v.status == '已封号'"  style="color:#FF6767" class="tr-first">
+                  <div>
+                    <i
+                      :class="[isDown && isDownindex === k?'el-icon-caret-bottom':'el-icon-caret-top']"
+                      @click="dropDown(v,k)"
+                    ></i>
+                    <img :src="BASE_URL + v.imgUrl" alt class="table-img"  @click="isShow(v,3)">
+                  </div>
+                  <div>{{v.name}}</div>
+                  <div>{{v.waitCount}}份</div>
+                  <div>{{v.maxWaitTime}}</div>
+                  <div>{{v.totalCorrectTime}}</div>
+                  <div>{{v.respSpeed}}/份</div>
+                  <div>{{v.status}}</div>
+                </div>
                 <div v-if="isDownindex === k && isDown">
                   <div class="tr-second" v-for="(v, k) of TeacherHomeworkList.list" :key="k">
                     <div class="tr-seconds">{{k+1}}</div>
@@ -109,7 +142,7 @@
                     <div class="tr-seconds">{{v.subject}}</div>
                     <div class="tr-seconds">{{v.grade}}</div>
                     <div v-if="v.status === 1" class="tr-seconds">未批改</div>
-                    <div v-if="v.status === 2" class="tr-seconds">批改中</div>
+                    <div v-if="v.status === 2" class="tr-seconds" style="color:#FFC303">批改中</div>
                     <div v-if="v.status === 3" class="tr-seconds">已批改</div>
                     <div class="tr-s" v-if="v.status === 1">
                       <el-button type="success" plain>去批改</el-button>
@@ -128,7 +161,7 @@
             background
             @size-change="handleSizeChange3"
             @current-change="pageChange3"
-            :page-sizes="[10, 20, 30, 40]"
+            :page-sizes="[10, 20]"
              layout="total, sizes, prev, pager, next, jumper"
              :total= parseInt(TeacherHomeworkList.pages)
             ></el-pagination>
@@ -383,7 +416,8 @@
           <div class="model-items-left">
             <div class="model-items-left-top">
               <div>
-                <img src="../../assets/img/user.jpg" alt class="model-items-left-top-img">
+                 <img :src="BASE_URL + v.imgUrl" v-if="v.imgUrl" alt class="model-items-left-top-img">
+                <img src="../../assets/img/user.jpg" v-if="!v.imgUrl" alt class="model-items-left-top-img">
                 <div style="display: inline-block">
                   <div style="font-size: 24px">{{v.name}}</div>
                   <div class="model-items-left-top-number">等待学生:{{v.waitCount}}</div>
@@ -392,7 +426,6 @@
               <div>
                 <el-button
                   v-show="v.type && v.type === 1"
-                  @click="GOtoTeacherAllot(v,k)"
                   disabled
                   type="info"
                 >已分配</el-button>
@@ -405,6 +438,14 @@
             </div>
           </div>
         </div>
+            <el-pagination
+            background
+            @size-change="handleSizeChange4"
+            @current-change="pageChange4"
+            :page-sizes="[10]"
+             layout="total, sizes, prev, pager, next, jumper"
+             :total= parseInt(TeacherAllotList.pages)
+            ></el-pagination>
       </div>
     </div>
     <!--所有未批改作业-->
@@ -416,7 +457,7 @@
         </div>
         <div>
           <!-- UnallotHomeworkInfo -->
-          <div class="tr-set" v-for="(v, k) of TeacherHomeworkList.list" :key="k">
+          <div class="tr-set" v-for="(v, k) of UnallotHomeworkInfo.list" :key="k">
             <div class="tr-secon">{{k+1}}</div>
             <div class="tr-secon" style="width:50px;">
               <span>{{v.name}}</span>
@@ -436,9 +477,9 @@
             background
             @size-change="handleSizeChange3"
             @current-change="pageChange3"
-            :page-sizes="[10, 20, 30, 40]"
+            :page-sizes="[10]"
              layout="total, sizes, prev, pager, next, jumper"
-             :total= parseInt(TeacherHomeworkList.pages)
+             :total= parseInt(UnallotHomeworkInfo.pages)
             ></el-pagination>
         </div>
   
@@ -457,7 +498,8 @@
         <div class="model-items">
           <div class="model-items-first">
             <div>
-              <img :src="BASE_URL + GetTeacherDetail.imgUrl" alt class="model-items-first-img">
+              <img :src="BASE_URL + GetTeacherDetail.imgUrl" v-if="GetTeacherDetail.imgUrl"  alt class="model-items-first-img">
+                 <img src="../../assets/img/user.jpg" v-if="!GetTeacherDetail.imgUrl" alt class="model-items-first-img">
               <div class="model-items-first-left">
                 <div class="Onlinename">{{GetTeacherDetail.name}}</div>
                 <div v-if="GetTeacherDetail.status ===1" class="Online">(在线)</div>
@@ -744,6 +786,16 @@ export default {
         pageSize: this.allotList.pageSize
       });
     },
+     // 可分配老师列表分页
+    async TeacherAllotfy() {
+      this.$store.dispatch("TeacherAllotList", {
+        grade: this.allotList.Allotgarde,
+        subject: this.allotList.Allotsubjct,
+        maxCreateTime: this.filters.MaxtimeValue,
+        pageNo: this.allotList.pageNo,
+        pageSize: this.allotList.pageSize
+      });
+    },
     // 未批改作业列表列表
     async UnallotHomework() {
       this.$store.dispatch("UnallotHomeworkList", {
@@ -874,6 +926,10 @@ export default {
       this.homeworkLIst.pageSize = val;
       this.TeacherHomeworkfy();
     },
+     handleSizeChange4(val) {
+      this.allotList.pageSize = val;
+      this.TeacherAllotfy();
+    },
       // 分页
     pageChange(val) {
       this.filters.pageNo = val;
@@ -891,6 +947,10 @@ export default {
       this.homeworkLIst.pageNo = val;
       this.TeacherHomeworkfy();
     },
+      pageChange4(val) {
+      this.allotList.pageNo = val;
+      this.TeacherAllotfy();
+    },
     // 排序
     sortChange(sort) {
       this.filters.orderField = sort.prop;
@@ -935,6 +995,7 @@ export default {
   font-size: 18px;
   text-align: center;
   line-height: 60px;
+  cursor: pointer;
 }
 el-table {
   color: #999999;
@@ -982,6 +1043,7 @@ el-table {
   height: 36px;
   border-radius: 6px;
   margin-left: 14px;
+  cursor: pointer;
 }
 .table {
   width: 94.5%;
@@ -1034,8 +1096,11 @@ el-table {
   font-size: 20px;
 }
 .tr-seconds {
+   text-align: center;
   font-size: 14px;
   word-wrap: break-word;
+   /* width: 40px; */
+   /* height: 30px; */
 }
 .tr-second-check {
   color: #3ab548;
@@ -1156,4 +1221,7 @@ el-table {
   font-size: 18px;
   margin: 0 20px;
 }
+.el-pagination{
+padding:30px;
+}
 </style>

+ 21 - 84
src/store/modules/user.js

@@ -92,14 +92,12 @@ const user = {
   actions: {
       //   unionid登录
       //  获取TOKEN
-       UnionidLogin({ state, commit, dispatch, getters }, data) {
+       UnionidLogin({ state, commit, dispatch }, data) {
         console.log(data);
-        // debugger
         axios.Tokenpost(GET_UUIONID_TOKEN, data).then(res => {
           if (res && res.code == '999') {
             const data = res.data
             commit('SET_TOKEN', data);
-            // debugger
             sessionStorage.setItem("accessToken",data.accessToken)
                     Message.success('登录成功')
                    dispatch('GetInfo').then(res => { // 拉取用户信息
@@ -110,19 +108,8 @@ const user = {
                         if (roles == 2) {
                           router.push("/super");
                         }
-                        // dispatch('GenerateRoutes', { roles }).then(() => { // 根据roles权限生成可访问的路由表
-                        //   console.log('addrouters', getters.addRouters)
-                        //   router.addRoutes(getters.addRouters) // 动态添加可访问路由表
-                        //   console.log(router)
-                        //   router.push("/home");
-                        //   // next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record
-                        // })
                       }).catch(() => {
-                        // dispatch('FedLogOut').then(() => {
-                        //   Message.error('验证失败,请重新登录')
-                        //   next({ path: '/login' })
-                        //   console.log('roles====5')
-                        // })
+                          Message.error('用户信息验证失败,请重新登录')
                       })
           } else {
             Message.error('验证失败,请重新登录')
@@ -131,68 +118,35 @@ const user = {
         })
       },
       
-    //   // 获取tokrn
-    //   UnionidLogin({ commit, state }, data) {
-    //   return new Promise((resolve, reject) => {
-    //     axios.Tokenpost(GET_UUIONID_TOKEN, data).then(response => {
-    //       debugger
-    //       if (response && response.code == '999') {
-    //         const data = response.data
-    //         commit('SET_TOKEN', data);
-    //         sessionStorage.setItem("accessToken",data.accessToken)
-    //         Message.success('登录成功')
-    //         router.push("/home");
-    //       } else {
-    //         Message.error('验证失败,请重新登录')
-    //         router.push("/");
-    //       }
-    //       resolve(response)
-    //     }).catch(error => {
-    //       reject(error)
-    //     })
-    //   })
-    // },
       // 微信授权登陆
        //获取TOKEN
-       GET_TOKEN({ state, commit }, data) {
+      GET_TOKEN({ state, commit, dispatch }, data) {
         console.log(data);
-        axios.get(GET_TOKEN, data).then(res => {
-          // debugger
+        axios.Tokenpost(GET_TOKEN, data).then(res => {
           if (res && res.code == '999') {
-            commit('SET_TOKEN', data.data);
-            sessionStorage.setItem("accessToken",data.data)
-          // this.$router.push("/home");
+            const data = res.data
+            commit('SET_TOKEN', data);
+            sessionStorage.setItem("accessToken",data.accessToken)
+                    Message.success('登录成功')
+                   dispatch('GetInfo').then(res => { // 拉取用户信息
+                        const roles = res.data.role 
+                        if (roles == 1) {
+                          router.push("/home");
+                        }
+                        if (roles == 2) {
+                          router.push("/super");
+                        }
+                      }).catch(() => {
+                          Message.error('用户信息验证失败,请重新登录')
+                      })
           } else {
-            this.$router.push("/");
+            Message.error('验证失败,请重新登录')
+                    router.push("/");
           }
         })
       },
     // 获取用户信息
     GetInfo({ commit, state }, data) {
-      console.log(data)
-      // debugger
-
-      // return new Promise((resolve, reject) => {
-      //   resolve({
-      //       "data": {
-      //         "approveStatus": 0,
-      //         "grade": "一年级,二年级,三年级,四年级,五年级,六年级,七年级,八年级,九年级",
-      //         "imgUrl": "/userimg/2019/03/13/55403363-f5b3-4af8-92e8-69aec41dd6b7.jpg",
-      //         "isFirst": 0,
-      //         "managerId": "",
-      //         "managerList": [],
-      //         "myManager": "",
-      //         "name": "丁颖",
-      //         "period": "",
-      //         "phone": "",
-      //         "role": ['1'],
-      //         "school": "",
-      //         "subject": "语文;数学;英语",
-      //         "wxName": "丁颖"
-      //       }
-      //     })
-      //   }) 
-      
       return new Promise((resolve, reject) => {
         axios.post(GetInfo, data).then((response = {}) => {
           const { data, code, msg } = response
@@ -206,23 +160,6 @@ const user = {
         })
       })
     },
-    // GetInfo({ commit, state }, data) {
-    //   console.log(data)
-    //   debugger
-    //   return new Promise((resolve, reject) => {
-    //     axios.post(GetInfo, data).then((response = {}) => {
-    //       debugger
-    //       const { data, code, msg } = response
-    //       const { role, name, imgUrl } = data
-    //       commit('SET_ROLES', role)
-    //       commit('SET_NAME', name)
-    //       commit('SET_AVATAR', imgUrl)
-    //       resolve(response)
-    //     }).catch(error => {
-    //       reject(error)
-    //     })
-    //   })
-    // },
     // 校区管理员数据监控
     InfoWatch({ commit, state }, data) {
       return new Promise((resolve, reject) => {