2021-12-30 21:05:45 +08:00
< template >
< div class = "AppVillageDiscuss" >
2022-01-07 08:50:23 +08:00
< AiTopFixed v-if = "tabs.length > 0" >
2021-12-30 21:05:45 +08:00
< div class = "tab-select" >
2022-01-07 08:50:23 +08:00
< div class = "item" : class = "{ active: type == item.dictValue }" v-for = "item in tabs" :key="item.dictValue" @click="tabClick(item.dictValue)" > {{ item.dictName }} < span / > < / div >
2021-12-30 21:05:45 +08:00
< / div >
< / AiTopFixed >
< template v-if = "datas.length > 0" >
< AiCard v-for = "(item, i) in datas" :ref="item.id" :key="i" @click.native="toAdd(item, 1)" >
< template # custom >
< div flex class = "w-100" >
2022-01-07 08:50:23 +08:00
< div class = "avatar" v-text = "item.avatar" / >
2021-12-30 21:05:45 +08:00
< div flex class = "column start fill" >
2022-01-07 08:50:23 +08:00
< b class = "color-333" v-text = "item.createUserName" / >
< span class = "color-999" v-text = "item.createTime" / >
2021-12-30 21:05:45 +08:00
< / div >
2022-01-07 08:50:23 +08:00
< div class = "statusTag" : class = "{ over: item.status > 0 }" v-text = "item.status == 0 ? (item.type == 0 ? '征集中' : '投票中') : $dict.getLabel('discussStatus', item.status)" / >
2021-12-30 21:05:45 +08:00
< / div >
< p class = "item-content" >
< u-parse :html = "item.content" > < / u-parse >
< / p >
2022-01-07 08:50:23 +08:00
< div v-if = "item.images && item.images.length" >
2021-12-30 21:05:45 +08:00
< div class = "img-list" v-if = "item.contentType != 1" >
2022-01-07 08:50:23 +08:00
< img :src = "items.accessUrl" alt = "" v-for = "(items, index) in item.images" :key="index" v-if="index < 3" @click.stop="previewImage(item.images, items.accessUrl)" / >
2021-12-30 21:05:45 +08:00
< / div >
< div class = "img-list" v-else >
2022-01-07 08:50:23 +08:00
< video class = "video" :src = "item.images[0].url" / >
2021-12-30 21:05:45 +08:00
< / div >
< / div >
< / template >
< / AiCard >
2022-01-07 08:50:23 +08:00
< u-loadmore :status = "loadmore" color = "#999" font -size = " 24 " margin -top = " 32 " margin -bottom = " 80 " / >
2021-12-30 21:05:45 +08:00
< / template >
< AiEmpty description = "暂无数据" v-else > < / AiEmpty >
< AiFixedBtn >
2022-01-07 08:50:23 +08:00
< div class = "addBtn iconfont iconfont-iconfangda" @tap.stop ="toAdd()" / >
< div class = "addBtn iconfont iconfont-iconDouble_Up" @tap.stop ="backTop" v-if = "showBackTop" / >
2021-12-30 21:05:45 +08:00
< / AiFixedBtn >
2022-01-07 08:50:23 +08:00
< u-modal v-model = "deletShow" content="您确认要删除该条信息吗?" :show-cancel-button="true" :mask-close-able="true" :show-title="false" @confirm="delet" > < / u -modal >
2021-12-30 21:05:45 +08:00
< / div >
< / template >
< script >
2022-01-07 08:50:23 +08:00
import { mapState } from 'vuex'
2021-12-30 21:05:45 +08:00
export default {
name : 'AppVillageDiscuss' ,
appName : '居民议事' ,
components : { } ,
props : { } ,
data ( ) {
return {
datas : [ ] ,
current : 1 ,
size : 10 ,
pages : 0 ,
deletShow : false ,
deletId : '' ,
type : '0' ,
listName : '' ,
tabIndex : 0 ,
2022-01-07 08:50:23 +08:00
showBackTop : false ,
2021-12-30 21:05:45 +08:00
}
} ,
computed : {
... mapState ( [ 'user' ] ) ,
loadmore ( ) {
return this . pages <= this . current ? 'loading ' : 'nomore'
} ,
tabs ( ) {
2022-01-07 08:50:23 +08:00
return this . $dict . getDict ( 'discussStatus' )
} ,
2021-12-30 21:05:45 +08:00
} ,
onLoad ( o ) {
this . moduleId = o . moduleId
this . listName = o . listName
this . getList ( )
uni . $on ( 'update' , ( ) => {
this . getList ( )
} )
2022-01-07 08:50:23 +08:00
this . $dict . load ( 'discussStatus' )
2021-12-30 21:05:45 +08:00
} ,
onShow ( ) {
2022-01-07 08:50:23 +08:00
document . title = '居民议事'
2021-12-30 21:05:45 +08:00
} ,
onPageScroll ( obj ) {
this . showBackTop = obj . scrollTop > 0
} ,
methods : {
previewImage ( images , img ) {
uni . previewImage ( {
2022-01-07 08:50:23 +08:00
urls : images . map ( ( v ) => v . url ) ,
current : img ,
2021-12-30 21:05:45 +08:00
} )
} ,
tabClick ( type ) {
this . type = type
this . current = 1
this . getList ( )
} ,
search ( ) {
this . current = 1
this . getList ( )
} ,
getList ( ) {
2022-01-07 08:50:23 +08:00
let { current , type } = this
this . $http
. post ( '/app/appvillagediscuss/list' , null , {
params : { size : 20 , current , type } ,
} )
. then ( ( res ) => {
if ( res ? . data ) {
res . data . records . forEach ( ( e ) => {
e . avatar = e . createUserName ? . substring ( 0 , 2 ) || '游客'
if ( e . images ) {
e . images = JSON . parse ( e . images )
}
} )
this . datas = this . current > 1 ? [ ... this . datas , ... res . data . records ] : res . data . records
this . pages = res . data . pages
}
} )
2021-12-30 21:05:45 +08:00
} ,
toAdd ( item , type ) {
if ( item ? . id ) {
this . $refs ? . [ item . id ] ? . [ 0 ] ? . handleClose ( )
}
if ( type == '1' ) {
2022-01-07 08:50:23 +08:00
uni . navigateTo ( { url : ` ./Detail?id= ${ item . id } ` } )
2021-12-30 21:05:45 +08:00
}
if ( type == '2' ) {
2022-01-07 08:50:23 +08:00
uni . navigateTo ( { url : ` ./Add?id= ${ item . id } ` } )
2021-12-30 21:05:45 +08:00
}
if ( type == null ) {
2022-01-07 08:50:23 +08:00
uni . navigateTo ( { url : ` ./Add ` } )
2021-12-30 21:05:45 +08:00
}
} ,
toDetele ( item ) {
this . deletShow = true
this . deletId = item . id
this . $refs ? . [ item . id ] ? . [ 0 ] ? . handleClose ( )
} ,
delet ( ) {
this . $http . post ( ` /app/appcontentinfo/delete?ids= ${ this . deletId } ` ) . then ( ( res ) => {
if ( res . code == 0 ) {
this . current = 1
this . $u . toast ( '删除成功!' )
this . getList ( )
}
} )
} ,
backTop ( ) {
uni . pageScrollTo ( {
2022-01-07 08:50:23 +08:00
scrollTop : 0 ,
} )
} ,
2021-12-30 21:05:45 +08:00
} ,
onReachBottom ( ) {
this . current ++
this . getList ( )
} ,
}
< / script >
< style scoped lang = "scss" >
. AppVillageDiscuss {
height : 100 % ;
. avatar {
height : 64 px ;
width : 64 px ;
color : # fff ;
background : $uni - color - primary ;
border - radius : 50 % ;
font - size : 24 px ;
text - align : center ;
line - height : 64 px ;
margin - right : 16 px ;
}
. color - 999 {
color : # 999999 ;
}
. color - 333 {
color : # 333 ;
}
. w - 100 {
width : 100 % ;
}
. statusTag {
padding : 0 12 px ;
line - height : 30 px ;
2022-01-07 08:50:23 +08:00
border : 1 px solid # 2573 ff ;
color : # 2573 ff ;
2021-12-30 21:05:45 +08:00
font - size : 22 px ;
& . over {
border - color : # 666 ;
color : # 666 ;
}
}
: : v - deep . AiTopFixed {
. content {
padding : 0 ;
}
}
. tab - select {
width : 100 % ;
height : 96 px ;
line - height : 96 px ;
2022-01-07 08:50:23 +08:00
background : # 3975 c6 ;
2021-12-30 21:05:45 +08:00
display : flex ;
. item {
flex : 1 ;
text - align : center ;
font - size : 28 px ;
font - family : PingFangSC - Regular , PingFang SC ;
2022-01-07 08:50:23 +08:00
color : # cddcf0 ;
2021-12-30 21:05:45 +08:00
}
. active {
font - family : PingFangSC - Medium , PingFang SC ;
font - weight : 500 ;
position : relative ;
color : # fff ;
span {
width : 48 px ;
height : 4 px ;
2022-01-07 08:50:23 +08:00
background : # fff ;
2021-12-30 21:05:45 +08:00
position : absolute ;
bottom : 14 px ;
left : 50 % ;
margin - left : - 24 px ;
}
}
}
: : v - deep . AiCard {
background : # f3f6f9 ;
position : relative ;
padding : 0 ;
margin - bottom : 16 px ;
& > . start {
background : # fff ;
padding : 32 px ;
border - radius : 16 px ;
. titles {
width : 600 px ;
font - size : 32 px ;
font - weight : 500 ;
color : # 333333 ;
margin - bottom : 16 px ;
line - height : 50 px ;
word - break : break - all ;
}
. item - content {
width : 100 % ;
word - break : break - all ;
overflow : hidden ;
text - overflow : ellipsis ;
display : - webkit - box ;
- webkit - line - clamp : 4 ;
- webkit - box - orient : vertical ;
font - size : 26 px ;
font - family : PingFangSC - Regular , PingFang SC ;
color : # 333 ;
line - height : 44 px ;
margin - top : 32 px ;
margin - bottom : 16 px ;
}
. img - list {
margin - bottom : 24 px ;
img {
width : calc ( 33 % - 16 px ) ;
height : 204 px ;
margin : 0 16 px 8 px 0 ;
}
}
. flex {
display : flex ;
justify - content : space - between ;
. left {
. garydiv {
font - size : 28 px ;
color : # 999999 ;
background : # eeeeee ;
border - radius : 24 px ;
padding : 4 px 16 px ;
}
. times {
font - size : 28 px ;
color : # 999999 ;
}
. type {
display : inline - block ;
padding : 0 16 px ;
line - height : 48 px ;
2022-01-07 08:50:23 +08:00
background : # eee ;
2021-12-30 21:05:45 +08:00
border - radius : 24 px ;
font - size : 24 px ;
font - family : PingFangSC - Regular , PingFang SC ;
font - weight : 400 ;
color : # 999 ;
margin - right : 16 px ;
}
}
. right {
font - size : 28 px ;
color : # 999 ;
img {
width : 32 px ;
height : 32 px ;
vertical - align : middle ;
margin - right : 8 px ;
}
. font {
color : # 4181 ff ;
}
}
}
}
}
. AiFixedBtn {
. movableArea {
. addBtn {
display : flex ;
justify - content : center ;
align - items : center ;
width : 96 px ;
height : 96 px ;
flex - shrink : 0 ;
box - shadow : 0 8 px 16 px 0 rgba ( 0 , 0 , 0 , 0.2 ) ;
font - size : 48 px ;
background : # fff ;
color : $uni - color - primary ;
border - radius : 50 % ;
& + . addBtn {
margin - top : 22 px ;
}
}
}
}
: : v - deep uni - video {
width : 100 % ;
}
}
< / style >