<template>
	<view>
		<view class="bg">
			<view class="" style="width: 100%;height: 750upx;text-align: center;overflow: hidden;"
				@click="saveImgs(order.massageImg)">
				<image class="" style="width: 750upx;height: 750upx;" mode="widthFix" :src="order.massageImg"></image>
			</view>
			<view class="flex align-center padding-lr justify-around" style="background: #f7fdfb;padding: 12rpx 0;">
				<!-- <view class="rir"> 
					<image
						src="https://admin.sjajk.com/file/uploadPath/2023/01/18/ddb89075e091f26aa0c84bede245fd6d.png"
						style="width: 87rpx;height:29rpx;"></image>
				</view> -->
				<view class="flex align-center" style="margin-right: 30upx;">
					<image src="../../../static/images/index/renzheng03.png" style="width: 30rpx;height: 32rpx;">
					</image>
					<text class="margin-left-xs" style="color: #75a794;">实名认证</text>
				</view>
				<view class="flex align-center" style="margin-right: 30upx;">
					<image src="../../../static/images/index/renzheng01.png" style="width:25upx;height: 30upx;"></image>
					<text class="margin-left-xs" style="color: #75a794;">资质认证</text>
				</view>
				<view class="flex align-center">
					<image src="../../../static/images/index/renzheng02.png" style="width: 32rpx;height: 30rpx;">
					</image>
					<text class="margin-left-xs" style="color: #75a794;">平台担保</text>
				</view>
			</view>
			<view class="margin-lr padding-bottom" style="margin-top: 40rpx;">
				<view class="margin-right-xs text-bold padding-bottom-sm"
					style="letter-spacing: 3rpx; font-size: 36rpx;">
					{{order.title}}
				</view>

				<view class="padding-bottom flex justify-between ">
					<view class="flex align-center" v-if="!isVip">
						<view style="color:#FF1200;font-size:26upx;font-weight: bold;">
							￥<text style="font-size: 40upx;">{{order.price}}</text>
							<text class="oldPrice_view">￥{{order.oldPrice}}</text>
						</view>
						<view class="flex align-center margin-left-sm">
							<image src="../../../static/time.png"
								style="width: 24rpx;height: 24rpx;margin-right: 5rpx;"></image>
							<view style="color: #999999;font-size: 26rpx;">{{order.duration}}分钟</view>
						</view>
					</view>
					<view class="flex align-center" style="color:#26C278;font-size: 24upx;" v-else>
						<view class="box">会员价</view>
						<view style="color:#FF1200;font-size:26upx;font-weight: bold;">
							￥<text style="font-size: 40upx;">{{order.memberPrice}}</text>
						</view>
						<view class="flex align-center margin-left-sm">
							<image src="../../../static/time.png"
								style="width: 24rpx;height: 24rpx;margin-right: 5rpx;"></image>
							<view style="color: #999999;font-size: 26rpx;">{{order.duration}}分钟</view>
						</view>
					</view>
					<view style="color: #999999;font-size: 26rpx;line-height: 46rpx;">已售{{order.sales}}</view>
				</view>
				<view class="import">
					<!-- <view class="" style="width: 40px;font-weight: bold;">
						保障
					</view> -->
					<view class="importInnerBox">
						<view class="importInnerBoxChild">
							<image src="../../../static/img/correct.png" alt="" />
							<view class="">
								未服务全额退
							</view>
						</view>
						<view class="importInnerBoxChild">
							<image src="../../../static/img/express.png" alt="" />
							<view class="">
								不满意重做
							</view>
						</view>
						<view class="importInnerBoxChild">
							<image src="../../../static/img/back.png" alt="" />
							<view class="">
								最快30分钟上门
							</view>
						</view>
					</view>
				</view>
			</view>

		</view>
		<view class="bg" style="background-color: #fff3de;">
			<view class="govip_view" v-if="!isVip && hyCheck != '否'">
				<image src="https://admin.sjajk.com/file/uploadPath/2023/02/17/0b2a9576259a35f7f0cbf8b9d3ee3df7.png">
				</image>
				<view class="govip_viewitem flex align-center" style="justify-content: space-evenly;">
					<view style="color: #d8b46f;font-weight: 600;font-size: 29rpx;">开通会员立享会员折扣价</view>
					<view class="govip_btn" @tap="goVip">去开通</view>
				</view>
			</view>
		</view>
		<view class="bg padding margin-top-sm">
			<view class=" text-bold padding-bottom" style="font-size: 30rpx;">
				适用说明
			</view>
			<view class=""
				style="width: 118rpx;height: 16rpx;background-color: #096f4b;opacity: 0.2;margin-top: -46rpx;">

			</view>
			<view class="flex padding-bottom-sm" style="margin-top: 30rpx;">
				<view style="color: #666666;">性别限制</view>
				<view class="margin-left">{{order.isSex}}</view>
			</view>
			<view class="flex padding-bottom-xs">
				<view style="color: #666666;width:-webkit-fill-available;">适用人群</view>
				<view class="margin-left">{{order.applyPeople}}</view>
			</view>
		</view>
		<view class="bg padding margin-top-sm" v-if="order.content">
			<view class=" text-bold padding-bottom" style="font-size: 30rpx;">
				服务内容
			</view>
			<view class=""
				style="width: 118rpx;height: 16rpx;background-color: #096f4b;opacity: 0.2;margin-top: -46rpx;">
			</view>
			<view v-html="order.content" style="margin-top: 30rpx;"></view>
		</view>

		<view class="margin-top-sm bg radius ">
			<view class="padding text-bold" style="font-size: 30rpx;">项目详情</view>
			<view class=""
				style="width: 118rpx;height: 16rpx;background-color: #096f4b;opacity: 0.2;margin-top: -46rpx;margin-left: 30rpx;margin-bottom: 30rpx;padding: 0;">
			</view>
			<view v-for="(item,index) in order.contentImg" :key="index" style="width: 100%;margin:0;padding: 0;"
				@click="saveImg(order.contentImg,index)">
				<image :src="item" style="width: 750upx;height: 963upx;vertical-align: bottom;" mode="widthFix"></image>
			</view>

		</view>

		<!-- 评价相关 -->
		<!-- 		<view class=" padding bg u-skeleton-fillet margin-top-sm" style="padding-bottom: 100rpx;">
			<view class="padding-bottom-sm flex align-center" style="font-size: 34rpx;">
				<view class="text-bold">
					评价
				</view>
				<view class="">
					({{commentList.length}})
				</view>
			</view>
			<view v-if="commentList.length<=0" class=""> 暂无评价</view>
			<view class="margin-bottom-sm" style="border-bottom: 1upx solid #f7f7f7;padding: 20rpx 0 26rpx 0;"
				v-for="(item, index) in commentList" :key='index' v-else>
				<view class="flex align-center">
					<u-avatar src="/static/logo.png" size="48"></u-avatar>
					<view class="flex margin-left-sm" style="line-height: 46upx;">匿名</view>
					<view class="flex" style="margin-left: 20rpx;">
						<u-icon v-for="ite in item.score" :key='ite' color="#ffbb34" name="star-fill" style=""></u-icon>
					</view>
				</view>
				<view class="" style="margin-top: 40rpx;">{{item.content}}</view>
			</view>
		</view> -->

		<view class=" text-lg cu-bar foot bg padding-lr" v-if="XCXIsSelect !='否'">
			<view class="text-center" v-if="order.classifyName === '足浴按摩'"
				style="width: 665upx;line-height: 78upx;background: linear-gradient(to right, #223845, #00a85b);border-radius: 39upx;margin: 0 auto;color: #FFFFFF;"
				@click="goNav(order.massageTypeId,order.classifyId)">
				选择技师
			</view>
			<view class="text-center" v-if="order.classifyName === '健身私教'"
				style="width: 665upx;line-height: 78upx;background: linear-gradient(to right, #223845, #00a85b);border-radius: 39upx;margin: 0 auto;color: #FFFFFF;"
				@click="goNav(order.massageTypeId,order.classifyId)">
				选择教练
			</view>
			<view class="text-center" v-if="order.classifyName != '健身私教' && order.classifyName != '足浴按摩'"
				style="width: 665upx;line-height: 78upx;background: linear-gradient(to right, #223845, #00a85b);border-radius: 39upx;margin: 0 auto;color: #FFFFFF;"
				@click="goNav(order.massageTypeId,order.classifyId)">
				选择技师
			</view>
		</view>
		<!-- <u-picker v-model="show" mode="time" :params="params" @confirm="statusChange"></u-picker> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				game: [],

				customStyle: {
					width: '400upx',
					color: '#FFFFFF',
					background: "#005DFF",
					border: 0
				},
				massageTypeId: '',
				orderDet: {},
				page: 1,
				limit: 10,
				order: {},

				isFollow: false,
				myId: '',
				isVip: false,
				AUDIO: uni.createInnerAudioContext(),
				isPlay: false,
				show: false,
				params: {
					year: false,
					month: true,
					day: true,
					hour: true,
					minute: true,
					second: true,
					timestamp: true
				},
				startTime: '',
				mobile: '',
				name: '',
				cityaddress: '',
				detailaddress: '',
				latitude: '',
				longitude: '',
				province: '',
				city: '',
				district: '',
				age: '',
				tabs: [{
					name: '服务',
					status: 0
				}, {
					name: '评价',
					status: 1
				}, {
					name: '资质证书',
					status: 2
				}],
				tabIndex: 0, // tab下标
				fwIndex: 0,
				fw: [],
				count: 5,
				value: 4,
				XCXIsSelect: '否',
				hyCheck: '否',
				commentList: [],
				page: 1,
				limit: 10,
			}
		},
		onLoad(option) {
			console.log(option)
			this.$queue.showLoading("加载中...");
			this.massageTypeId = option.massageTypeId
			this.XCXIsSelect = this.$queue.getData("XCXIsSelect");
			this.getDet()
			this.getOrderComment()

			this.myId = uni.getStorageSync('userId')
			this.hyCheck = this.$queue.getData('hyCheck');
			if (this.hyCheck != '否') {
				this.isVip = uni.getStorageSync('isVIP')
			}
		},
		onShow() {
			if (this.massageTypeId) {
				this.getDet()
				this.hyCheck = this.$queue.getData('hyCheck');
				if (this.hyCheck != '否') {
					this.isVip = uni.getStorageSync('isVIP')
				}
				this.myId = uni.getStorageSync('userId')
				this.getDet()
			}
		},
		onReady() {
			this.AUDIO.onEnded(function(res) {
				this.isPlay = false;
			});
		},
		methods: {
			goVip() {
				uni.navigateTo({
					url: '/my/vip/index'
				});
			},
			// 评价
			getOrderComment() {
				this.$Request.get("/app/takingComment/selectOrderTakingComment", {
					massageTypeId: this.massageTypeId,
					page: this.page,
					limit: this.limit
				}).then(res => {
					if (res.code == 0) {
						this.commentList = [...this.commentList, ...res.data.list]
					}
				});
			},
			// 切换菜单
			tabChange(index) {
				this.tabIndex = index
				this.fwIndex = index
			},
			// 详情
			getDet() {
				this.$Request.get("/app/artificer/selectMassageTypeById", {
					massageTypeId: this.massageTypeId,
				}).then(res => {

					if (res.code == 0) {
						this.order = res.data
						if (this.order.isSex == 1) {
							this.order.isSex = '男';
						} else if (this.order.isSex == 2) {
							this.order.isSex = '女';
						} else {
							this.order.isSex = '不限性别';
						}
						this.order.contentImg = this.order.contentImg.split(",");
						this.selectFollow()

					}
					uni.hideLoading();
				});

			},

			// 是否关注
			selectFollow() {
				this.$Request.get("/app/userFollow/selectFollowUser", {
					followUserId: this.order.userId
				}).then(res => {
					if (res.data == true) {
						this.isFollow = true
					} else {
						this.isFollow = false
					}

				});
			},
			playVoice() {
				console.log(this.isPlay)
				this.AUDIO.src = this.order.voiceIntroduce;
				if (this.isPlay) {
					this.AUDIO.stop();
				} else {
					this.AUDIO.play();
				}
				this.isPlay = !this.isPlay;
			},
			goNav(massageTypeId, classifyId) {
				uni.navigateTo({
					url: '/pages/therapist/therapistList?massageTypeId=' + massageTypeId + '&classifyId=' +
						classifyId
				})
				//uni.navigateTo({ url: '/pages/therapist/map/index?massageTypeId=' + massageTypeId + '&classifyId=' +classifyId })
			},
			goMsg() {
				let data = {
					userId: this.myId,
					focusedUserId: this.order.userId
				}
				this.$Request.postJson('/app/chat/insertChatConversation ', data).then(res => {
					if (res.code == 0) {
						let id = this.order.userId == res.data.userId ? res.data.focusedUserId : this.order.userId
						uni.navigateTo({
							url: '/pages/msg/im?chatConversationId=' + res.data.chatConversationId +
								'&byUserId=' + id
						})
					}
				})
			},
			// 关注
			follow() {
				let that = this
				that.$Request.get("/app/userFollow/insert", {
					followUserId: that.order.userId
				}).then(res => {
					uni.showToast({
						title: res.msg,
						icon: 'none'
					})
					setTimeout(function() {
						that.selectFollow()
					}, 500)
				});
			},
			saveImg(imgs, index) {
				let that = this;
				let imgArr = imgs
				// imgArr.push(imgs);
				// //预览图片
				uni.previewImage({
					urls: imgArr,
					current: imgArr[index]
				});
			},
			saveImgs(imgs) {
				console.log(imgs)
				// let that = this
				// let imgArr = imgs
				this.imgArr.push(imgs);
				console.log(this.imgArr)
				// //预览图片
				uni.previewImage({
					urls: this.imgArr,
					current: this.imgArr[0]
				});
			},
		}

	}
