获取个人消息接口联调
This commit is contained in:
parent
925d56c48a
commit
94a533eb75
|
@ -534,18 +534,18 @@ const projectGetCustom = (data) =>{
|
||||||
* 展示全部消息
|
* 展示全部消息
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const messageGetAll = (token) => {
|
const messageGet = (token) => {
|
||||||
return axios({
|
return axios({
|
||||||
url:api + "/message/get/all",
|
url:api + "/message/get",
|
||||||
method:"get",
|
method:"get",
|
||||||
headers:{
|
headers:{
|
||||||
'Authorization':'Bearer '+token,
|
'Authorization':'Bearer '+token,
|
||||||
|
'content-type': 'application/json;charset=utf-8',
|
||||||
'Timestamp': getCurrentTimestamp()
|
'Timestamp': getCurrentTimestamp()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
login,
|
login,
|
||||||
register,
|
register,
|
||||||
|
@ -584,6 +584,6 @@ export default {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
messageGetAll
|
messageGet
|
||||||
|
|
||||||
}
|
}
|
|
@ -31,37 +31,15 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="(message, index) in messages" :key="index" class="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
|
<tr v-for="(message, index) in messages" :key="index" class="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
|
||||||
<th class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white" scope="row">
|
<th class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white" scope="row">
|
||||||
{{ message.uid }}
|
{{ message.title }}
|
||||||
</th>
|
</th>
|
||||||
<td class="px-6 py-4">
|
<td class="px-6 py-4">
|
||||||
{{ message.createdAt }}
|
{{ message.text }}
|
||||||
</td>
|
|
||||||
<td class="px-6 py-4 flex justify-end">
|
|
||||||
<a-button class="flex justify-center items-center" type="link"><DeleteOutlined />删除</a-button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
|
|
||||||
<th class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white" scope="row">
|
|
||||||
小明老师
|
|
||||||
</th>
|
|
||||||
<td class="px-6 py-4">
|
|
||||||
时间
|
|
||||||
</td>
|
</td>
|
||||||
<td class="px-6 py-4 flex justify-end">
|
<td class="px-6 py-4 flex justify-end">
|
||||||
<a-button class="flex justify-center items-center" type="link" @click="deleteMessage(message.id)"><DeleteOutlined />删除</a-button>
|
<a-button class="flex justify-center items-center" type="link" @click="deleteMessage(message.id)"><DeleteOutlined />删除</a-button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class=" bg-white border-b dark:bg-gray-800 dark:border-gray-700">
|
|
||||||
<th class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white" scope="row">
|
|
||||||
小明老师
|
|
||||||
</th>
|
|
||||||
<td class="px-6 py-4">
|
|
||||||
时间
|
|
||||||
</td>
|
|
||||||
<td class="px-6 py-4 flex justify-end">
|
|
||||||
<a-button class="flex justify-center items-center" type="link"><DeleteOutlined />删除</a-button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
@ -81,23 +59,27 @@ const messages = ref([]); // 使用ref创建响应式数据
|
||||||
|
|
||||||
|
|
||||||
onMounted(() =>{
|
onMounted(() =>{
|
||||||
messageGetAll();
|
/*requests.userGetProfile(token).then((res)=>{
|
||||||
|
const data = {
|
||||||
|
"uid": res.data.data.id,
|
||||||
|
"begin": "",
|
||||||
|
"end": "",
|
||||||
|
"page": "",
|
||||||
|
"pageSize": ""
|
||||||
|
}*/
|
||||||
|
|
||||||
|
request.messageGet(token).then((res) => {
|
||||||
|
messages.value = res.data.data.rows;
|
||||||
|
})
|
||||||
|
/* });*/
|
||||||
})
|
})
|
||||||
|
|
||||||
function messageGetAll() {
|
|
||||||
request.messageGetAll(token).then((res) => {
|
|
||||||
// 假设返回的res是你想要的数据数组
|
|
||||||
messages.value = res.data.data; // 更新messages
|
|
||||||
}).catch(error => {
|
|
||||||
console.error("Failed to fetch messages:", error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const deleteMessage = (messageId) => {
|
const deleteMessage = (id) => {
|
||||||
// 这里调用后端接口删除消息
|
// 这里调用后端接口删除消息
|
||||||
console.log("Deleting message with id:", messageId);
|
console.log("Deleting message with id:", id);
|
||||||
// 假设删除成功,从messages中移除这条消息
|
// 假设删除成功,从messages中移除这条消息
|
||||||
messages.value = messages.value.filter(message => message.id !== messageId);
|
messages.value = messages.value.filter(message => message.id !== id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user