Files
dvcp_v2_wxcp_app/src/apps/AppServicePublic/AppServicePublic.vue
aixianling c9f9bb1f8d BUG 25819
2021-12-23 17:56:36 +08:00

327 lines
7.5 KiB
Vue

<template>
<div class="AppServicePublic">
<AiTopFixed v-if="tabs.length">
<div class="tab-select" @click="tabClick(item)">
<div class="item" :class="tabIndex == index ? 'active' : ''" v-for="(item, index) in tabs" :key="index"
@click="tabClick(item)">{{ item.categoryName }}<span></span></div>
</div>
</AiTopFixed>
<div class="header-top">
<div>区域选择</div>
<AiAreaPicker v-model="areaId" :areaId="user.areaId" @select="areaSelect"></AiAreaPicker>
</div>
<u-search class="serach_content" placeholder="请输入标题" :show-action="false" v-model="keyword" @clear="clearSearch"
@search="search"></u-search>
<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 class="titles">{{ item.title }}</div>
<div class="flex">
<span class="left">
<span class="garydiv" v-if="item.categoryName">{{ item.categoryName }}</span>
<span class="times">{{ item.createTime.substring(0, 10) }}</span>
</span>
<span class="right">
<span class="font">{{ item.viewCount }}</span>
<span>人看过</span>
</span>
</div>
<div class="imgs">
<!-- <img :src="items.url" alt="" v-for="(items, i) in item.images" :key="i" @click.stop="previewImage(item.images, items.url)" /> -->
</div>
</template>
<template #menu>
<div class="menu" @tap.stop="toAdd(item, 2)">编辑</div>
<div class="menu" @tap.stop="toDetele(item)">删除</div>
</template>
</AiCard>
<u-loadmore :status="loadmore" color="#999" font-size="24" margin-top="32" margin-bottom="80"/>
</template>
<AiEmpty description="暂无数据" v-else></AiEmpty>
<AiFixedBtn>
<div class="addBtn iconfont iconfont-iconfangda" @tap.stop="toAdd()"/>
</AiFixedBtn>
<u-modal v-model="deletShow" content="您确认要删除该条信息吗?" :show-cancel-button="true" :mask-close-able="true"
:show-title="false" @confirm="delet"></u-modal>
</div>
</template>
<script>
import {mapState} from 'vuex'
export default {
name: 'AppServicePublic',
appName: '三务公开',
components: {},
props: {},
data() {
return {
datas: [],
keyword: '',
areaId: '',
current: 1,
size: 10,
pages: 0,
deletShow: false,
deletId: '',
moduleId: '',
listName: '',
tabs: [],
tabIndex: 0,
categoryId: ''
}
},
computed: {
...mapState(['user']),
loadmore() {
return this.pages <= this.current ? 'loading ' : 'nomore'
},
},
watch: {},
onLoad(o) {
this.areaId = this.user.areaId
this.moduleId = o.moduleId
this.listName = o.listName
this.getType()
this.getList()
uni.$on('update', () => {
this.getList()
})
uni.setNavigationBarTitle({title: this.listName})
},
methods: {
getType() {
this.$http.post(`/app/appcontentmoduleinfo/listByName?names=${this.listName}`).then((res) => {
if (res.code == 0) {
if (res.data && res.data[0].categoryList.length) {
var all = [{
categoryName: '全部',
id: '',
showIndex: 0,
}]
this.tabs = [...all, ...res.data[0].categoryList]
}
}
})
},
tabClick(row) {
this.tabIndex = row.showIndex
this.categoryId = row.id
},
getList() {
this.$http.post('/app/appcontentinfo/list', null, {
params: {
size: 6,
current: this.current,
areaId: this.areaId,
title: this.keyword,
moduleId: this.moduleId,
categoryId: this.categoryId
},
})
.then((res) => {
if (res.code == 0) {
this.datas = this.current > 1 ? [...this.datas, ...res.data.records] : res.data.records
this.pages = res.data.pages
}
})
},
areaSelect(e) {
this.areaId = e.id
this.getList()
},
toAdd(item, type) {
if (item?.id) {
this.$refs?.[item.id]?.[0]?.handleClose()
}
if (type == '1') {
uni.navigateTo({url: `./Detail?id=${item.id}&listName=${this.listName}`})
}
if (type == '2') {
uni.navigateTo({url: `./Add?id=${item.id}&moduleId=${this.moduleId}&listName=${this.listName}`})
}
if (type == null) {
uni.navigateTo({url: `./Add?moduleId=${this.moduleId}&listName=${this.listName}`})
}
},
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()
}
})
},
},
onReachBottom() {
this.current = this.current + 1
this.getList()
},
}
</script>
<style scoped lang="scss">
uni-page-body {
height: 100%;
}
::v-deep .content {
padding: 0 !important;
}
.tab-select {
width: 100%;
height: 96px;
line-height: 96px;
background: #3975C6;
display: flex;
.item {
flex: 1;
text-align: center;
font-size: 28px;
font-family: PingFangSC-Regular, PingFang SC;
color: #CDDCF0;
}
.active {
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
position: relative;
color: #fff;
span {
width: 48px;
height: 4px;
background: #FFF;
position: absolute;
bottom: 14px;
left: 50%;
margin-left: -24px;
}
}
}
.iconfont-iconMore {
// margin-top: 8px;
}
.AppServicePublic {
height: 100%;
.header-top {
display: flex;
background: #fff;
justify-content: space-between;
align-items: center;
padding: 10px 30px;
border-bottom: 1px solid #d8dde6;
}
.u-search {
background: #fff;
padding: 20px 30px;
}
::v-deep .AiCard {
background: #f3f6f9;
.start {
background: #fff;
padding: 32px;
border-radius: 16px;
.titles {
font-size: 32px;
font-weight: 500;
color: #333333;
margin-bottom: 16px;
}
.flex {
display: flex;
justify-content: space-between;
.left {
.garydiv {
font-size: 28px;
color: #999999;
background: #eeeeee;
border-radius: 24px;
padding: 4px 16px;
}
.times {
margin-left: 16px;
font-size: 28px;
color: #999999;
}
}
.right {
font-size: 28px;
color: #999;
.font {
color: #4181ff;
}
}
}
}
.mask {
.moreMenu {
.menu {
text-align: center;
line-height: 80px;
width: 192px;
height: 80px;
font-size: 28px;
font-weight: 400;
color: #333333;
}
}
}
}
.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>