|
@ -18,6 +18,7 @@ import device from './device'
|
|
import machine from './machine'
|
|
import machine from './machine'
|
|
import {getPublicKey, getHwlyyDecrypt, checkWlyyLogin} from '@/api/login'
|
|
import {getPublicKey, getHwlyyDecrypt, checkWlyyLogin} from '@/api/login'
|
|
import JSEncrypt from "@/utils/jsencrypt";
|
|
import JSEncrypt from "@/utils/jsencrypt";
|
|
|
|
import { Toast } from 'vant'
|
|
Vue.use(VueRouter)
|
|
Vue.use(VueRouter)
|
|
|
|
|
|
const routes = [
|
|
const routes = [
|
|
@ -118,7 +119,11 @@ router.beforeEach(async (to, from, next) => {
|
|
}
|
|
}
|
|
new Promise((resolve, reject)=>{
|
|
new Promise((resolve, reject)=>{
|
|
if(to.query._code){
|
|
if(to.query._code){
|
|
return authLogin(to.query._code, to)
|
|
|
|
|
|
authLogin(to.query._code, to)
|
|
|
|
.then(res=>{
|
|
|
|
Toast.clear()
|
|
|
|
resolve()
|
|
|
|
})
|
|
} else {
|
|
} else {
|
|
resolve()
|
|
resolve()
|
|
}
|
|
}
|
|
@ -141,6 +146,11 @@ router.beforeEach(async (to, from, next) => {
|
|
|
|
|
|
function authLogin(code, to){
|
|
function authLogin(code, to){
|
|
return new Promise((resolve, reject)=>{
|
|
return new Promise((resolve, reject)=>{
|
|
|
|
Toast.loading({
|
|
|
|
message: '授权登录中..',
|
|
|
|
duration: 0,
|
|
|
|
forbidClick: true
|
|
|
|
})
|
|
getHwlyyDecrypt({code: decodeURIComponent(code)})
|
|
getHwlyyDecrypt({code: decodeURIComponent(code)})
|
|
.then(data=>{
|
|
.then(data=>{
|
|
return new Promise((resolve, reject)=>{
|
|
return new Promise((resolve, reject)=>{
|
|
@ -164,7 +174,7 @@ function authLogin(code, to){
|
|
})
|
|
})
|
|
.then(res=>{
|
|
.then(res=>{
|
|
if(res.obj && res.obj.authCode==1){
|
|
if(res.obj && res.obj.authCode==1){
|
|
var userInfo = loginRes.obj.WlyyUserSimple
|
|
|
|
|
|
var userInfo = res.obj.WlyyUserSimple
|
|
userInfo.token = userInfo.accessToken
|
|
userInfo.token = userInfo.accessToken
|
|
userInfo.clientType = to.query.clientType//1 来自i健康app 区域互联网
|
|
userInfo.clientType = to.query.clientType//1 来自i健康app 区域互联网
|
|
store
|
|
store
|