construct.vue 2.78 KB
<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>