<template>
	<view style="display: flex;flex-wrap: wrap;">
		<view class="project" v-for="item in projects" :key="item.number" @tap="showDetail" :data-code="item.code">
			<image class="image" src="../../static/项目管理/项目管理@2x.png"></image>
			<text class="text">{{item.name}}</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				projects: [],

			}
		},
		onLoad() {
			uni.request({
				url: 'http://127.0.0.1:9999/project/list',
				method: 'GET',
				data: {},
				success: res => {
					this.projects = res.data.data.projects;
					console.log(res.data.data.projects);
				},

			})

			uni.$on('flush', () => {
				uni.request({
					url: 'http://127.0.0.1:9999/project/list',
					method: 'GET',
					data: {},
					success: res => {
						this.projects = res.data.data.projects;
						console.log(res.data.data.projects);
					},

				})
			})
		},
		methods: {
			showDetail(e) {
				console.log(e);
				var code = e.currentTarget.dataset.code;

				uni.navigateTo({
					url: '/pages/project/projectInfo/projectInfo?code=' + code,
				});

			}
		}
	}
</script>

<style lang="scss" scoped>
	.project {
		width: 343rpx;
		height: 260rpx;
		background-color: white;
		display: flex;
		flex-direction: column;
		margin-left: 22rpx;
		margin-top: 30rpx;
		border-radius: 10rpx;
		text-align: center;
	}

	.image {
		margin-left: 100rpx;
		margin-top: 30rpx;
		width: 140rpx;
		height: 140rpx;
	}

	.text {
		margin-top: 10rpx;
	}
</style>
