Новости

This commit is contained in:
iriska-gri committed 2023-10-11 15:19:46 +03:00
1 parent 182f643b5c
commit 89d45d8469
5 files changed
+90 -161

No files matched your search

+75 -60
View File
@@ -8,7 +8,7 @@
:ref="i"
class="mx-auto"
:class="i>0?'mt-1':''"
v-for="(x, i) in newss" :key= i
v-for="(x, i) in newss.result" :key= i
>
<v-list-item class="w-100 pl-4 py-2 pt-3">
@@ -63,23 +63,22 @@
</v-btn>
</v-card-actions>
<!-- :to="'/news'" -->
</v-card>
<!-- <div ref="#g">hello</div> -->
<!-- ------------------------------ @click="scrollMeTo('porto')"---------------------------------------------------- -->
<div >
<v-card v-show="pages=='news'"
class="mx-auto rounded-0 gggggggggggggggggggggggggg"
class="mx-auto rounded-0"
:ref="el => { if (el) divs[i] = el }"
v-for="(x, i) in newss" :key=i
v-for="(x, i) in newss.result" :key=i
>
<v-list-item class="w-100 pl-4 py-2 pt-3">
<template v-slot:prepend>
@@ -89,7 +88,7 @@
:image=accountStore.user.photo></v-avatar>
</template>
<v-list-item-title>{{x.author.fio}} {{ i }}</v-list-item-title>
<v-list-item-title>{{x.author.fio}}</v-list-item-title>
<v-list-item-subtitle>Участник</v-list-item-subtitle>
</v-list-item>
@@ -109,13 +108,10 @@
<template v-slot:append>
<div class="justify-self-end">
<!-- <v-btn v-scroll-to="{element:'#nh'}">
2
</v-btn> -->
<v-icon class="me-1" :icon="x.scores.filter(e=> e.user==accountStore.user.id && e.score == true).length>0?'mdi-thumb-up':'mdi-thumb-up-outline'" @click="toggleIncrementLike(x.id, true)"></v-icon>
<span class="subheading me-2">{{x.scores.filter(e=> e.score==true).length}}</span>
<span class="me-1">·</span>
<v-icon class="me-1" icon="mdi-thumb-down-outline" @click="toggleIncrementLike(x.id, false)"/>
<v-icon class="me-1" :icon="x.scores.filter(e=> e.user==accountStore.user.id && e.score == false).length>0?'mdi-thumb-down':'mdi-thumb-down-outline'" @click="toggleIncrementLike(x.id, false)"/>
<span class="subheading me-2">{{x.scores.filter(e=> e.score==false).length}}</span>
<span class="me-1">·</span>
<v-icon class="me-1" icon="mdi-message-text-outline" @click="openComent(x.id)"/>
@@ -166,13 +162,7 @@
</v-row>
<!-- <div style="text-align: center;">
<div style="display: inline-block; text-align: left;">
Centered
Content
</div>
</div> -->
<div class="text-subtitle-2">
@@ -220,8 +210,27 @@
</v-card>
<!-- <div id="nh">ss</div> -->
<v-pagination
v-model="page"
:length="newss.allnews"
prev-icon="mdi-menu-left"
next-icon="mdi-menu-right"
@click="pagelistNews"
></v-pagination>
<v-select
v-model="selecnews"
variant="outlined"
:items="['1', '2', '3', '4', '5', '6']"
></v-select>
</div>
<v-row justify="center">
<v-dialog
v-model="dialogCommentShow"
@@ -299,40 +308,59 @@ export default {
const burl = baseURL.slice(0,-1)
const textcomment = ref('')
const idnews = ref(0)
const page = ref(1)
const selecnews = ref(2)
const toggleIncrementLike = (news, scores) => {
axiosApiInstance.post(`api/navigation/news/`, {news: news, scores: scores}).then(result => {
newss.value[newss.value.findIndex(e=> e.id==news)].scores= result.data
// console.log(result.data, 'result.data-----------------')
newss.value.result[newss.value.result.findIndex(e=> e.id==news)].scores= result.data
})
}
const dateformat = (datas) => {
return format(new Date(datas), 'dd.MM.yyyy HH:mm')
}
const newses =() => {
}
const openComent = (news) => {
dialogCommentShow.value=!dialogCommentShow.value
idnews.value = news
}
const addComment = () => {
axiosApiInstance.post(`api/navigation/news/`, {news: idnews.value, text: textcomment.value}).then(result => {
dialogCommentShow.value=!dialogCommentShow.value
newss.value[newss.value.findIndex(e=> e.id==result.data['news'])].comment = result.data.comment
newss.value.result[newss.value.result.findIndex(e=> e.id==result.data['news'])].comment = result.data.comment
})
}
const deletComment = (id, news) => {
axiosApiInstance.post(`api/navigation/news/`, {delid: id, news: news}).then(result => {
newss.value.result[newss.value.result.findIndex(e=> e.id==result.data['news'])].comment = result.data.comment
})
}
getfromserver(`api/navigation/news/?name=${props.pages}&page=${page.value-1}&selected=${selecnews.value}`, newss)
const pagelistNews =() => {
getfromserver(`api/navigation/news/?name=${props.pages}&page=${page.value-1}&selected=${selecnews.value}`, newss)
}
watch(()=>accountStore.cod2user ,(newValue,oldValue)=>{
if(newValue){
getfromserver(`api/navigation/news/?name=${props.pages}&page=${page.value-1}&selected=${selecnews.value}`,newss)
}
}, {deep:true})
watch(()=>selecnews ,(newValue,oldValue)=>{
if(newValue){
getfromserver(`api/navigation/news/?name=${props.pages}&page=${page.value-1}&selected=${newValue.value}`, newss)
}
}, {deep:true})
const dateformat = (datas) => {
return format(new Date(datas), 'dd.MM.yyyy HH:mm')
}
const openComent = (news) => {
dialogCommentShow.value=!dialogCommentShow.value
idnews.value = news
}
const limitText=(text)=> {
const t = text.split(' ').slice(0, 25)
return `${text.split(' ').slice(0, 25).join(' ')} ${t.length<25?'':'...'}`
@@ -342,24 +370,9 @@ export default {
return name.familyname + ' ' + name.name[0] + '.' + name.parentname[0]+ '.'
}
getfromserver(`api/navigation/news/?name=${props.pages}`, newss)
watch(()=>accountStore.cod2user ,(newValue,oldValue)=>{
if(newValue){
getfromserver(`api/navigation/news/`,newss)
}
}, {deep:true})
const deletComment = (id, news) => {
axiosApiInstance.post(`api/navigation/news/`, {delid: id, news: news}).then(result => {
newss.value[newss.value.findIndex(e=> e.id==result.data['news'])].comment = result.data.comment
})
}
return {
@@ -376,8 +389,10 @@ export default {
addComment,
idnews,
deletComment,
newses,
divs
pagelistNews,
divs,
page,
selecnews
}
}