<template>
	<view class="">
		<view style="padding-top: 1rpx;" v-if="orderList.length">
			<view class="flex align-center margin-bottom-sm bg padding-sm radius margin-sm"
				v-for="(item,index) in orderList" :key='index' @click="goOrderDetail(item)"
				style="box-shadow: 6rpx 10rpx 4px #F5F5F5;position: relative;">
				<view style="position: absolute;z-index: 99;top: 0rpx;left: 0;" v-if="item.isGoods == 1">
							<image
								src="/static/image/text_you.png"
								style="width: 42rpx;height: 36rpx;"></image>
						</view>
						<view style="width:160rpx;height:190upx;border-radius: 50%;display: flex;flex-direction: column;align-items: center;">
							<image :src="item.artificerImg?item.artificerImg: '../../static/logo.png'"
								@click.stop="saveImgs(item.artificerImg)"
								style="width: 160rpx;height: 160rpx;border-radius: 50%;" mode="aspectFill"></image>
							<image v-if="item.isHot == 1"
								src="/static/image/icon_fire.png"
								style="width: 30rpx;height: 36rpx;position: absolute;z-index: 99;top: 40rpx;left: 110rpx;">
							</image>
							<view class="kyy_view" v-if="item.state == 1">可服务</view>
							<view class="kfw_view" v-else-if="item.state == 2">可预约</view>
							<view class="byy_view" v-else>休息中</view>
						</view>
						<view class="margin-left  flex flex-direction" style="width: 85%;">
							<view class="flex align-center justify-between">
								<view class="flex align-center">
									<view class="text-bold text-30 margin-right-xs jishi_name">{{item.artificerName}}</view>
							<!-- 		<image
										src="/static/image/icon_pao.png"
										style="width: 40rpx;height:40rpx;">
									</image> -->
									<view class="zpmore_view" v-if="item.lifePhoto" @click.stop="saveImgss(item.lifePhoto,0)">更多照片</view>
								</view>
								<view class="zz_view" v-if="item.status == 1 && item.time">
									<view class="zz_label">
										最早可约
									</view>
									<view class="zz_value">
										{{item.time}}
									</view>
								</view>
							</view>
							<view class="flex justify-between " style="margin:15rpx 0rpx 20rpx">
								<view class="flex align-center">
									<view v-if="item.ordersScore" class="flex margin-right-sm">
										<text style="color: #FCAD3D;">{{item.ordersScore}}</text>
										<!-- <image src="../../static/images/start.png"  style="width: 24upx;height: 22upx;"> -->
										<!-- </image> -->
											<u-rate activeColor="#FCAD3D" size="20rpx" :count="5" v-model="item.ordersScore"></u-rate>
									</view>
									<!-- <view style="color: #999999;">已服务:{{item.ordersCount}}单</view> -->
								</view>
				
								<!-- <view class="flex align-center" v-if="item.tripWay != 3">
									<image src="../../static/images/address.png" style="width: 24rpx;height: 29rpx;"></image>
									<view style="color: #333333;margin-left: 8rpx;">{{item.distance}}</view>
								</view> -->
								<view class="flex align-center" style="font-size: 26rpx;color: #f49650;font-weight: bold;" v-if="item.tripWay == 3">
									免出行费
								</view>
							</view>
							<view class="flex align-center" style="color: #AAAAAA;font-size: 24rpx;">
								<view class="flex align-center" >已服务: 
									<view style="color: #FF6E98;margin-left: 8rpx;">
										{{item.ordersCount}}单
									</view>
								</view>
								<view class="flex align-center" style="margin-left: 24rpx;" v-if="item.tripWay != 3">
									距您
									<view style="color: #FF6E98;margin-left: 8rpx;">{{item.distance}}</view>
								</view>
							</view>
							
							<view style="width: 100%;display: flex;justify-content: space-between;align-items: center;"
								v-if="XCXIsSelect !='否'">
								<view class="flex flex-wrap align-center" style="margin-top: 10rpx;">
									<image
										src="/static/image/icon_shang.png"
										style="width: 24rpx;height: 24rpx;"></image>
									<view style="margin-left: 10rpx;color: #999;font-size: 24rpx;margin-right: 24rpx;">商家</view>
									<image
										src="/static/image/icon_ping.png"
										style="width: 24rpx;height: 24rpx;"></image>
									<view style="margin-left: 10rpx;color: #999;font-size: 24rpx;margin-right: 24rpx;">
										{{item.commentCount ? item.commentCount : 0}}
									</view>
									<image
										src="/static/image/icon_cang.png"
										style="width: 24rpx;height: 24rpx;"></image>
									<view style="margin-left: 10rpx;color: #999;font-size: 24rpx;">
										{{item.collectCount ? item.collectCount : 0}}
									</view>
								</view>
								<view class="text-center text-sm" v-if="item.status == 1"
									style="background: linear-gradient( 313deg, #FFE6EE 0%, #FFBACA 100%);color: #222222;width: 160rpx;border-radius: 36rpx;line-height: 64rpx;font-weight: bold;position: relative;"
									@click.stop="goOrder(item)">
									立即预约
									<image style="position: absolute;width: 39rpx;height: 39rpx;top: -4rpx;right: -8rpx;" src="../../static/image/btn-icon.png" mode=""></image>
								</view>
								<view class="text-center text-sm" v-else
									style="background: #d9d9d9;color: #222222;width: 160rpx;border-radius: 36rpx;line-height: 64rpx;font-weight: bold;position: relative;">
									立即预约
									<image style="position: absolute;width: 39rpx;height: 39rpx;top: -4rpx;right: -8rpx;" src="../../static/image/btn-icon.png" mode=""></image>
								</view>
							</view>
						</view>
					</view>
				</view>
		<empty v-if="orderList.length == 0"></empty>

		<!-- <u-skeleton :loading="loading" :animation="true" elColor='#FFFFFF' bgColor='#FFFFFF'></u-skeleton> -->
	</view>
