<template>
	<view class="product">
		<view class="newslist" v-for="(item,index) in list" :key="index" @click="handleActive(item.id)">
			<view class="right">
				<image :src="item.headimg" mode="aspectFit"></image>
			</view>
			<view class="left">
				<view class="title">
					{{item.title}}
				</view>
			</view>
			<view class="time">
				<view class="size14 c999" style="width:60%">
					<icon class="iconfont icon-icon-test1"></icon>
					{{item.createdtime}}
				</view>
				<view class="size14 c999 textR" style="width:40%">
					<icon class="iconfont icon-icon-test"></icon>
					{{item.browsecnt}}次浏览
				</view>
			</view>
			<!-- <view class="time isAddress" v-if="isAddress==4">
				<view class="size14 c999">
					<uni-icons type="location-filled" size="20" class="location"></uni-icons>
					{{item.province}}{{item.city}}{{item.area}}{{item.address}}
				</view>
				<view class="size14 c999 ml-10">
					<icon class="iconfont icon-icon-test1"></icon>
					{{item.starttime}}至{{item.endtime}}
				</view>
			</view> -->
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from "vuex";
	export default {
		name: "productList",
		props: {
			isAddress: {
				type: Number,
				default: 1 //1资讯4活动,7党建
			},
			list: {
				type: Array,
				default () {
					return []
				}
			}
		},
		methods: {
			handleActive(id) {
				let that = this
				// if (!uni.getStorageSync('token')) {
				// 	that.$tools.msg("登录后查看更多")
				// 	return
				// }
				let type = that.isAddress == 1 || that.isAddress == 4 ? 1 : that.isAddress
				let account = {
					id: id,
					IsBrowseCnt: 2,
					type: type.toString()
				}
				let https = ""
				if (type == 1 || type == 4 || type == 5 || type == 6 || type == 7) {
					https = that.$model.getInfoDetail(account)
					// } else if (type == 4) {

					// 	https = that.$model.getCampaignDetail(account)
				}
				return https.then((res) => {
					if (res.code != 0) return
					res.data.type = type
					that.$emit("handleSearchId", id, res.data.browsecnt)
					if (type == 4) {
						uni.navigateTo({
							url: "/pageTwo/news/detail?id=" + res.data.id + "&type=" + res.data.type
						})
					} else {
						that.$tools.NewsPtype(res.data)
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.location {
		float: left;
		display: block;
		margin-top: 0px;
	}

	.textR {
		display: flex !important;
		justify-content: flex-end !important;
	}
</style>