<template>
	<view class="content">
		<view class="onecontent flex-between">
			<u-search shape="square" :clearabled="true" @blur='servicelists' :showAction="false" placeholder="输入关键字"
				v-model="like"></u-search>
			<view class="flex-start" style="padding-left:20rpx;" @click="contentfixedclick()">
				<u-icon name="order" color="#666" size="22"></u-icon>
				<text class="flex-starttext">新建项目</text>
			</view>
			<view class="flex-start" style="padding-left:20rpx;" @click="createcap()">
				<u-icon name="order" color="#666" size="22"></u-icon>
				<text class="flex-starttext">新建分类</text>
			</view>
		</view>
		<view class="contenttow">
			<view class="contenttowitem" v-for="(item,index) in list" :key="index" @click="contentfixedclick(item.service_id)">
				<view class="contenttowitemone flex-between">
					<text class="contenttowitemone_one"
						:style="item.service_status == 0?'color: #ccc;':''">{{item.service_title}}</text>
					<view class="contenttowitemone_tow flex-start" >
						<text class="contenttowitemone_towtext">编辑项目</text>
						<u-icon name="file-text" color="#999" size="20"></u-icon>
					</view>
				</view>
				<view class="contenttowitemtow flex-between">
					<image class="contenttowitemtowimage" :src="item.service_img" mode=""></image>
					<view class="contenttowitemtow_item flex-colum-start">
						<view class="contenttowitemtow_itemone" :style="item.service_status == 0?'color: #ccc;':''">
							{{item.service_describe}}
						</view>
						<view class="contenttowitemtow_ittow flex-between">
							<view class="contenttowitemtow_ittowone"
								:style="item.service_status == 0?'color: #ccc;':''">
								¥{{item.service_price}}<text
									class="contenttowitemtow_ittowonetext">{{item.service_y_price}}</text>
							</view>
							<view class="contenttowitemtow_ittowtow">
								<text v-if="item.service_status == 1" style="color: green;">已上架</text>
								<text v-else style="color: red;">已下架</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view v-if="list.length==0 && form.is_end == true" class="flex-colum">
			<image src="https://ointmentweapp.oss-cn-beijing.aliyuncs.com/image/my/order/nothave.png" mode="">
			</image>
		</view>
		<u-loadmore :status="form.status" />
	</view>
</template>
<script>
	export default {
		data() {
			return {
				like: "",
				list: [],
				form: {
					is_end: false,
					page: 1,
					status: 'loadmore',
				},
			}
		},
		onShow() {
			this.form = {
					is_end: false,
					page: 1,
					status: 'loadmore',
				},
				this.list = []
			this.servicelist()
		},
		onReachBottom() {
			this.servicelist()
		},
		methods: {
			servicelists() {
				this.list = []
				this.form.page = 1
				this.servicelist()
			},
			contentfixedclick(e) {
				uni.pro.navigateTo('project/create', {
					id: e
				})
			},
			createcap() {
				uni.pro.navigateTo('project/createcap')
			},
			async servicelist(e) { //项目列表
				let res = await this.api.servicelist({
					page: this.form.page,
					like: this.like
				});
				if (res.data.length == 0) {
					this.form.is_end = true
					this.form.status = 'nomore'
					return false;
				} else {
					this.form.status = 'loading';
					this.form.page = ++this.form.page;
					setTimeout(() => {
						this.list = [...this.list, ...res.data];
						if (res.data.length == 10) {
							this.form.status = 'loading';
						} else {
							this.form.is_end = true;
							this.form.status = 'nomore';
						}
					}, 500)

				}
			},

		}
	}
</script>

<style lang="scss">
	page {
		background: #fbfbfa;
	}

	.content {
		.onecontent {
			padding: 16rpx 20rpx;
			width: 100%;
			background: #FFFFFF;

			.flex-start {
				.flex-starttext {
					font-size: 28rpx;
					font-family: SourceHanSansCN-Regular, SourceHanSansCN;
					font-weight: 400;
					color: #666666;
				}
			}
		}

		.contenttow {
			padding: 0 28rpx;

			.contenttowitem {
				margin-top: 34rpx;
				padding: 24rpx;
				width: 100%;
				background: #FFFFFF;
				border-radius: 24rpx;

				.contenttowitemone {
					width: 100%;
					padding-bottom: 18rpx;
					border-bottom: 1rpx solid #EAEAEA;

					.contenttowitemone_one {
						width: 60%;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
						font-size: 28rpx;
						font-family: SourceHanSansCN-Medium, SourceHanSansCN;
						font-weight: bold;
						color: #333333;
					}

					.contenttowitemone_tow {
						.contenttowitemone_towtext {
							font-size: 24rpx;
							font-family: SourceHanSansCN-Regular, SourceHanSansCN;
							font-weight: 400;
							color: #666666;
						}
					}
				}

				.contenttowitemtow {
					width: 100%;
					padding-top: 18rpx;

					.contenttowitemtowimage {
						width: 136rpx;
						height: 136rpx;
						border-radius: 10rpx;
					}

					.contenttowitemtow_item {
						height: 136rpx;
						width: 75%;
						justify-content: space-between;

						.contenttowitemtow_itemone {
							width: 100%;
							font-size: 24rpx;
							font-family: SourceHanSansCN-Regular, SourceHanSansCN;
							font-weight: 400;
							color: #333333;
						}

						.contenttowitemtow_ittow {
							width: 100%;

							.contenttowitemtow_ittowone {
								font-size: 32rpx;
								font-family: SourceHanSansCN-Medium, SourceHanSansCN;
								font-weight: bold;
								color: #333333;

								.contenttowitemtow_ittowonetext {
									text-decoration: line-through;
									margin-left: 10rpx;
									font-size: 22rpx;
									font-weight: 400;
								}
							}

							.contenttowitemtow_ittowtow {
								font-size: 16rpx;
								font-family: SourceHanSansCN-Regular, SourceHanSansCN;
								font-weight: 400;
								color: #999999;
							}
						}
					}
				}
			}
		}
	}
</style>