diff --git a/src/project/fd/AppAnswer/Add.vue b/src/project/fd/AppAnswer/Add.vue index 17229791..5c02eee7 100644 --- a/src/project/fd/AppAnswer/Add.vue +++ b/src/project/fd/AppAnswer/Add.vue @@ -1,9 +1,9 @@ @@ -14,7 +14,29 @@ data () { return { + content: '' + } + }, + methods: { + submit () { + if (!this.content) { + return this.$u.toast('请输入题目内容') + } + + this.$loading() + this.$http.post(`/app/applearningquestion/addOrUpdate`, { + content: this.content + }).then(res => { + if (res.code == 0) { + this.$u.toast('提交成功') + uni.$emit('update') + + setTimeout(() => { + uni.navigateTo() + }, 500) + } + }) } } } diff --git a/src/project/fd/AppAnswer/AppAnswer.vue b/src/project/fd/AppAnswer/AppAnswer.vue index c4c256e0..e10276f9 100644 --- a/src/project/fd/AppAnswer/AppAnswer.vue +++ b/src/project/fd/AppAnswer/AppAnswer.vue @@ -7,7 +7,7 @@
- +
@@ -39,6 +39,13 @@ computed: { ...mapState(['user']), }, + + onLoad () { + uni.$on('update', () => { + this.$refs.List.update() + }) + }, + methods: { getList () { @@ -55,7 +62,7 @@ }, onReachBottom () { - this.getList() + this.$refs[this.component].getMore() } } diff --git a/src/project/fd/AppAnswer/component/List.vue b/src/project/fd/AppAnswer/component/List.vue index ead1f911..cc026303 100644 --- a/src/project/fd/AppAnswer/component/List.vue +++ b/src/project/fd/AppAnswer/component/List.vue @@ -7,12 +7,12 @@
-
+
- 于2022年12月30日 12:23:54 提问 + 于{{ item.createTime }} 提问
-

基层工作如何展开相关工作合适基层工作如何展开相关工作合适基层工作如何展...

+

{{ item.content }}

@@ -25,6 +25,7 @@
+
提问
@@ -36,18 +37,69 @@ export default { data () { return { - name: '' + search: { + current: 1, + title: '', + size: 20 + }, + isMore: false, + list: [] } }, mounted () { - + this.$loading() + this.getList() }, methods: { - linkTo (url) { + linkTo () { uni.navigateTo({ - url + url: './Add' + }) + }, + + getMore () { + this.current = this.current + 1 + + this.getList() + }, + + update () { + this.current = 1 + this.isMore = false + + this.getList() + }, + + getList () { + if (this.isMore) return + this.$http.post(`/app/applearningquestion/list`, null, { + params: { + ...this.search + } + }).then(res => { + if (res.code == 0) { + if (this.search.current > 1) { + this.list = [...this.list, ...res.data.records] + } else { + this.list = res.data.records + } + + uni.hideLoading() + + if (res.data.records.length < 20) { + this.isMore = true + + return false + } + + this.search.current = this.search.current + 1 + } else { + uni.hideLoading() + } + }).catch(() => { + uni.hideLoading() }) } } diff --git a/src/project/fd/AppAnswer/component/Ranking.vue b/src/project/fd/AppAnswer/component/Ranking.vue index cbfb2eaa..28876de5 100644 --- a/src/project/fd/AppAnswer/component/Ranking.vue +++ b/src/project/fd/AppAnswer/component/Ranking.vue @@ -27,12 +27,19 @@ export default { data () { return { - + search: { + current: 1, + title: '', + size: 20 + }, + isMore: false, + list: [] } }, - mounted: { - + mounted () { + this.$loading() + this.getList() }, methods: { @@ -40,6 +47,37 @@ uni.navigateTo({ url: './IntegralDetail' }) + }, + + getList () { + if (this.isMore) return + this.$http.post(`/app/applearningquestion/scoreRanking`, null, { + params: { + ...this.search + } + }).then(res => { + if (res.code == 0) { + if (this.search.current > 1) { + this.list = [...this.list, ...res.data.records] + } else { + this.list = res.data.records + } + + uni.hideLoading() + + if (res.data.records.length < 20) { + this.isMore = true + + return false + } + + this.search.current = this.search.current + 1 + } else { + uni.hideLoading() + } + }).catch(() => { + uni.hideLoading() + }) } } }