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"; @import "@/uni_modules/uview-ui/index.scss";
</style> </style>
<script> <script>
import website from '@/config/website.js'
import { import {
mapGetters mapGetters
} from 'vuex' } from 'vuex'
@@ -13,8 +14,35 @@
// #endif // #endif
export default { export default {
onLaunch: function() { onLaunch: function(options) {
if (this.$store.state.user.token) { 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('startRefreshTokenTimer')
this.$store.dispatch('startRefreshNewsTimer') this.$store.dispatch('startRefreshNewsTimer')
this.$store.dispatch('refreshAuthState') this.$store.dispatch('refreshAuthState')

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -4,7 +4,8 @@ module.exports = {
proxy: { proxy: {
'/api': { '/api': {
// target: 'http://192.168.3.108:8000', // 本地服务接口地址 // 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, ws: true,
pathRewrite: { pathRewrite: {
'^/api': '/' '^/api': '/'