<template>
	<view style="background-color: #ffffff;">
		<view style="background-color: #f4f4f4;">
			<u-row>
				<u-col span="10">
					<view style="padding: 10rpx 15px;" class="font-jianju">
						<u-text :text="title" size="18" color="rgb(55,186,189)"></u-text>
					</view>
				</u-col>
				<u-col span="2">
					<view @tap.stop="onClick">
						<u-text v-if="limit !== 0" text="更多>>" color="rgb(83, 201, 255)"></u-text>
					</view>
				</u-col>
			</u-row>
		</view>
		<view v-if="list.length === 0 || null === list || undefined === list"
			style="text-align: center;padding: 50px 0;color: #5a5a5a;">
			<view class="font-jianju">
				暂无数据
			</view>
		</view>
		<view v-if="1 === showType" v-for="(item, index) in list" :key="index">
			<view v-if="limit == 0 || index < limit" @click="ononclick(1,item)"
				style="border-bottom: 1rpx solid #cfcfcf;">
				<view style="padding: 10rpx 40rpx;">
					<u-row>
						<u-col>
							<view class="font-jianju">
								<u-text :text="item.noticeTitle" size="14" color="#474747" mode="text">
								</u-text>
							</view>
						</u-col>
					</u-row>
					<u-row>
						<view style="padding-top: 3px;">
							<view>
								<view>
									<u-text :text="item.createTime" color="#b1b1b1" size="12">
									</u-text>
								</view>
							</view>
						</view>
					</u-row>
				</view>
			</view>
		</view>
		<view v-if="2 === showType" v-for="(item, index) in list" :key="index">
			<view v-if="limit == 0 || index < limit" style="border-bottom: 1px solid #cfcfcf;padding: 0;"
				@click="ononclick(2,item)">
				<view style="padding: 10rpx 40rpx;">
					<view class="uni-flex uni-row">
						<view>
							<img :src="url+item.imgPath"
								style="border-radius: 5px;width: 198rpx; height: 150.5rpx ;border: 1px solid #f3f3f3;">
							</img>
						</view>
						<view>
							<view class="font-jianju" style="padding-left: 10px;height: 100%;width: 490rpx">
								<u-text :text="item.text" mode="text" color="#6c6c6c" size="15">
								</u-text>
							</view>
						</view>
					</view>
					<view>
						<view
							style="height: 5rpx;padding: 0;position: relative;bottom: 20rpx;text-align: right;color:#b1b1b1;">
							<view style="font-size: 20rpx;">
								{{item.updateTime}}
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>

		<view v-if="3 === showType" v-for="(item, index) in list" :key="index">
			<u-row style="border-bottom: 1px solid #cfcfcf;padding: 10rpx;">
				<view>
					<view style="padding: 0 5px 2px 5px;">
						<u-text :text="item.text" mode="text" bold :lines="3" size="18">
						</u-text>
					</view>
					<view style="padding: 0 5px;">
						<img :src="url+item.imgPath" width="100%" height="100%"
							style="border-radius: 5px;border: 1px solid #f3f3f3;">
						</img>
					</view>
					<view style="padding: 0 5px;">
						<u-text :text="item.updateTime" mode="text" color="#b1b1b1" size="14">
						</u-text>
					</view>
				</view>
				</u-col>
			</u-row>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			list: {
				type: Array,
				default: () => []
			},
			url: {
				type: String
			},
			title: {
				type: String
			},
			showType: {
				type: Number,
				default: 0
			},
			limit: {
				type: Number,
				default: 0
			}
		},
		name: "homelist",
		data() {
			return {
				data: {},
				show: false,
				open: false,
				baseURL: uni.$BASE_URL,
				timeFormat: uni.$u.timeFormat
			}
		},
		onLoad() {},
		methods: {
			ononclick(type, item) {
				item.type = type
				uni.setStorageSync("noticeData", item)
				this.$goto("../../pageA/notice/notice")
			},
			// close() {
			// 	uni.showTabBar({
			// 		animation: true,
			// 	})
			// 	//this.$refs.popup[0].close()
			// },
			// dialogConfirm() {
			// 	uni.showTabBar({
			// 		animation: true,
			// 	})
			// },
			onClick() {
				const form = {
					titile: this.title,
					limit: 0,
					showType: this.showType,
					list: this.list
				}
				uni.setStorageSync("moreData", form)
				this.$goto('../../pages/home/more')
			},
			// 打开自定义链接
			openCustomLink(link = '') {
				console.log(`link: ${link}`)
				window.location.href = "https://" + link
			},
			downLoad(item) {
				if (item) {
					let url = encodeURIComponent(item)
					uni.navigateTo({
						url: '../../pages/home/myWebView?url=' + url
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		padding: 0px;
	}

	.font-jianju {
		letter-spacing: 5rpx;
	}
</style>
