<template>
	<view class="content">
<!-- 		<view class="top-bg">

		</view> -->
		<view class="flex jg-jz">
			<view class="">
				规格
			</view>
			<view class="zj">
				{{long}}m*{{wide}}m*{{high}}m={{high*wide*long}}吨冷水箱 {{2*(long*wide + long*high + wide*high)}}平方
			</view>
		</view>
		<view class="new-bg">
			<view class="bg-line flex">
				<view class="title">
					名称
				</view>
				<view class="name">
					材质/厚度
				</view>
				<view class="specifications">
					规格
				</view>
				<view class="number">
					数量
				</view>
				<view class="unit_price">
					单价
				</view>
				<view class="ot-price">
					总价格
				</view>
			</view>
			<view class="bg-line flex" v-for="item in jsjg">
				<view class="title clamp2">
					{{item.title}}
				</view>
				<view class="name">
					{{item.name}}
				</view>
				<view class="specifications">
					{{item.specifications}}
				</view>
				<view class="number">
					{{item.number}}
				</view>
				<view class="unit_price">
					{{item.unit_price*1}}
				</view>
				<view class="ot-price">
					{{item.ot_price*1}}
				</view>
			</view>
		</view>
		<view class="flex jg-jz">
			<view class="">
				总重量：{{(weight*1).toFixed(2)}}kg
			</view>
			<view class="zj">
				含税总价：{{price*1}}元
			</view>
		</view>
		<!-- <view class="jg-wrap">
			<view class="jsjg-wrap flex" v-for="jitem in jsjg">
				<view class="jg-left">
					<view class="left-top">
						<text
							class="item-tit">{{jitem.title}}</text><text>单价:{{jitem.unit_price}}数量:{{jitem.number}}</text>
					</view>
					<view class="left-btm">
						规格：{{jitem.specifications}} {{jitem.name}}
					</view>
				</view>
				<view class="jg-right">
					￥{{jitem.ot_price}}元
				</view>
			</view>
			<view class="flex jg-zj">
				<view class="">
					总计(元):
				</view>
				<view class="price">
					{{price}}
				</view>
			</view>
			<view class="jg-tip">
				*此结果为预估价格 详细请联系我们
			</view>
		</view> -->

		<view class="btn-wrap flex">
			<!-- 			<view class="xyb syb" @click="endjs">
				结束计算
			</view> -->
			<button open-type="contact" plain="true" class="xyb ksjs" style="color: #fff;border: none;">
				联系我们
			</button>
		</view>
		<view class="" style="height: 50rpx;">

		</view>
		<!-- 客服 start -->
		<uni-popup ref="popupkf" type="center">
			<view class="popup-box">
				<view class="img">
					<image src="../../static/img/img009.png" mode=""></image>
				</view>
				<view class="mian">
					<view class="delivery">
						<view class="title">已经为您定制专属客服</view>
						<image src="../../static/img/img010.png" mode=""></image>
					</view>
					<view class="nocancel">客服VX:{{ text }}</view>
					<view class="comfirm-box">
						<view class="cancel" @click="cancel">取消</view>
						<view class="comfirm" @click="comfirm(text)">复制微信</view>
					</view>
				</view>
			</view>
		</uni-popup>
		<!-- 客服 end -->
	</view>
</template>

<script>
	import {
		getjsDetail
	} from '@/api/user.js'
	export default {
		data() {
			return {
				text: '',
				jsjg: [],
				id: '',
				price: '',
				weight: '',
				high: '',
				wide: '',
				long: ''
			}
		},
		onLoad(opt) {
			console.log(opt)
			if (opt.id) {
				this.id = opt.id
				this.getjsDetail()
			}
			if (opt.price) {
				this.price = opt.price
			}
			if(opt.weight) {
				this.weight = opt.weight
			}
			//weight=' + item.weight + '&long=' + item.long + '&wide=' + item.wide + '&high=' + item.high
			if(opt.high) {
				this.high = opt.high*1
				console.log(this.high)
			}
			if(opt.wide) {
				this.wide = opt.wide*1
				console.log(this.wide)
			}
			if(opt.long) {
				this.long = opt.long*1
				console.log(this.long)
			}
		},
		onShow() {

		},
		onReachBottom() {

		},
		onReady() {

		},
		methods: {
			getjsDetail() {
				let obj = this
				getjsDetail({
					id: obj.id
				}).then(res => {
					console.log(res)
					obj.jsjg = res.data
				})
			},
			// 打开客服
			openKf() {
				this.$refs.popupkf.open();
			},
			// 关闭客服
			cancel() {
				this.$refs.popupkf.close();
			},
			// 复制客服微信
			comfirm(text) {
				console.log(text);
				const result = this.uniCopy(text);
				if (result === false) {
					uni.showToast({
						title: '不支持'
					});
				} else {
					uni.showToast({
						title: '复制成功',
						icon: 'none'
					});
				}
				this.$refs.popupkf.close();
			},
			uniCopy(content) {
				/**
				 * 小程序端 和 app端的复制逻辑
				 */
				//#ifndef H5
				uni.setClipboardData({
					data: content,
					success: function() {
						console.log('success');
						return true;
					}
				});
				//#endif

				/**
				 * H5端的复制逻辑
				 */
				// #ifdef H5
				if (!document.queryCommandSupported('copy')) {
					//为了兼容有些浏览器 queryCommandSupported 的判断
					// 不支持
					return false;
				}
				let textarea = document.createElement('textarea');
				textarea.value = content;
				textarea.readOnly = 'readOnly';
				document.body.appendChild(textarea);
				textarea.select(); // 选择对象
				textarea.setSelectionRange(0, content.length); //核心
				let result = document.execCommand('copy'); // 执行浏览器复制命令
				textarea.remove();
				return result;
				// #endif
			},
		}
	}
