<template>
	<view class="wrap">
		<page-nav :desc="desc" :title="title"></page-nav>
		<!-- <view class="list-wrap"> -->
			<!-- <u-cell-group title-bg-color="rgb(243, 244, 246)" :title="getGroupTitle(item)" -->
		<!-- 		v-for="(item, index) in projectList" :key="index"> -->
	<!-- 			<u-cell-item :titleStyle="{fontWeight: 500}" @click="openPage(item1)" :title="getFieldTitle(item1)"
					v-for="(item1, index1) in projectList" :key="index1">
					<image slot="icon" class="u-cell-icon" :src="getIcon('cell')" mode="widthFix"></image>
				</u-cell-item> -->
			<!-- </u-cell-group> -->
	<!-- 	</view> -->
		
		<view class="container">
			<uni-list>
				<uni-list-item @click="openPage(item)" :clickable="true" showArrow :title="getFieldTitle(item)"
					v-for="(item, index) in projectList" :key="index" :thumb="getIcon('cell')" thumb-size="sm">
					<!-- 				<template v-slot:body>
						<image slot="icon" class="u-cell-icon" :src="getIcon('cell')" mode="widthFix"></image>
						<view @click="openPage(item)">
							<text>{{getFieldTitle(item)}}</text>
						</view>
					</template>
					<template v-slot:footer>
						<uni-icons type="right" size="20" style="color: #969799;"></uni-icons>
					</template> -->
				</uni-list-item>
			</uni-list>
		</view>
		
		<u-gap height="70"></u-gap>
	</view>
</template>

<script>
	import pageNav from '@/components/page-nav/page-nav.vue';
	import http from '@/http/api.js'
	export default {
		components: {
			pageNav
		},
		onLoad(option) {
			const current = 1;
			const size = 1000;
			// let projectList = {};
			// projectList['groupName'] = '项目列表';
			var list = [];

			http.request({
				url: '/blade-business/report/projectInfo/listByUserId',
				method: 'GET',
				params: {
					current,
					size
				}
			}).then(res => {
				console.log(res.data)
				if (res.data != null && res.data.length > 0) {
					for (let i in res.data) {
						var projectInfo = {
							id: res.data[i].id,
							title: '' + res.data[i].projectName
						};
						list.push(projectInfo);
					}
				}

			}).catch(err => {
				console.log(err)
			})

		//	projectList['list'] = list;
			this.projectList = list;

		},
		data() {
			return {
				projectList: [],
				title: '开始检查',
				desc: '',
				model: '0'
			}
		},
		computed: {
			getIcon() {
				return path => {
					return 'https://cdn.uviewui.com/uview/example/' + path + '.png';
				}
			},
		},
		onShow() {
			uni.setNavigationBarTitle({
				title: "开始检查"
			});
		},
		created() {

		},
		methods: {
			openPage(item) {
				const basePath = '/pages/checkReport/addCheckReport';
				const path = basePath + '?id=' + item.id;
				this.$u.route({
					url: path
				})
			},
			getGroupTitle(item) {
				return item.groupName
			},
			getFieldTitle(item) {
				return item.title
			}
		}
	}
</script>

<style>
	/* page {
		background-color: rgb(240, 242, 244);
	} */
</style>

<style lang="scss" scoped>
	.u-cell-icon {
		width: 36rpx;
		height: 36rpx;
		margin-right: 8rpx;
	}
</style>
