七牛云组件更改
This commit is contained in:
parent
364c51b154
commit
df890e5531
|
|
@ -154,7 +154,12 @@ export default {
|
||||||
try {
|
try {
|
||||||
// 确保有token
|
// 确保有token
|
||||||
if (!this.qiniuToken) {
|
if (!this.qiniuToken) {
|
||||||
await this.getQiniuToken()
|
// await this.getQiniuToken()
|
||||||
|
uni.showToast({
|
||||||
|
title: '上传失败',
|
||||||
|
icon: 'error',
|
||||||
|
})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成唯一文件名
|
// 生成唯一文件名
|
||||||
|
|
@ -208,22 +213,22 @@ export default {
|
||||||
async getQiniuToken() {
|
async getQiniuToken() {
|
||||||
try {
|
try {
|
||||||
const res = await getQiniuUploadToken()
|
const res = await getQiniuUploadToken()
|
||||||
console.log('Token响应:', res)
|
console.log('七牛云Token响应:', res)
|
||||||
|
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
// 尝试不同的可能字段名
|
// 尝试不同的可能字段名
|
||||||
const token = res.data
|
const token = res.data
|
||||||
if (token) {
|
if (token) {
|
||||||
this.qiniuToken = token
|
this.qiniuToken = token
|
||||||
console.log('Token获取成功:', token.substring(0, 20) + '...')
|
console.log('七牛云Token获取成功:', token.substring(0, 20) + '...')
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Token字段不存在')
|
throw new Error('七牛云oken字段不存在')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error(res.msg || '获取Token失败')
|
throw new Error(res.msg || '获取七牛云Token失败')
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取Token失败:', error)
|
console.error('获取七牛云Token失败:', error)
|
||||||
this.errorMessage = `获取上传凭证失败: ${error.message}`
|
this.errorMessage = `获取上传凭证失败: ${error.message}`
|
||||||
this.$emit('error', error)
|
this.$emit('error', error)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user