修改网络请求,登录,用户查询,用户菜单
This commit is contained in:
parent
34a9071405
commit
12a7d931f1
@ -1,7 +1,7 @@
|
||||
VITE_ENV = 'development'
|
||||
VITE_BASE_API = 'http://39.105.121.219'
|
||||
#VITE_BASE_API = 'http://127.0.0.1'
|
||||
#VITE_BASE_API = 'http://39.105.121.219'
|
||||
VITE_BASE_API = 'http://127.0.0.1'
|
||||
#VITE_BASE_API = 'http://api.jsyzhineng.com'
|
||||
|
||||
VITE_APP_BASE_API = '/dev-api'
|
||||
VITE_BASE_MQTT = '39.105.121.219:8083/mqtt'
|
||||
#VITE_BASE_MQTT = '8.130.77.146:8083/mqtt'
|
10
api/login.js
10
api/login.js
@ -1,15 +1,15 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 登录方法
|
||||
export function login(loginName, password, code, uuid) {
|
||||
export function login(username, password, code, uuid) {
|
||||
return request({
|
||||
url: '/login/user/app',
|
||||
url: '/auth/loginApp',
|
||||
headers: {
|
||||
isToken: false
|
||||
},
|
||||
method: 'post',
|
||||
data: {
|
||||
loginName,
|
||||
username,
|
||||
password,
|
||||
code,
|
||||
uuid
|
||||
@ -37,7 +37,7 @@ export function phoneLogin(data) {
|
||||
//查询用户的菜单权限
|
||||
export function userRoles() {
|
||||
return request({
|
||||
url: '/app/getRouters',
|
||||
url: '/system/role/getRoleMenu',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
@ -57,7 +57,7 @@ export function register(data) {
|
||||
// 获取用户详细信息
|
||||
export function getInfo() {
|
||||
return request({
|
||||
url: '/getInfo',
|
||||
url: '/system/user/getInfo',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
// 应用全局配置
|
||||
const config = {
|
||||
port: 9000,
|
||||
port: 3006,
|
||||
baseUrl: '',
|
||||
// 应用信息
|
||||
appInfo: {
|
||||
|
@ -14,6 +14,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"jsencrypt": "^3.3.2",
|
||||
"mqtt": "^3.0.0"
|
||||
"mqtt": "^3.0.0",
|
||||
"axios": "0.28.1"
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@
|
||||
if (uni.getStorageSync("jsy_remember") === true) {
|
||||
rememberPassword.value = true
|
||||
loginForm.value.loginName = uni.getStorageSync("jsy_username")
|
||||
loginForm.value.password = rsaDecrypt(uni.getStorageSync("jsy_password"))
|
||||
loginForm.value.password = uni.getStorageSync("jsy_password")
|
||||
}
|
||||
// //页面加载完后,重置这个参数
|
||||
// getApp().globalData.updateApp = false;
|
||||
@ -210,7 +210,6 @@
|
||||
setCodeTimer();
|
||||
}, 3000)
|
||||
|
||||
return;
|
||||
store
|
||||
.dispatch("onGetCodePhone", loginForm.value.phone)
|
||||
.then(res => {
|
||||
@ -291,7 +290,7 @@
|
||||
url: "Login",
|
||||
data: {
|
||||
loginName: loginObj.loginName,
|
||||
password: rsaEncrypt(loginObj.password)
|
||||
password: loginObj.password
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -326,7 +325,7 @@
|
||||
if (rememberPassword.value) {
|
||||
uni.setStorageSync("jsy_remember", true)
|
||||
uni.setStorageSync("jsy_username", loginForm.value.loginName)
|
||||
uni.setStorageSync("jsy_password", rsaEncrypt(loginForm.value.password))
|
||||
uni.setStorageSync("jsy_password", loginForm.value.password)
|
||||
} else {
|
||||
uni.removeStorageSync("jsy_remember")
|
||||
uni.removeStorageSync("jsy_username")
|
||||
|
@ -108,7 +108,7 @@
|
||||
</view> -->
|
||||
</view>
|
||||
<view class="menu-list">
|
||||
<view class="list-cell list-cell-arrow" style="border-radius: 10px;">
|
||||
<view class="list-cell list-cell-arrow" style="border-radius: 10px;" @click="handleToSetting">
|
||||
<view class="menu-item-box">
|
||||
<view class="iconfont icon-shezhi menu-icon"></view>
|
||||
<view>设置</view>
|
||||
|
@ -70,8 +70,9 @@ const user = {
|
||||
return new Promise((resolve, reject) => {
|
||||
login(loginName, password, code, uuid)
|
||||
.then(res => {
|
||||
setToken(res.token)
|
||||
commit("SET_TOKEN", res.token)
|
||||
console.log(res)
|
||||
setToken(res.data.access_token)
|
||||
commit("SET_TOKEN", res.data.access_token)
|
||||
resolve(res)
|
||||
})
|
||||
.catch(error => {
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
import store from "@/store"
|
||||
import {
|
||||
getToken
|
||||
@ -11,15 +12,12 @@ import {
|
||||
|
||||
let timeout = 10000
|
||||
const request = config => {
|
||||
let baseUrl
|
||||
if (config.port && config.port == 9001) {
|
||||
baseUrl = import.meta.env.VITE_BASE_API + ":9001"
|
||||
} else {
|
||||
baseUrl = import.meta.env.VITE_BASE_API + ":9000"
|
||||
}
|
||||
// 创建axios实例
|
||||
let baseUrl = import.meta.env.VITE_BASE_API+":3006"+import.meta.env.VITE_APP_BASE_API;
|
||||
// 是否需要设置 token
|
||||
const isToken = (config.headers || {}).isToken === false
|
||||
config.header = config.header || {}
|
||||
console.log(getToken())
|
||||
if (getToken() && !isToken) {
|
||||
config.header["Authorization"] = "Bearer " + getToken()
|
||||
}
|
||||
@ -39,6 +37,7 @@ const request = config => {
|
||||
dataType: "json"
|
||||
})
|
||||
.then(response => {
|
||||
console.log(response)
|
||||
const res = response
|
||||
const code = res.data.code || 200
|
||||
const msg = errorCode[code] || res.data.msg || errorCode["default"]
|
||||
|
@ -1,13 +1,25 @@
|
||||
import {defineConfig} from 'vite'
|
||||
import {
|
||||
defineConfig
|
||||
} from 'vite'
|
||||
import uni from '@dcloudio/vite-plugin-uni'
|
||||
|
||||
export default defineConfig(() => {
|
||||
return {
|
||||
server: {
|
||||
port: '3002'
|
||||
},
|
||||
plugins: [
|
||||
uni()
|
||||
],
|
||||
}
|
||||
})
|
||||
return {
|
||||
server: {
|
||||
port: '3006',
|
||||
host: '0.0.0.0',
|
||||
open: true,
|
||||
proxy: {
|
||||
// https://cn.vitejs.dev/config/#server-proxy
|
||||
'/dev-api': {
|
||||
target: 'http://localhost:8088',
|
||||
changeOrigin: true,
|
||||
rewrite: (p) => p.replace(/^\/dev-api/, '')
|
||||
}
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
uni()
|
||||
],
|
||||
}
|
||||
})
|
Loading…
Reference in New Issue
Block a user