七牛云组件更改

This commit is contained in:
WindowBird 2025-09-10 15:00:34 +08:00
parent 364c51b154
commit df890e5531

View File

@ -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)
} }