小程序公告
This commit is contained in:
182
src/apps/AppUniMsg/Add.vue
Normal file
182
src/apps/AppUniMsg/Add.vue
Normal file
@@ -0,0 +1,182 @@
|
||||
<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="names">
|
||||
<u-input v-model="forms.title" placeholder="请输入标题" maxlength="30" />
|
||||
</u-form-item>
|
||||
|
||||
<u-form-item label="发布单位" prop="publishUnitName" required :border-bottom="false" class="phones">
|
||||
<u-input v-model="forms.publishUnitName" placeholder="请输入发布单位" maxlength="16" />
|
||||
</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="请输入正文" type="textarea" auto-height height="100" maxlength="500" />
|
||||
</u-form-item>
|
||||
|
||||
<div class="line"></div>
|
||||
|
||||
<u-form-item label="图片上传 (最多9张)" prop="images" :border-bottom="false" class="avatars" label-position="top">
|
||||
<AiUploader :def.sync="forms.images" multiple placeholder="上传图片" :limit="9"></AiUploader>
|
||||
</u-form-item>
|
||||
|
||||
<div class="line"></div>
|
||||
</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: '',
|
||||
publishUnitName: '',
|
||||
content: '',
|
||||
images: [],
|
||||
},
|
||||
flag: false,
|
||||
}
|
||||
},
|
||||
computed: { ...mapState(['user']) },
|
||||
onLoad(o) {
|
||||
this.id = o.id
|
||||
this.getDetail()
|
||||
},
|
||||
|
||||
mounted() {},
|
||||
methods: {
|
||||
getDetail() {
|
||||
this.$http.post(`/app/appmininotice/queryDetailById?id=${this.id}`).then((res) => {
|
||||
if (res?.data) {
|
||||
this.forms = res.data
|
||||
if (res.data.images) {
|
||||
this.forms.images = JSON.parse(res.data.images || '[]')
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
submit() {
|
||||
if (this.flag) return
|
||||
|
||||
this.$refs.uForm.validate((valid) => {
|
||||
if (valid) {
|
||||
if (!this.forms.title) {
|
||||
return this.$u.toast('请输入标题')
|
||||
}
|
||||
if (!this.forms.publishUnitName) {
|
||||
return this.$u.toast('请输入正文')
|
||||
}
|
||||
|
||||
const imgs = []
|
||||
if (this.forms.images) {
|
||||
this.forms.images.map((e) => {
|
||||
imgs.push({ url: e.url, id: e.id })
|
||||
})
|
||||
}
|
||||
|
||||
this.flag = true
|
||||
this.$http
|
||||
.post(`/app/appmininotice/addOrUpdate`, {
|
||||
title: this.forms.title,
|
||||
publishUnitName: this.forms.publishUnitName,
|
||||
content: this.forms.content,
|
||||
images: JSON.stringify(imgs) || [],
|
||||
id: this.id,
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.code == 0) {
|
||||
this.$u.toast('发布成功')
|
||||
this.flag = false
|
||||
uni.navigateTo({ url: `./AppUniMsg` })
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.$u.toast('失败')
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.add {
|
||||
height: 100%;
|
||||
padding-bottom: 112px;
|
||||
|
||||
.header-description {
|
||||
::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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.names,
|
||||
.modeTypes,
|
||||
.phones {
|
||||
.u-form-item__body {
|
||||
border-bottom: 1px solid #dddddd;
|
||||
}
|
||||
}
|
||||
|
||||
.u-form-item:last-child {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.avatars,
|
||||
.contents {
|
||||
padding-bottom: 20px !important;
|
||||
.u-form-item__body {
|
||||
.u-form-item--right__content__slot {
|
||||
.u-input {
|
||||
text-align: left !important;
|
||||
}
|
||||
}
|
||||
.default {
|
||||
width: 160px;
|
||||
height: 160px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.line {
|
||||
height: 24px;
|
||||
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>
|
||||
Reference in New Issue
Block a user