</script>

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

	.bgs {
		background-color: #FFFFFF;
	}

	.bg {
		background-color: #FFFFFF;
	}

	.govip_view {
		margin-top: 20rpx;
		width: 700rpx;
		height: 90rpx;

		.govip_viewitem {
			position: absolute;
			left: 120rpx;
			height: 90rpx;
			line-height: 90rpx;
			width: 580rpx;
			align-items: center;

			.govip_btn {
				background: #e5c588;
				border-radius: 50rpx;
				width: 140rpx;
				text-align: center;
				// height: 50rpx;
				line-height: 50rpx;
				color: #333333;
			}
		}

		image {
			width: 700rpx;
			height: 90rpx;
			position: absolute;
		}
	}

	.wrap {
		padding: 20upx 23upx;
	}

	.oldPrice_view {
		font-size: 22rpx;
		font-family: PingFang SC;
		font-weight: 400;
		text-decoration: line-through;
		margin-left: 8rpx;
		color: #c7c7c7;
	}

	.rir {
		font-size: 30upx;
		font-family: DFZongYi-Bd-80-Win-GB;
		font-weight: 800;
		color: #30B47A;
		margin-right: 30rpx;
	}

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

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

	.tab>view {
		border-bottom: 2upx solid #F5F5F2;
	}

	.tab>view:last-of-type {
		border: none;
	}

	.box {

		background: #E8FAE1;
		color: #096f4b;
		padding: 5rpx 15rpx;
		font-size: 26rpx;
		letter-spacing: 2rpx;
		border-radius: 8rpx;
		// margin-top: 10rpx;
		margin-right: 8upx;
	}

	.import {
		display: flex;
		justify-content: left;
		width: 100%;
		align-items: center;
	}

	.importInnerBox {
		display: flex;
		justify-conten: space-around;
		width: calc(100% - 40px)
	}

	.importInnerBoxChild {
		display: flex;
		justify-content: left;
		align-items: center;
	}

	.importInnerBoxChild image {
		width: 20px;
		height: 20px;
	}

	.importInnerBoxChild view {
		// padding: 0px 5px;
		color: #898989;
		// font-size: 24rpx;
	}
</style>