This commit is contained in:
liuye
2021-12-23 17:42:50 +08:00
parent 2f5529cc2c
commit f9b22190fe
2 changed files with 49 additions and 54 deletions

View File

@@ -67,7 +67,10 @@ export default {
computed: { ...mapState(['user']) }, computed: { ...mapState(['user']) },
onLoad(o) { onLoad(o) {
console.log(o) console.log(o)
this.id = o.id if(o.id) {
this.id = o.id
}
this.moduleId = o.moduleId this.moduleId = o.moduleId
this.forms.areaId = this.user.areaId this.forms.areaId = this.user.areaId
this.listName = o.listName this.listName = o.listName
@@ -111,54 +114,53 @@ export default {
}, },
submit() { submit() {
if (this.flag) return if (this.flag) return
if (!this.forms.title) {
return this.$u.toast('请输入标题')
}
if (!this.forms.content) {
return this.$u.toast('请输入正文')
}
this.$refs.uForm.validate((valid) => { if(this.selectList.length && this.forms.selectIndex === '') {
if (valid) { return this.$u.toast('请选择类别')
if (!this.forms.title) { }
return this.$u.toast('请输入标题')
}
if (!this.forms.content) {
return this.$u.toast('请输入正文')
}
if(this.selectList.length && this.forms.selectIndex === '') { var imgs = []
return this.$u.toast('请选择类别') if (this.forms.fileIds.length) {
} this.forms.fileIds.map((e) => {
imgs.push({ url: e.url, id: e.id })
})
}
var imgs = [] console.log(222)
if (this.forms.fileIds) { var categoryId = '', categoryName = ''
this.forms.fileIds.map((e) => {
imgs.push({ url: e.url, id: e.id })
})
}
console.log(222) if(this.selectList.length) {
this.$http.post(`/app/appcontentinfo/addOrUpdate`, { categoryId = this.selectList[this.forms.selectIndex].id
title: this.forms.title, categoryName = this.selectList[this.forms.selectIndex].categoryName
areaId: this.forms.areaId, }
content: this.forms.content, this.$http.post(`/app/appcontentinfo/addOrUpdate`, {
files: imgs || [], title: this.forms.title,
id: this.id, areaId: this.forms.areaId,
moduleId: this.moduleId, content: this.forms.content,
categoryId: this.selectList[this.forms.selectIndex].id, files: imgs || [],
categoryName: this.selectList[this.forms.selectIndex].categoryName, id: this.id,
}) moduleId: this.moduleId,
.then((res) => { categoryId: categoryId,
console.log(333) categoryName: categoryName,
if (res.code == 0) { })
uni.$emit('update') .then((res) => {
this.$u.toast('发布成功') console.log(333)
this.flag = true if (res.code == 0) {
setTimeout(() => { uni.$emit('update')
uni.navigateBack() this.$u.toast('发布成功')
}, 600) this.flag = true
} setTimeout(() => {
}).catch((err) => { uni.navigateBack()
console.log(err) }, 600)
})
} else {
this.$u.toast('失败')
} }
}).catch((err) => {
console.log(444333)
}) })
}, },

View File

@@ -4,8 +4,8 @@
<div class="titles">{{data.title}}</div> <div class="titles">{{data.title}}</div>
<div class="titles-bottom"> <div class="titles-bottom">
<span>类型</span> <span v-if="selectList.length">类型</span>
<span>{{selectList[data.showIndex].categoryName}}</span> <span v-if="selectList.length">{{data.categoryName}}</span>
<span class="to-left">浏览量</span> <span class="to-left">浏览量</span>
<span>{{data.viewCount}}</span> <span>{{data.viewCount}}</span>
</div> </div>
@@ -48,13 +48,6 @@ export default {
this.$http.post(`/app/appcontentinfo/queryDetailById?id=${this.id}`).then((res) => { this.$http.post(`/app/appcontentinfo/queryDetailById?id=${this.id}`).then((res) => {
if (res?.data) { if (res?.data) {
this.data = res.data this.data = res.data
if(this.selectList.length) {
this.selectList.map((item, index) => {
if(item.id == res.data.categoryId) {
this.data.showIndex = index
}
})
}
} }
}) })
}, },
@@ -63,8 +56,8 @@ export default {
if (res.code == 0) { if (res.code == 0) {
if(res.data && res.data[0].categoryList.length) { if(res.data && res.data[0].categoryList.length) {
this.selectList = res.data[0].categoryList this.selectList = res.data[0].categoryList
this.getDetail()
} }
this.getDetail()
} }
}) })
}, },