</template>

<script>
	import empty from '@/components/empty.vue'
	export default {
		components: {
			empty,
		},
		data() {
			return {
				loading: true, // 是否显示骨架屏组件
				game: [],
				orderList: [],
				isVip: false,
				myId: uni.getStorageSync('userId') ? uni.getStorageSync('userId') : '',
				showModal: true,
				arr: [],
				tab: '',
				massageTypeId: '',
				page: 1,
				limit: 10,
				latitude: '',
				XCXIsSelect:'否',
				longitude: ''
			}
		},
		onLoad(e) {
			let that = this
			that.XCXIsSelect = this.$queue.getData("XCXIsSelect");
			uni.getLocation({
				type: 'gcj02',
				geocode: true, //设置该参数为true可直接获取经纬度及城市信息
				success: function(res) {
					console.log(res, '地理位置')
					that.latitude = res.latitude
					that.longitude = res.longitude
					// uni.setStorageSync('latitude', res.latitude)
					// uni.setStorageSync('longitude', res.longitude)

					that.getData(that.latitude, that.longitude)
				},
				fail: function() {
					console.log('获取地址失败')
				}
			})


		},
		onShow() {
			if(this.latitude && this.longitude){
				this.getData(this.latitude, this.longitude)
			}
		},
		methods: {
			saveImgss(imgs, index) {
				console.log(imgs, index)
				// let that = this
				let imgArr = imgs
				// this.imgArr.push(imgs);
				// console.log(this.imgArr)
				// //预览图片
				uni.previewImage({
					urls: imgArr,
					current: imgArr[index]
				});
			},
			saveImgs(imgs) {
				let imgArr = [];
				imgArr.push(imgs);
				// //预览图片
				uni.previewImage({
					urls: imgArr,
					current: 0
				});
			},
			getData(latitude, longitude) {
				let data = {
					page: this.page,
					limit: this.limit,
					latitude: latitude,
					longitude: longitude,
				}
				this.$Request.get("/app/artificer/selectCollectList", data).then(res => {
					this.loading = false;
					if (res.code == 0) {
						for (var i = 0; i < res.data.list.length; i++) {
							if (res.data.list[i].distance > 1000) {
								res.data.list[i].distance = (res.data.list[i].distance / 1000).toFixed(1) +
									'km'
							} else {
								res.data.list[i].distance = (res.data.list[i].distance).toFixed(1) + 'm'
							}
							if (res.data.list[i].lifePhoto) {
								res.data.list[i].lifePhoto = res.data.list[i].lifePhoto.split(',')
							}
						}
						if (this.page == 1) {
							this.orderList = res.data.list
						} else {
							this.orderList = [...this.orderList, ...res.data.list]
						}

					}

				}).catch(() => {
					//联网失败, 结束加载
					// this.mescroll.endErr();
				});

			},

			// 跳转订单
			goOrder(e) {
				let token = this.$queue.getData('token');
				if (token) {
					uni.navigateTo({
						url: "/pages/index/order/orderDet?artificerId=" + e.artificerId + '&massageTypeId=' + this
							.massageTypeId
					})
				} else {
					uni.navigateTo({
						url: '/pages/public/login'
					});
				}
			},
			goOrderDetail(e) {
				uni.navigateTo({
					url: "/pages/therapist/orderDetail?artificerId=" + e.artificerId + '&massageTypeId=' + this
						.massageTypeId
				})
			}
		},
		onReachBottom: function() {
			this.page = this.page + 1;
			this.getData(this.latitude, this.longitude)
		},
		onPullDownRefresh: function() {
			this.page = 1;
			this.getData(this.latitude, this.longitude)
			setTimeout(d => {
				uni.stopPullDownRefresh();
			}, 3000);
		},
	}
