diff --git a/src/apps/AppServicePublic/Add.vue b/src/apps/AppServicePublic/Add.vue index aae0ca15..5dfc27e2 100644 --- a/src/apps/AppServicePublic/Add.vue +++ b/src/apps/AppServicePublic/Add.vue @@ -67,7 +67,10 @@ export default { computed: { ...mapState(['user']) }, onLoad(o) { console.log(o) - this.id = o.id + if(o.id) { + this.id = o.id + } + this.moduleId = o.moduleId this.forms.areaId = this.user.areaId this.listName = o.listName @@ -111,54 +114,53 @@ export default { }, submit() { 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 (valid) { - if (!this.forms.title) { - return this.$u.toast('请输入标题') - } - if (!this.forms.content) { - return this.$u.toast('请输入正文') - } + if(this.selectList.length && this.forms.selectIndex === '') { + return this.$u.toast('请选择类别') + } - if(this.selectList.length && this.forms.selectIndex === '') { - return this.$u.toast('请选择类别') - } + var imgs = [] + if (this.forms.fileIds.length) { + this.forms.fileIds.map((e) => { + imgs.push({ url: e.url, id: e.id }) + }) + } - var imgs = [] - if (this.forms.fileIds) { - this.forms.fileIds.map((e) => { - imgs.push({ url: e.url, id: e.id }) - }) - } + console.log(222) + var categoryId = '', categoryName = '' - console.log(222) - this.$http.post(`/app/appcontentinfo/addOrUpdate`, { - title: this.forms.title, - areaId: this.forms.areaId, - content: this.forms.content, - files: imgs || [], - id: this.id, - moduleId: this.moduleId, - categoryId: this.selectList[this.forms.selectIndex].id, - categoryName: this.selectList[this.forms.selectIndex].categoryName, - }) - .then((res) => { - console.log(333) - if (res.code == 0) { - uni.$emit('update') - this.$u.toast('发布成功') - this.flag = true - setTimeout(() => { - uni.navigateBack() - }, 600) - } - }).catch((err) => { - console.log(err) - }) - } else { - this.$u.toast('失败') + if(this.selectList.length) { + categoryId = this.selectList[this.forms.selectIndex].id + categoryName = this.selectList[this.forms.selectIndex].categoryName + } + this.$http.post(`/app/appcontentinfo/addOrUpdate`, { + title: this.forms.title, + areaId: this.forms.areaId, + content: this.forms.content, + files: imgs || [], + id: this.id, + moduleId: this.moduleId, + categoryId: categoryId, + categoryName: categoryName, + }) + .then((res) => { + console.log(333) + if (res.code == 0) { + uni.$emit('update') + this.$u.toast('发布成功') + this.flag = true + setTimeout(() => { + uni.navigateBack() + }, 600) } + }).catch((err) => { + console.log(444333) }) }, diff --git a/src/apps/AppServicePublic/Detail.vue b/src/apps/AppServicePublic/Detail.vue index 8474747f..34e02e9a 100644 --- a/src/apps/AppServicePublic/Detail.vue +++ b/src/apps/AppServicePublic/Detail.vue @@ -4,8 +4,8 @@