osbert 4 лет назад
Родитель
Сommit
122d596bd0

BIN
TEAMModelOS/ClientApp/src/assets/icon/studentIcon.png


BIN
TEAMModelOS/ClientApp/src/assets/icon/teacherIcon.png


+ 13 - 0
TEAMModelOS/ClientApp/src/components/public/frontEndMain/Index.less

@@ -11,6 +11,19 @@
         left:30px;
         top:30px;
     }
+    &-schoolName{
+        position: fixed;
+        left: calc(50% - 300px);
+        top: 40px;
+        width: 100%;
+        max-width: 600px;
+        color: white;
+        font-size: 45px;
+        overflow: hidden;
+        white-space: nowrap;
+        text-overflow: ellipsis;
+        text-align: center;        
+    }
     &-server{
         position: fixed;
         right:30px;

+ 18 - 2
TEAMModelOS/ClientApp/src/components/public/frontEndMain/Index.vue

@@ -49,6 +49,9 @@
     <div class="login-mark">
       <img width="125" src="@/assets/ies5_logo.svg">    
     </div>
+    <div calss="login-schoolName">
+      {{ schoolName }}
+    </div>
     <div class="login-server">
       <h5>{{ $t('login.title.ser') }}</h5>
       <Dropdown trigger="click" @on-click="chgSerType">
@@ -87,7 +90,7 @@ import { mapState, mapGetters } from 'vuex'
 export default {
   data(){
     return {
-      
+      schoolName: ''
     }
   },
   computed: {
@@ -116,6 +119,19 @@ export default {
         }
       }
     },
-  }
+    setLoginSchoolCode: function(){ // 設定預設的學校簡碼
+      let schoolCode = this.$route.query.schoolcode == undefined ? '' : this.$route.query.schoolcode;
+      if(schoolCode){
+        this.$api.login.getSchoolName({schoolCode: schoolCode}).then( res => {
+          this.schoolName = res.name
+          sessionStorage.setItem('defaultSchool', encodeURIComponent(JSON.stringify({code: res.code, name: res.name}), "utf-8"))          
+        })
+      }
+    },
+  },
+  created() {
+    // 統一處理預設登入學校
+    this.setLoginSchoolCode()
+  },
 }
 </script>

+ 38 - 8
TEAMModelOS/ClientApp/src/router/routes.js

@@ -21,18 +21,48 @@ export const routes = [
 		path: '',
 		redirect: identity == 'student' ? '/studentWeb' : '/home'
 	},
+	// {
+	// 	path: '/login',
+	// 	component: FrontEndMain,
+	// 	children: [{
+	// 			name: 'login',
+	// 			path: '/',
+	// 			meta: {
+	// 				middleware: ['login?']
+	// 			},
+	// 			component: resolve => require(['@/view/login/Index.vue'], resolve)
+	// 		}]
+	// },
 	{
 		path: '/login',
 		component: FrontEndMain,
-		children: [{
-			name: 'login',
-			path: '/',
-			meta: {
-				middleware: ['login?']
+		children: [
+			{
+				name: 'login',
+				path: '/',
+				meta: {
+					middleware: ['login?']
+				},
+				component: resolve => require(['@/view/login/test.vue'], resolve)
 			},
-			component: resolve => require(['@/view/login/Index.vue'], resolve)
-		}]
-	},
+			{
+				name: 'loginTeacher',
+				path: 'teacher',
+				meta: {
+					middleware: ['login?']
+				},
+				component: resolve => require(['@/view/login/page/Teacher.vue'], resolve)
+			},
+			{
+				name: 'loginStudent',
+				path: 'student',
+				meta: {
+					middleware: ['login?']
+				},
+				component: resolve => require(['@/view/login/page/Student.vue'], resolve)
+			}
+		]
+	},	
 	{
 		path: '/regist',
 		component: FrontEndMain,

+ 3 - 3
TEAMModelOS/ClientApp/src/view/login/Index.vue

@@ -556,9 +556,9 @@ export default {
         }
       })
     },
