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