征信小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
zhengxinApplets/pages/user/release.vue

199 lines
4.0 KiB

<template>
<view class="release">
<view class="tab">
<view class="li" v-for="(a,i) in typeList" :class="tabIndex == i?'li-on':''" @click="tabItem(i)">{{a.name}}</view>
</view>
<view class="item" v-for="(a,i) in list" :key="i" @click="openPage(a.id)">
<view class="a">
{{a.title}}
<text>{{a.content_tag}}</text>
</view>
<view class="b">
<view class="tag" :class="a.status!=-1?'':'tag-on'">{{a.status_text}}</view>
阅读:{{a.readnum}}
</view>
</view>
<view class="empty" v-if="total == 0">
<image src="https://zhengxin.njrenzhou.cn/static/empty.png"></image>
<view class="txt">暂无数据 ~</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
tabIndex: 0,
list: [],
total: 1,
offset: 1,
typeList: []
};
},
mounted() {
this.getTylelist();
},
onShow() {
this.querytContentList(2);
},
onReachBottom() {
const that = this;
uni.showLoading({
title: "加载中"
})
if(this.list.length <= this.total){
that.offset ++;
setTimeout(function() {
that.querytContentList(1);
}, 1000);
}
},
methods: {
//数组对象去重
arrayUnique (arr, name) {
var hash = {};
return arr.reduce(function (item, next) {
hash[next[name]]
? ""
: (hash[next[name]] = true && item.push(next));
return item;
}, []);
},
//事件类型
async getTylelist() {
const { code, data } = await this.$api.getTylelist({})
if(code == 1){
let arr = []
if(data && data.length > 0){
data.map(a=>{
a.name = a.title
})
}
this.typeList = [{name: "全部事件"},...data]
}
},
//获取事件
async querytContentList(type) {
const that = this;
if(type==2){
this.offset = 1;
this.tabIndex= 0;
}
const { code, data } = await that.$api.getUserContentList({
offset: this.offset,
limit: 20,
content_type_id: (this.tabIndex==0?0:this.typeList[this.tabIndex].id),
user_id: uni.getStorageSync("userInfo").id,
token: uni.getStorageSync("token")
})
if(code == 1){
if(type==1){
uni.hideLoading();
}
that.list = this.arrayUnique([...that.list,...data.rows],'id');
that.total = data.total;
}
},
tabItem(index){
this.tabIndex = index;
this.list = [];
this.offset = 1;
this.querytContentList();
},
openPage(id){
uni.navigateTo({
url: "/pages/release/detail?id="+id
})
},
}
}
</script>
<style scoped lang="scss">
.release{
padding: 0 25rpx 25rpx;
overflow: hidden;
.empty{
padding: 150rpx 0;
text-align: center;
font-size: 26rpx;
color: #666;
image{
width: 460rpx;
height: 400rpx;
margin-bottom: 30rpx;
}
}
.tab{
width: 110%;
overflow: hidden;
padding-top: 10rpx;
.li{
width: 150rpx;
line-height: 60rpx;
border-radius: 10rpx;
border: 1px solid #D4E4DF;
text-align: center;
font-weight: 500;
font-size: 28rpx;
color: #999999;
margin-top: 20rpx;
float: left;
margin-right: 20rpx;
&-on{
color: #00C6A9;
border-color: #00C6A9;
}
}
}
.item{
padding: 30rpx 25rpx;
overflow: hidden;
display: flex;
align-items: center;
justify-content: space-between;
background-color: #FFFFFF;
margin-top: 20rpx;
box-shadow: 0px 3rpx 10rpx 0px rgba(9,44,39,0.05);
border-radius: 20rpx;
.a{
flex: 1;
font-weight: 500;
font-size: 30rpx;
color: #222222;
text{
font-weight: 500;
font-size: 24rpx;
color: #999999;
display: block;
margin-top: 15rpx;
}
}
.b{
font-weight: 500;
font-size: 24rpx;
color: #333333;
margin-left: 20rpx;
.tag{
width: 100rpx;
height: 50rpx;
line-height: 50rpx;
background: #00C6A9;
border-radius: 4rpx;
font-weight: 500;
font-size: 22rpx;
display: flex;
align-items: center;
justify-content: center;
color: #FFFFFF;
margin: 0 auto 10rpx;
&-on{
background-color: #D80C0C;
}
}
}
}
}
</style>