construct.vue
2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<template>
<view class="page" style="overflow: hidden;">
<!-- 搜索 -->
<view class="search-head">
<view class="search">
<image src="../../static/fdj1.png"></image>
<text></text>
<input type="text" placeholder="搜索关键词" />
</view>
<view class="btn">
<text>搜索</text>
</view>
</view>
<!-- 党的建设发布 -->
<!-- 文章数据 -->
<view v-if="TabShow===0">
<view>
<view class="article-data">
<view class="postCon" v-show="isAdmin"
@click="toPostCon()">
党的建设发布
</view>
<view class="article-list">
<view class="list" v-for="(item,index) in newsList"
@click="onArticle(item.id)"
:key="index">
<view class="item">
<view class="title">
<text class="two-omit">{{item.tItle}}</text>
</view>
<view class="find-collect">
<view class="find">
<text>{{item.creatorTime}}</text>
</view>
</view>
</view>
<view class="thumb">
<image src="../../static/img/ma.jpg"></image>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import utils from '../../service/utils';
export default {
data() {
return {
TabShow: 0,
newsList:[],
isAdmin:false
};
},
onLoad() {
this.getUser()
this.getConstructList()
},
methods:{
// 获取用户信息判断是否有党建建设发布的ID,权限判断authority = 519148751890154757
getUser(){
if (uni.getStorageSync('user')) {
let userCode = uni.getStorageSync('user')
// console.log("用户的code", this.userCode)
this.userId = userCode.userInfo.userId
console.log(userCode)
let authorityID = userCode.permissionList
this.isAdmin = authorityID.some(it => it.modelId === '519148751890154757')
console.log('是否有党建发布权限',this.isAdmin)
} else {
uni.showToast({
title: '请登录',
icon: 'none'
})
}
},
// 获取党的建设列表
getConstructList(){
let that = this
that.API.getConstructList().then(res => {
console.log(res)
that.newsList = res.data.list
// that.highThree = that.newsList.sort(function(a,b){return a.ViewCount - b.ViewCount}).slice(-3)
that.newsList = JSON.parse(JSON.stringify(that.newsList.map(it =>{
return {
...it,
creatorTime:utils.formatTime(it.creatorTime)
}
})))
console.log(that.newsList)
})
},
onCouponTab(type){
this.TabShow = type;
},
onArticle(item){
uni.navigateTo({
url: `/pages/conDetail/conDetail?data=${JSON.stringify(item)}`
})
},
// 党的建设发布
toPostCon(item){
uni.navigateTo({
url:`/pages/postCon/postCon`
})
}
}
}
</script>
<style scoped lang="scss">
@import 'construct.scss';
</style>