-      saveUserCodes: function (res) {
-		this.$store.commit('setUserInfo',res)
-	},
+    saveUserCodes: function (res) {
+		  this.$store.commit('setUserInfo',res)
+	  },
     getSchools: function(){ // 取得學校清單
       let _this = this
       this.$api.getSchoolList().then( res =>{

+ 171 - 0
TEAMModelOS/ClientApp/src/view/login/page/Student.less

@@ -0,0 +1,171 @@
+.loginDiv{
+    height: 520px;
+    display: flex;
+    align-items: center;
+    flex-direction: column;
+    justify-content: space-around;
+    .iconFrame:before{
+        border-radius: 50%;
+        border: 1px solid #808695;
+    }
+    .schoolName{
+        letter-spacing: 7px;
+        height: 120px;
+        display: flex;
+        justify-content: center;
+        align-items: center;
+        img{
+            width: 63px;
+            height: 63px;
+            margin-right: 6px;
+        }
+        span{
+            color: white;
+            font-size: 45px;
+        }
+    }
+    .formDiv{
+        width: 800px;
+        display: flex;
+        justify-content: space-between;
+        .loginBox{
+            width: 300px;
+            height: 310px;
+            .title{
+                display: flex;
+                align-items: center;
+                // align-content: center !important;
+                margin-bottom: 5px;
+                .logo{
+                    margin-right: 5px;
+                    height: 15px;
+                }
+                .text{
+                    margin-right: 15px;
+                    color: #ffffff;
+                    font-size: 16px;
+                }
+                .tooltip{
+                    height: 15px;
+                }
+            }
+            .subTitle{
+                font-size: 14px;
+                color: #d1d1d3;
+                margin-bottom: 25px;
+            }
+            .loginForm{
+                margin-bottom: 10px;
+                .formItem{
+                    margin: 0;
+                }
+                .errlable{
+                    text-align: right;
+                    color: #f22613;
+                    font-size: 12px;
+                    margin-top: 3px;
+                    height: 12px;
+                }
+            }
+            .extra{
+                display: flex;
+                align-items: center;
+                justify-content: space-between;
+                margin-bottom: 30px;
+                .qrlogin{
+                    display: flex;
+                    align-items: center;
+                    .logo{
+                        margin-right: 5px;
+                        height: 15px;
+                    }
+                    a{
+                        font-size: 12px;
+                        color: #668fbc;
+                        text-decoration: underline;
+                    }
+                }
+                .link{
+                    a{
+                        font-size: 12px;
+                        color: #668fbc;
+                        text-decoration: underline;
+                    }
+                }
+            }
+            .communyLoging{
+                .description{
+                    text-align: center;
+                    font-size: 12px;
+                    color: #d1d1d3;
+                    margin-bottom: 20px;
+                    letter-spacing: 1.5px;
+                }
+                .links{
+                    display: flex;
+                    align-items: center;
+                    justify-content: space-around;
+                    .icon{
+                        display: flex;
+                        align-items: center;
+                        flex-direction: column;
+                        cursor: pointer;
+                        img{
+                            width: 35px;
+                        }
+                        span{
+                            font-size: 12px;
+                            color: #d1d1d3;
+                        }
+                    }
+                }
+            }
+            .qrloginMode{
+                .qrcodeBox{
+                    width:240px;
+                    height:240px;
+                    margin:auto;
+                    margin-bottom: 10px;
+                    position: relative;
+                    display: flex;
+                    justify-content: center;
+                    align-items: center;
+                    .qrcode{
+                        padding:20px;
+                        background-color:white;
+                    }
+                    .expired{
+                        position: absolute;
+                        background-color: #ffffffde;
+                        width: 200px;
+                        height: 200px;
+                        display: flex;
+                        justify-content: center;
+                        align-items: center;
+                        .ivu-icon{
+                            cursor: pointer;
+                        }
+                    }
+                }            
+                .links{
+                    display: flex;
+                    align-items: center;
+                    justify-content: space-between;
+                    .icon-a{
+                        display: flex;
+                        align-items: center;
+                        img{
+                            margin-right: 3px;
+                            width: 15px;
+                            height: 15px;
+                        }
+                    }
+                    a{
+                        font-size: 12px;
+                        color: #668fbc;
+                    }
+                }
+            }
+        }
+    }
+}

+ 589 - 0
TEAMModelOS/ClientApp/src/view/login/page/Student.vue

@@ -0,0 +1,589 @@
+<style lang="less" scoped>
+  @import './Student.less';
+</style>
+
+<style lang="less">
+.loginBox{
+  .loginForm{
+    .formItem{
+      input, select{
+        border-radius: 0;
+        font-size: 12px;
+      }
+      .ivu-select-selection{
+        border-radius: 0;
+      }
+    }
+    .schoolAutoComplete{
+      height: 170px;
+      .schoolsBox{
+        border-bottom: 1px solid #e9e9e9;
+        padding: 5px 5px 5px 15px;
+        .area{
+          font-size: 12px;
+          padding: 5px;
+        }
+      }
+    }
+    .ivu-select-dropdown{
+      border-radius: 0;
+    }
+  }
+}
+.identityModal{
+  .ivu-modal{
+    .ivu-modal-content{
+      background-color: #2a292e;
+      padding: 12px;
+      border: 1px solid #ccc;
+      .ivu-modal-header, .ivu-modal-footer{
+        border: 0;
+      }
+      .ivu-modal-footer{
+        padding: 0;
+      }
+      .ivu-modal-header{
+        padding: 5px 16px;
+        p{
+          color: whitesmoke;
+        }
+      }
+      .identity-body{
+        display: flex;
+        justify-content: space-around;
+        align-items: center;
+        .ivu-btn{
+          background-color: #1cc0f2;
+          color: white;
+          font-weight: bold;
+          border: 0;
+          padding: 0 22px;
+        }
+      }
+    }        
+  }
+}
+.demo-spin-col .ivu-spin-main{
+	background-color: transparent;
+	padding: 0;
+}
+</style>
+
+<template>
+  <div class="loginDiv">
+    <div class="schoolName">
+        <div style="width: 100px;height: 100px;background-color: #69b0d0;border-radius: 4px;cursor: pointer;">
+          <img style="display: block;width: 100%;height: 100%;" src="@/assets/icon/studentIcon.png">
+        </div>
+    </div>
+    <div class="formDiv">
+      <div class="loginBox">
+        <div class="title">
+          <div class="logo">
+            <img  width="15" height="15" src="@/assets/icon/tmd_account.svg">
+          </div>
+          <h4 class="text">
+            {{ qrloginFlag ? $t('login.title.QRLogin'): $t('login.title.IDLogin') }}
+          </h4>
+          <Tooltip class="tooltip" placement="right-end" :transfer="true" max-width="200">
+            <img src="@/assets/icon/icon_info.svg" width="15" height="15">
+            <div slot="content">
+              <p style="font-size: 12px;">{{ $t('login.tooltip.text1') }}</p>
+            </div>
+          </Tooltip>
+        </div>
+        <h4 class="subTitle">
+          {{ qrloginFlag ? $t('login.subTitle.QRLogin') : $t('login.subTitle.IDLogin')}}
+        </h4>
+
+        <div v-show="!qrloginFlag">
+          <Form class="loginForm" ref="loginForm" :model="loginForm" :rules="loginRule" :show-message="false" @keydown.enter.native="loginSubmit('loginForm')">
+            <FormItem class="formItem" prop="id" >
+              <Input element-id = "tmdID" v-model="loginForm.id" :placeholder="$t('login.placeholder.id')"/>
+            </FormItem>
+            <FormItem class="formItem"  prop="pass">
+              <Input element-id = "tmdpw" type="password" v-model="loginForm.pass" :placeholder="$t('login.placeholder.psw')" >
+                <Icon size="24" v-show="!loading && loginFormEnter" @click="loginSubmit('loginForm')" type="md-arrow-forward" slot="suffix" class="iconFrame" />
+                <div v-show="loading" class="demo-spin-col" slot="suffix">
+                  <Spin>
+                    <Icon type="ios-loading" size="18" class="demo-spin-icon-load"></Icon>
+                  </Spin>
+                </div>
+              </Input>
+            </FormItem>
+            <div class="errlable">{{ loginErrText }}</div>
+          </Form>
+
+          <div class="extra">
+            <div class="qrlogin">
+              <div class="logo">
+                <img  width="15" height="15" src="@/assets/icon/icon_qrcode.svg">
+              </div>
+              <a @click="chgLoginType()">{{ $t('login.link.QRLogin') }}</a>
+            </div>
+            <div class="link">
+              <router-link to="/regist">{{ $t('login.link.regist') }}</router-link> | <router-link to="/forgotpw">{{ $t('login.link.forgetPsw') }}</router-link>
+            </div>
+          </div>
+
+          <div class="communyLoging">
+            <div class="description">{{ $t('login.communy.title')}}</div>
+            <div class="links">
+              <div v-if="!(srvAdr == 'China')" class="icon" @click="oauthLogin('facebook')">
+                <img  src="@/assets/icon/icon_fb.svg">
+                <span>{{ $t('login.communy.fb')}}</span>
+              </div>
+              <div v-if="!(srvAdr == 'China')" class="icon" @click="oauthLogin('google')">
+                <img  src="@/assets/icon/icon_google.svg">
+                <span>{{ $t('login.communy.google')}}</span>
+              </div>
+              <div v-if="!(srvAdr == 'Global')" class="icon" @click="oauthLogin('wechat')">
+                <img  src="@/assets/icon/icon_wechat.svg">
+                <span>{{ $t('login.communy.wechat')}}</span>
+              </div>
+            </div>
+          </div>
+        </div>
+        <div v-show="qrloginFlag">
+          <div class="qrloginMode">
+            <div class="qrcodeBox">
+              <div id="qrcode" :class="{'qrcode': joinQRcode != undefined}" ref="qrcode"></div>
+              <div class="expired" v-if="joinQRcode != undefined && !sseSurvive">
+                <Icon size="40" type="md-refresh-circle" @click="SEELink()" />
+              </div>
+            </div>              
+            <div class="links">
+              <div class="icon-a">
+                <img src="@/assets/icon/icon_account.svg">
+                <a @click="chgLoginType()">{{ $t('login.link.IDLogin') }}</a>
+              </div>
+              <router-link to="/regist">{{ $t('login.link.regist') }}</router-link>
+            </div>
+          </div>
+        </div>
+      </div>
+
+      <div class="loginBox">
+      <div class="title">
+        <div class="logo">
+          <img  width="15" height="15" src="@/assets/icon/tmd_account.svg">
+        </div>
+        <h4 class="text">{{ $t('login.title.schoolLogin') }}</h4>
+        <Tooltip class="tooltip" placement="right-end" :transfer="true" max-width="200">
+            <img src="@/assets/icon/icon_info.svg" width="15" height="15">
+            <div slot="content">
+              <p style="font-size: 12px;">{{ $t('login.tooltip.text2') }}</p>
+            </div>
+        </Tooltip>
+      </div>
+      <h4 class="subTitle">{{ $t('login.subTitle.schoolLogin') }}</h4>
+      <Form class="loginForm" ref="studForm" :model="studForm" :rules="studRule" :show-message="false" @keydown.enter.native="loginSubmit('studForm')">
+        <FormItem class="formItem" style="margin-bottom: 15px;" prop="schoolCode">
+          <Select v-show="!defaultSchool.code" v-model="studForm.schoolCode" :placeholder="$t('login.placeholder.schoolMenu')" filterable clearable >
+            <template v-for="(item, index) in schoolList" >
+              <OptionGroup :label="item.province" :key="index">
+                <Option v-for="school in item.schools" :key="school.id" :value="school.id">{{ school.name }}</Option>
+              </OptionGroup>
+            </template>
+          </Select>
+        </FormItem>
+        <FormItem class="formItem" prop="id" >
+          <Input element-id = "studId" v-model="studForm.id" :placeholder="$t('login.placeholder.schoolID')"/>
+          <input type="text" style="position:fixed;z-index:-10000;width:0;border:none"/>
+        </FormItem>
+        <FormItem class="formItem"  prop="pass">
+          <input type="password" style="position:fixed;z-index:-10000;width:0;border:none"/>
+          <Input element-id="studpw"  type="password" v-model="studForm.pass" :placeholder="$t('login.placeholder.schoolPsw')" >
+            <!-- <Icon v-show="studFormEnter" @click="loginSubmit('studForm')" type="md-arrow-forward" slot="suffix" /> -->
+            <Icon size="24" v-show="!loading && studFormEnter" @click="loginSubmit('studForm')" type="md-arrow-forward" slot="suffix" class="iconFrame" />
+            <div v-show="loading" class="demo-spin-col" slot="suffix">
+              <Spin>
+                <Icon type="ios-loading" size="18" class="demo-spin-icon-load"></Icon>
+              </Spin>
+            </div>
+          </Input>
+        </FormItem>
+        <div class="errlable">{{ schoolErrText }}</div>
+      </Form>
+      </div>
+    </div>
+  </div>
+</template>
+<script>
+import { EventSourcePolyfill } from 'event-source-polyfill';
+import QRCode from 'qrcodejs2'
+import { User } from '@/service/User'
+import { mapState, mapGetters } from 'vuex'
+
+export default {
+  data() {
+    const validateID = (rule, value, callback) => {
+      if (value === '') {
+          callback(new Error());
+          this.loginErrText = this.$t('error.required')
+      } else if (value.search(/^\+/) == 0) {
+          callback(new Error());
+          this.loginErrText = this.$t('error.format.default')
+      } else {
+        if(value.indexOf('@') >=0){ //是否為Email
+          var emailRule = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z]+$/;
+          if(value.search(emailRule)!= -1){
+              callback();
+              this.loginErrText = ''
+          } else {
+              callback(new Error());
+              this.loginErrText = this.$t('error.format.email')
+          }
+        } else {
+          callback();
+          this.loginErrText = ''
+        }
+      }
+    };
+    const validatePW = (rule, value, callback) => {
+      if (value === '') {
+          callback(new Error());
+          this.loginErrText = this.$t('error.required')
+      }
+      else {
+          callback();
+          this.loginErrText = ''
+      }
+    };
+    const validateStudID = (rule, value, callback) => {
+      if (value === '') {
+          callback(new Error());
+          this.schoolErrText = this.$t('error.required')
+      } else if (value.search(/^\+/) == 0) {
+          callback(new Error());
+          this.schoolErrText = this.$t('error.format.default')
+      } else {
+        if(value.indexOf('@') >=0){ //是否為Email
+          var emailRule = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z]+$/;
+          if(value.search(emailRule)!= -1){
+              callback();
+              this.schoolErrText = ''
+          } else {
+              callback(new Error());
+              this.schoolErrText = this.$t('error.format.email')
+          }
+        } else {
+          callback();
+          this.schoolErrText = ''
+        }
+      }
+    };
+    const validateStudPW = (rule, value, callback) => {
+      if (value === '') {
+          callback(new Error());
+          this.schoolErrText = this.$t('error.required')
+      }
+      else {
+          callback();
+          this.schoolErrText = ''
+      }
+    };
+    const validateStudSchoolCode = (rule, value, callback) => {
+      if (value === '') {
+          callback(new Error());
+          this.schoolErrText = this.$t('error.required')
+      }
+      else {
+          callback();
+          this.schoolErrText = ''
+      }
+    };
+    return {
+      qrloginFlag: false,
+      loginForm: {
+          id: '',
+          pass: '',
+      },
+      loginRule: {
+          id: [
+              { validator: validateID, trigger: 'blur' },
+          ],
+          pass: [
+              { validator: validatePW, trigger: 'blur' },
+          ]
+      },
+      studForm: {
+        schoolCode: '',
+        id: '',
+        pass: ''
+      },
+      studRule: {
+          schoolCode: [
+            { validator: validateStudSchoolCode, trigger: 'blur' },
+          ],
+          id: [
+            { validator: validateStudID, trigger: 'blur' },
+          ],
+          pass: [
+            { validator: validateStudPW, trigger: 'blur' },
+          ]
+      },
+      loginErrText: '',
+      schoolErrText: '',
+      userOauth: {        // 社群帳號
+          code: '',
+          state: ''
+      },
+      schoolList: [],
+      loading: false,
+      sseSurvive: false,
+      joinQRcode: undefined,
+      defaultSchool: {
+        name: '',
+        code: ''
+      },
+      identityFlag: false
+    }
+  },
+  computed: {
+    ...mapState({
+      config: state => state.config
+    }),
+    ...mapGetters({
+        srvAdr: 'config/getSrvAdr'
+    }),
+    loginFormEnter: function(){
+      let flag = false
+      if(this.loginForm.id && this.loginForm.pass) flag = true
+      return flag
+    },
+    studFormEnter: function(){
+      let flag = false
+      if(this.studForm.schoolCode && this.studForm.id && this.studForm.pass) flag = true
+      return flag
+    }
+  },
+  created() {
+    // 此頁面為學生頁面
+    localStorage.setItem('identity', 'student')
+
+    // 建立學校LIST清單
+    this.getSchools()
+
+    // 取得學校設定簡碼
+    this.setLoginSchoolCode()
+  },
+  methods: {
+    chgLoginType: function(){ // 變更登入類型
+      this.qrloginFlag = !this.qrloginFlag
+      if(this.qrloginFlag && !this.sseSurvive) {
+        // SSE 連線
+        this.SEELink()
+      }
+    },
+    loginSubmit: function(name){  // 登入
+      this.$refs[name].validate( async(valid) => {        
+        if (valid) {
+          this.loading = true // 登入中動畫
+          let result; // 輸出暫存
+          let isFail = false // 失敗flag
+
+          switch (name) {
+            case 'loginForm':
+              
+              // 詢問帳號是否有效
+              await this.$api.login.verification({id: this.loginForm.id, pass: this.loginForm.pass}).then(res => {
+                result = res
+              }).catch(err=>{
+                isFail = true
+              })
+              console.log('res***',result)
+              if(isFail){
+                this.loginErrText = this.$t('login.apiError.text1')
+                this.loading = false
+              } else {
+                this.loginProcess(result, this.defaultSchool.code)
+              }              
+              break;
+            case 'studForm':
+
+              // 學生登入大雲
+              await this.$api.login.studLogin({schoolCode: this.studForm.schoolCode, id: this.studForm.id, pw: this.studForm.pass}).then( res => {
+                  result = res
+              }).catch(err=>{
+                isFail = true
+              })
+
+
+              if(isFail){
+                this.schoolErrText = this.$t('login.apiError.text1')
+                this.loading = false
+              } else {
+                //設定權限並登入
+                User.login(result).then(res => {
+                  if(res) {
+                    localStorage.setItem('identity', 'student')
+                    this.$router.push({ path: '/studentWeb' })
+                  }
+                })
+              }              
+              break;
+          }          
+          return false;
+        }
+      })
+    },
+    oauthLogin: function(provider){ // 第三方登入
+      let redirect_uri = window.location.origin + '/login';
+      this.$api.BuildOauthUrl(provider, redirect_uri).then(res=>{
+          window.location.href  = res
+      })
+    },
+    SSOLogin: function(code){ // 快速登入
+      this.$Spin.show(); //開啟加載畫面
+      this.$api.SSOLogin(code).then( async res=>{
+        this.$Spin.hide(); // 關閉加載畫面
+          if(!res.error){
+            // 登入大雲開始
+            this.loginProcess(res, this.defaultSchool.code)
+          } else {
+            this.$Message.warning(this.$t('login.sse.error.text1'));
+          }
+
+          // 回到首頁清楚多餘URL參數
+          this.$router.push({ name: 'login' })
+      })
+    },
+    SEELink: function() { // 開啟SSE連結
+      if(!this.sseSurvive){
+        let url = this.config[this.srvAdr].coreAPIUrl
+
+        let es = new EventSourcePolyfill(url+'/service/sse',{headers: {'X-Auth-Name': 'IES5'}});
+        let _this = this;
+
+        var closeSSE = function(){
+          if(_this.sseSurvive) {
+            es.close();
+            _this.sseSurvive = false
+          }
+        }
+
+        es.addEventListener('open', function (e) {
+          _this.sseSurvive = true
+        }, false);
+
+        //取得登入網址
+        es.addEventListener('message', function (e) {
+          if (e.data) {
+            let data = JSON.parse(e.data)
+            
+            if(data.sid) {
+              let qrcodeURL = url + '/qrcode/login?sid=' + encodeURIComponent(data.sid, "utf-8") + '&info=' + encodeURIComponent(_this.$t('login.sse.text1'),"utf-8")
+              _this.crtQrcode(qrcodeURL)
+            } else if(data.code){
+              closeSSE()
+              _this.SSOLogin(data.code)
+            }
+
+          }
+        }, false);
+
+        // 錯誤
+        es.addEventListener('error', function (e) {
+          closeSSE()
+        }, false);
+
+        // 設定五分鐘後關閉連接
+        setTimeout(() => {
+          closeSSE()
+        }, 300000);
+      }
+    },
+    crtQrcode: function(url) { // 開啟QRCODE
+      this.$nextTick(() => {
+        if(this.joinQRcode == undefined){
+          let qrcode = new QRCode('qrcode', {
+            width: 200, // 设置宽度,单位像素
+            height: 200, // 设置高度,单位像素
+            text: url, // 设置二维码内容或跳转地址
+          })
+          this.joinQRcode = qrcode
+        } else {
+          this.joinQRcode.clear()
+          this.joinQRcode.makeCode(url)
+        }
+      })
+    },
+    loginProcess: async function(item, schoolCode){ // 登入用function
+      let result;
+
+      await this.$api.login.loginIES(item, schoolCode).then( res => {
+        result = res
+      })
+      console.log('////',result)
+      //設定權限並登入
+      User.login(result).then(res => {
+        if(res) {
+          this.saveUserCodes({
+            TEAMModelId: result.id,
+            name:result.name,
+            schoolCode: result.defaultschool
+          })
+          this.$router.push({ path: '/studentWeb' })
+        }
+      })
+    },
+    saveUserCodes: function (res) {
+		  this.$store.commit('setUserInfo',res)
+	  },
+    getSchools: function(){ // 取得學校清單
+      let _this = this
+      this.$api.getSchoolList().then( res =>{
+        if(Array.isArray(res.schools) && res.schools.length > 0){
+          res.schools.forEach(function(item){
+
+            let isProvinceSame = _this.schoolList.find(function( val ){
+              return val.province == item.province
+            })
+
+            if(isProvinceSame){
+
+              let index = _this.schoolList.indexOf(isProvinceSame)
+              _this.schoolList[index].schools.push({
+                id: item.id,
+                name: item.name,
+              })
+            } else {
+              let data = {
+                province: item.province,
+                schools: [
+                  {
+                    id: item.id,
+                    name: item.name,
+                  }
+                ]
+              }
+
+              _this.schoolList.push(data)
+
+            }
+          })
+        }
+      })
+    },
+    setLoginSchoolCode: function(){ // 設定預設的學校簡碼
+      let schoolCode = this.$route.query.schoolcode == undefined ? '' : this.$route.query.schoolcode;
+      if(schoolCode){
+          this.$api.login.getSchoolName({schoolCode: schoolCode}).then( res => {
+          this.defaultSchool.code = res.code
+          this.defaultSchool.name = res.name
+          this.studForm.schoolCode = this.defaultSchool.code
+        })
+      }
+    },
+    setDefSchool: function(){
+      let defschool = sessionStorage.defaultSchool
+      if(defschool){
+        defschool = JSON.parse(decodeURIComponent(defschool), "utf-8")
+        this.defaultSchool.code = defSchool.code
+        this.defaultSchool.name = defSchool.name
+      }      
+    }
+  }
+}
+</script>

+ 166 - 0
TEAMModelOS/ClientApp/src/view/login/page/Teacher.less

@@ -0,0 +1,166 @@
+.loginDiv{
+    height: 520px;
+    display: flex;
+    align-items: center;
+    flex-direction: column;
+    justify-content: space-around;
+    .iconFrame:before{
+        border-radius: 50%;
+        border: 1px solid #808695;
+    }
+    .schoolName{
+        letter-spacing: 7px;
+        height: 120px;
+        display: flex;
+        justify-content: center;
+        align-items: center;
+        img{
+            width: 63px;
+            height: 63px;
+        }
+    }
+    .formDiv{
+        width: 800px;
+        display: flex;
+        justify-content: center;
+        .loginBox{
+            width: 300px;
+            height: 310px;
+            .title{
+                display: flex;
+                align-items: center;
+                // align-content: center !important;
+                margin-bottom: 5px;
+                .logo{
+                    margin-right: 5px;
+                    height: 15px;
+                }
+                .text{
+                    margin-right: 15px;
+                    color: #ffffff;
+                    font-size: 16px;
+                }
+                .tooltip{
+                    height: 15px;
+                }
+            }
+            .subTitle{
+                font-size: 14px;
+                color: #d1d1d3;
+                margin-bottom: 25px;
+            }
+            .loginForm{
+                margin-bottom: 10px;
+                .formItem{
+                    margin: 0;
+                }
+                .errlable{
+                    text-align: right;
+                    color: #f22613;
+                    font-size: 12px;
+                    margin-top: 3px;
+                    height: 12px;
+                }
+            }
+            .extra{
+                display: flex;
+                align-items: center;
+                justify-content: space-between;
+                margin-bottom: 30px;
+                .qrlogin{
+                    display: flex;
+                    align-items: center;
+                    .logo{
+                        margin-right: 5px;
+                        height: 15px;
+                    }
+                    a{
+                        font-size: 12px;
+                        color: #668fbc;
+                        text-decoration: underline;
+                    }
+                }
+                .link{
+                    a{
+                        font-size: 12px;
+                        color: #668fbc;
+                        text-decoration: underline;
+                    }
+                }
+            }
+            .communyLoging{
+                .description{
+                    text-align: center;
+                    font-size: 12px;
+                    color: #d1d1d3;
+                    margin-bottom: 20px;
+                    letter-spacing: 1.5px;
+                }
+                .links{
+                    display: flex;
+                    align-items: center;
+                    justify-content: space-around;
+                    .icon{
+                        display: flex;
+                        align-items: center;
+                        flex-direction: column;
+                        cursor: pointer;
+                        img{
+                            width: 35px;
+                        }
+                        span{
+                            font-size: 12px;
+                            color: #d1d1d3;
+                        }
+                    }
+                }
+            }
+            .qrloginMode{
+                .qrcodeBox{
+                    width:240px;
+                    height:240px;
+                    margin:auto;
+                    margin-bottom: 10px;
+                    position: relative;
+                    display: flex;
+                    justify-content: center;
+                    align-items: center;
+                    .qrcode{
+                        padding:20px;
+                        background-color:white;
+                    }
+                    .expired{
+                        position: absolute;
+                        background-color: #ffffffde;
+                        width: 200px;
+                        height: 200px;
+                        display: flex;
+                        justify-content: center;
+                        align-items: center;
+                        .ivu-icon{
+                            cursor: pointer;
+                        }
+                    }
+                }            
+                .links{
+                    display: flex;
+                    align-items: center;
+                    justify-content: space-between;
+                    .icon-a{
+                        display: flex;
+                        align-items: center;
+                        img{
+                            margin-right: 3px;
+                            width: 15px;
+                            height: 15px;
+                        }
+                    }
+                    a{
+                        font-size: 12px;
+                        color: #668fbc;
+                    }
+                }
+            }
+        }
+    }
+}

+ 404 - 0
TEAMModelOS/ClientApp/src/view/login/page/Teacher.vue

@@ -0,0 +1,404 @@
+<style lang="less" scoped>
+  @import './Teacher.less';
+</style>
+
+<style lang="less">
+.loginBox{
+  .loginForm{
+    .formItem{
+        input, select{
+            border-radius: 0;
+            font-size: 12px;
+        }
+        .ivu-select-selection{
+          border-radius: 0;
+        }
+    }
+    .schoolAutoComplete{
+      height: 170px;
+      .schoolsBox{
+        border-bottom: 1px solid #e9e9e9;
+        padding: 5px 5px 5px 15px;
+        .area{
+          font-size: 12px;
+          padding: 5px;
+        }
+      }
+    }
+    .ivu-select-dropdown{
+      border-radius: 0;
+    }
+  }
+}
+.identityModal{
+  .ivu-modal{
+    .ivu-modal-content{
+      background-color: #2a292e;
+      padding: 12px;
+      border: 1px solid #ccc;
+      .ivu-modal-header, .ivu-modal-footer{
+        border: 0;
+      }
+      .ivu-modal-footer{
+        padding: 0;
+      }
+      .ivu-modal-header{
+        padding: 5px 16px;
+        p{
+          color: whitesmoke;
+        }
+      }
+      .identity-body{
+        display: flex;
+        justify-content: space-around;
+        align-items: center;
+        .ivu-btn{
+          background-color: #1cc0f2;
+          color: white;
+          font-weight: bold;
+          border: 0;
+          padding: 0 22px;
+        }
+      }
+    }        
+  }
+}
+.demo-spin-col .ivu-spin-main{
+	background-color: transparent;
+	padding: 0;
+}
+</style>
+
+<template>
+  <div class="loginDiv">
+    <div class="schoolName">
+      <div style="width: 100px;height: 100px;background-color: #69b0d0;border-radius: 4px;cursor: pointer;">
+        <img style="    display: block;
+          width: 100%;
+          height: 100%;" src="@/assets/icon/teacherIcon.png">
+      </div>
+    </div>
+    <div class="formDiv">
+      <div class="loginBox">
+        <div class="title">
+          <div class="logo">
+            <img  width="15" height="15" src="@/assets/icon/tmd_account.svg">
+          </div>
+          <h4 class="text">
+            {{ qrloginFlag ? $t('login.title.QRLogin'): $t('login.title.IDLogin') }}
+          </h4>
+          <Tooltip class="tooltip" placement="right-end" :transfer="true" max-width="200">
+            <img src="@/assets/icon/icon_info.svg" width="15" height="15">
+            <div slot="content">
+              <p style="font-size: 12px;">{{ $t('login.tooltip.text1') }}</p>
+            </div>
+          </Tooltip>
+        </div>
+        <h4 class="subTitle">
+          {{ qrloginFlag ? $t('login.subTitle.QRLogin') : $t('login.subTitle.IDLogin')}}
+        </h4>
+
+        <div v-show="!qrloginFlag">
+          <Form class="loginForm" ref="loginForm" :model="loginForm" :rules="loginRule" :show-message="false" @keydown.enter.native="loginSubmit('loginForm')">
+            <FormItem class="formItem" prop="id" >
+              <Input element-id = "tmdID" v-model="loginForm.id" :placeholder="$t('login.placeholder.id')"/>
+            </FormItem>
+            <FormItem class="formItem"  prop="pass">
+              <Input element-id = "tmdpw" type="password" v-model="loginForm.pass" :placeholder="$t('login.placeholder.psw')" >
+                <Icon size="24" v-show="!loading && loginFormEnter" @click="loginSubmit('loginForm')" type="md-arrow-forward" slot="suffix" class="iconFrame" />
+                <div v-show="loading" class="demo-spin-col" slot="suffix">
+                  <Spin>
+                    <Icon type="ios-loading" size="18" class="demo-spin-icon-load"></Icon>
+                  </Spin>
+                </div>
+              </Input>
+            </FormItem>
+            <div class="errlable">{{ loginErrText }}</div>
+          </Form>
+
+          <div class="extra">
+            <div class="qrlogin">
+              <div class="logo">
+                <img  width="15" height="15" src="@/assets/icon/icon_qrcode.svg">
+              </div>
+              <a @click="chgLoginType()">{{ $t('login.link.QRLogin') }}</a>
+            </div>
+            <div class="link">
+              <router-link to="/regist">{{ $t('login.link.regist') }}</router-link> | <router-link to="/forgotpw">{{ $t('login.link.forgetPsw') }}</router-link>
+            </div>
+          </div>
+
+          <div class="communyLoging">
+            <div class="description">{{ $t('login.communy.title')}}</div>
+            <div class="links">
+              <div  class="icon" @click="oauthLogin('facebook')">
+                <img v-if="!(srvAdr == 'China')" src="@/assets/icon/icon_fb.svg">
+                <span>{{ $t('login.communy.fb')}}</span>
+              </div>
+              <div v-if="!(srvAdr == 'China')" class="icon" @click="oauthLogin('google')">
+                <img  src="@/assets/icon/icon_google.svg">
+                <span>{{ $t('login.communy.google')}}</span>
+              </div>
+              <div v-if="!(srvAdr == 'Global')" class="icon" @click="oauthLogin('wechat')">
+                <img  src="@/assets/icon/icon_wechat.svg">
+                <span>{{ $t('login.communy.wechat')}}</span>
+              </div>
+            </div>
+          </div>
+        </div>
+        <div v-show="qrloginFlag">
+          <div class="qrloginMode">
+            <div class="qrcodeBox">
+              <div id="qrcode" :class="{'qrcode': joinQRcode != undefined}" ref="qrcode"></div>
+              <div class="expired" v-if="joinQRcode != undefined && !sseSurvive">
+                <Icon size="40" type="md-refresh-circle" @click="SEELink()" />
+              </div>
+            </div>              
+            <div class="links">
+              <div class="icon-a">
+                <img src="@/assets/icon/icon_account.svg">
+                <a @click="chgLoginType()">{{ $t('login.link.IDLogin') }}</a>
+              </div>
+              <router-link to="/regist">{{ $t('login.link.regist') }}</router-link>
+            </div>
+          </div>
+        </div>
+      </div>
+    </div>
+  </div>
+</template>
+<script>
+import { EventSourcePolyfill } from 'event-source-polyfill';
+import QRCode from 'qrcodejs2'
+import { User } from '@/service/User'
+import { mapState, mapGetters } from 'vuex'
+
+export default {
+  data() {
+    const validateID = (rule, value, callback) => {
+      if (value === '') {
+          callback(new Error());
+          this.loginErrText = this.$t('error.required')
+      } else if (value.search(/^\+/) == 0) {
+          callback(new Error());
+          this.loginErrText = this.$t('error.format.default')
+      } else {
+        if(value.indexOf('@') >=0){ //是否為Email
+          var emailRule = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z]+$/;
+          if(value.search(emailRule)!= -1){
+              callback();
+              this.loginErrText = ''
+          } else {
+              callback(new Error());
+              this.loginErrText = this.$t('error.format.email')
+          }
+        } else {
+          callback();
+          this.loginErrText = ''
+        }
+      }
+    };
+    const validatePW = (rule, value, callback) => {
+      if (value === '') {
+          callback(new Error());
+          this.loginErrText = this.$t('error.required')
+      }
+      else {
+          callback();
+          this.loginErrText = ''
+      }
+    };
+    return {
+      qrloginFlag: false,
+      loginForm: {
+          id: '',
+          pass: '',
+      },
+      loginRule: {
+          id: [
+              { validator: validateID, trigger: 'blur' },
+          ],
+          pass: [
+              { validator: validatePW, trigger: 'blur' },
+          ]
+      },
+      loginErrText: '',
+      schoolErrText: '',
+      userOauth: {        // 社群帳號
+          code: '',
+          state: ''
+      },
+      loading: false,
+      sseSurvive: false,
+      joinQRcode: undefined,
+      defaultSchool: {
+        name: '',
+        code: ''
+      },
+      identityFlag: false
+    }
+  },
+  computed: {
+    ...mapState({
+      config: state => state.config
+    }),
+    ...mapGetters({
+        srvAdr: 'config/getSrvAdr'
+    }),
+    loginFormEnter: function(){
+      let flag = false
+      if(this.loginForm.id && this.loginForm.pass) flag = true
+      return flag
+    }
+  },
+  created() {
+    // 此頁面為老師頁面
+    localStorage.setItem('identity', 'teacher')
+
+    // 取得學校設定簡碼
+    this.setDefSchool()
+  },
+  methods: {
+    chgLoginType: function(){ // 變更登入類型
+      this.qrloginFlag = !this.qrloginFlag
+      if(this.qrloginFlag && !this.sseSurvive) {
+        // SSE 連線
+        this.SEELink()
+      }
+    },
+    loginSubmit: function(name){  // 登入
+      this.$refs[name].validate( async(valid) => {        
+        if (valid) {
+          this.loading = true // 登入中動畫
+          let result; // 輸出暫存
+          let isFail = false // 失敗flag
+            // 詢問帳號是否有效
+            await this.$api.login.verification({id: this.loginForm.id, pass: this.loginForm.pass}).then(res => {
+              result = res
+            }).catch(err=>{
+              isFail = true
+            })
+            console.log('res***',result)
+            if(isFail){
+              this.loginErrText = this.$t('login.apiError.text1')
+              this.loading = false
+            } else {
+              this.loginProcess(result, this.defaultSchool.code)
+            }
+        }
+      })
+    },
+    oauthLogin: function(provider){ // 第三方登入
+      let redirect_uri = window.location.origin + '/login';
+      this.$api.BuildOauthUrl(provider, redirect_uri).then(res=>{
+          window.location.href = res
+      })
+    },
+    SEELink: function() { // 開啟SSE連結
+      if(!this.sseSurvive){
+        let url = this.config[this.srvAdr].coreAPIUrl
+
+        let es = new EventSourcePolyfill(url+'/service/sse',{headers: {'X-Auth-Name': 'IES5'}});
+        let _this = this;
+
+        var closeSSE = function(){
+          if(_this.sseSurvive) {
+            es.close();
+            _this.sseSurvive = false
+          }
+        }
+
+        es.addEventListener('open', function (e) {
+          _this.sseSurvive = true
+        }, false);
+
+        //取得登入網址
+        es.addEventListener('message', function (e) {
+          if (e.data) {
+            let data = JSON.parse(e.data)
+            
+            if(data.sid) {
+              let qrcodeURL = url + '/qrcode/login?sid=' + encodeURIComponent(data.sid, "utf-8") + '&info=' + encodeURIComponent(_this.$t('login.sse.text1'),"utf-8")
+              _this.crtQrcode(qrcodeURL)
+            } else if(data.code){
+              closeSSE()
+              _this.SSOLogin(data.code)
+            }
+
+          }
+        }, false);
+
+        // 錯誤
+        es.addEventListener('error', function (e) {
+          closeSSE()
+        }, false);
+
+        // 設定五分鐘後關閉連接
+        setTimeout(() => {
+          closeSSE()
+        }, 300000);
+      }
+    },
+    crtQrcode: function(url) { // 開啟QRCODE
+      this.$nextTick(() => {
+        if(this.joinQRcode == undefined){
+          let qrcode = new QRCode('qrcode', {
+            width: 200, // 设置宽度,单位像素
+            height: 200, // 设置高度,单位像素
+            text: url, // 设置二维码内容或跳转地址
+          })
+          this.joinQRcode = qrcode
+        } else {
+          this.joinQRcode.clear()
+          this.joinQRcode.makeCode(url)
+        }
+      })
+    },
+    loginProcess: async function(item, schoolCode){ // 登入用function
+      let result;
+
+      await this.$api.login.loginIES(item, schoolCode).then( res => {
+        result = res
+      })
+      console.log('////',result)
+      //設定權限並登入
+      User.login(result).then(res => {
+        if(res) {
+          this.saveUserCodes({
+            TEAMModelId: result.id,
+            name:result.name,
+            schoolCode: result.defaultschool
+          })
+          this.$router.push({ path: '/home' })
+        }
+      })
+    },
+    saveUserCodes: function (res) {
+		  this.$store.commit('setUserInfo',res)
+	  },
+    setDefSchool: function(){
+      let defschool = sessionStorage.defaultSchool
+      if(defschool){
+        defschool = JSON.parse(decodeURIComponent(defschool), "utf-8")
+        this.defaultSchool.code = defSchool.code
+        this.defaultSchool.name = defSchool.name
+      }      
+    },
+    SSOLogin: function(code){ // 快速登入
+      this.$Spin.show(); //開啟加載畫面
+      this.$api.SSOLogin(code).then( async res=>{
+        this.$Spin.hide(); // 關閉加載畫面
+          if(!res.error){
+            // 登入大雲開始
+            this.loginProcess(res, this.defaultSchool.code)
+          } else {
+            this.$Message.warning(this.$t('login.sse.error.text1'));
+          }
+
+          // 回到首頁清楚多餘URL參數
+          this.$router.push({ name: 'login' })
+      })
+    },
+  }
+}
+</script>

