<template>
	<view>
		<view class="xw_content" v-for="(item,index) in newsList" :key="index" @click="clickNews(item)">
			<u--image :src="imgUrl+item.cover" width="192rpx" height="122rpx" :lazy-load="true">
			</u--image>
			<view class="xw_right">
				<view class="xw_title">
					{{item.title}}
				</view>
				<view style="display: flex;">
					<text class="xw_time">
						{{item.pub_time_str}}
					</text>
					<text class="xw_time xw_place">
						{{item.pub_name}}
					</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		dateFormat
	} from '../../utills/date.js'
	export default {
		data() {
			return {
				imgUrl: '',
				newsList: [],
			}
		},
		created() {
			this.getNews()
			this.imgUrl = uni.getStorageSync('img_url')
		},
		methods: {
			getNews() {
				this.$apiServe.getNews().then(res => {
					console.log('行业新闻', res.data.data)
					for (const item of res.data.data) {
						item.pub_time_str = dateFormat(item.pub_time_str)
					}
					this.newsList = res.data.data
				}).finally(_ => {})
			},
			// 跳转到新闻详情页
			clickNews(item) {
				uni.navigateTo({
					url: '../../packageReport/xwDetail/xwDetail?id=' + item.id
				})
			},
		}
	}
</script>
