接口对接

This commit is contained in:
yanran200730
2023-03-17 14:48:30 +08:00
parent cf996ed83d
commit d53e5f3b4b
3 changed files with 145 additions and 15 deletions

View File

@@ -19,7 +19,7 @@
</div>
<div class="topic">
<h3 v-if="!form.themeId" @click="isShow = true">#绑定话题</h3>
<div class="choosed" v-else>
<div class="choosed" v-else @click="isShow = true">
<span>#{{ form.themeTitle }}</span>
</div>
<p>绑定一个与您发布内容相关很高的话题会被更多人看到哦</p>
@@ -62,7 +62,7 @@
themeTitle: '',
source: 0,
content: '',
visibleRange: 0
visibleRange: 1
},
topicList: [],
isShow: false
@@ -79,6 +79,7 @@
return this.$toast(`内容不能为空`)
}
this.$loading()
this.$instance.post(`/app/appneighborhoodassistance/addOrUpdate`, {
...this.form
}).then(res => {
@@ -96,7 +97,7 @@
},
onSwitchChange (e) {
this.form.visibleRange = e.detail.value ? 1 : 0
this.form.visibleRange = e.detail.value ? 0 : 1
},
getTopicList () {

View File

@@ -90,6 +90,10 @@
onLoad() {
this.getTopicList()
uni.$on('updateList', () => {
this.changeTab(this.currIndex)
})
},
methods: {
@@ -124,6 +128,7 @@
this.$loading()
this.$instance.post(`/app/appneighborhoodassistance/list`, null, {
params: {
withoutToken: this.token ? false : true,
current: this.current,
size: 10,
visibleRange: this.currIndex === 0 ? 1 : 0

View File

@@ -9,15 +9,15 @@
<div class="add-btn" hover-class="text-hover" @click="$linkTo('./Add')">发贴</div>
</div>
<div class="bottom">
<div class="bottom-item" @click="currIndex = 0" :class="[currIndex === 0 ? 'active' : '']">
<div class="bottom-item" @click="changeTab(0)" :class="[currIndex === 0 ? 'active' : '']">
<span>发贴</span>
<h2>23</h2>
</div>
<div class="bottom-item" @click="currIndex = 1" :class="[currIndex === 1 ? 'active' : '']">
<div class="bottom-item" @click="changeTab(1)" :class="[currIndex === 1 ? 'active' : '']">
<span>点赞</span>
<h2>23</h2>
</div>
<div class="bottom-item" @click="currIndex = 2" :class="[currIndex === 2 ? 'active' : '']">
<div class="bottom-item" @click="changeTab(2)" :class="[currIndex === 2 ? 'active' : '']">
<span>评论</span>
<h2>23</h2>
</div>
@@ -144,7 +144,7 @@
methods: {
getTopicList () {
this.$instance.post(`/api/appneighborhoodassistancetheme/list`, null, {
this.$instance.post(`/app/appneighborhoodassistancetheme/list`, null, {
withoutToken: true,
params: {
current: 1,
@@ -152,28 +152,146 @@
}
}).then(res => {
if (res.code === 0) {
this.topicList = res.data.records
this.getMyPublish()
}
})
},
getList () {
changeTab (index) {
this.currIndex = index
this.isMore = false
this.current = 1
this.$nextTick(() => {
if (this.currIndex === 0) {
this.getMyPublish()
} else if (this.currIndex === 1) {
this.myPraiseList()
} else {
this.getMyCommentList()
}
})
},
getMyPublish () {
if (this.isMore) return
this.$loading()
this.$instance.post(`/api/appactivityinfo/list`, null, {
withoutToken: true,
this.$instance.post(`/app/appneighborhoodassistance/list`, null, {
params: {
withoutToken: this.token ? false : true,
current: this.current,
size: 10
size: 10,
visibleRange: this.currIndex === 0 ? 1 : 0
}
}).then(res => {
if (res.code === 0) {
this.$hideLoading()
if (this.current > 1) {
this.list = [...this.list, ...res.data.records]
this.list = [...this.list, ...res.data.records.map(e => {
return {
...e,
topicName: this.topicList.filter(v => v.id === e.themeId).length ? this.topicList.filter(v => v.id === e.themeId)[0].title : ''
}
})]
} else {
this.list = res.data.records
this.list = res.data.records.map(e => {
return {
...e,
topicName: this.topicList.filter(v => v.id === e.themeId).length ? this.topicList.filter(v => v.id === e.themeId)[0].title : ''
}
})
}
if (res.data.records.length < 10) {
this.isMore = true
return false
}
this.current = this.current + 1
} else {
this.isMore = true
}
}).catch(() => {
this.$hideLoading()
})
},
getMyCommentList () {
if (this.isMore) return
this.$loading()
this.$instance.post(`/app/appneighborhoodassistance/list`, null, {
params: {
withoutToken: this.token ? false : true,
current: this.current,
size: 10,
visibleRange: this.currIndex === 0 ? 1 : 0
}
}).then(res => {
if (res.code === 0) {
this.$hideLoading()
if (this.current > 1) {
this.list = [...this.list, ...res.data.records.map(e => {
return {
...e,
topicName: this.topicList.filter(v => v.id === e.themeId).length ? this.topicList.filter(v => v.id === e.themeId)[0].title : ''
}
})]
} else {
this.list = res.data.records.map(e => {
return {
...e,
topicName: this.topicList.filter(v => v.id === e.themeId).length ? this.topicList.filter(v => v.id === e.themeId)[0].title : ''
}
})
}
if (res.data.records.length < 10) {
this.isMore = true
return false
}
this.current = this.current + 1
} else {
this.isMore = true
}
}).catch(() => {
this.$hideLoading()
})
},
myPraiseList () {
if (this.isMore) return
this.$loading()
this.$instance.post(`/app/appneighborhoodassistance/list`, null, {
params: {
withoutToken: this.token ? false : true,
current: this.current,
size: 10,
visibleRange: this.currIndex === 0 ? 1 : 0
}
}).then(res => {
if (res.code === 0) {
this.$hideLoading()
if (this.current > 1) {
this.list = [...this.list, ...res.data.records.map(e => {
return {
...e,
topicName: this.topicList.filter(v => v.id === e.themeId).length ? this.topicList.filter(v => v.id === e.themeId)[0].title : ''
}
})]
} else {
this.list = res.data.records.map(e => {
return {
...e,
topicName: this.topicList.filter(v => v.id === e.themeId).length ? this.topicList.filter(v => v.id === e.themeId)[0].title : ''
}
})
}
if (res.data.records.length < 10) {
@@ -193,7 +311,13 @@
},
onReachBottom () {
this.getList()
if (this.currIndex === 0) {
this.getMyPublish()
} else if (this.currIndex === 1) {
this.myPraiseList()
} else {
this.getMyCommentList()
}
}
}
</script>