This commit is contained in:
zmj 2024-05-13 19:28:05 +08:00
parent babdd302f2
commit 038e56a26d
3 changed files with 44 additions and 11 deletions

9
api/feedBack.js Normal file
View File

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

View File

@ -64,6 +64,13 @@
import { import {
config config
} from "@/config/app.js" } from "@/config/app.js"
import {
addFeedBackApi,
userfeedbackListApi
} from "@/api/feedBack.js"
import useUserStore from '@/store/user'; import useUserStore from '@/store/user';
const userStore = useUserStore(); const userStore = useUserStore();
@ -83,6 +90,7 @@
images: [], images: [],
name: "", name: "",
contact: "", contact: "",
uid: userStore.userInfo.id
}) })
@ -94,20 +102,20 @@
// //
const fileList1 = ref([]); // const formData.images = ref([]);
// //
const deletePic = (event) => { const deletePic = (event) => {
fileList1.value.splice(event.index, 1); formData.images.value.splice(event.index, 1);
}; };
// //
const afterRead = async (event) => { const afterRead = async (event) => {
// mutiple true , file // mutiple true , file
let lists = [].concat(event.file); let lists = [].concat(event.file);
let fileListLen = fileList1.value.length; let fileListLen = formData.images.length;
lists.map((item) => { lists.map((item) => {
fileList1.value.push({ formData.images.push({
...item, ...item,
status: 'uploading', status: 'uploading',
message: '上传中', message: '上传中',
@ -115,11 +123,9 @@
}); });
for (let i = 0; i < lists.length; i++) { for (let i = 0; i < lists.length; i++) {
const result = await uploadFilePromise(lists[i].url); const result = await uploadFilePromise(lists[i].url);
let item = fileList1.value[fileListLen]; console.log(result)
fileList1.value.splice(fileListLen, 1, { let item = formData.images[fileListLen];
...item, formData.images.splice(fileListLen, 1, {
status: 'success',
message: '',
url: result, url: result,
}); });
fileListLen++; fileListLen++;
@ -137,14 +143,23 @@
}, },
success: (res) => { success: (res) => {
setTimeout(() => { setTimeout(() => {
resolve(res.data.data); resolve(JSON.parse(res.data).data.uri);
}, 1000); }, 1000);
}, },
}); });
}); });
}; };
const submit = () => { console.log()
const submit = async () => {
formData.images = formData.images.map(item => {
return item.url
})
await addFeedBackApi({
...formData
})
uni.showToast({ uni.showToast({
title: '提交成功', title: '提交成功',
duration: 2000 duration: 2000

View File

@ -19,6 +19,15 @@
</template> </template>
<script setup> <script setup>
import {
userfeedbackListApi
} from "@/api/feedBack.js"
userfeedbackListApi().then(res => {
console.log(res)
})
const goDetail = () => { const goDetail = () => {
uni.navigateTo({ uni.navigateTo({
url: '/pageQuota/feedBack/detail' url: '/pageQuota/feedBack/detail'