Browse Source

浙里办对接 测试

bzkf3 2 years ago
parent
commit
7f140abc74

+ 9 - 4
public/config.js

@@ -5,6 +5,8 @@ const local = {
     api: 'https://tyyxopenapi.bozedu.top/',
     oss: 'https://tyyxopenapi.bozedu.top/',
     origin: window.location.origin,
+    // 浙里办中转
+    pend: 'https://tyyxopenapi.txhlwxx.com/',
 }
 
 // 测试服环境
@@ -13,7 +15,8 @@ const development = {
     web_mobile: 'https://tyyxm.bozedu.top/',
     origin: window.location.origin,
     api: 'https://tyyxopenapi.bozedu.top/',
-    oss: 'https://tyyxopenapi.bozedu.top/'
+    oss: 'https://tyyxopenapi.bozedu.top/',
+    pend: 'https://tyyxopenapi.txhlwxx.com/',
 }
 // 演示服环境
 const demo = {
@@ -21,7 +24,8 @@ const demo = {
     web_mobile: 'https://tyyxm.bozedu.net/',
     origin: window.location.origin,
     api: 'https://tyyxopenapi.bozedu.net/',
-    oss: 'https://tyyxopenapi.bozedu.net/'
+    oss: 'https://tyyxopenapi.bozedu.net/',
+    pend: 'https://tyyxopenapi.txhlwxx.com/',
 }
 // 正式服环境
 const production = {
@@ -29,7 +33,8 @@ const production = {
     web_mobile: 'https://tyyxm.txhlwxx.com/',
     origin: window.location.origin,
     api: 'https://tyyxopenapi.txhlwxx.com/',
-    oss: 'https://tyyxopenapi.txhlwxx.com/'
+    oss: 'https://tyyxopenapi.txhlwxx.com/',
+    pend: 'https://tyyxopenapi.txhlwxx.com/',
 }
 
 function isWhich() {
@@ -43,4 +48,4 @@ function isWhich() {
         return local
     }
 }
-window.GLOBAL_CONFIG = isWhich()
+window.GLOBAL_CONFIG = isWhich()

+ 39 - 13
public/pending.html

@@ -102,17 +102,43 @@
     // 受限redirectTo只能带一个参数
     // const from = SearchMap.get('from')
     // const type = SearchMap.get('type')
-    const [from, type,redirectUrl] = fromType.split('_')
+    const [from, type, redirectUrl] = fromType.split('_')
     console.log('from, type :>> ', from, type);
+
+    // jyej
     const gaeatoken = SearchMap.get('gaeatoken')
+    // zlb
+    const ticket = SearchMap.get('ticket')
+
+    const RequestUrl = {
+      jyej: '/openapi/oauth/jyej/index.php',
+      zlb: '/openapi/oauth/zlb/checkticket.php',
+    }
+    const RequestTicket = {
+      jyej: { gaeatoken },
+      zlb: { ticket },
+    }
+    const RequestType = {
+      jyej: {
+        bind: 'bind',
+        unbind: 'unbind',
+        login: 'user2local',
+        loginback: 'user2local',
+      }, zlb: {
+        bind: 'bind',
+        unbind: 'unbind',
+        login: 'login',
+      }
+    }
+
     switch (type) {
       case 'bind': {
         _request({
-          url: `/openapi/oauth/${from}/index.php`,
+          url: RequestUrl[from],
           data: {
-            type: 'bind',
+            type: RequestType[from][type],
             token: userInfo.token,
-            gaeatoken
+            ...RequestTicket[from]
           }
         }).then(response => {
           const res = response.data
@@ -130,16 +156,16 @@
       case 'unbind': {
         console.log('userInfo.token :>> ', userInfo.token);
         _request({
-          url: `/openapi/oauth/${from}/index.php`,
+          url: RequestUrl[from],
           data: {
-            type: 'unbind',
+            type: RequestType[from][type],
             token: userInfo.token,
           }
         }).then(response => {
           const res = response.data
           if (res.code === '1') {
             Message.success('解绑成功')
-            localStorage.setItem('userInfo',JSON.stringify(Object.assign(userInfo, {
+            localStorage.setItem('userInfo', JSON.stringify(Object.assign(userInfo, {
               ext: {
                 [`ue_${from}_account`]: "",
                 [`ue_${from}_id`]: "",
@@ -157,10 +183,10 @@
       // 登录
       case 'login': {
         _request({
-          url: `/openapi/oauth/${from}/index.php`,
+          url: RequestUrl[from],
           data: {
-            type: 'user2local',
-            gaeatoken,
+            type: RequestType[from][type],
+            ...RequestTicket[from]
           }
         }).then(response => {
           const res = response.data
@@ -178,10 +204,10 @@
       }
       case 'loginback': {
         _request({
-          url: `/openapi/oauth/${from}/index.php`,
+          url: RequestUrl[from],
           data: {
-            type: 'user2local',
-            gaeatoken,
+            type: RequestType[from][type],
+            ...RequestTicket[from]
           }
         }).then(response => {
           const res = response.data

+ 34 - 26
src/components/CommonHeader/index.vue

@@ -1,6 +1,6 @@
 <script setup>
-import {login, message} from "./api.js";
-import {user, refresh} from '~/store/user';
+import { login, message } from "./api.js";
+import { user, refresh } from '~/store/user';
 
 // console.log('user :>> ', user);
 const navList = [
@@ -88,7 +88,7 @@ function handleCommand(command) {
       if (localStorage.getItem('userInfo')) {
         localStorage.removeItem('userInfo');
 
-        router.replace({name: 'home'});
+        router.replace({ name: 'home' });
         setTimeout(() => {
           location.reload();
         }, 300);
@@ -100,9 +100,9 @@ function handleCommand(command) {
       let userData = JSON.parse(userInfo);
       let isStudent = userData.user_role_id == 76 ? true : false;
       if (!isStudent) {
-        router.replace({name: 'personal'});
+        router.replace({ name: 'personal' });
       } else {
-        router.replace({name: 'personalStudent'});
+        router.replace({ name: 'personalStudent' });
       }
       break;
     case 'back_manager':
@@ -126,13 +126,13 @@ function routerReplace(name) {
   if (name === 'tbkt') {
     window.open('https://tyyxopenapi.bozedu.net/tbkt.php?token=' + JSON.parse(localStorage.getItem('userInfo')).token, '_self');
   } else {
-    router.replace({name})
+    router.replace({ name })
   }
 
 }
 
 function toMessage() {
-  router.replace({name: 'message'});
+  router.replace({ name: 'message' });
 }
 
 let messageList = $ref([]);
@@ -161,7 +161,10 @@ function partyLogin(from) {
       location.replace(`https://jyyj.zjjxedu.gov.cn:86/edu-manager/login?redirectTo=${window.location.origin}/pending.html?fromType=${from}_login`)
       break;
     case 'zlb':
-
+      location.replace(`https://puser.zjzwfw.gov.cn/sso/newusp.do?action=ssoLogin&servicecode=beb8fa1fd85f4963bebf839f0d304d63&redirectUrl=`
+        + encodeURIComponent(
+          `${window.GLOBAL_CONFIG.pend}/openapi/oauth/zlb/checkticket.php?goto=${window.location.origin}/pending.html?fromType=${from}_login`
+        ))
       break;
     default:
       break;
@@ -221,8 +224,8 @@ function partyLogin(from) {
     </div>
     <div class="nav-list">
       <ul>
-        <li v-for="item in navList" :class="{'selected':currentRootRoute===item.name}"
-            @click="handleSwitchRoute(item.name)">
+        <li v-for="item in navList" :class="{ 'selected': currentRootRoute === item.name }"
+          @click="handleSwitchRoute(item.name)">
           {{ item.title }}
         </li>
       </ul>
@@ -267,22 +270,22 @@ function partyLogin(from) {
         <div class="w-full flex-auto flex-auto mt-8 flex flex-col justify-between">
           <el-input v-model="loginForm.user_name" class="h-70px" size="large" placeholder="账号">
             <template #suffix>
-              <i:ant-design:user-outlined class="w-23px h-23px"/>
+              <i:ant-design:user-outlined class="w-23px h-23px" />
             </template>
           </el-input>
           <el-input v-model="loginForm.user_password" class="h-70px mt-4" size="large" :type="passwordType"
-                    placeholder="数字、字母或符号组成的密码">
+            placeholder="数字、字母或符号组成的密码">
             <template #suffix>
-              <i:bi:eye-slash class="w-23px h-23px cursor-pointer" v-show="passwordType==='password'"
-                              @click="passwordType='text'"/>
-              <i:bi:eye class="w-23px h-23px cursor-pointer" v-show="passwordType==='text'"
-                        @click="passwordType='password'"/>
+              <i:bi:eye-slash class="w-23px h-23px cursor-pointer" v-show="passwordType === 'password'"
+                @click="passwordType = 'text'" />
+              <i:bi:eye class="w-23px h-23px cursor-pointer" v-show="passwordType === 'text'"
+                @click="passwordType = 'password'" />
               <!-- <i:akar-icons:lock-off class="w-23px h-23px" /> -->
             </template>
           </el-input>
-          <button type="button" :disabled="!(loginForm.user_name &&loginForm.user_password)" @click="userLoginSubmit"
-                  class="w-full mt-12 h-56px bg-hex-409EFF rounded text-white tracking-0.5rem "
-                  :class="!(loginForm.user_name &&loginForm.user_password) && 'cursor-not-allowed bg-hex-79BBFF'">登录
+          <button type="button" :disabled="!(loginForm.user_name && loginForm.user_password)" @click="userLoginSubmit"
+            class="w-full mt-12 h-56px bg-hex-409EFF rounded text-white tracking-0.5rem "
+            :class="!(loginForm.user_name && loginForm.user_password) && 'cursor-not-allowed bg-hex-79BBFF'">登录
           </button>
           <div class="mt-12 w-full">
             <el-divider>其他登录方式</el-divider>
@@ -340,8 +343,9 @@ function partyLogin(from) {
   .nav-list {
     width: 100%;
     height: 80px;
-    background:#423F72;
-    ul{
+    background: #423F72;
+
+    ul {
       width: 1200px;
       margin: 0 auto;
       display: flex;
@@ -356,12 +360,13 @@ function partyLogin(from) {
       text-align: center;
       cursor: pointer;
       line-height: 80px;
-      &+li{
+
+      &+li {
         margin-left: 13px;
       }
 
       &.selected {
-        background: rgba(255,255,255,.2);
+        background: rgba(255, 255, 255, .2);
       }
     }
   }
@@ -433,7 +438,7 @@ function partyLogin(from) {
 
           &:hover {
             .m-con {
-              background: rgba(66,63,114,0.06);
+              background: rgba(66, 63, 114, 0.06);
             }
 
             .dot {
@@ -441,7 +446,7 @@ function partyLogin(from) {
             }
           }
 
-          & + li {
+          &+li {
             border-top: 1px solid #EFF0F1;
           }
 
@@ -530,6 +535,7 @@ function partyLogin(from) {
     }
   }
 }
+
 .login-close {
   position: absolute;
   right: -40px;
@@ -540,6 +546,7 @@ function partyLogin(from) {
   background-size: 30px 30px;
   cursor: pointer;
 }
+
 .login-mask {
   position: fixed;
   left: 0;
@@ -551,6 +558,7 @@ function partyLogin(from) {
   display: flex;
   align-items: center;
   justify-content: center;
+
   .login-box {
     position: relative;
     width: 1065px;
@@ -584,7 +592,7 @@ function partyLogin(from) {
         padding-left: 20px;
         padding-right: 15px;
 
-        & + .form-line {
+        &+.form-line {
           margin-top: 8px;
         }
       }

+ 14 - 5
src/pages/personal/components/main/setting.vue

@@ -74,10 +74,10 @@
           <el-form label-position="top" size="large">
             <el-form-item label="绑定浙里办账号">
               <div class="w-full flex justify-between">
-                <el-input disabled class="flex-auto" v-model="zhbdform.ue_jlb_account"></el-input>
-                <el-button v-show="!zhbdform.ue_jlb_account" @click="handleBindingClick('zlb','bind')" type="primary" class="ml-2 flex-none">绑定
+                <el-input disabled class="flex-auto" v-model="zhbdform.ue_zlb_account"></el-input>
+                <el-button v-show="!zhbdform.ue_zlb_account" @click="handleBindingClick('zlb','bind')" type="primary" class="ml-2 flex-none">绑定
                 </el-button>
-                <el-button v-show="zhbdform.ue_jlb_account" @click="handleBindingClick('zlb','unbind')" type="primary" class="ml-2 flex-none">解绑
+                <el-button v-show="zhbdform.ue_zlb_account" @click="handleBindingClick('zlb','unbind')" type="primary" class="ml-2 flex-none">解绑
                 </el-button>
               </div>
             </el-form-item>
@@ -157,7 +157,7 @@ export default {
       isRead: true,
       commitLoading: false,
       zhbdform: {
-        ue_jlb_account: undefined,
+        ue_zlb_account: undefined,
         ue_jyej_account: undefined
       },
     };
@@ -166,7 +166,16 @@ export default {
     handleBindingClick(from, type) {
       switch (type) {
         case 'bind':
+          if(from==='jyej')
           location.replace(`https://jyyj.zjjxedu.gov.cn:86/edu-manager/login?redirectTo=${window.location.origin}/pending.html?fromType=${from}_${type}_${btoa(location.href)}`)
+          else if(from==='zlb')
+          location.replace(
+            `https://puser.zjzwfw.gov.cn/sso/newusp.do?action=ssoLogin&servicecode=beb8fa1fd85f4963bebf839f0d304d63&redirectUrl=`
+            +
+            encodeURIComponent(
+              `${window.GLOBAL_CONFIG.pend}/openapi/oauth/zlb/checkticket.php?goto=${window.location.origin}/pending.html?fromType=${from}_${type}_${btoa(location.href)}`
+            )
+          )
           break;
         case 'unbind':
           location.replace(`${window.location.origin}/pending.html?fromType=${from}_${type}_${btoa(location.href)}`)
@@ -225,7 +234,7 @@ export default {
             ue_zym: this.userInfo.ext.ue_zym,
           }
           this.zhbdform = {
-            ue_jlb_account: this.userInfo?.ext?.ue_jlb_account,
+            ue_zlb_account: this.userInfo?.ext?.ue_zlb_account,
             ue_jyej_account: this.userInfo?.ext?.ue_jyej_account,
           }
           this.subjectData.map((item) => {

+ 47 - 34
src/pages/personal/components/sz/index.vue

@@ -14,7 +14,7 @@
             <div class="uploadDiv">
               <el-upload class="mainUpload" action="" accept=".png, .jpg, .jpeg" :auto-upload="false"
                 list-type="picture-card" :on-change="handleMainChange" :file-list="fileList">
-                <el-icon size="38" color="#9d9ab9" v-if="fileList.length==0">
+                <el-icon size="38" color="#9d9ab9" v-if="fileList.length == 0">
                   <Picture />
                 </el-icon>
                 <img v-else :src="fileList[0].url" alt="" style="width: 100%;height: 100%;" />
@@ -25,13 +25,13 @@
           <el-form-item label="真实姓名" prop="user_realname">
             <el-input v-model="formline.user_realname" placeholder="请输入真实姓名" />
           </el-form-item>
-          <el-form-item label="学号" prop="stu_code" v-if="this.wholeData.user_role_id==76">
+          <el-form-item label="学号" prop="stu_code" v-if="this.wholeData.user_role_id == 76">
             <el-input v-model="formline.stu_code" placeholder="请输入学号" />
           </el-form-item>
           <el-form-item label="手机号码" prop="user_phone">
             <el-input v-model="formline.user_phone" placeholder="请输入手机号码" />
           </el-form-item>
-          <el-form-item label="任教学科" prop="subject_id" v-if="this.wholeData.user_role_id!=76">
+          <el-form-item label="任教学科" prop="subject_id" v-if="this.wholeData.user_role_id != 76">
             <remote-select v-model="formline.subject_id" to="subject"></remote-select>
           </el-form-item>
           <!-- <el-form-item label="学校" prop="ue_xxmc">
@@ -55,34 +55,38 @@
         </el-form>
       </div>
 
- <!--  -->
- <el-divider></el-divider>
-        <div class="header">
-          <div class="title">账号绑定</div>
-        </div>
-        <div class="formContent" v-loading="loading">
-          <el-form label-position="top" size="large">
-            <el-form-item label="绑定浙里办账号">
-              <div class="w-full flex justify-between">
-                <el-input disabled class="flex-auto" v-model="zhbdform.ue_jlb_account"></el-input>
-                <el-button v-show="!zhbdform.ue_jlb_account" @click="handleBindingClick('zlb','bind')" type="primary" class="ml-2 flex-none">绑定
-                </el-button>
-                <el-button v-show="zhbdform.ue_jlb_account" @click="handleBindingClick('zlb','unbind')" type="primary" class="ml-2 flex-none">解绑
-                </el-button>
-              </div>
-            </el-form-item>
-
-            <el-form-item label="绑定教育E家账号">
-              <div class="w-full flex justify-between">
-                <el-input disabled class="flex-auto" v-model="zhbdform.ue_jyej_account"></el-input>
-                <el-button v-show="!zhbdform.ue_jyej_account" @click="handleBindingClick('jyej','bind')" type="primary" class="ml-2 flex-none">绑定
-                </el-button>
-                <el-button v-show="zhbdform.ue_jyej_account" @click="handleBindingClick('jyej','unbind')" type="primary" class="ml-2 flex-none">解绑
-                </el-button>
-              </div>
-            </el-form-item>
-          </el-form>
-        </div>
+      <!--  -->
+      <el-divider></el-divider>
+      <div class="header">
+        <div class="title">账号绑定</div>
+      </div>
+      <div class="formContent" v-loading="loading">
+        <el-form label-position="top" size="large">
+          <el-form-item label="绑定浙里办账号">
+            <div class="w-full flex justify-between">
+              <el-input disabled class="flex-auto" v-model="zhbdform.ue_zlb_account"></el-input>
+              <el-button v-show="!zhbdform.ue_zlb_account" @click="handleBindingClick('zlb', 'bind')" type="primary"
+                class="ml-2 flex-none">绑定
+              </el-button>
+              <el-button v-show="zhbdform.ue_zlb_account" @click="handleBindingClick('zlb', 'unbind')" type="primary"
+                class="ml-2 flex-none">解绑
+              </el-button>
+            </div>
+          </el-form-item>
+
+          <el-form-item label="绑定教育E家账号">
+            <div class="w-full flex justify-between">
+              <el-input disabled class="flex-auto" v-model="zhbdform.ue_jyej_account"></el-input>
+              <el-button v-show="!zhbdform.ue_jyej_account" @click="handleBindingClick('jyej', 'bind')" type="primary"
+                class="ml-2 flex-none">绑定
+              </el-button>
+              <el-button v-show="zhbdform.ue_jyej_account" @click="handleBindingClick('jyej', 'unbind')" type="primary"
+                class="ml-2 flex-none">解绑
+              </el-button>
+            </div>
+          </el-form-item>
+        </el-form>
+      </div>
 
     </div>
   </div>
@@ -140,7 +144,7 @@ export default {
       mainTip: "",
 
       zhbdform: {
-        ue_jlb_account: undefined,
+        ue_zlb_account: undefined,
         ue_jyej_account: undefined
       },
     };
@@ -149,7 +153,16 @@ export default {
     handleBindingClick(from, type) {
       switch (type) {
         case 'bind':
-          location.replace(`https://jyyj.zjjxedu.gov.cn:86/edu-manager/login?redirectTo=${window.location.origin}/pending.html?fromType=${from}_${type}_${btoa(location.href)}`)
+          if (from === 'jyej')
+            location.replace(`https://jyyj.zjjxedu.gov.cn:86/edu-manager/login?redirectTo=${window.location.origin}/pending.html?fromType=${from}_${type}_${btoa(location.href)}`)
+          else if (from === 'zlb')
+            location.replace(
+              `https://puser.zjzwfw.gov.cn/sso/newusp.do?action=ssoLogin&servicecode=beb8fa1fd85f4963bebf839f0d304d63&redirectUrl=`
+              +
+              encodeURIComponent(
+                `${window.GLOBAL_CONFIG.pend}/openapi/oauth/zlb/checkticket.php?goto=${window.location.origin}/pending.html?fromType=${from}_${type}_${btoa(location.href)}`
+              )
+            )
           break;
         case 'unbind':
           location.replace(`${window.location.origin}/pending.html?fromType=${from}_${type}_${btoa(location.href)}`)
@@ -178,7 +191,7 @@ export default {
           this.formline.subject_id = res.data.subject_id;
           this.formline.user_avatar = res.data.user_avatar;
           this.zhbdform = {
-            ue_jlb_account: this.wholeData?.ext?.ue_jlb_account,
+            ue_zlb_account: this.wholeData?.ext?.ue_zlb_account,
             ue_jyej_account: this.wholeData?.ext?.ue_jyej_account,
           }
           this.loading = false;