<template>
	<view>
		<view class="bg ">
			<view class="" style="width: 100%;text-align: center;position: relative;" @click="saveImgs(order.massageImg)">
				<image class="" style="width: 750upx;height: 480upx;" mode="widthFix" :src="order.massageImg"></image>
				<view class="govip_view" v-if="!isVip && hyCheck != '否'">
					<view class="icon-box">
						<image style="width: 48rpx;height: 48rpx;"
							src="/static/image/vip.png">
						</image>
						<view style="font-weight: bold;font-size: 32rpx;color: #975A0B;">开通会员立享会员折扣价</view>
					</view>
					<view class="btn-box" @tap="goVip">
						<view class="btn">去开通</view>
						<image style="width: 30rpx;height: 30rpx;margin-left: 20rpx;"
							src="/static/image/vip_btn.png">
						</image>
					</view>
				</view>
			</view>
			<view class="padding-lr padding-top-sm padding-bottom" style="background: #fff;position: relative;margin-top:20rpx;z-index: 9;border-radius: 32rpx 32rpx 0rpx 0rpx;">
				<view class="margin-right-xs text-bold padding-bottom-sm"
					style="letter-spacing: 3rpx; font-size: 35rpx;">
					{{order.title}}
				</view>

				<view class="padding-bottom flex justify-between ">
					<view class="flex align-center" v-if="!isVip">
						<view style="color:#FF6E98;font-size:28rpx;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;">已售{{order.sales}}</view>
				</view>
				<view class="flex align-center padding-tb-sm padding-lr "
					style="background: #EDFAF7;border-radius: 24rpx;">
					<view class="rir">
						<!-- 安心购 -->
						<image
							src="/static/image/text_axg.png"
							style="width: 87rpx;height:29rpx;"></image>
					</view>

					<view class="flex align-center" style="margin-right: 30upx;">
						<image src="../../../static/images/index/renz1.png" style="width: 24rpx;height: 24rpx;"></image>
						<text class="margin-left-xs" style="font-size: 24rpx;color: #222222;">实名认证</text>
					</view>
					<view class="flex align-center" style="margin-right: 30upx;">
						<image src="../../../static/images/index/renz2.png" style="width: 24rpx;height: 24rpx;"></image>
						<text class="margin-left-xs" style="font-size: 24rpx;color: #222222;">资质认证</text>
					</view>
					<view class="flex align-center">
						<image src="../../../static/images/index/renz3.png" style="width: 24rpx;height: 24rpx;"></image>
						<text class="margin-left-xs" style="font-size: 24rpx;color: #222222;">平台担保</text>
					</view>
				</view>
				
			</view>
		</view>

		<view class="bg padding margin-top-sm">
			<view class=" text-bold padding-bottom" style="font-size: 34rpx;">
				适用说明
			</view>
			<view class="flex padding-bottom-sm">
				<view style="color: #666666;">性别限制</view>
				<view class="margin-left">{{order.isSex}}</view>
			</view>
			<view class="flex padding-bottom-xs">
				<view style="color: #666666;">适用人群</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: 34rpx;">
				服务内容：
			</view>
			<view v-html="order.content"></view>
		</view>

		<view class="margin-top-sm bg radius ">
			<view class="padding text-bold" style="font-size: 34rpx;">项目详情</view>
			<view v-for="(item,index) in order.contentImg" :key="index" style="width: 100%;"
				@click="saveImg(order.contentImg,index)">
				<image :src="item" style="width: 750upx;height: 963upx;" mode="widthFix"></image>
			</view>

		</view>
		
		<view class=" padding bg u-skeleton-fillet margin-top-sm" style="padding-bottom: 100rpx;">
			<view class=" text-bold padding-bottom-sm" style="font-size: 34rpx;">
				用户评价({{commentList.length}})
			</view>
			<view v-if="commentList.length<=0" class=""> 暂无评价</view>
			<view class="margin-bottom-sm padding-tb-sm" style="border-bottom: 1upx solid #f0f0f0;"
				v-for="(item, index) in commentList" :key='index' v-else>
				<view class="flex justify-between">
					<u-avatar src="/static/logo.png" size="48"></u-avatar>
					<view class="flex-sub margin-left-sm" style="line-height: 46upx;">匿名</view>
					<view class="flex">
						<u-icon v-for="ite in item.score" :key='ite' color="#FFAA01" name="star-fill"></u-icon>
					</view>
				</view>
				<view class="margin-top-sm">{{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: 686upx;line-height: 100rpx;background: linear-gradient( 143deg, #FFE6EE 0%, #FF9AB2 100%);border-radius: 86rpx;margin: 0 auto;font-weight: bold;font-size: 32rpx;color: #222222;"
				@click="goNav(order.massageTypeId,order.classifyId)">
				选择技师
			</view>
			<view class="text-center" v-if="order.classifyName === '健身私教'"
				style="width: 665upx;line-height: 78upx;background: #2FB57A;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: #2FB57A;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,
				imgArr:[]
			}
		},
		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
				})
			},
			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,this.imgArr)
				// 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 {
		width: 750rpx;
		height: 148rpx;
		background: linear-gradient( 104deg, #FFEDC4 0%, #FFD061 100%);
		border-radius: 32rpx 32rpx 0rpx 0rpx;
		position: absolute;
		bottom: -80rpx;
		left: 0;
		display: flex;
		justify-content: space-between;
		padding: 24rpx 32rpx;
		.icon-box{
			display: flex;
			align-items: center;
			height: 44rpx;
		}
		.btn-box{
			display: flex;
			align-items: center;
			height: 44rpx;
			.btn{
				font-weight: bold;
				font-size: 32rpx;
				color: #975A0B;
				
			}
		}
		
		

		
	}

	.wrap {
		padding: 20upx 23upx;
	}

	.oldPrice_view {
		font-family: PingFang SC;
		text-decoration: line-through;
		margin-left: 8rpx;
		font-size: 24rpx;
		color: #AAAAAA;
	}

	.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: #2FB57A;
		padding: 5rpx 15rpx;
		font-size: 26rpx;
		letter-spacing: 2rpx;
		border-radius: 8rpx;
		// margin-top: 10rpx;
		margin-right: 8upx;
	}
</style>
