Files
dvcp_v2_wxcp_app/library/project/fd/AppAnswer/Search.vue

266 lines
5.8 KiB
Vue
Raw Normal View History

2023-01-10 14:08:05 +08:00
<template>
<div class="AppAnswerList">
<div class="search-wrapper">
<div class="search">
<image src="./img/search.png" />
2023-01-11 11:31:07 +08:00
<input placeholder="请输入" v-model="content" @confirm="onChange">
2023-01-11 15:07:01 +08:00
<image v-if="content" src="./img/close.png" @click="content = '', onChange()" />
2023-01-10 14:08:05 +08:00
</div>
</div>
<div class="list-wrapper">
2023-01-11 11:31:07 +08:00
<div class="item" v-for="(item, index) in list" :key="index" @click="linkTo('./answerList?id=' + item.id)">
2023-01-10 14:08:05 +08:00
<div class="item-title">
2023-01-11 11:31:07 +08:00
<i>{{ item.createUserId === user.id ? '我' : item.createUserName }} </i>
<span>{{ item.createTime }} 提问</span>
2023-01-10 14:08:05 +08:00
</div>
2023-01-17 09:24:20 +08:00
<p v-html="item.content"></p>
2023-01-10 14:08:05 +08:00
<div class="item-bottom">
<div class="left">
<span></span>
2023-01-11 11:31:07 +08:00
<i>{{ item.answerCount }}</i>
2023-01-10 14:08:05 +08:00
<span>条回答</span>
</div>
<div class="right">
2023-01-11 11:31:07 +08:00
<span @click.stop="linkTo('./Add?id=' + item.id)" v-if="item.createUserId === user.id && item.answerCount === 0">修改问题</span>
2023-01-10 14:08:05 +08:00
<span @click.stop="linkTo('./answerAdd')">去回答</span>
</div>
</div>
</div>
2023-01-11 11:31:07 +08:00
<AiEmpty v-if="!list.length"></AiEmpty>
2023-01-10 14:08:05 +08:00
</div>
</div>
</template>
<script>
2023-01-11 11:31:07 +08:00
import { mapState } from 'vuex'
2023-01-10 14:08:05 +08:00
export default {
2023-01-10 14:19:26 +08:00
appName: '学习问答',
2023-01-10 14:08:05 +08:00
data () {
return {
2023-01-11 11:31:07 +08:00
search: {
current: 1,
size: 10
},
content: '',
isMore: false,
list: []
2023-01-10 14:08:05 +08:00
}
},
2023-01-11 11:31:07 +08:00
computed: {
...mapState(['user']),
},
2023-01-10 14:08:05 +08:00
2023-01-11 11:31:07 +08:00
mounted () {
2023-01-10 14:08:05 +08:00
},
methods: {
linkTo (url) {
uni.navigateTo({
url
})
2023-01-11 11:31:07 +08:00
},
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) {
2023-01-17 09:24:20 +08:00
this.list = [...this.list, ...res.data.records.map(v => {
if (v.content.indexOf(this.content) > -1) {
v.content = v.content.replaceAll(this.content, `<i style="font-style: normal; color: #3975C6;" class="keyworld">${this.content}</i>`)
}
return v
})]
2023-01-11 11:31:07 +08:00
} else {
2023-01-17 09:24:20 +08:00
this.list = res.data.records.map(v => {
if (v.content.indexOf(this.content) > -1) {
v.content = v.content.replaceAll(this.content, `<i style="font-style: normal; color: #3975C6;" class="keyworld">${this.content}</i>`)
}
return v
})
2023-01-11 11:31:07 +08:00
}
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()
})
2023-01-10 14:08:05 +08:00
}
2023-01-11 11:31:07 +08:00
},
onReachBottom () {
this.current = this.current + 1
this.getList()
2023-01-10 14:08:05 +08:00
}
}
</script>
<style lang="scss" scoped>
.AppAnswerList {
padding: 0 32px 20px;
.search-wrapper {
position: sticky;
top: 0;
z-index: 11;
padding: 20px 0;
background: #F3F5F9;
}
.search {
display: flex;
align-items: center;
height: 64px;
padding: 0 32px;
border-radius: 16px;
background: #fff;
image {
width: 32px;
height: 32px;
margin-right: 8px;
}
input {
flex: 1;
font-size: 26px;
color: #999999;
}
}
.answer-btn {
position: fixed;
bottom: 0;
left: 0;
z-index: 11;
width: 100%;
padding: 16px 32px;
text-align: center;
box-sizing: border-box;
background: #F3F5F9;
div {
height: 88px;
line-height: 88px;
background: #3975C6;
border-radius: 44px;
font-size: 34px;
color: #FFFFFF;
}
}
.list-wrapper {
padding-bottom: 40px;
.item {
margin-bottom: 24px;
padding: 24px;
border-radius: 16px;
background: #fff;
2023-01-17 09:24:20 +08:00
.keyworld {
font-style: normal;
color: #3975C6;
}
2023-01-10 14:08:05 +08:00
.item-bottom {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 48px;
.right {
span {
height: 56px;
line-height: 56px;
margin-right: 24px;
padding: 0 16px;
background: #FFFFFF;
border: 1px solid #FF883C;
color: #FF883C;
border-radius: 8px;
&:last-child {
margin-right: 0;
color: #3975C6;
border: 1px solid #3975C6;
}
}
}
div {
display: flex;
align-items: center;
font-size: 28px;
color: #999;
}
i {
font-style: normal;
color: #3975C6;;
}
}
p {
line-height: 1.3;
font-size: 34px;
color: #333333;
}
.item-title {
display: flex;
align-items: center;
margin-bottom: 16px;
font-size: 28px;
color: #999;
i {
font-style: normal;
color: #3975C6;;
}
}
}
}
}
</style>