From 038e56a26d6b399134e70a8d708b4d837d737de6 Mon Sep 17 00:00:00 2001 From: zmj <1493694146@qq.com> Date: Mon, 13 May 2024 19:28:05 +0800 Subject: [PATCH] add --- api/feedBack.js | 9 +++++++++ pageQuota/feedBack/index.vue | 37 +++++++++++++++++++++++++----------- pageQuota/feedBack/list.vue | 9 +++++++++ 3 files changed, 44 insertions(+), 11 deletions(-) create mode 100644 api/feedBack.js diff --git a/api/feedBack.js b/api/feedBack.js new file mode 100644 index 0000000..0243b82 --- /dev/null +++ b/api/feedBack.js @@ -0,0 +1,9 @@ +import request from '@/utils/request'; + +export const addFeedBackApi = (data) => { + return request.post('/user/userfeedback/add', data); +} + +export const userfeedbackListApi = (data) => { + return request.get('/user/userfeedback/lists', data); +} \ No newline at end of file diff --git a/pageQuota/feedBack/index.vue b/pageQuota/feedBack/index.vue index 920bb2b..f8ee779 100644 --- a/pageQuota/feedBack/index.vue +++ b/pageQuota/feedBack/index.vue @@ -64,6 +64,13 @@ import { config } from "@/config/app.js" + + import { + addFeedBackApi, + userfeedbackListApi + } from "@/api/feedBack.js" + + import useUserStore from '@/store/user'; const userStore = useUserStore(); @@ -83,6 +90,7 @@ images: [], name: "", contact: "", + uid: userStore.userInfo.id }) @@ -94,20 +102,20 @@ // 上传 - const fileList1 = ref([]); + // const formData.images = ref([]); // 删除图片 const deletePic = (event) => { - fileList1.value.splice(event.index, 1); + formData.images.value.splice(event.index, 1); }; // 新增图片 const afterRead = async (event) => { // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式 let lists = [].concat(event.file); - let fileListLen = fileList1.value.length; + let fileListLen = formData.images.length; lists.map((item) => { - fileList1.value.push({ + formData.images.push({ ...item, status: 'uploading', message: '上传中', @@ -115,11 +123,9 @@ }); for (let i = 0; i < lists.length; i++) { const result = await uploadFilePromise(lists[i].url); - let item = fileList1.value[fileListLen]; - fileList1.value.splice(fileListLen, 1, { - ...item, - status: 'success', - message: '', + console.log(result) + let item = formData.images[fileListLen]; + formData.images.splice(fileListLen, 1, { url: result, }); fileListLen++; @@ -137,14 +143,23 @@ }, success: (res) => { setTimeout(() => { - resolve(res.data.data); + resolve(JSON.parse(res.data).data.uri); }, 1000); }, }); }); }; - const submit = () => { + console.log() + const submit = async () => { + formData.images = formData.images.map(item => { + return item.url + }) + + await addFeedBackApi({ + ...formData + }) + uni.showToast({ title: '提交成功', duration: 2000 diff --git a/pageQuota/feedBack/list.vue b/pageQuota/feedBack/list.vue index bf76597..22d0844 100644 --- a/pageQuota/feedBack/list.vue +++ b/pageQuota/feedBack/list.vue @@ -19,6 +19,15 @@