添加需求时需要携带token,修改为添加token
This commit is contained in:
parent
031f14f7f0
commit
7e6c2a1740
@ -180,6 +180,7 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, nextTick } from 'vue'
|
||||
import axiosInstance from '../../api/axiosConfig'
|
||||
|
||||
// 响应式数据
|
||||
const demands = ref([])
|
||||
@ -299,25 +300,23 @@ async function submitAddForm() {
|
||||
const now = new Date();
|
||||
const dateStr = `${now.getFullYear()}-${(now.getMonth()+1).toString().padStart(2,'0')}-${now.getDate().toString().padStart(2,'0')} ${now.getHours().toString().padStart(2,'0')}:${now.getMinutes().toString().padStart(2,'0')}:${now.getSeconds().toString().padStart(2,'0')}`;
|
||||
const payload = {
|
||||
requester: addForm.value.requester , // 如果requester为空,则使用qq_code
|
||||
requester: addForm.value.requester,
|
||||
sendcontent: addForm.value.sendcontent,
|
||||
content: addForm.value.sendcontent,
|
||||
reward: addForm.value.reward,
|
||||
date: dateStr,
|
||||
qq_code: addForm.value.qq_code
|
||||
};
|
||||
const response = await fetch('http://zybdatasupport.online:8000/demands/add', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload)
|
||||
})
|
||||
if (!response.ok) throw new Error('提交失败')
|
||||
showAddModal.value = false
|
||||
fetchDemands() // 刷新列表
|
||||
const response = await axiosInstance.post('/demands/add', payload);
|
||||
if (response.status === 200) {
|
||||
showAddModal.value = false;
|
||||
fetchDemands(); // 刷新列表
|
||||
}
|
||||
} catch (e) {
|
||||
addError.value = '提交失败,请稍后重试'
|
||||
console.error('提交失败:', e);
|
||||
addError.value = e.response?.data?.detail || '提交失败,请稍后重试';
|
||||
} finally {
|
||||
addLoading.value = false
|
||||
addLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user