Blame view

pages/construct/construct.vue 2.78 KB
290144e9   易尊强   第一次
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
  <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 class="postCon" v-show="isAdmin"
  			@click="toPostCon()">
  			党的建设发布
  		</view>
  		<!-- 文章数据 -->
  		<view v-if="TabShow===0">
      <view>
  		<view class="article-data">
  			<view class="article-list">
  				<view class="list" v-for="(item,index) in newsList"
  				@click="onArticle(item)"
  				: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:{
  			// 获取用户信息
  			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
  					console.log(userCode)
  					if(userCode.userInfo.userId === 'admin'){
  						this.isAdmin = true
  					}
  				} 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>