Browse Source

登录完成

zhangrenyuan/feature-20250623164058-金币前端
lihuilin 2 days ago
parent
commit
a669588ec5
  1. 2
      src/util/request.js
  2. 22
      src/views/login.vue
  3. 14
      src/views/workspace/index.vue

2
src/util/request.js

@ -19,7 +19,7 @@ service.interceptors.request.use(config => {
} else { } else {
config.data = { token }; config.data = { token };
} }
// config.headers.Authorization = `${token}`
config.headers.token = `${token}`
} }
return config return config
}, error => { }, error => {

22
src/views/login.vue

@ -6,27 +6,25 @@ import request from '@/util/http'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { VscGlobe } from 'vue-icons-plus/vsc' import { VscGlobe } from 'vue-icons-plus/vsc'
const router = useRouter() //
// //
var url = window.location.href // var url = window.location.href //
var machineId = null
var machineId1 = ref(null)
// machineId // machineId
function getMachineId() { function getMachineId() {
var parts = url.split('machineId=') var parts = url.split('machineId=')
if (parts.length > 1) { if (parts.length > 1) {
machineId = parts[1].split('&')[0] // &
machineId1 = parts[1].split('&')[0] // &
} }
// machineId = decodeURIComponent(machineId); //machineId
console.log('机器码获取到了吗:', machineId)
if (machineId) {
// machineId1 = decodeURIComponent(machineId1); //machineId
console.log('机器码获取到了吗:', machineId1)
form.value.machineId = machineId1
if (machineId1) {
// machineId // machineId
localStorage.setItem('machineId', machineId)
localStorage.setItem('machineId', machineId1)
} }
} }
const router = useRouter() //
let formData = new FormData()
const form = ref({ account: '', password: '', token: '', machineId: machineId })
const form = ref({ account: '', password: '', token: '', machineId: machineId1.value })
// //
const login = async function () { const login = async function () {
try { try {
@ -34,7 +32,7 @@ const login = async function () {
url: '/admin/login', url: '/admin/login',
data: form.value data: form.value
}) })
console.log('看看传给后端的参数', form)
console.log('看看传给后端的参数', form.value)
if (result.code == 200) { if (result.code == 200) {
localStorage.setItem('token', result.msg) localStorage.setItem('token', result.msg)
// localStorage.setItem('permission', result.data.permission) // localStorage.setItem('permission', result.data.permission)

14
src/views/workspace/index.vue

@ -145,7 +145,8 @@ const selectedType = ref('all')
const tableData = ref([]) const tableData = ref([])
const chartRef = ref(null) const chartRef = ref(null)
let chartInstance = null let chartInstance = null
//
const adminData = ref({})
// //
const currentGold = ref(0) const currentGold = ref(0)
const dailyChange = ref(0) const dailyChange = ref(0)
@ -507,7 +508,15 @@ const handleDateRangeChange = () => {
timeRange.value = 'custom' timeRange.value = 'custom'
loadChart() loadChart()
} }
const getAdminData = async function () {
try {
const result = await API({ url: '/admin/userinfo', data: {} })
adminData.value = result
console.log('用户信息', adminData.value)
} catch (error) {
console.log('请求失败', error)
}
}
// //
const loadChart = () => { const loadChart = () => {
getChartData() getChartData()
@ -530,6 +539,7 @@ const getCardData = async () => {
} }
onMounted(async () => { onMounted(async () => {
await getAdminData()
await getCardData() await getCardData()
await getMarkets() await getMarkets()
handleTimeRangeChange() // handleTimeRangeChange() //

Loading…
Cancel
Save