<template> <div class="SpongeCultureCLass"> <van-list v-model:loading="allData.loading" :finished="allData.finished" finished-text="已经到底了~~" :offset="50" @load="lowerRefresh" > <div class="ConstrucClass" v-for="(item, index) in tableData" :key="index"> <div class="MainBox"> <div class="AvatarAppearance"> <div class="zp"> <img :src="item.headImg" alt="" class="txclass" /> </div> <div class="NameTime"> <p class="Namea">{{ item.wechatName }}</p> <p class="Timea">{{ item.publishTime }}</p> </div> </div> <div class="below"> <p class="belowNr"> {{ item.opinion }} </p> <div class="belowZp"> <img v-for="(item1, index) in item.filelist" :key="index" :src="item1.url" style="width: 100px; height: 50px; margin-top: 5px; padding-left: 5px" @click="clickImg(item1)" /> </div> </div> </div> </div> </van-list> <div class="rotundity" @click="sayClick"> <p>我想说</p> </div> </div> <van-form @submit="onSubmitData"> <van-popup v-model:show="allData.showCancel" position="bottom" closeable :style="{ width: '100%', height: '70%' }"> <div class="popup_tittle"> <div class="tittle">留言</div> </div> <van-cell-group> <!-- <van-field v-model="allData.paramsDate.text" label="留言标题" placeholder="请输入留言标题" show-word-limit required :rules="[{ required: true, message: '请输入留言标题' }]" :key="fieldKey" /> --> <van-field v-model="allData.paramsDate.opinion" rows="1" label="留言描述" type="textarea" maxlength="100" placeholder="请输入留言描述" show-word-limit required :rules="[{ required: true, message: '请输入留言描述' }]" style="margin-top: 10px" :key="fieldKey" /> </van-cell-group> <div class="mediumList"> <span class="Title">现场图片(最多3张)</span> <div class="picBox"> <UploadImg :maxCount="3" :saveFileArr="allData.paramsDate.filelist" :acceptFormat="'image/*'" @update:saveFileArr="getImgList" /> </div> </div> <div class="BottomView"> <van-button @click="closeDaKa" class="BotBtn">返回</van-button> <van-button native-type="submit" class="BotBtn" type="primary">提交</van-button> </div> </van-popup> </van-form> </template> <script setup> import { peopleOpinionPage, peopleOpinionAdd } from '@/api/PublicAdvice.js'; import UploadImg from '@/views/components/uploadFile.vue'; import { useRouter } from 'vue-router'; import { showImagePreview } from 'vant'; const { proxy } = getCurrentInstance(); const router = useRouter(); const fieldKey = ref(0); const tableData = ref([]); const allData = reactive({ newslist: [], loading: false, finished: false, showCancel: false, paramsDate: { opinion: '', // text: '', filelist: [], //获取的图片数组 }, ListPage: { page: 1, size: 10, total: 0, //当前接口返回数据的总条数 }, }); //分页pageNum+1 const lowerRefresh = (e) => { console.log(allData.ListPage.page, 'allData.ListPage.page'); if (allData.ListPage.total > tableData.value.length) { allData.ListPage.page++; getDataList(); } else { allData.finished = true; allData.loading = false; } }; /** 获取查询数据列表 */ function getDataList(bol) { allData.finished = false; allData.loading = true; if (bol) { // 初始化分页 allData.ListPage.page = 1; allData.ListPage.size = 10; } let params = { pageNum: allData.ListPage.page, pageSize: allData.ListPage.size, }; peopleOpinionPage(params).then((response) => { tableData.value = response.data; allData.ListPage.total = response.total; // 加载状态结束 状态更新为false allData.loading = false; }); } // 点击预览大图//照片弹框 function clickImg(url) { showImagePreview([url.url]); } // 我想说点击事件 function sayClick() { allData.showCancel = true; } // 获取上传的图片 function getImgList(e) { e.forEach((item) => { item.refField = 'commentPhotos'; }); allData.paramsDate.filelist = e; } // 取消按钮 function closeDaKa() { allData.showCancel = false; allData.paramsDate = {}; fieldKey.value++; } // 提交上报 const onSubmitData = async () => { console.log('表单数据信息:', allData.paramsDate); peopleOpinionAdd(allData.paramsDate).then((response) => { allData.showCancel = false; getDataList(); }); }; onMounted(() => { getDataList(); }); </script> <style lang="less"> .SpongeCultureCLass { height: 100%; overflow: auto; background: #f1f1f1; .ConstrucClass { margin: 30px 20px 30px 20px; padding: 20px; display: flex; align-items: center; background: #ffffff; .MainBox { width: 100%; .AvatarAppearance { width: 100%; height: 120px; display: flex; justify-content: space-around; border-bottom: 1px solid #eaeaea; .zp { width: 20%; height: 120px; // background: red; .txclass { width: 80px; height: 80px; border-radius: 50px; position: relative; top: 18px; left: 25px; } } .NameTime { width: 80%; height: 60px; .Namea { width: 100%; color: rgba(18, 18, 18, 1); font-family: Source Han Sans CN; font-weight: bold; font-size: 28px; // background: red; } .Timea { width: 100%; font-family: Source Han Sans CN; font-weight: 400; font-size: 22px; color: #7b7b7e; } } } .below { width: 100%; padding-bottom: 10px; // background: red; .belowNr { width: 95%; font-family: Source Han Sans CN; font-weight: 400; font-size: 24px; color: #121212; margin-left: 15px; // background: yellow; } .belowZp { margin-left: 15px; display: inline-block; // background: red; } } } } .rotundity { width: 120px; height: 120px; background: rgba(20, 91, 247, 1); border-radius: 100px; position: absolute; bottom: 120px; right: 20px; display: flex; justify-content: center; align-items: center; p { font-family: Source Han Sans CN; font-weight: 500; font-size: 24px; color: #ffffff; } } } .popup_tittle { display: flex; align-items: center; justify-items: center; // justify-content: space-between; padding: 15px; height: 100px; // background: red; .tittle { font-size: 40px; font-weight: bold; } } .BottomView { width: 100%; height: 120px; display: flex; justify-content: space-around; margin-top: 20px; .BotBtn { width: 45%; } } .mediumList { width: 100%; height: auto; .Title { width: 100%; height: 60px; line-height: 60px; display: inline-block; } .picBox { width: 100%; height: auto; } } </style>