<template>
	<view class="container">
		<custom-navbar title="给员工分配服务" :leftImg="'/static/images/whiteBack.png'" :showUser="true"
			backgroundColor="linear-gradient( 134deg, #F52540 0%, #FF4767 100%)" titleColor="#fff" borderBottom="none"></custom-navbar>
		<searchBox placeholder="服务名称" v-model="queryData.title" :showAdd="false" @confirm="search" @search="search">
		</searchBox>
		<view class="container-tip flex-row-center">
			<image class="tip-icon" src="/static//images/icons/tip_icon.png"></image>
			<text class="container-tip-text">已上架服务分配给员工后，员工可接此服务的到家订单！</text>
		</view>

		<CommonList ref="groupRef" apiUrl="/sj/sjserverslist"
			:listScrollHeight="`calc(100vh - ${statusBarHeight + 302}rpx)`">
			<template #listData="{ list }">
				<view class="service-list">
					<view class="service-item flex-row-end-between" v-for="(item, index) in list" :key="index">
						<view class="item-left flex-row-start">
							<image class="item-left-photo" :src="item.photo[0]" mode="aspectFill"></image>
							<view class="item-left-texts">
								<view class="item-left-text1">
									{{ item.title }}
								</view>
								<view class="flex-row-center">
									<text class="item-left-text2" style="color: #FF4767">¥</text>
									<text class="item-left-text2"
										style="color: #FF4767; font-size: 28rpx">{{ item.server_price }}</text>
								</view>
							</view>
						</view>
						<view class="item-right flex-row-center-center" @click="goSlectSyr(item)">
							分配
						</view>
					</view>
				</view>
			</template>

			<!-- 空数据状态 -->
			<template #empty>
				<noData></noData>
			</template>
		</CommonList>
	</view>
</template>

<script>
	import request from "@/utils/request";
	import searchBox from "./components/search-box.vue";
	import CommonList from "@/components/common/CommonList.vue";
	export default {
		components: {
			searchBox,
			CommonList,
		},
		data() {
			return {
				userInfo: {},
				queryData: {
					title: "",
				},
				statusBarHeight: 0,
			};
		},
		async onLoad(options) {
			let type = 3;
			let result = await request.post("/user/getuser", {
				type,
			});
			this.userInfo = result.data;
			this.queryData.sjid = this.userInfo.id;
			this.statusBarHeight = this.getRpxStatusBarHeight();
			this.$nextTick(() => {
				this.search();
			});
		},
		methods: {
			search() {
				this.$refs.groupRef.manualRefresh(this.queryData);
			},
			goSlectSyr(item) {
				uni.navigateTo({
					url: `/pages/shop/staff/selectSyr?server_id=${item.id}`,
				});
			},
		},
	};
</script>

<style lang="less">
	.container {
		.container-tip {
			width: 750rpx;
			padding: 27rpx 16rpx 22rpx 32rpx;
			background: #fae7ec;

			.container-tip-text {
				font-weight: 400;
				font-size: 26rpx;
				color: #FF4767;
				line-height: 37rpx;
				text-align: left;
				font-style: normal;
			}

			.tip-icon {
				width: 46rpx;
				height: 46rpx;
				margin-right: 8rpx;
			}
		}

		.service-list {
			// background-color: #fff;
			// margin: 20rpx 20rpx 26rpx 20rpx;
			// border-radius: 10rpx;

			.service-item {
				//   padding-top: 20rpx;
				//   margin: 0rpx 20rpx 30rpx 20rpx;
				//   padding-bottom: 30rpx;
				//   border-bottom: 1rpx solid #f1f1f1;
				padding: 30rpx 20rpx;
				margin: 20rpx;

				background: #FFFFFF;
				border-radius: 10rpx;

				.item-left {
					.item-left-photo {
						width: 100rpx;
						height: 100rpx;
						border-radius: 20rpx;
						background: #000;
					}

					.item-left-texts {
						margin-left: 20rpx;

						.item-left-text1 {
							font-weight: 500;
							font-size: 30rpx;
							color: #333333;
							line-height: 34rpx;
							text-align: left;
							font-style: normal;
							margin-bottom: 27rpx;
							margin-top: 6rpx;
							max-width: 400rpx;
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
						}

						.item-left-text2 {
							font-weight: 400;
							font-size: 26rpx;
							color: #666666;
							line-height: 34rpx;
							text-align: left;
							font-style: normal;
						}

						.item-left-line {
							margin: 0 10rpx;
							width: 2rpx;
							height: 20rpx;
							background: #666666;
						}
					}
				}

				.item-right {
					width: 124rpx;
					height: 53rpx;
					border-radius: 27rpx;
					border: 1rpx solid rgba(232, 16, 30, 0.5);
					font-size: 24rpx;
					color: #FF4767;
					text-align: left;
					font-style: normal;
				}
			}
		}
	}

	.common-list {
		background: #f5f5f5 !important;
		border-radius: 30rpx !important;
		padding-bottom: 0 !important;
	}

	::v-deep .list-container {
		padding: 0 !important;
	}

	::v-deep .list-scroll {
		margin-top: 0 !important;
	}
</style>