学习问答

This commit is contained in:
yanran200730
2023-01-11 11:31:07 +08:00
parent 315f0e6fdd
commit 4d5c6dfe0f
4 changed files with 171 additions and 27 deletions

View File

@@ -3,54 +3,123 @@
<div class="search-wrapper">
<div class="search">
<image src="./img/search.png" />
<input placeholder="请输入" v-model="name">
<image v-if="name" src="./img/close.png" @click="name = ''" />
<input placeholder="请输入" v-model="content" @confirm="onChange">
<image v-if="content" src="./img/close.png" @click="content = ''" />
</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>
<i>{{ item.createUserId === user.id ? '我' : item.createUserName }} </i>
<span>{{ item.createTime }} 提问</span>
</div>
<p>基层工作如何展开相关工作合适基层工作如何展开相关工作合适基层工作如何展...</p>
<p>{{ item.content }}</p>
<div class="item-bottom">
<div class="left">
<span></span>
<i>0</i>
<i>{{ item.answerCount }}</i>
<span>条回答</span>
</div>
<div class="right">
<span @click.stop="linkTo('./answerList')">修改问题</span>
<span @click.stop="linkTo('./Add?id=' + item.id)" v-if="item.createUserId === user.id && item.answerCount === 0">修改问题</span>
<span @click.stop="linkTo('./answerAdd')">去回答</span>
</div>
</div>
</div>
<AiEmpty v-if="!list.length"></AiEmpty>
</div>
</div>
</template>
<script>
import { mapState } from 'vuex'
export default {
appName: '学习问答',
data () {
return {
name: ''
search: {
current: 1,
title: '',
size: 10
},
content: '',
isMore: false,
list: []
}
},
mounted () {
computed: {
...mapState(['user']),
},
mounted () {
},
methods: {
linkTo (url) {
console.log(url)
uni.navigateTo({
url
})
},
onChange () {
this.current = 1
this.isMore = false
this.getList()
},
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,
content: this.content || ''
}
}).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 < 10) {
this.isMore = true
return false
}
this.search.current = this.search.current + 1
} else {
uni.hideLoading()
}
}).catch(() => {
uni.hideLoading()
})
}
},
onReachBottom () {
this.current = this.current + 1
this.getList()
}
}
</script>