</script>

<style lang="scss">
	page {
		background-color: #F7F7F7;
	}

	.zz_view {
		display: flex;
		line-height: 40rpx;
		text-align: center;
		font-size: 24rpx;
		.zz_label{
			width: 120rpx;
			background: #4B2F20;
			border-radius: 32rpx 0 0 32rpx;
			color: #FFFFFF;
		}
		.zz_value{
			width: 88rpx;
			border-radius: 0 32rpx 32rpx 0;
			background: #EECEAC;
			color: #4B2F20;
		}
	}
	
	.zpmore_view {
		background: #07BF89;
		width: 128rpx;
		height: 40rpx;
		text-align: center;
		border-radius: 32rpx;
		line-height: 40rpx;
		font-size: 24rpx;
		color: #FFFFFF;
		margin-left: 10rpx;
	}
	
	.byy_view {
		background: #ebebeb;
		width: 120upx;
		text-align: center;
		border-radius: 50rpx;
		height: 46rpx;
		line-height: 46rpx;
		font-size: 24rpx;
		color: #000000;
		// border: 3upx solid #999999;
		margin-top: 6rpx;
	}
	
	.kfw_view {
		background: #ffaa00;
		width: 120upx;
		text-align: center;
		border-radius: 50rpx;
		height: 46rpx;
		line-height: 46rpx;
		font-size: 24rpx;
		color: #FFFFFF;
		margin-top: 6rpx;
	}
	
	.kyy_view {
		background: #DCFFEA;
		width: 120upx;
		text-align: center;
		border-radius: 36rpx;
		height: 40rpx;
		line-height: 40rpx;
		font-size: 24rpx;
		color: #54CC84;
	}
	.kyy_view,.kfw_view,.byy_view{
		margin-top: -10rpx;
		z-index: 9;
	}

	.bg {
		background: #FFFFFF;
	}

	.ytp_view {
		background: #e3e3e3;
		width: 400rpx;
		border-radius: 10rpx;
		font-size: 28rpx;
		text-align: center;
		height: 80rpx;
		line-height: 80rpx;
		color: #848484;
		margin-top: 40rpx;
	}

	.tp_view {
		background: #ee6c54;
		width: 400rpx;
		border-radius: 10rpx;
		font-size: 28rpx;
		text-align: center;
		height: 80rpx;
		line-height: 80rpx;
		color: #FFFFFF;
		margin-top: 40rpx;
	}

	.sticky-tabs {
		z-index: 990;
		position: sticky;
		top: var(--window-top);
		// background-color: #fff;
	}

	/* // 使用mescroll-uni,则top为0 */
	.mescroll-uni,
	/deep/.mescroll-uni {
		.sticky-tabs {
			top: 0;
		}
	}

	.demo-tip {
		padding: 18upx;
		font-size: 24upx;
		text-align: center;
	}

	.line_s {
		display: inline-flex;
		width: 10rpx;
		height: 10rpx;
		background: #1AD566;
		border-radius: 50%;
		margin-right: 10rpx;
	}

	.line_x {
		display: inline-flex;
		width: 10rpx;
		height: 10rpx;
		background: #000000;
		border-radius: 50%;
		margin-right: 10rpx;
	}

	.box {
		// border: 3rpx solid #005dff;
		background: #E8FAE1;
		color: #2FB57A;
		padding: 5rpx 15rpx;
		font-size: 26rpx;
		letter-spacing: 2rpx;
		border-radius: 8rpx;
		// margin-top: 10rpx;
		margin-right: 8upx;
	}

	.actve {
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 800;
		color: #20C675;
	}

	.tabview1 {
		padding: 20rpx 20rpx;
		// width: 686upx;
		// height: 100upx;
		background: #FFFFFF;
		// margin-top: -50upx;
		// z-index: 99;
		// display: flex;
		// line-height: 100upx;

		.tabview {
			// width: 686upx;
			// // height: 100upx;
			background: #F2FFF9;
			border-radius: 24rpx 24rpx 0 0;
			// margin-top: -50upx;
			// z-index: 99;
			display: flex;
			line-height: 100upx;

			.tabItem_sel {
				font-size: 30upx;
				font-family: PingFang SC;
				font-weight: 800;
				color: #20C675;
				flex: 1;
				text-align: center;
			}

			.tabItem {
				font-size: 26upx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #333333;
				flex: 1;
				text-align: center;
			}
		}

		.tabsx {
			width: 686upx;
			border-radius: 24rpx;
			padding-bottom: 10rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 20rpx 30rpx;
			font-size: 26rpx;

			.active {
				color: #20C675;
				font-size: 30rpx;
				font-weight: bold;
			}
		}
	}
</style>
