学习问答

This commit is contained in:
yanran200730
2023-01-11 09:58:04 +08:00
parent 4fcc643a09
commit e59cc375d1
4 changed files with 133 additions and 14 deletions

View File

@@ -1,9 +1,9 @@
<template>
<div class="add">
<textarea placeholder="请输入回答内容" :maxlength="500"></textarea>
<textarea placeholder="请输入" :maxlength="500" v-model="content"></textarea>
<div class="answer-btn">
<div>提问</div>
<div @click="submit">提问</div>
</div>
</div>
</template>
@@ -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)
}
})
}
}
}

View File

@@ -7,7 +7,7 @@
</div>
</div>
<div class="AppAnswer-body">
<component :is="component"></component>
<component :is="component" :ref="component"></component>
</div>
</div>
</template>
@@ -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()
}
}
</script>

View File

@@ -7,12 +7,12 @@
</div>
</div>
<div class="list-wrapper">
<div class="item" v-for="(item, index) in 12" :key="index" @click="linkTo('./answerList')">
<div class="item" v-for="(item, index) in list" :key="index" @click="linkTo('./answerList?id=' + item.id)">
<div class="item-title">
<i> </i>
<span>2022年12月30日 12:23:54 提问</span>
<span>{{ item.createTime }} 提问</span>
</div>
<p>基层工作如何展开相关工作合适基层工作如何展开相关工作合适基层工作如何展...</p>
<p>{{ item.content }}</p>
<div class="item-bottom">
<div class="left">
<span></span>
@@ -25,6 +25,7 @@
</div>
</div>
</div>
<AiEmpty v-if="!list.length && isMore"></AiEmpty>
</div>
<div class="answer-btn">
<div @click="linkTo('./Add')">提问</div>
@@ -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()
})
}
}

View File

@@ -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()
})
}
}
}