mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-06 17:36:45 +08:00
139 lines
3.0 KiB
Vue
139 lines
3.0 KiB
Vue
<template>
|
|
<view class="news-page-info">
|
|
<view class="tabs-info">
|
|
<u-tabs :list="listTabs" @click="click"
|
|
lineColor="#387DF7"
|
|
lineWidth="35"
|
|
lineHeight="4"
|
|
:activeStyle="{
|
|
color: '#333333',
|
|
fontWeight: '600',
|
|
transform: 'scale(1.1)'
|
|
}"
|
|
:inactiveStyle="{
|
|
color: '#666666',
|
|
}"
|
|
></u-tabs>
|
|
</view>
|
|
<view class="" v-show="tab == 0">
|
|
<system-news></system-news>
|
|
</view>
|
|
<view class="" v-show="tab == 1">
|
|
<at-my :items="data"></at-my>
|
|
</view>
|
|
<view v-if="total>query.pageSize">
|
|
<uni-load-more :status="loadStatus"></uni-load-more>
|
|
</view>
|
|
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import apiQa from '@/api/modules/qa.js'
|
|
import apiComments from '../../api/modules/comments.js';
|
|
import apiUser from '@/api/system/user.js'
|
|
export default {
|
|
data() {
|
|
return {
|
|
listTabs:[
|
|
{name:'系统'},
|
|
{name:'@我的'}
|
|
],
|
|
tab:0,
|
|
data:[],//拿到的数据
|
|
total:0,//总条数
|
|
loadStatus:'more',//more,loading,noMore
|
|
query:{
|
|
pageIndex:1,//当前页
|
|
type:null,//当前只限于文章
|
|
pageSize:10,//条数
|
|
},//查询条件
|
|
}
|
|
},
|
|
onLoad() {
|
|
this.findData(true);
|
|
},
|
|
onPullDownRefresh() {
|
|
this.onReachBottom();
|
|
},
|
|
onReachBottom() {
|
|
console.log('111111')
|
|
this.loadStatus='loading';//more,loading,noMore
|
|
if(this.data.length<this.total){
|
|
this.query.pageIndex++;
|
|
this.findData(false);
|
|
this.loadStatus='more'
|
|
}else{
|
|
this.loadStatus='noMore'
|
|
}
|
|
},
|
|
methods: {
|
|
click(item) {
|
|
this.tab = item.index;
|
|
},
|
|
ubtab(num){
|
|
this.tab = num
|
|
},
|
|
findData(flag) {
|
|
uni.showLoading({ title: '加载中...' });
|
|
if(flag){
|
|
this.data=[]
|
|
this.pageIndex=1
|
|
}
|
|
apiComments.pagelist(this.query).then(res=>{
|
|
if (res.status == 200) {
|
|
this.total=res.result.count;
|
|
let ids = [];
|
|
if (res.result.list.length != 0) {
|
|
res.result.list.forEach(item=>{
|
|
ids.push(item.sysCreateAid);
|
|
item.authorInfo={avatar:'',name:'',code:'',sex:null};
|
|
this.data.push(item)
|
|
})
|
|
this.loadAuthorInfo(res.result.list,ids);
|
|
}
|
|
}else{
|
|
this.$refs.interactToast.show({message:'加载@我的评论失败',type:'error'});
|
|
}
|
|
uni.hideLoading();
|
|
})
|
|
},
|
|
loadAuthorInfo(list, ids) {
|
|
//加载作者信息,头像,机构信息
|
|
if (ids.length == 0) {
|
|
return;
|
|
}
|
|
const noReapetIds = [...new Set(ids)];
|
|
apiUser.getByIds(ids).then(res => {
|
|
if (res.status == 200) {
|
|
list.forEach((item, index) => {
|
|
res.result.some(author => {
|
|
if (author.aid == item.sysCreateAid) {
|
|
item.authorInfo = author;
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
});
|
|
});
|
|
} else {
|
|
console.log('加载用户信息失败:' + res.error);
|
|
}
|
|
});
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
|
|
.news-page-info{
|
|
background-color: #fff;
|
|
.tabs-info{
|
|
padding: 0 254upx;
|
|
}
|
|
|
|
|
|
}
|
|
</style>
|