Files
dvcp_v2_wxcp_app/src/apps/AppResidentActivitie/Add.vue

284 lines
7.9 KiB
Vue
Raw Normal View History

2021-12-17 11:55:28 +08:00
<template>
<div class="add">
<div class="header-description">
<u-form :model="forms" ref="uForm" label-width="auto" :border-bottom="false">
<u-form-item label="标题" prop="title" required :border-bottom="false" class="titles" label-position="top">
<u-input v-model="forms.title" placeholder="请输入标题(30字以内)" type="textarea" auto-height height="60" maxlength="30" />
</u-form-item>
<u-form-item label="活动详情" prop="content" required :border-bottom="false" label-position="top" class="contents">
<u-input v-model="forms.content" placeholder="请输入活动详情(500字以内)" type="textarea" auto-height height="100" maxlength="500" />
</u-form-item>
<div class="line"></div>
2021-12-23 11:54:21 +08:00
<u-form-item label="活动封面图" prop="url" required :border-bottom="false" class="avatars" label-position="top">
<AiUploader :def.sync="forms.url" multiple placeholder="上传图片" :limit="1"></AiUploader>
2021-12-17 11:55:28 +08:00
</u-form-item>
<div class="line"></div>
2021-12-23 17:12:57 +08:00
<u-form-item label="发布地区" prop="areaId" required :border-bottom="false" right-icon="arrow-right">
2021-12-23 11:54:21 +08:00
<AiAreaPicker v-model="forms.areaId" :areaId="areaId" @select="areaSelect" style="color: #333"></AiAreaPicker>
2021-12-17 11:55:28 +08:00
</u-form-item>
<div class="line"></div>
2021-12-23 11:54:21 +08:00
<u-form-item label="开始时间" prop="beginTime" required :border-bottom="false" right-icon="arrow-right">
<u-input v-model="forms.beginTime" placeholder="请选择开始时间" @click="showStartTime = true" />
2021-12-17 11:55:28 +08:00
<u-picker mode="time" :params="params" v-model="showStartTime" @confirm="confirm"></u-picker>
</u-form-item>
<u-form-item label="结束时间" prop="endTime" required :border-bottom="false" right-icon="arrow-right">
<u-input v-model="forms.endTime" placeholder="请选择结束时间" @click="showEndTime = true" />
<u-picker mode="time" :params="params" v-model="showEndTime" @confirm="confirm"></u-picker>
</u-form-item>
2021-12-23 11:54:21 +08:00
<u-form-item label="活动地点" prop="address" required :border-bottom="false" label-position="top" class="areaNmaes">
2021-12-23 17:12:10 +08:00
<u-input v-model="forms.address" placeholder="请输入活动地点(30字以内)" type="textarea" auto-height height="70" maxlength="30" />
2021-12-17 11:55:28 +08:00
</u-form-item>
<div class="line"></div>
2021-12-23 11:54:21 +08:00
<u-form-item label="联系人" prop="contactPerson" required :border-bottom="false">
<u-input v-model="forms.contactPerson" placeholder="请输入联系人" maxlength="30" />
2021-12-17 11:55:28 +08:00
</u-form-item>
2021-12-23 11:54:21 +08:00
<u-form-item label="联系方式" prop="contactPhone" required :border-bottom="false">
<u-input v-model="forms.contactPhone" placeholder="请输入联系方式" maxlength="16" />
2021-12-17 11:55:28 +08:00
</u-form-item>
</u-form>
</div>
<div class="btn" @click="submit">保存</div>
<AiBack></AiBack>
</div>
</template>
<script>
import { mapState } from 'vuex'
export default {
name: 'Add',
components: {},
props: {},
data() {
return {
id: '',
forms: {
title: '',
content: '',
2021-12-23 11:54:21 +08:00
url: [],
areaId: '',
2021-12-17 11:55:28 +08:00
2021-12-23 11:54:21 +08:00
beginTime: '',
2021-12-17 11:55:28 +08:00
endTime: '',
2021-12-23 11:54:21 +08:00
address: '',
contactPerson: '',
2021-12-17 11:55:28 +08:00
2021-12-23 11:54:21 +08:00
contactPhone: '',
2021-12-17 11:55:28 +08:00
},
2021-12-23 11:54:21 +08:00
2021-12-17 11:55:28 +08:00
showStartTime: false,
showEndTime: false,
flag: false,
2021-12-23 11:54:21 +08:00
areaId: '',
2021-12-17 11:55:28 +08:00
params: {
year: true,
month: true,
day: true,
hour: true,
minute: true,
2021-12-23 11:54:21 +08:00
second: false,
2021-12-17 11:55:28 +08:00
timestamp: true,
},
}
},
computed: { ...mapState(['user']) },
onLoad(o) {
2021-12-23 17:16:34 +08:00
console.log(this.user)
2021-12-23 11:54:21 +08:00
this.id = o.id ? o.id : ''
2021-12-17 11:55:28 +08:00
this.$dict.load('realityStatus').then(() => {
// this.getDetail()
2021-12-23 11:54:21 +08:00
this.areaId = this.user.areaId
this.forms.areaId = this.user.areaId
2021-12-23 17:16:34 +08:00
this.user.phone = this.forms.contactPhone
this.user.name = this.forms.contactPerson
2021-12-17 11:55:28 +08:00
})
},
mounted() {},
methods: {
// getDetail() {
// this.$http.post(`/app/appvisitvondolence/queryDetailById?id=${this.id}`).then((res) => {
// if (res?.data) {
// this.forms = res.data
2021-12-23 11:54:21 +08:00
//
2021-12-17 11:55:28 +08:00
// }
// })
// },
submit() {
if (this.flag) return
this.$refs.uForm.validate((valid) => {
if (valid) {
if (!this.forms.title) {
return this.$u.toast('请输入标题')
}
if (!this.forms.content) {
return this.$u.toast('请输入活动详情')
}
2021-12-23 11:54:21 +08:00
if (this.forms.url.length == 0) {
2021-12-20 16:12:47 +08:00
return this.$u.toast('请选择活动封面图')
2021-12-17 11:55:28 +08:00
}
2021-12-23 11:54:21 +08:00
if (!this.forms.beginTime) {
2021-12-17 11:55:28 +08:00
return this.$u.toast('请选择开始时间')
}
if (!this.forms.endTime) {
return this.$u.toast('请选择结束时间')
}
2021-12-23 11:54:21 +08:00
if (!this.forms.address) {
2021-12-17 11:55:28 +08:00
return this.$u.toast('请输入活动地点')
}
2021-12-23 11:54:21 +08:00
if (!this.forms.contactPerson) {
2021-12-17 11:55:28 +08:00
return this.$u.toast('请输入联系人')
}
2021-12-23 11:54:21 +08:00
if (!this.forms.contactPhone) {
2021-12-17 11:55:28 +08:00
return this.$u.toast('请输入联系方式')
}
const imgs = []
2021-12-23 11:54:21 +08:00
if (this.forms.url) {
this.forms.url.map((e) => {
2021-12-17 11:55:28 +08:00
imgs.push({ url: e.url, id: e.id })
})
}
this.flag = true
this.$http
2021-12-23 10:31:10 +08:00
.post(`/app/appvillageactivityinfo/addOrUpdate`, {
2021-12-17 11:55:28 +08:00
title: this.forms.title,
content: this.forms.content,
2021-12-23 11:54:21 +08:00
url: JSON.stringify(imgs) || [],
areaId: this.forms.areaId,
2021-12-17 11:55:28 +08:00
2021-12-23 11:54:21 +08:00
beginTime: this.forms.beginTime,
2021-12-17 11:55:28 +08:00
endTime: this.forms.endTime,
2021-12-23 11:54:21 +08:00
address: this.forms.address,
contactPerson: this.forms.contactPerson,
2021-12-17 11:55:28 +08:00
2021-12-23 11:54:21 +08:00
contactPhone: this.forms.contactPhone,
2021-12-17 11:55:28 +08:00
id: this.id,
})
.then((res) => {
if (res.code == 0) {
this.$u.toast('发布成功')
this.flag = false
2021-12-23 10:31:10 +08:00
uni.navigateTo({ url: `./AppResidentActivities` })
2021-12-17 11:55:28 +08:00
}
})
} else {
this.$u.toast('失败')
}
})
},
confirm(e) {
if (this.showStartTime == true) {
2021-12-23 11:54:21 +08:00
this.forms.beginTime = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute + ':' + '00'
2021-12-17 11:55:28 +08:00
}
if (this.showEndTime == true) {
2021-12-23 11:54:21 +08:00
this.forms.endTime = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute + ':' + '00'
2021-12-17 11:55:28 +08:00
}
},
2021-12-23 11:54:21 +08:00
areaSelect(e) {
if (e.type == 5) {
this.forms.areaId = e.id
}
if (e.type == 4) {
this.forms.areaId = e.id
}
2021-12-17 11:55:28 +08:00
},
},
}
</script>
<style lang="scss" scoped>
.add {
height: 100%;
padding-bottom: 112px;
.header-description {
2021-12-23 10:31:10 +08:00
padding-bottom: 112px;
2021-12-17 11:55:28 +08:00
::v-deep .u-form {
.u-form-item {
padding: 0 45px !important;
.u-form-item__body {
.u-form-item--right__content__slot {
padding-bottom: 0;
.u-input {
text-align: right !important;
}
}
}
}
.u-form-item:last-child {
margin-bottom: 40px;
}
.titles,
.contents,
.areaNmaes {
.u-form-item__body {
.u-form-item--right__content__slot {
.u-input {
text-align: left !important;
}
}
}
}
.avatars,
.areaNmaes,
.contents {
padding-bottom: 20px !important;
}
.avatars {
.u-form-item__body {
.default {
width: 160px;
height: 160px;
}
}
}
.line {
height: 16px;
background: #f3f6f9;
}
}
}
.btn {
position: fixed;
bottom: 0;
width: 100%;
height: 112px;
line-height: 112px;
background: #1365dd;
text-align: center;
font-size: 32px;
font-weight: 500;
color: #ffffff;
}
}
</style>