generated from Leo_Ding/web-template
修改
This commit is contained in:
commit
ae489532cc
@ -1,5 +1,5 @@
|
|||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
import axios from 'axios'
|
||||||
// 获取地区
|
// 获取地区
|
||||||
export const getRegion = (params) => request.basic.get('/region', params)
|
export const getRegion = (params) => request.basic.get('/region', params)
|
||||||
|
|
||||||
@ -10,4 +10,10 @@ export const getCaptcha = (params) => request.basic.get('/api/v1/captcha/id', pa
|
|||||||
export const getCaptchaImage = (params) => request.basic.get('/api/v1/captcha/image', params , { responseType: 'blob' })
|
export const getCaptchaImage = (params) => request.basic.get('/api/v1/captcha/image', params , { responseType: 'blob' })
|
||||||
|
|
||||||
//上传图片
|
//上传图片
|
||||||
export const uploadImg=(params)=>request.basic.post('/api/v1/upload',params,{Headers:{'Content-Type': 'multipart/form-data'}})
|
// export const uploadImg=(params)=>request.basic.post('/api/v1/upload',params,{Headers:{'Authorization':'','Content-Type': 'multipart/form-data'}})
|
||||||
|
export const uploadImg=(params)=>axios.post('https://zh.shibeitong.com/api/v1/upload',params,{
|
||||||
|
headers: {
|
||||||
|
'Authorization':'',
|
||||||
|
'Content-Type': 'multipart/form-data'
|
||||||
|
},
|
||||||
|
})
|
||||||
@ -95,11 +95,24 @@ onMounted(() => {
|
|||||||
* 获取 验证码ID
|
* 获取 验证码ID
|
||||||
*/
|
*/
|
||||||
async function getCaptcha() {
|
async function getCaptcha() {
|
||||||
const { data } = await apis.common.getCaptcha().catch((err) => {
|
try {
|
||||||
console.log(err)
|
// 1. 获取 captcha_id
|
||||||
})
|
const response = await apis.common.getCaptcha()
|
||||||
|
const data = response.data
|
||||||
|
if (!data?.captcha_id) {
|
||||||
|
console.warn('验证码ID缺失')
|
||||||
|
return
|
||||||
|
}
|
||||||
captcha_id.value = data.captcha_id
|
captcha_id.value = data.captcha_id
|
||||||
captcha_img.value = httpApi + `?id=${data.captcha_id}`
|
const imageResponse = await apis.common.getCaptchaImage({ id: data.captcha_id,reload:1 })
|
||||||
|
console.log('Blob 对象:', imageResponse)
|
||||||
|
const blobUrl = URL.createObjectURL(imageResponse)
|
||||||
|
captcha_img.value = blobUrl
|
||||||
|
console.log('验证码图片URL:', blobUrl)
|
||||||
|
} catch (err) {
|
||||||
|
console.error('获取验证码失败:', err)
|
||||||
|
captcha_img.value = ''
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 登录
|
* 登录
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user