flat: 123

This commit is contained in:
Apcallover
2024-03-20 17:16:16 +08:00
parent 53cfc53ba8
commit 36ed184cd4
7 changed files with 41 additions and 7 deletions

32
App.vue
View File

@@ -3,6 +3,7 @@
@import "@/uni_modules/uview-ui/index.scss";
</style>
<script>
import website from '@/config/website.js'
import {
mapGetters
} from 'vuex'
@@ -13,8 +14,35 @@
// #endif
export default {
onLaunch: function() {
if (this.$store.state.user.token) {
onLaunch: function(options) {
console.log(options.query)
if(options.query.token) {
const { token } = options
this.$store.dispatch("LoginByUsername", {
username: 'admin',
password: "admin",
key: '',
code: '1111',
type: "account",
token: options.query.token,
tenantId: website.tenantId
}).then((resp) => {
this.$store.dispatch('refreshAuthState').then(() => {
that.loading = false
var auth = this.auth
if (!auth.bankCardState) {
that.goSign(0)
} else {
uni.switchTab({
url: '/pages/index/index'
})
}
})
}).catch((err) => {
this.loading = false
// this.$refs.code.refushCode()
});
} else if (this.$store.state.user.token) {
this.$store.dispatch('startRefreshTokenTimer')
this.$store.dispatch('startRefreshNewsTimer')
this.$store.dispatch('refreshAuthState')

View File

@@ -6,7 +6,7 @@ import {
} from '@/untils/store.js'
import website from "@/config/website";
export const loginByUsername = (tenantId, username, password, type, key, code) => request({
export const loginByUsername = (tenantId, username, password, type, key, code, token) => request({
url: '/api/jobslink-auth/oauth/token',
method: 'post',
headers: {
@@ -24,7 +24,10 @@ export const loginByUsername = (tenantId, username, password, type, key, code) =
grant_type: (website.captchaMode ? "captcha" : "password"),
scope: "all",
type
}
},
data: {
token
}
});
export const refreshToken = (refresh_token, tenantId) => request({

View File

@@ -79,7 +79,6 @@
icon:'none',
})
} else {
debugger
var that = this
this.loading = true
this.$store.dispatch("LoginByUsername", {

View File

@@ -301,6 +301,7 @@ const news = {
commit,
dispatch
}) {
console.log('触发2')
dispatch('newsInit').then(() => {
startRefreshToken(dispatch);
})

View File

@@ -283,6 +283,7 @@ const news = {
stopRefreshToken();
},
startRefreshNewsTimer({ state, commit, dispatch }) {
console.log('触发1')
dispatch("newsInit").then(() => {
startRefreshToken(dispatch);
});

View File

@@ -75,7 +75,7 @@ const user = {
}, userInfo) {
return new Promise((resolve, reject) => {
loginByUsername(userInfo.tenantId, userInfo.username, md5(userInfo.password), userInfo.type, userInfo.key,
userInfo.code).then(res => {
userInfo.code, userInfo.token).then(res => {
const data = res.data;
if (data.error_description) {
uni.showToast({
@@ -88,6 +88,7 @@ const user = {
commit('SET_TENANT_ID', data.tenant_id);
commit('SET_USER_INFO', data);
dispatch('refreshAuthState')
cons.log('开始1')
dispatch('startRefreshNewsTimer')
startRefreshToken();
}

View File

@@ -4,7 +4,8 @@ module.exports = {
proxy: {
'/api': {
// target: 'http://192.168.3.108:8000', // 本地服务接口地址
target: 'http://192.168.3.173:8000', // 本地服务接口地址
target: 'http://192.168.3.112:8000', // 本地服务接口地址
// target: 'http://10.165.0.173:8000', // 本地服务接口地址
ws: true,
pathRewrite: {
'^/api': '/'