Commit 07f14184 by liang ce

登录流程判定

parent 432f7d0f
import axios from 'axios'
import qs from 'qs'
// axios.defaults.baseURL = 'http://192.168.1.193:8300' // 本地荣
axios.defaults.baseURL = 'http://192.168.1.193:8300' // 本地荣
// axios.defaults.baseURL = 'http://192.168.1.174:8300' // 本地钱
axios.defaults.baseURL = 'http://139.196.213.18:8300' // beta环境
// axios.defaults.baseURL = 'http://139.196.213.18:8300' // beta环境
let loadingInstance // 创建Loading 的实例
// axios.defaults.headers.post['Content-Type'] = 'application/json; charset=utf-8'
// axios.defaults.crossDomain = true
......
......@@ -4,13 +4,13 @@ import qs from 'qs'
import { MINGPAY_CONSTANT } from './constant'
const config = {
ddconfig: () => {
return new Promise((resolve, reject) => {
let senddate = qs.stringify({
version: MINGPAY_CONSTANT.MINGPAY_CONSTANT_VERSION,
url: MINGPAY_CONSTANT.MINGPAY_CONSTANT_URL,
agentId: MINGPAY_CONSTANT.MINGPAY_CONSTANT_AGENTID
})
return axios.post(`http://139.196.213.18:8300/v1/auth/getJsAuthenticationParameter?${senddate}`).then((res) => {
console.log(res)
let agentId = res.data.data.agentId
let timeStamp = res.data.data.timeStamp
let nonceStr = res.data.data.nonceStr
......@@ -30,7 +30,11 @@ const config = {
})
dd.error(function (error) {
console.log('dd error: ' + JSON.stringify(error))
return 'no'
resolve('no')
})
setTimeout(() => {
resolve()
}, 2000)
})
})
},
......@@ -43,6 +47,7 @@ const config = {
},
ddpermission: () => {
// dd.ready参数为回调函数,在环境准备就绪时触发,jsapi的调用需要保证在该回调函数触发后调用,否则无效。
return new Promise((resolve, reject) => {
dd.runtime.permission.requestAuthCode({
corpId: sessionStorage.getItem('corpId'), // 企业id
onSuccess: function (info) {
......@@ -51,17 +56,23 @@ const config = {
code: info.code,
corpId: 'ding9a93ca550f036ffe35c2f4657eb6378f'
})
console.log(senddate)
axios.post(`http://139.196.213.18:8300/v1/auth/token?${senddate}`).then((res) => {
return axios.post(`http://139.196.213.18:8300/v1/auth/token?${senddate}`).then((res) => {
console.log(res)
if (res.data.resultCode === '0') {
sessionStorage.setItem('token', res.data.data.accessToken.access_token)
sessionStorage.setItem('userId', res.data.data.oapiUser.userid)
sessionStorage.setItem('avatar', res.data.data.oapiUser.avatar)
sessionStorage.setItem('name', res.data.data.oapiUser.name)
console.log(res)
resolve('ok')
} else {
resolve('noPermission')
}
}).catch((err) => {
console.log(err)
})
} })
}
})
})
},
ddchooseOne: () => {
return new Promise((resolve, reject) => {
......
const MINGPAY_CONSTANT = {
// MINGPAY_CONSTANT_URL: 'http://mingpay-web-beta.mingwork.com:8888/',
MINGPAY_CONSTANT_URL: 'http://ming.vaiwan.com/',
MINGPAY_CONSTANT_URL: 'http://mingpay-web-beta.mingwork.com:8888/',
// MINGPAY_CONSTANT_URL: 'http://ming.vaiwan.com/',
MINGPAY_CONSTANT_AGENTID: 270198704,
MINGPAY_CONSTANT_VERSION: 'v1'
}
......
<template>
<div class="ConfigError">
<a-layout style="padding: 24px 0; background: #fff">
<h1>获取权限失败</h1>
</a-layout>
<div><img src="../../assets/getTokenError.png"/></div>
<div>
<div style="margin-bottom: 16px">抱歉,获取用户身份失败</div>
<div><a-button type="primary" @click="Re_acquisition()">重试获取</a-button></div>
</div>
</div>
</template>
<script>
export default {
name: 'configError',
name: 'noPermission',
components: {},
data () {
return {}
},
watch: {},
computed: {},
methods: {},
methods: {
Re_acquisition () {
this.$router.push({ name: 'dashboard' })
}
},
mounted () {}
}
</script>
<style scoped>
.ConfigError{
position: fixed;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.ConfigError>div:nth-of-type(2){
font-size: 20px;
}
.ConfigError image {
width: 408px;
height: 308px;
}
.ConfigError>div:nth-of-type(1){
margin-right: 88px;
}
</style>
<template>
<div class="Dashboard">
<a-layout style="padding: 24px 0; background: #fff">
<h1>默认入123123口页面</h1>
<a-layout class="content" style="padding: 24px 0; background: #fff;">
<div><img src="../../assets/Welcome.png"/></div>
<div>欢迎您进入mingwork管理后台</div>
</a-layout>
</div>
</template>
......@@ -19,3 +20,23 @@ export default {
mounted () {}
}
</script>
<style scoped>
.content{
display: flex;
align-items: center;
justify-content: center;
flex-direction: inherit;
height: 500px;
}
.content>div:nth-of-type(2){
font-size: 20px;
}
.content image {
width: 395px;
height: 260px;
}
.content>div:nth-of-type(1){
margin-right: 88px;
}
</style>
<template>
<div class="noPermission">
<div><img src="../../assets/noPrremission.png"/></div>
<div>抱歉,您无访问权限</div>
</div>
</template>
<script>
export default {
name: 'noPermission',
components: {},
data () {
return {}
},
watch: {},
computed: {},
methods: {},
mounted () {}
}
</script>
<style scoped>
.noPermission{
position: fixed;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.noPermission>div:nth-of-type(2){
font-size: 20px;
}
.noPermission image {
width: 402px;
height: 284px;
}
.noPermission>div:nth-of-type(1){
margin-right: 88px;
}
</style>
......@@ -34,23 +34,33 @@ Vue.prototype.$message = message
router.beforeEach(function (to, from, next) {
// 项目初始化进行鉴权
if (to.name === 'noPermission' || to.name === 'configError') {
next()
} else {
if (sessionStorage.getItem('userId')) {
next()
} else {
config.ddconfig().then((res) => {
console.log(res)
if (res === 'no') {
console.log('no', res)
next({ name: 'configError' })
}
}).then(() => {
config.ddready('ddpermission').then((res) => {
console.log('ddpermission', res)
if (res === 'noPermission') {
next({ name: 'noPermission' })
} else {
next()
}
}).then(() => {
config.ddready('ddpermission')
}).catch((err) => {
console.log('ddpermission', err)
})
}).catch((err) => {
console.log(err, '登录失败')
})
}
}
})
new Vue({
......
......@@ -24,11 +24,6 @@ export default new Router({
component: resolve => require(['./components/pages/Dashboard.vue'], resolve)
},
{
path: '/configError',
name: 'configError',
component: resolve => require(['./components/pages/ConfigError.vue'], resolve)
},
{
path: '/paymentManagementHome',
name: 'paymentManagementHome',
component: resolve => require(['./components/pages/PaymentManagement/PaymentManagementHome.vue'], resolve),
......@@ -81,6 +76,11 @@ export default new Router({
path: '/noPermission',
name: 'noPermission',
component: resolve => require(['./components/pages/NoPermission.vue'], resolve)
},
{
path: '/configError',
name: 'configError',
component: resolve => require(['./components/pages/ConfigError.vue'], resolve)
}
]
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment