Files
dvcp_v2_wxcp_app/src/apps/AppUniMsg/AppUniMsg.vue

246 lines
5.5 KiB
Vue
Raw Normal View History

2021-12-21 19:13:37 +08:00
<template>
<div class="AppUniMsg">
2021-12-24 11:26:12 +08:00
<u-tabs :list="tabList" :is-scroll="false" :current="currentTabs" height="96" bg-color="#3975C6" inactive-color="#fff" active-color="#fff" @change="change"></u-tabs>
2021-12-22 09:28:39 +08:00
2021-12-21 19:13:37 +08:00
<template v-if="datas.length > 0">
2021-12-23 17:53:40 +08:00
<AiCard v-for="(item, i) in datas" :ref="item.id" :key="i" @click.native="toAdd(item, 1)">
2021-12-21 19:13:37 +08:00
<template #custom>
<div class="titles">
{{ item.title }}
</div>
2021-12-22 09:28:39 +08:00
<div class="publishUnitNames">
<span>发布部门</span>
2021-12-21 19:13:37 +08:00
<span>{{ item.publishUnitName }}</span>
</div>
2021-12-22 09:28:39 +08:00
<div class="createTimes">
<span>发布时间</span>
2021-12-21 19:13:37 +08:00
<span>{{ item.createTime }}</span>
</div>
2021-12-22 09:28:39 +08:00
2021-12-22 09:44:40 +08:00
<div class="imgs">
2021-12-24 11:26:12 +08:00
<img :src="items.url" alt="" v-for="(items, i) in item.images" :key="i" v-if="i < 3" @click.stop="previewImage(item.images, items.url)" />
2021-12-22 09:44:40 +08:00
</div>
2021-12-21 19:13:37 +08:00
</template>
<template #menu>
<div class="menu" @tap.stop="toAdd(item, 2)">编辑</div>
<div class="menu" @tap.stop="toDetele(item)">删除</div>
</template>
</AiCard>
2021-12-24 11:26:12 +08:00
<u-loadmore :status="loadmore" color="#999" font-size="24" margin-top="32" margin-bottom="80" />
2021-12-21 19:13:37 +08:00
</template>
<AiEmpty description="暂无数据" v-else></AiEmpty>
<AiFixedBtn>
2021-12-24 11:26:12 +08:00
<div class="addBtn iconfont iconfont-iconfangda" @tap.stop="toAdd()" />
2021-12-21 19:13:37 +08:00
</AiFixedBtn>
2021-12-24 11:26:12 +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-21 19:13:37 +08:00
</div>
</template>
<script>
2021-12-24 11:26:12 +08:00
import { mapState } from 'vuex'
2021-12-22 09:28:39 +08:00
2021-12-21 19:13:37 +08:00
export default {
name: 'AppUniMsg',
appName: '小程序公告',
components: {},
props: {},
data() {
return {
datas: [],
current: 1,
size: 10,
deletShow: false,
deletId: '',
2021-12-22 09:28:39 +08:00
tabList: [
{
name: '全部公告',
},
{
name: '我的发布',
},
],
currentTabs: 0,
2021-12-21 19:13:37 +08:00
}
},
computed: {
2021-12-22 09:28:39 +08:00
...mapState(['user']),
2021-12-21 19:13:37 +08:00
loadmore() {
return this.pages <= this.current ? 'loading ' : 'nomore'
},
},
watch: {},
onLoad() {
2021-12-24 14:06:07 +08:00
uni.setNavigationBarTitle({ title: '通知公告' })
2021-12-21 19:13:37 +08:00
this.getList()
2021-12-24 11:33:28 +08:00
uni.$on('updateList', () => {
this.current = 1
this.getList()
})
2021-12-21 19:13:37 +08:00
},
2021-12-24 11:26:12 +08:00
onShow() {},
2021-12-21 19:13:37 +08:00
methods: {
getList() {
this.$http
2021-12-24 11:26:12 +08:00
.post('/app/appmininotice/list', null, {
params: {
size: this.size,
current: this.current,
createUserId: this.currentTabs == 1 ? this.user.id : '',
},
})
.then((res) => {
if (res.code == 0) {
this.datas = this.current > 1 ? [...this.datas, ...res.data.records] : res.data.records
if (this.datas) {
this.datas.map((item) => {
if (item.images) {
item.images = JSON.parse(item.images || '[]')
}
return item
})
}
this.pages = res.data.pages
2021-12-21 19:13:37 +08:00
}
2021-12-24 11:26:12 +08:00
})
2021-12-21 19:13:37 +08:00
},
toAdd(item, type) {
2021-12-23 17:53:40 +08:00
if (item?.id) {
this.$refs?.[item.id]?.[0]?.handleClose()
}
2021-12-21 19:13:37 +08:00
if (type == '1') {
2021-12-24 11:26:12 +08:00
uni.navigateTo({ url: `./Detail?id=${item.id}` })
2021-12-21 19:13:37 +08:00
}
if (type == '2') {
2021-12-24 11:26:12 +08:00
uni.navigateTo({ url: `./Add?id=${item.id}` })
2021-12-21 19:13:37 +08:00
}
if (type == null) {
2021-12-24 11:26:12 +08:00
uni.navigateTo({ url: `./Add` })
2021-12-21 19:13:37 +08:00
}
},
toDetele(item) {
this.deletShow = true
this.deletId = item.id
2021-12-23 17:53:40 +08:00
this.$refs?.[item.id]?.[0]?.handleClose()
2021-12-21 19:13:37 +08:00
},
delet() {
this.$http.post(`/app/appmininotice/delete?ids=${this.deletId}`).then((res) => {
if (res.code == 0) {
this.$u.toast('删除成功!')
this.getList()
}
})
},
2021-12-22 09:28:39 +08:00
change(index) {
this.currentTabs = index
this.getList()
},
2021-12-23 16:19:05 +08:00
2021-12-23 17:53:40 +08:00
previewImage(images, img) {
2021-12-23 16:19:05 +08:00
uni.previewImage({
2021-12-24 11:26:12 +08:00
urls: images.map((v) => v.url),
current: img,
2021-12-23 16:19:05 +08:00
})
},
2021-12-21 19:13:37 +08:00
},
onReachBottom() {
this.current = this.current + 1
this.getList()
},
}
</script>
<style scoped lang="scss">
2021-12-22 09:44:40 +08:00
uni-page-body {
height: 100%;
}
2021-12-23 17:53:40 +08:00
2021-12-21 19:13:37 +08:00
.AppUniMsg {
height: 100%;
2021-12-23 17:53:40 +08:00
2021-12-21 19:13:37 +08:00
::v-deep .AiCard {
background: #f3f6f9;
2021-12-23 17:53:40 +08:00
2021-12-21 19:13:37 +08:00
.start {
background: #fff;
padding: 32px;
border-radius: 16px;
2021-12-23 17:53:40 +08:00
2021-12-22 09:28:39 +08:00
.fill {
.titles {
font-size: 30px;
color: #333;
font-family: 500;
}
2021-12-23 17:53:40 +08:00
2021-12-22 09:44:40 +08:00
.imgs {
margin-top: 10px;
2021-12-23 17:53:40 +08:00
2021-12-22 09:44:40 +08:00
img {
width: 200px;
height: 200px;
margin-right: 8px;
}
2021-12-23 17:53:40 +08:00
2021-12-22 09:44:40 +08:00
img:nth-child(3n) {
margin-right: 0;
}
2021-12-22 09:28:39 +08:00
}
}
2021-12-21 19:13:37 +08:00
}
2021-12-23 17:53:40 +08:00
2021-12-21 19:13:37 +08:00
.mask {
.moreMenu {
transform: translate(-175px, 20px);
2021-12-23 17:53:40 +08:00
2021-12-21 19:13:37 +08:00
.menu {
text-align: center;
line-height: 80px;
width: 192px;
height: 80px;
font-size: 28px;
font-weight: 400;
color: #333333;
}
}
}
}
2021-12-22 09:44:40 +08:00
.u-load-more-wrap {
background: #f3f6f9 !important;
margin: 0 !important;
padding: 34px 0;
}
2021-12-21 19:13:37 +08:00
.AiFixedBtn {
.movableArea {
.addBtn {
display: flex;
justify-content: center;
align-items: center;
width: 96px;
height: 96px;
flex-shrink: 0;
background: $uni-color-primary;
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
font-size: 48px;
color: #fff;
border-radius: 50%;
}
}
}
}
</style>