Commit 07f14184 by liang ce

登录流程判定

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