学习问答

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

@@ -51,7 +51,7 @@
uni.$emit('update') uni.$emit('update')
setTimeout(() => { setTimeout(() => {
uni.navigateTo() uni.navigateBack()
}, 500) }, 500)
} }
}) })

View File

@@ -1,18 +1,78 @@
<template> <template>
<div class="integralDetail"> <div class="integralDetail">
<div class="item" v-for="(item, index) in 10" :key="index"> <div class="item" v-for="(item, index) in list" :key="index">
<div class="left"> <div class="left">
<h2>提问</h2> <h2>{{ item.changeDesc }}</h2>
<p>2022-07-21 10:10:02</p> <p>{{ item.createTime }}</p>
</div> </div>
<span>+10</span> <span>+{{ item.changeScore }}</span>
</div> </div>
<AiEmpty v-if="!list.length && isMore"></AiEmpty>
</div> </div>
</template> </template>
<script> <script>
import { mapState } from 'vuex'
export default { export default {
appName: '积分明细', appName: '积分明细',
data () {
return {
search: {
current: 1,
size: 20
},
isMore: false,
list: []
}
},
computed: {
...mapState(['user']),
},
mounted () {
this.getList()
},
methods: {
getList () {
if (this.isMore) return
this.$http.post(`/app/applearningquestion/scoreDetail`, null, {
params: {
...this.search,
sysUserId: this.user.id
}
}).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()
})
}
},
onReachBottom () {
this.current = this.current + 1
this.getList()
}
} }
</script> </script>

View File

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

View File

@@ -2,44 +2,51 @@
<div class="ranking"> <div class="ranking">
<div class="list-wrapper"> <div class="list-wrapper">
<div class="item my" @click="linkTo"> <div class="item my" @click="linkTo">
<span>113</span> <span>{{ info['积分排行'] }}</span>
<div class="userinfo"> <div class="userinfo">
<image :src="'https://cdn.cunwuyun.cn/wxmp/tianfuxing/avatar.png'" /> <image :src="user.avatar || 'https://cdn.cunwuyun.cn/wxmp/tianfuxing/avatar.png'" />
<h3>且听风吟</h3> <h3>{{ user.name }}</h3>
</div> </div>
<i>20</i> <i>{{ info['累计获取积分'] }}</i>
<image class="right" src="../img/right.png" /> <image class="right" src="../img/right.png" />
</div> </div>
<div class="item" v-for="(item, index) in 21" :key="index"> <div class="item" v-for="(item, index) in list" :key="index">
<span>{{ index + 1 }}</span> <span>{{ index + 1 }}</span>
<div class="userinfo"> <div class="userinfo">
<image :src="'https://cdn.cunwuyun.cn/wxmp/tianfuxing/avatar.png'" /> <image :src="item.avatar || 'https://cdn.cunwuyun.cn/wxmp/tianfuxing/avatar.png'" />
<h3>且听风吟</h3> <h3>{{ item.name }}</h3>
</div> </div>
<i>20</i> <i>{{ item.score }}</i>
</div> </div>
<!-- <AiEmpty v-if="!list.length"></AiEmpty> --> <AiEmpty v-if="!list.length && isMore"></AiEmpty>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { mapState } from 'vuex'
export default { export default {
data () { data () {
return { return {
search: { search: {
current: 1, current: 1,
title: '', title: '',
size: 20 size: 100
}, },
isMore: false, isMore: false,
info: {},
list: [] list: []
} }
}, },
computed: {
...mapState(['user']),
},
mounted () { mounted () {
this.$loading() this.$loading()
this.getList() this.getList()
this.getInfo()
}, },
methods: { methods: {
@@ -49,6 +56,14 @@
}) })
}, },
getInfo () {
this.$http.post(`/app/applearningquestion/myScore`).then(res => {
if (res.code === 0) {
this.info = res.data
}
})
},
getList () { getList () {
if (this.isMore) return if (this.isMore) return
this.$http.post(`/app/applearningquestion/scoreRanking`, null, { this.$http.post(`/app/applearningquestion/scoreRanking`, null, {
@@ -65,7 +80,7 @@
uni.hideLoading() uni.hideLoading()
if (res.data.records.length < 20) { if (res.data.records.length < 100) {
this.isMore = true this.isMore = true
return false return false