policy.vue 7.48 KB
<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>
		<!-- 搜索 -->
		<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: "http://deyanggaoxin.fengshiyun.com",
				haveData:false,
				isImg:false
			};
		},
		onLoad() {
			let that = this
			that.getUser()
			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() {
				let that = this
				that.API.getPolicyList({
					// categoryId: this.categorrId,
					// categoryId:'360234017372505349',
					// keyword: this.keyword,
					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.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.TabSecond,
					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
				console.log(type)
				that.API.getPolicyList({
					isType:this.TabShow,
					isType2:this.TabSecond,
					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>