<template>
	<view class="workark-list">
		<view class="workark-item" v-for="(item,index) in list" :key="item.id">
			<view class="workark-item-title">{{item.name}}</view>
			<view class="workark-content">
				<view class="workark-content-item" v-for="(serve,i) in item.children" :key="serve.id">
					<view class="workark-content-box">
						<view class="product-item"
							@tap="$navigateTo('/subPages/workarkPage/workarkDetail/workarkDetail?productLevelId=' + serve.id)">
							<view class="product-item-image">
								<uv-image :src="imageUrl(serve.showPictures)" mode="scaleToFill" width="100%"
									height="100%">
								</uv-image>
							</view>
							<view class="product-content">
								<uv-text :lines="2" :text="serve.name" size="32" :customStyle="{
									fontWeight: 600,
									marginBottom: '10rpx'
								}"></uv-text>
								<uv-text :lines="2" :text="serve.remark" type="tips" size="26"></uv-text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import {
		getServeProductList
	} from '@/request/api/workark.js'
	export default {
		data() {
			return {
				list: []
			}
		},
		onLoad() {
			this.init();
		},
		methods: {
			async init() {
				let productData = await getServeProductList(-1);
				if (productData.state) this.list = productData.data;
			},
			imageUrl(data) {
				if (!data) return 'https://assets.api.uizard.io/api/cdn/stream/c05650d2-192b-4a56-ae97-05638f53804c.png';
				let imgData = JSON.parse(data)[0];
				if (!imgData) {
					return 'https://assets.api.uizard.io/api/cdn/stream/c05650d2-192b-4a56-ae97-05638f53804c.png';
				}
				return imgData.url;
			}
		}
	}
</script>
<style lang="scss" scoped>
	.workark-list {
		padding: 30rpx;
	}

	.workark-item {
		margin-bottom: 30rpx;
	}

	.workark-item-title {
		padding-bottom: 20rpx;
		font-weight: bold;
	}

	.workark-content {
		display: flex;
		flex-wrap: wrap;
	}

	.workark-content-item {
		width: 50%;
		box-sizing: border-box;
		margin-bottom: 30rpx;


		&:nth-child(2n) {
			padding-left: 15rpx;
		}

		&:nth-child(2n-1) {
			padding-right: 15rpx;
		}


	}

	.workark-content-box {
		background: #fff;
		box-shadow: 0px 2rpx 24rpx rgba(3, 3, 3, 0.1);
		border-radius: 16rpx;
		overflow: hidden;
	}

	.product-item-image {
		width: 100%;
		height: 200rpx;
		overflow: hidden;
		border-radius: 16rpx;
	}

	.product-content {
		padding: 20rpx;
	}
</style>