</script>

<style lang="scss">
	.jg-wrap {
		width: 710rpx;
		margin: -120rpx auto 0;
		background: #FFFFFF;
		box-shadow: 0px 3rpx 18rpx 0px rgba(114, 136, 231, 0.27);
		border-radius: 0px 0px 14rpx 14rpx;
		border-radius: 20rpx;
	}

	.jsjg-wrap {
		height: 110rpx;
		border-top: 1px solid #EDEDED;
		border-bottom: 1px solid #EDEDED;
		width: 646rpx;
		margin: auto;
		font-size: 22rpx;
		padding: 0 15rpx;

		.jg-left {
			.left-top {

				.item-tit {
					font-size: 30rpx;
					font-weight: bold;
					color: #0C0C0C;
					padding-right: 10rpx;
				}
			}
		}

		.jg-right {
			flex-shrink: 0;
			font-size: 32rpx;
			font-weight: 500;
			color: #282828;
		}
	}

	.jg-zj {
		padding: 35rpx 43rpx 20rpx 40rpx;
		font-size: 28rpx;
		font-weight: 500;
		color: #444444;

		.price {
			font-size: 60rpx;
			font-weight: bold;
			color: #444444;

			&::before {
				content: '￥';
				font-size: 32rpx;
				padding-right: 10rpx;
			}
		}
	}

	.jg-tip {
		font-size: 25rpx;
		font-weight: 500;
		color: #A0A0A0;
		text-align: right;
		padding-right: 44rpx;
		padding-bottom: 50rpx;
	}

	.top-bg {
		width: 750rpx;
		height: 187rpx;
		background: linear-gradient(-43deg, #4464ED, #0328C7);
	}

	.xyb {
		width: 520rpx;
		height: 88rpx;
		line-height: 88rpx;
		text-align: center;
		background: linear-gradient(270deg, #4464ED, #0328C7);
		border-radius: 44rpx;
		margin: 45rpx auto 0;
		font-size: 32rpx;
		font-weight: 500;
		color: #FFFFFF;
	}


	.syb {
		width: 318rpx;
		height: 88rpx;
		background: #ECEFFC;
		border: 1px solid #4261E3;
		border-radius: 44px;
		color: #4261E3;
	}

	.ksjs {
		width: 318rpx;
		height: 88rpx;
		background: linear-gradient(270deg, #4464ED, #0328C7);
		border-radius: 44rpx;
	}

	.popup-box {
		width: 522rpx;
		height: 605rpx;
		background-color: #ffffff;
		border-radius: 20rpx;
		position: relative;

		.img {
			position: relative;
			top: -56rpx;
			left: 0;
			width: 522rpx;
			height: 132rpx;
			display: flex;
			justify-content: center;

			image {
				border-radius: 20rpx 20rpx 0 0;
				width: 450rpx;
				height: 132rpx;
			}
		}

		.mian {
			margin-top: -44rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			// padding: 32rpx 32rpx;
			background-color: #ffffff;
			border-radius: 0 0 20rpx 20rpx;
			text-align: center;

			.delivery {
				font-size: 40rpx;
				color: #333333;
				display: flex;
				align-items: center;
				flex-direction: column;

				image {
					margin-top: 48rpx;
					width: 172rpx;
					height: 160rpx;
				}
			}

			.nocancel {
				font-size: 32rpx;
				color: #333333;
				margin-top: 14rpx;
			}

			.comfirm-box {
				margin-top: 52rpx;
				display: flex;
				// margin-bottom: 32rpx;

				// justify-content: space-around;
				.cancel {
					display: flex;
					align-items: center;
					justify-content: center;
					width: 197rpx;
					height: 74rpx;
					border: 1px solid #dcc786;
					border-radius: 38rpx;

					font-size: 32rpx;
					color: #605128;
				}

				.comfirm {
					margin-left: 32rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					width: 197rpx;
					height: 74rpx;
					background: linear-gradient(-90deg, #d1ba77 0%, #f7e8ad 100%);
					border-radius: 38px;
					font-size: 32rpx;
					color: #605128;
				}
			}
		}
	}

	.new-bg {
		width: 750rpx;
		background-color: #fff;
		padding: 0 10rpx;
		.bg-line {
			height: 90rpx;
			font-size: 26rpx;
			justify-content: flex-start;
			border-bottom: 1px solid #eeeeee;
			&:nth-child(odd) {
				background-color: #f6f7fb;
			}
			view {
				border-top: 1px solid #eee;
				text-align: center;
				height: 90rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				border-right: 1px solid #eee;
			}
			.title {
				width: 128rpx;

				text-align: left;
				
			}
			.name {
	
				width: 160rpx;
			}
			.specifications {
				width: 140rpx;
			}
			.number {
				width: 95rpx;
			}
			.unit_price {
				width: 120rpx;
			}
			.ot-price {
				width: 110rpx;
		
				border-right: none;
			}
		}
	}
	.jg-jz {
		padding: 0 20rpx;
		font-size: 30rpx;
		height: 90rpx;
		line-height: 90rpx;
	}
</style>