+ 222 - 0
TEAMModelOS/ClientApp/src/view/login/test.vue

@@ -0,0 +1,222 @@
+<style lang="less" scoped>
+  @import './Index.less';
+</style>
+
+<style lang="less">
+.loginBox{
+  .loginForm{
+    .formItem{
+        input, select{
+            border-radius: 0;
+            font-size: 12px;
+        }
+        .ivu-select-selection{
+          border-radius: 0;
+        }
+    }
+    .schoolAutoComplete{
+      height: 170px;
+      .schoolsBox{
+        border-bottom: 1px solid #e9e9e9;
+        padding: 5px 5px 5px 15px;
+        .area{
+          font-size: 12px;
+          padding: 5px;
+        }
+      }
+    }
+    .ivu-select-dropdown{
+      border-radius: 0;
+    }
+  }
+}
+.identityModal{
+  .ivu-modal{
+    .ivu-modal-content{
+      background-color: #2a292e;
+      padding: 12px;
+      border: 1px solid #ccc;
+      .ivu-modal-header, .ivu-modal-footer{
+        border: 0;
+      }
+      .ivu-modal-footer{
+        padding: 0;
+      }
+      .ivu-modal-header{
+        padding: 5px 16px;
+        p{
+          color: whitesmoke;
+        }
+      }
+      .identity-body{
+        display: flex;
+        justify-content: space-around;
+        align-items: center;
+        .ivu-btn{
+          background-color: #1cc0f2;
+          color: white;
+          font-weight: bold;
+          border: 0;
+          padding: 0 22px;
+        }
+      }
+    }        
+  }
+}
+.demo-spin-col .ivu-spin-main{
+	background-color: transparent;
+	padding: 0;
+}
+</style>
+
+<template>
+  <div style="display: flex;
+    justify-content: space-evenly;
+    width: 100%;
+    height: 600px;
+    flex-direction: row;
+    align-items: center;">
+      <div style="width: 45%;
+        max-width: 600px;
+        height: 100%;padding: 12px;">
+        <div style="font-size: 55px;
+            color: rgb(255, 255, 255);
+            font-weight: bolder;
+            letter-spacing: 2px;
+            word-break: break-all;
+            line-height: 1;
+            margin-bottom: 21px;">
+          Welcome !!
+          sometimes YES
+          sometimes NO
+        </div>
+        <p style="color: #9e9e9e;font-size: 14px; margin-bottom: 15px;" v-text="'calc() 是一個 CSS function 作用於屬性設定是數值的時候可以進行加減乘除的運算,例如: <length> 長度、<frequency> 頻率、<angle> 角度、<time> 時間、<number> 數字或者是 <integer> 整數這幾個屬性值都可以使用 calc()。'"></p>
+        <img style="max-width: 400px;" src="https://dozen168.com/wp-content/uploads/2019/06/%E6%B7%A1%E6%B0%B4%E6%99%AF%E9%BB%9E%E6%B7%A1%E6%B0%B4%E9%A2%A8%E6%99%AF%E6%B7%A1%E6%B0%B4%E4%BB%8B%E7%B4%B9%E6%B7%A1%E6%B0%B4%E6%97%85%E9%81%8A%E6%B7%A1%E6%B0%B4%E5%B0%8F%E5%90%83%E6%B7%A1%E6%B0%B4%E7%BE%8E%E9%A3%9F%E6%B7%A1%E6%B0%B4%E6%97%85%E9%81%8A%E6%9B%9C%E8%BC%97%E6%B7%A1%E6%B0%B4%E4%BB%8B%E7%B4%B9%E6%9B%9C%E8%BC%97%E6%B7%A1%E6%B0%B4%E6%99%AF%E9%BB%9E%E4%BB%8B%E7%B4%B9-1168x737.jpg"/>
+      </div>
+      <div style="width: 45%;
+              max-width: 600px;
+              height: 100%;
+              display: flex;
+              flex-direction: row;
+              flex-wrap: nowrap;
+              justify-content: space-evenly;
+              align-items: center;">
+            <div style="width: 200px;height: 200px;background-color: #69b0d0;border-radius: 4px;cursor: pointer;" @click="loginTo('teacher')">
+              <img style="display: block;width: 100%;" src="@/assets/icon/teacherIcon.png">
+            </div>
+            <div style="width: 200px;;height: 200px;background-color: #94ca87;border-radius: 4px;cursor: pointer;" @click="loginTo('student')">
+              <img style="display: block;width: 100%;" src="@/assets/icon/studentIcon.png">
+            </div>
+      </div>
+    <!-- 提示視窗 -->
+    <Modal v-model="identityFlag" width="360" :mask-closable="false" :closable="false" class-name="identityModal">
+        <p slot="header">{{ $t('login.modal.title') }}</p>
+        <div class="identity-body">
+            <Button size="large" @click="goWhere('teacher')">{{ $t('login.modal.btn1') }}</Button>
+            <Button size="large" @click="goWhere('student')">{{ $t('login.modal.btn2') }}</Button>
+        </div>
+        <div slot="footer"></div>
+    </Modal>
+  </div>
+</template>
+<script>
+import { User } from '@/service/User'
+
+export default {
+  data() {
+    return {
+      defaultSchool: {
+        name: '',
+        code: ''
+      },
+      userOauth:{
+        code: '',
+        state: ''
+      },
+      identityFlag: false
+    }
+  },
+  created() {
+    // 取得學校設定簡碼
+    this.setDefSchool()
+
+    //TEAMModelID 社群登入資訊
+    this.userOauth.code = this.$route.query.code == undefined ? '' : this.$route.query.code;
+    this.userOauth.state = this.$route.query.state == undefined ? '' : this.$route.query.state;
+
+    // 社群帳號登入
+    if(this.userOauth.code != '' & this.userOauth.state !='' ) {
+      this.putUserCode()
+    } else if(this.userOauth.code != ''){ // 大雲快速登入
+      this.SSOLogin(this.userOauth.code)
+    }
+  },
+  methods: {
+    putUserCode: function(){ //如果第三方登入會啟動的function
+      this.$Spin.show(); //開啟加載畫面
+      let redirect_uri = window.location.origin + '/login'
+      this.$api.OauthLogin(this.userOauth.state, this.userOauth.code, redirect_uri).then(res=>{
+        this.$Spin.hide(); //關閉加載畫面
+        this.loginProcess(res, this.defaultSchool.code)
+      })  
+    },
+    SSOLogin: function(code){ // 快速登入
+      this.$Spin.show(); //開啟加載畫面
+      this.$api.SSOLogin(code).then( async res=>{
+        this.$Spin.hide(); // 關閉加載畫面
+          if(!res.error){
+            // 登入大雲開始
+            this.loginProcess(res, this.defaultSchool.code)
+          } else {
+            this.$Message.warning(this.$t('login.sse.error.text1'));
+          }
+
+          this.$router.push({ name: 'login' })
+      })
+    },
+    loginProcess: async function(item, schoolCode){ // 登入用function
+      let result;
+
+      await this.$api.login.loginIES(item, schoolCode).then( res => {
+        result = res
+      })
+      console.log('////',result)
+      //設定權限並登入
+      let identity = localStorage.getItem('identity')
+      User.login(result).then(res => {
+        if(res && identity) {
+          this.saveUserCodes({
+            TEAMModelId: result.id,
+            name:result.name,
+            schoolCode: result.defaultschool
+          })
+          let path = identity == 'student' ? '/studentWeb' : '/home'
+          this.$router.push({ path: path })
+        } else {
+          this.identityFlag = true;
+        }
+      })
+    },
+    saveUserCodes: function (res) {
+  		this.$store.commit('setUserInfo',res)
+	  },
+    setDefSchool: function(){
+      let defschool = sessionStorage.defaultSchool
+      if(defschool){
+        defschool = JSON.parse(decodeURIComponent(defschool), "utf-8")
+        this.defaultSchool.code = defSchool.code
+        this.defaultSchool.name = defSchool.name
+      }      
+    },
+    goWhere: function(identity){
+      localStorage.setItem('identity', identity)
+      let path = identity == 'student' ? '/studentWeb' : '/home'
+      this.$router.push({ path: path })
+    },
+    loginTo: function(identity) {
+      let pathname = identity == 'student' ? 'loginStudent' : 'loginTeacher'
+      this.$router.push({ name: pathname })
+    }
+  }
+}
+</script>