policy.vue
7.87 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
<template>
<view class="page">
<view class="coupon-tab">
<view class="tab" :class="{'action':TabShow==='人才'}" @click="onCouponTab('人才')">
<text>人才</text>
</view>
<view class="tab" :class="{'action':TabShow==='企业'}" @click="onCouponTab('企业')">
<text>企业</text>
</view>
<view class="tab" :class="{'action':TabShow==='金融'}" @click="onCouponTab('金融')">
<text>金融</text>
</view>
<view class="tab" :class="{'action':TabShow==='法律法规'}" @click="onCouponTab('法律法规')">
<text>法律法规</text>
</view>
<view class="tab" :class="{'action':TabShow==='其他'}" @click="onCouponTab('其他')">
<text>其他</text>
</view>
</view>
<view class="coupon-tab-one">
<view class="tab" :class="{'action':TabSecond==='全部'}" @click="onCouponSecondTab('全部')">
<text>全部</text>
</view>
<view class="tab" :class="{'action':TabSecond==='国家级'}" @click="onCouponSecondTab('国家级')">
<text>国家级</text>
</view>
<view class="tab" :class="{'action':TabSecond==='省级'}" @click="onCouponSecondTab('省级')">
<text>省级</text>
</view>
<view class="tab" :class="{'action':TabSecond==='市级'}" @click="onCouponSecondTab('市级')">
<text>市级</text>
</view>
<view class="tab" :class="{'action':TabSecond==='本地'}" @click="onCouponSecondTab('本地')">
<text>本地</text>
</view>
</view>
<!-- 搜索 -->
<view class="search-head">
<view class="search">
<image src="../../static/fdj1.png"></image>
<text></text>
<input type="text" v-model="keyword" placeholder="搜索关键词" />
</view>
<view class="btn" @click="search">
<text>搜索</text>
</view>
</view>
<!-- 文章数据 -->
<view>
<!-- @down="downCallback"
@up="upCallback"
:down="downOption"
:up="upOption"
:top="0" -->
<!-- <mescroll-body ref="mescrollRef"
> -->
<view ref="mescrollRef">
<view class="article-data">
<!-- 党的建设发布 -->
<view class="postCon" v-show="isAdmin" @click="toPost()">
政策法规发布
</view>
<!-- <view class="noData" v-show="haveData">
暂无此类数据
</view> -->
<view class="article-list">
<view class="list" v-for="(item,index) in fenLeiList" @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.createTime}}</text>
</view>
</view>
</view>
<!-- <view class="thumb" v-if="item.isImg">
<image :src="baseUrl + item.imgUrl[0].url"></image>
</view> -->
<!-- <view class="thumb">
<image src="../../static/img/img3.jpg"></image>
</view> -->
</view>
</view>
</view>
</view>
<!-- </mescroll-body> -->
</view>
</view>
</template>
<script>
import service from '../../service/service.js'
import utils from '../../service/utils.js';
import util from '../../service/utils.js'
export default {
data() {
return {
TabShow: '人才',
TabSecond: '全部',
AllList: [],
fenLeiList: [],
searchList: [],
keyword: '',
isAdmin: false,
categoryId: '360234017372505349',
baseUrl: "https://www.dygxq-es.cn",
haveData:false,
isImg:false,
isType2:'全部'
};
},
onLoad() {
let that = this
that.getUser()
this.onCouponTab(this.TabShow)
this.onCouponSecondTab(this.TabSecond)
// that.getPolicyList()
},
methods: {
// 获取用户信息判断是否有政策法规发布的ID,权限判断authority = 396297481161278725
getUser() {
if (uni.getStorageSync('user')) {
let userCode = uni.getStorageSync('user')
// console.log("用户的code", this.userCode)
this.userId = userCode.userInfo.userId
this.userName = userCode.userInfo.userAccount
this.userIcon = userCode.userInfo.headIcon
this.organizeName = userCode.userInfo.organizeName
// this.isAdmin = userCode.userInfo.isCompany
let authorityID = userCode.permissionList
this.isAdmin = authorityID.some(it => it.modelId === '396297481161278725')
console.log('是否有政策法规发布权限',this.isAdmin)
} else {
uni.showToast({
title: '请登录',
icon: 'none'
})
}
},
// 获取政策法规列表
getPolicyList(type) {
let that = this
this.TabSecond = type
that.API.getPolicyList({
// categoryId: this.categorrId,
// categoryId:'360234017372505349',
// keyword: this.keyword,
isType:this.TabShow,
pageSize:1000
}).then(res => {
console.log(res)
that.AllList = res.data.list
console.log('总的',that.AllList)
that.AllList = that.AllList.map(it => {
return {
...it,
createTime: utils.formatTime(it.createTime),
// isImg: it.imgUrl.length > 0
}
})
this.fenLeiList = that.AllList.filter(it=>{
return it.isType == '人才'
})
if(this.fenLeiList === []){
this.haveData = true
}
console.log("this.AllList", this.AllList)
console.log("分类", this.fenLeiList)
})
},
onCouponTab(type) {
let that = this
this.TabShow = type;
// if(type == '其他'){
// that.fenLeiList = that.AllList.filter(it => {
// return it.isType === that.TabShow || it.isType === null
// })
// if(this.fenLeiList === null){
// this.haveData = true
// }
// }else{
// that.fenLeiList = that.AllList.filter(it => {
// return it.isType === that.TabShow
// })
// if(this.fenLeiList === null){
// this.haveData = true
// }
// }
that.API.getPolicyList({
isType:this.TabShow,
isType2:this.isType2,
pageSize:500
}).then(res => {
console.log(res)
that.AllList = res.data.list
console.log(that.AllList)
that.AllList = that.AllList.map(it => {
return {
...it,
createTime: utils.formatTime(it.createTime),
// isImg: it.imgUrl.length > 0
}
})
this.fenLeiList = that.AllList
if(this.fenLeiList === []){
this.haveData = true
}
console.log("分类", this.fenLeiList)
})
console.log('this.fenLeiList',this.fenLeiList)
console.log(type)
},
// 获取全部
// 显示下方为国家级还是省级等
onCouponSecondTab(type) {
let that = this
this.TabSecond = type
if(type == '全部'){
this.isType2 = ''
}else{
this.isType2 = type
}
console.log(type)
that.API.getPolicyList({
isType:this.TabShow,
isType2:this.isType2,
pageSize:500
}).then(res => {
console.log(res)
that.AllList = res.data.list
console.log(that.AllList)
that.AllList = that.AllList.map(it => {
return {
...it,
createTime: utils.formatTime(it.createTime),
// isImg: it.imgUrl.length > 0
}
})
this.fenLeiList = that.AllList
if(this.fenLeiList === []){
this.haveData = true
}
console.log("分类", this.fenLeiList)
})
},
onArticle(item) {
uni.navigateTo({
url: `/pages/policyDetail/policyDetail?data=${JSON.stringify(item)}`
})
},
search() {
let that = this
that.API.getPolicyList({
// categoryId: this.categoryId,
keyword: this.keyword
}).then(res => {
// console.log(res)
that.fenLeiList = res.data.list.map(it => {
return {
...it,
createTime: utils.formatTime(it.createTime),
// isImg: it.imgUrl.length > 0
}
})
if(this.fenLeiList === null){
this.haveData = true
}
// console.log(that.AllList)
})
},
// 跳转到发布页面
toPost() {
uni.navigateTo({
url: '/pages/postPolicy/postPolicy'
})
}
}
}
</script>
<style scoped lang="scss">
@import 'policy.scss';
</style>