123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964 |
- <script setup lang="ts">
- import CpmdHeader from '@/components/CpmdHeader.vue';
- import { onMounted, onUnmounted, ref } from 'vue'
- import { userInfoStore } from '@/stores'
- import { getUnread } from '../utils/test'
- //持久化设置 菜单状态
- import { menuStatusStore } from '@/stores'
- import { ElMessage } from 'element-plus';
- import { pubMsgApi, queryMsgApi, queryMsgApi1, subPubMsgApi } from '@/api/plan';
- import { number } from 'echarts';
- import { fa } from 'element-plus/es/locales.mjs';
- const menuStatus = menuStatusStore();
- menuStatus.saveActiveIndex('3')
- const subMM = ref<string>('')
- //获取缓存用户信息
- const userInfo = userInfoStore();
- //显示发布评论的弹出框
- const pub_visible = ref<boolean>(false)
- //显示查看子评论的弹出框
- const sub_visible = ref<boolean>(false)
- //用户姓名
- const userName = ref<string>('')
- //用户性别
- const userSex = ref<string>('')
- //用户编号
- const userNo = ref<string>('')
- //用户发送的信息
- const user_msg = ref<string>('')
- //输入框样式
- const des_input = ref<any>()
- //防止重复点
- const isLock = ref<boolean>(false)
- //刚进入页面就将高度设置为页面需要的
- onMounted(() => {
- userName.value = userInfo.userInfo.userName;
- userNo.value = userInfo.userInfo.userNo;
- userSex.value = userInfo.userInfo.gender;
- //进到界面开始轮询
- // queryMsg()
- if (userInfo.token) {
- getUnread()
- }
- })
- //界面销毁函数
- const parentId = ref<string>('')
- const pageNum = ref<number>(1)
- const pageSize = ref<number>(10)
- //数据总共多少条
- const totol = ref<number>(0)
- //显示是否是在加载中
- const isLoading = ref<boolean>(false)
- //是否显示noMore
- const noMore = ref<boolean>(false)
- const list = ref<any>([])
- const queryMsg = async () => {
- let params = {
- pageNum: pageNum.value,
- pageSize: pageSize.value
- }
- let res: any = await queryMsgApi(params)
- if (res.code == 200) {
- // 将值赋值给列表
- if (res.data.content.length > 0) {
- list.value.push(...res.data.content)
- totol.value = res.data.totalElements
- } else {
- //显示没有更多了
- list.value = []
- totol.value = 0
- noMore.value = true
- // totalElements
- }
- }
- }
- //获取数据报
- const getData = async () => {
- //判断总条数是否大于当前页面的数据
- //先判断
- if (totol.value < list.value.length) {
- noMore.value = true;
- return
- }
- if (totol.value != 0) {
- if (totol.value == list.value.length) {
- //显示noMore
- if (totol.value == 0) {
- noMore.value = false;
- } else {
- noMore.value = true;
- }
- return
- }
- }
- // //先是加载中的话就不加载了
- // if (isLoading.value) {
- // return
- // }
- isLoading.value = true;
- //参数构造
- //到这里就可以显示加载中
- let res = await queryMsg()
- pageNum.value++
- isLoading.value = false;
- }
- //---------------------//查询字恢复------------------------字恢复
- const pageNum1 = ref<number>(1)
- const pageSize1 = ref<number>(10)
- //数据总共多少条
- const totol1 = ref<number>(0)
- //显示是否是在加载中
- const isLoading1 = ref<boolean>(false)
- //是否显示noMore
- const noMore1 = ref<boolean>(false)
- const list1 = ref<any>([])
- const queryMsg1 = async () => {
- let params = {
- pageNum: pageNum1.value,
- pageSize: pageSize1.value,
- //parentUserNo: parentUserNo.value
- parentId: parentId.value
- }
- let res: any = await queryMsgApi1(params)
- //修改文本
- if (res.code == 200) {
- // 将值赋值给列表
- if (res.data.content.length > 0) {
- list1.value.push(...res.data.content)
- totol1.value = res.data.totalElements
- } else {
- list1.value = []
- totol1.value = 0
- // totalElements
- }
- }
- }
- //查询字恢复------------------------字恢复
- //获取数据报
- const getData1 = async () => {
- //判断总条数是否大于当前页面的数据
- if (totol1.value < list1.value.length) {
- noMore1.value = true;
- return
- }
- //先判断
- if (totol1.value == list1.value.length) {
- //显示noMore
- if (totol1.value == 0) {
- noMore1.value = false;
- } else {
- noMore1.value = true;
- }
- return
- }
- //先是加载中的话就不加载了
- if (isLoading1.value) {
- return
- }
- isLoading1.value = true;
- //参数构造
- //到这里就可以显示加载中
- let res = await queryMsg1()
- pageNum1.value++
- isLoading1.value = false;
- }
- //点击发布留言按钮 打开弹出框
- const openPubMsg = () => {
- //重置输入框
- user_msg.value = ''
- //调用填写的内容
- pub_visible.value = true
- }
- //点击进行发布信息
- const pubMsg = async () => {
- //判断用户是否登陆了
- if (!userInfo.token) {
- ElMessage({
- message: '尚未登录',
- type: 'warning'
- })
- return
- }
- if (des_input.value == '') {
- ElMessage({
- message: '留言不能为空',
- type: 'warning'
- })
- return
- }
- if (isLock.value) {
- return
- }
- isLock.value = true
- let params = {
- userNo: userNo.value,
- userName: userName.value,
- commentContent: des_input.value
- }
- let res: any = await pubMsgApi(params)
- //
- //重新刷新列表
- //
- //重新渲染列表数据
- // list.value = []
- // pageNum.value = 1
- // getData()
- if (res.code == 200) {
- list.value.unshift(res.data)
- des_input.value = ''
- isLock.value = false
- pub_visible.value = false
- ElMessage({
- message: res.msg,
- type: 'success'
- })
- } else {
- ElMessage({
- message: res.msg,
- type: 'error'
- })
- }
- //调用新增留言的方法
- }
- //打开子页面进行回复
- //评论名称
- const comName = ref<string>('')
- //评论时间
- const comTime = ref<string>('')
- //具体评论
- const comDes = ref<string>('')
- const parentUserNo = ref<string>('')
- //评论性别
- const comSex = ref<string>('0')
- const subFun = (item: any) => {
- parentId.value = item.id;
- comName.value = item.userName;
- comTime.value = item.createTime;
- comDes.value = item.commentContent;
- parentUserNo.value = item.userNo
- sub_visible.value = true
- subMM.value = ''
- //打开的时候
- // 需要将数据值空
- resetFun()
- queryMsg1()
- }
- //点击进行发布信息-----子信息
- const subPubMsg = async () => {
- //判断是否登陆了
- if (!userInfo.token) {
- ElMessage({
- message: '尚未登录',
- type: 'warning'
- })
- return
- }
- if (subMM.value == '') {
- ElMessage({
- message: '留言不能为空',
- type: 'warning'
- })
- return
- }
- if (isLock.value) {
- return
- }
- isLock.value = true
- // <!-- "parentUserNo": "string",
- // "userName": "string",
- // "userNo": "string"
- // "commentContent": "string", -->
- let params = {
- userNo: userNo.value,
- userName: userName.value,
- commentContent: subMM.value,
- // parentUserNo: parentUserNo.value
- parentId: parentId.value
- }
- let res: any = await subPubMsgApi(params)
- if (res.code == 200) {
- //查找list中ID等于parentID的对象,将起count+1
- // let li = list.value.filter((item:any)=>{
- // return item.id==parentId.value
- // })
- for (let i = 0; i < list.value.length; i++) {
- if (list.value[i].id == parentId.value) {
- list.value[i].count += 1
- }
- }
- isLock.value = false
- // sub_visible.value = false
- //调用个查询
- //加一条在上边
- list1.value.push(res.data)
- subMM.value = ''
- //禁用滚动
- //在这里应该需要滚动到最底部
- // resetFun()
- // queryMsg1()
- } else {
- ElMessage({
- message: res.msg,
- type: 'error'
- })
- }
- //调用新增留言的方法
- }
- const resetFun = () => {
- pageNum1.value = 1;
- pageSize1.value = 10;
- totol1.value = 0;
- isLoading1.value = false;
- noMore1.value = false;
- list1.value = [];
- }
- //退出页面销毁 方法
- onUnmounted(() => {
- })
- </script>
- <template>
- <div class="home_header_out">
- <div class=" home_header_inner">
- <CpmdHeader />
- <div style="text-align: center;">
- <!-- <img class="xlts_img" style="margin-top:40px" src="../assets/home/other_text.png" /> -->
- </div>
- </div>
- <div class="leave_message">
- <!-- <img class="img" src="../assets/zs/community.png" alt=""> -->
- <div class="font_blue"> 留言社区 </div>
- </div>
- <div class="kply">
- <div class="kply_inner">
- <div style="padding :20px 40px">
- <!-- <div style="padding:10% 20% ;" v-show="true">
- <img width="100%" src="../assets/planNo.png">
- </div> -->
- <div class="kepu_title">
- <div class="kepu_title_des">
- 留言社区
- </div>
- <div>
- <div class="home_mid_plan_button">
- <div class="pub_button" @click="openPubMsg">
- <!-- <img width="30px" src="../assets/kepu/pub.png" /> -->
- 发布留言
- </div>
- </div>
- </div>
- </div>
- <!-- //留言内容 -->
- <div class="com_out" style="overflow: auto" :infinite-scroll-distance="20"
- :infinite-scroll-disabled="isLoading || noMore" v-infinite-scroll="getData">
- <div v-for="item in list">
- <div class="com_title">
- <img src="../assets/kepu/man.png" />
- <div class="com_des">
- <div class="com_name">
- {{ item.userName }}
- </div>
- <div class="com_time">
- {{ item.createTime }}
- </div>
- </div>
- </div>
- <div class="com_content">
- {{ item.commentContent }}
- <div class="com_yan">
- <span style="color: #818996;">{{ item.count }}</span>
- <img height="20px" src="../assets/kepu/yan1.png" @click="subFun(item)" />
- </div>
- </div>
- <el-divider content-position="right"></el-divider>
- </div>
- <div style="text-align: center" v-if="isLoading">努力加载中...</div>
- <div style="text-align: center;" v-if="noMore">没有更多了</div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <el-dialog v-model="pub_visible" :show-close="true" width="60%" style="border-radius: 5px; ">
- <template #header="{ close, titleId, titleClass }">
- <div class="my-header">
- <div class="msg_dig">
- <img width="40px" v-show="userSex == '1'" src="../assets/kepu/man.png" />
- <img width="40px" v-show="userSex == '0'" src="../assets/kepu/woman.png" />
- <div style="margin-left:20px">{{ userName }}</div>
- </div>
- <!-- <textarea ref="des_input" rows="5" cols="43" placeholder="写下你珍贵的留言" /> -->
- <el-input type="textarea" style="margin-top: 20px;" :autosize="{ minRows: 6 }" placeholder="写下你珍贵的留言"
- v-model="des_input">
- </el-input>
- <div class="home_mid_plan_button">
- <div class="pub_button" @click="pubMsg"> 发布留言
- </div>
- </div>
- </div>
- </template>
- </el-dialog>
- <el-dialog v-model="sub_visible" :show-close="true" width="60%" top="5vh" style="border-radius: 5px;">
- <template #header="{ close, titleId, titleClass }">
- <div class="my-header">
- <div class="msg_dig">
- <img width="40px" src="../assets/kepu/man.png" />
- <div style="margin-left:20px;display: flex;flex-direction: column;justify-content: space-between;">
- <div>
- {{ comName }}
- </div>
- <div style="color:#999999;font-size: 10px;margin-top:10px">{{ comTime }}</div>
- </div>
- </div>
- <div class="com_des">
- {{ comDes }}
- </div>
- <el-divider border-style="dotted" style="margin-top:40px;" />
- <div class="sub_infinite-list-wrapper" style="overflow: auto" :infinite-scroll-distance="20"
- v-infinite-scroll="getData1">
- <div v-for="item in list1" style="margin-top:40px">
- <div class="msg_dig">
- <img width="40px" src="../assets/kepu/man.png" />
- <div
- style="margin-left:20px;display: flex;flex-direction: column;justify-content: space-between;">
- <div>
- {{ item.userName }}
- </div>
- <div style="color:#999999;font-size: 10px;margin-top:10px">{{ item.createTime }}</div>
- </div>
- </div>
- <div class="com_des1">
- {{ item.commentContent }}
- </div>
- </div>
- <div style="text-align: center;margin-top:20px" v-if="isLoading1">努力加载中...</div>
- <div style="text-align: center;;margin-top:20px" v-if="noMore1">没有更多了</div>
- </div>
- <el-divider border-style="dotted" style="margin-top:40px;" />
- <div class="input_cus">
- <el-input v-model="subMM" placeholder="发表你的评论" />
- </div>
- <div class="home_mid_plan_button">
- <div class="pub_button" @click="subPubMsg"> 发布
- </div>
- </div>
- </div>
- </template>
- </el-dialog>
- </template>
- <style></style>
- <style lang="scss" scoped>
- :deep(.el-divider--horizontal) {
- margin: 16px 0 !important;
- opacity: 0.4;
- }
- :deep(.el-input__wrapper) {
- align-items: center;
- background-color: #F7F7F7 !important;
- border-radius: 5px !important;
- // border: none;
- // outline: none !important;
- box-shadow: none;
- }
- :deep(.input_cus .el-input__inner) {
- height: 60px;
- border: none;
- outline: none;
- }
- .sub_infinite-list-wrapper {
- max-height: 400px;
- }
- // :v-deep(.el-textarea__inner) {
- // color: var(--textarea-color)
- // }
- // textarea {
- // font-size: 0.8rem;
- // letter-spacing: 1px;
- // }
- :deep(.el-textarea__inner) {
- background-color: #F7F7F7 !important;
- border: none !important;
- border-radius: 20px;
- border: none !important;
- box-shadow: none !important;
- }
- textarea {
- margin-top: 30px;
- outline: none;
- padding: 10px;
- max-width: 100%;
- line-height: 1.5;
- border-radius: 5px;
- border: none;
- background-color: #F7F7F7;
- }
- textarea:focus {
- outline: none;
- border: none !important;
- }
- label {
- display: block;
- margin-bottom: 10px;
- }
- .my-header {
- padding: 60px 60px 10px 60px;
- display: flex;
- flex-direction: column;
- .com_des {
- background-color: #F7F7F7;
- padding: 20px 40px;
- margin-top: 40px;
- border-radius: 5px;
- }
- .com_des1 {
- padding: 20px 40px;
- margin-top: 10px;
- border-radius: 40px;
- }
- .home_mid_plan_button {
- width: 100%;
- display: flex;
- flex-direction: row;
- justify-content: end;
- margin-top: 40px;
- // text-align: right;
- .pub_button {
- cursor: pointer;
- // width: 100px;
- border-radius: 5px;
- border: 1px solid #48D68E;
- color: #ffffff;
- background-color: #3B3B3B;
- padding: 8px 30px;
- cursor: pointer;
- display: flex;
- align-items: center;
- }
- }
- .msg_dig {
- display: flex;
- flex-direction: row;
- align-items: center;
- }
- }
- .home_header_out {
- /* 启用滚动捕捉对齐 */
- scroll-snap-align: start;
- // position: relative;
- padding-bottom: 60px;
- width: 100%;
- min-width: 1200px;
- // background-image: url('../assets/home/bg_ty.png');
- background-repeat: no-repeat;
- background-size: contain;
- background-color: #ffffff; //估计是需要动态
- flex: 1;
- //获取屏幕宽度home_header_out 这个div的宽度--然后宽度*1000再除1920即为当前div的宽度
- .home_header_inner {
- min-height: 1;
- left: 0;
- right: 0;
- margin: auto;
- // height: 100px;
- width: 100%;
- .xlts_img {
- height: 60px;
- }
- }
- .leave_message {
- left: 0;
- right: 0;
- margin: auto;
- width: 1200px;
- margin-bottom: 20px;
- margin-top: 20px;
- .font_blue {
- position: relative;
- color: #00DE7E;
- font-weight: 700;
- font-size: 22px;
- font-family: 'Rammetto One-Regular';
- padding-top: 30px;
- z-index: 10;
- background: url(../assets/zs/community.png) no-repeat;
- background-size: auto 50px;
- // img {
- // position: absolute;
- // height: 50px;
- // left: 0;
- // top: 10px;
- // }
- }
- }
- .kply {
- width: 100%;
- // margin-top: 40px;
- // background-color: #FAFAFA;
- .kply_inner {
- left: 0;
- right: 0;
- margin: auto;
- width: 1200px;
- // padding: 20px 20px;
- background-color: #ffffff;
- border-radius: 5px;
- // height: 1000px;
- box-shadow: 0px 4px 32px 0px rgba(0, 0, 0, 0.17);
- // margin-bottom: 60px;
- .kepu_title {
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- .kepu_title_des {
- font-family: Alibaba PuHuiTi 2.0;
- font-weight: 600;
- font-size: 20px;
- color: #000000;
- }
- .home_mid_plan_button {
- width: 100%;
- display: flex;
- flex-direction: row;
- justify-content: end;
- // text-align: right;
- .pub_button {
- cursor: pointer;
- // width: 100px;
- border-radius: 5px;
- border: 1px solid #48D68E;
- color: #ffffff;
- background-color: #3B3B3B;
- padding: 8px 30px;
- cursor: pointer;
- display: flex;
- align-items: center;
- }
- }
- }
- .com_out {
- height: 500px;
- padding-top: 20px;
- .com_title {
- margin-top: 5px;
- display: flex;
- flex-direction: row;
- align-items: center;
- img {
- width: 40px
- }
- .com_des {
- margin-left: 5px;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- height: 40px;
- .com_name {
- font-weight: normal;
- font-size: 16px;
- color: #222222;
- }
- .com_time {
- font-weight: normal;
- font-size: 16px;
- color: #000000;
- opacity: 0.4;
- }
- }
- }
- .com_content {
- letter-spacing: 3px;
- margin-top: 10px;
- background-color: #F6F6F6;
- padding: 10px 20px;
- border-radius: 5px;
- line-height: 24px;
- font-size: 14px;
- }
- .com_yan {
- margin-top: 10px;
- display: flex;
- align-items: center;
- justify-content: end;
- span {
- margin-left: 8px;
- }
- }
- }
- }
- }
- }
- .home_mid {
- // background-color: blanchedalmond;
- width: 1200px;
- left: 0;
- right: 0;
- margin: auto;
- margin-top: 40px;
- // position: relative;
- .kepu_title {
- text-align: center;
- font-size: 50px;
- color: #111111;
- line-height: 95px;
- // width: 100%;
- // left: 0;
- // right: 0;
- // margin: auto
- }
- .kepu_title_sub {
- margin-top: 30px;
- text-align: center;
- font-size: 28px;
- color: #48D68E;
- line-height: 26px;
- }
- .man1_group {
- margin-top: 60px;
- height: 100%;
- display: flex;
- .man1 {
- position: relative;
- width: 327px;
- // height: 100%;
- // height: 100%
- .man1_img {
- position: absolute;
- bottom: 0;
- /* bottom: 0px; */
- /* height: auto; */
- width: 100%;
- left: 100px
- }
- }
- .des {
- border: #48D68E solid 5px;
- border-radius: 40px;
- padding: 20px;
- letter-spacing: 6px;
- flex: 1;
- .des_inner {
- border: 1px dashed #48D68E;
- border-radius: 40px;
- padding-bottom: 40px;
- padding-top: 30px;
- padding-left: 100px;
- padding-right: 20px;
- letter-spacing: 6px;
- font-weight: normal;
- font-size: 24px;
- color: #333333;
- line-height: 40px;
- }
- }
- }
- .man2_group {
- margin-top: 60px;
- height: 100%;
- display: flex;
- .man2 {
- position: relative;
- width: 327px;
- // height: 100%;
- // height: 100%
- .man2_img {
- position: absolute;
- bottom: 0;
- /* bottom: 0px; */
- /* height: auto; */
- width: 100%;
- left: -100px
- }
- }
- .des2 {
- border: #48D68E solid 5px;
- border-radius: 40px;
- padding: 20px;
- letter-spacing: 6px;
- flex: 1;
- .des2_inner {
- border: 1px dashed #48D68E;
- border-radius: 40px;
- padding-bottom: 40px;
- padding-top: 30px;
- padding-left: 20px;
- padding-right: 100px;
- letter-spacing: 6px;
- font-weight: normal;
- font-size: 24px;
- color: #333333;
- line-height: 40px;
- }
- }
- }
- .get_more {
- text-align: center;
- img {
- width: 300px;
- margin-top: 60px;
- margin-bottom: 60px;
- }
- }
- }
- // .home_footer_out {
- // width: 100%;
- // background-color: #000000;
- // }</style>
|