AddPosts
This commit is contained in:
137
src/apps/AppResidentActivitie/AddPosts.vue
Normal file
137
src/apps/AppResidentActivitie/AddPosts.vue
Normal file
@@ -0,0 +1,137 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="textarea-div mar-b16">
|
||||
<div class="title mar-b32"><span></span>帖子内容</div>
|
||||
<div class="pad-l20">
|
||||
<u-input v-model="form.content" type="textarea" :border="false" :height="140" :auto-height="true" placeholder="请输入内容(1000字以内)" placeholder-style="color:#999;font-size:16px;" maxLength="140" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="textarea-div pad-b208">
|
||||
<div class="title mar-b32"><span></span>图片(最多9张)</div>
|
||||
<div class="pad-l20">
|
||||
<AiUploader :limit="9" v-model="form.images"></AiUploader>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer-btn">
|
||||
<div class="btn" @click="addPost">立即发布</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState } from 'vuex'
|
||||
|
||||
export default {
|
||||
name: 'AddPosts',
|
||||
components: {},
|
||||
computed: {
|
||||
...mapState(['user']),
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
files: [],
|
||||
id: '',
|
||||
flag: false,
|
||||
form: {
|
||||
content: '',
|
||||
images: [],
|
||||
},
|
||||
}
|
||||
},
|
||||
onLoad(o) {
|
||||
this.id = o.id || ''
|
||||
},
|
||||
methods: {
|
||||
addPost() {
|
||||
if (this.flag) return
|
||||
|
||||
if (!this.form.content && !this.form.images.length) {
|
||||
return this.$u.toast('帖子内容不能为空')
|
||||
}
|
||||
this.flag = true
|
||||
|
||||
let imagesList = []
|
||||
if (this.form.images) {
|
||||
this.form.images.map((item) => {
|
||||
imagesList.push({ id: item.id, url: item.url })
|
||||
})
|
||||
}
|
||||
|
||||
this.$http
|
||||
.post(`/app/appvillageactivitypost/addOrUpdate`, {
|
||||
content: this.form.content,
|
||||
avatar: this.user.avatarUrl,
|
||||
name: this.user.realName,
|
||||
phone: this.user.phone ? this.user.phone : '',
|
||||
userId: this.user.partyId,
|
||||
activityId: this.id,
|
||||
images: JSON.stringify(imagesList),
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.code == 0) {
|
||||
this.$u.toast('发布成功')
|
||||
this.flag = false
|
||||
uni.$emit('refresh')
|
||||
uni.navigateBack()
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.textarea-div {
|
||||
width: 100%;
|
||||
padding: 32px 32px 38px 32px;
|
||||
box-sizing: border-box;
|
||||
background-color: #fff;
|
||||
}
|
||||
.title {
|
||||
font-size: 32px;
|
||||
font-family: PingFangSC-Regular, PingFang SC;
|
||||
color: #333;
|
||||
line-height: 44px;
|
||||
span {
|
||||
font-family: PingFangSC-Regular, PingFang SC;
|
||||
color: #ff4466;
|
||||
margin-right: 4px;
|
||||
}
|
||||
}
|
||||
.border {
|
||||
border-bottom: 2px solid #ddd;
|
||||
}
|
||||
.mar-b32 {
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
.pad-l20 {
|
||||
padding-left: 20px;
|
||||
}
|
||||
.mar-b16 {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.pad-b208 {
|
||||
padding-bottom: 208px;
|
||||
}
|
||||
.footer-btn {
|
||||
width: 100%;
|
||||
padding: 116px 32px 32px;
|
||||
box-sizing: border-box;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
background-color: #f3f6f9;
|
||||
z-index: 99;
|
||||
.btn {
|
||||
width: 100%;
|
||||
height: 92px;
|
||||
line-height: 92px;
|
||||
text-align: center;
|
||||
background: #1365dd;
|
||||
border-radius: 8px;
|
||||
font-size: 34px;
|
||||
color: #fff;
|
||||
font-family: PingFangSC-Medium, PingFang SC;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="page">
|
||||
<div class="header-content">
|
||||
<div class="header-top">
|
||||
<img :src="detail.url[0].url" alt="" />
|
||||
<img :src="detail.url && detail.url[0].url" alt="" />
|
||||
</div>
|
||||
|
||||
<div class="header-middle">
|
||||
@@ -104,7 +104,7 @@
|
||||
</div>
|
||||
|
||||
<AiFixedBtn>
|
||||
<div class="addBtn iconfont iconfont-iconfangda" @tap.stop="toAdd()" />
|
||||
<div class="addBtn iconfont iconfont-iconfangda" @tap.stop="AddPosts()" />
|
||||
</AiFixedBtn>
|
||||
</div>
|
||||
</template>
|
||||
@@ -140,6 +140,10 @@ export default {
|
||||
this.$dict.load(['villageActivityStatus']).then(() => {
|
||||
this.getDetail()
|
||||
})
|
||||
|
||||
uni.$on('refresh', () => {
|
||||
this.getListInit()
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
getDetail() {
|
||||
@@ -154,32 +158,43 @@ export default {
|
||||
console.log(this.detail.url)
|
||||
}
|
||||
}
|
||||
this.getActiveList()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
getListInit() {
|
||||
this.current == 1
|
||||
this.getActiveList()
|
||||
},
|
||||
|
||||
getActiveList() {
|
||||
this.$http.post(`/app/apppostinfo/list?activityId=${this.id}`).then((res) => {
|
||||
if (res?.data) {
|
||||
// this.activeList = res.data.records
|
||||
// if (this.activeList) {
|
||||
// let imagesList = []
|
||||
// this.activeList.map((item) => {
|
||||
// if (item.images) {
|
||||
// item.images = JSON.parse(item.images || '[]')
|
||||
// imagesList.push(item.images)
|
||||
// }
|
||||
// return item
|
||||
// })
|
||||
// this.imgList = imagesList
|
||||
// }
|
||||
this.activeList = res.data.records
|
||||
if (this.activeList) {
|
||||
let imagesList = []
|
||||
this.activeList.map((item) => {
|
||||
if (item.images) {
|
||||
item.images = JSON.parse(item.images || '[]')
|
||||
imagesList.push(item.images)
|
||||
}
|
||||
return item
|
||||
})
|
||||
this.imgList = imagesList
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
change(index) {
|
||||
this.current = index
|
||||
if (this.current == 1) {
|
||||
this.getActiveList()
|
||||
}
|
||||
},
|
||||
|
||||
AddPosts() {
|
||||
uni.navigateTo({ url: `./AddPosts` })
|
||||
},
|
||||
|
||||
previewImage(images, img) {
|
||||
@@ -414,63 +429,21 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
.addicon {
|
||||
position: fixed;
|
||||
bottom: 280px;
|
||||
right: 30px;
|
||||
background: #fefefe;
|
||||
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
|
||||
border-radius: 50%;
|
||||
padding: 26px 24px 22px 24px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
// height: 112px;
|
||||
background: #f3f6f9;
|
||||
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 32px 0;
|
||||
text-align: center;
|
||||
.edit {
|
||||
width: 254px;
|
||||
height: 92px;
|
||||
line-height: 92px;
|
||||
background: #ffffff;
|
||||
border-radius: 8px;
|
||||
border: 2px solid #3671ee;
|
||||
|
||||
font-size: 34px;
|
||||
font-weight: 500;
|
||||
color: #3671ee;
|
||||
margin-left: 32px;
|
||||
}
|
||||
|
||||
.public {
|
||||
width: 400px;
|
||||
|
||||
line-height: 92px;
|
||||
border-radius: 8px;
|
||||
font-size: 34px;
|
||||
font-weight: 500;
|
||||
color: #ffffff;
|
||||
margin-right: 32px;
|
||||
}
|
||||
|
||||
.max {
|
||||
margin: 0 auto;
|
||||
width: 686px;
|
||||
height: 92px;
|
||||
line-height: 92px;
|
||||
background: #cbddf9;
|
||||
border-radius: 8px;
|
||||
|
||||
font-size: 34px;
|
||||
font-weight: 500;
|
||||
color: #ffffff;
|
||||
.AiFixedBtn {
|
||||
.movableArea {
|
||||
.addBtn {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 96px;
|
||||
height: 96px;
|
||||
flex-shrink: 0;
|
||||
background: #fff;
|
||||
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
|
||||
font-size: 48px;
|
||||
color: #1365dd;
|
||||
border-radius: 50%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user