<template>
	<view class="page">
		<u-navbar title="换车骑行" :border-bottom="false" :background="bgc" title-color='#000' title-size='36' height='45'
			back-icon-color='#000'></u-navbar>
			<view class="cont_box">
				<view class="tit">
					<image src="https://lxnapi.ccttiot.com/bike/img/static/uByIrgaV23PDGZWReKHW" mode=""></image>
					请选择换车原因
				</view>
				<!-- https://lxnapi.ccttiot.com/bike/img/static/uZQYJi6D7tPy4CszHtau -->
				<view class="choose_li">
					<view class="li_cont">
						<view class="img_box">
							<image src="https://lxnapi.ccttiot.com/bike/img/static/uZQYJi6D7tPy4CszHtau" mode=""></image>
						</view>
						电量不足
					</view>
					<view class="li_cont">
						<view class="img_box">
							<image src="https://lxnapi.ccttiot.com/bike/img/static/uZQYJi6D7tPy4CszHtau" mode=""></image>
						</view>
						车辆损坏
					</view>
				</view>
				<view class="tit" style="margin-top: 20rpx;">
				
					SN：2315721
				</view>
			</view>
			<view class="cont_box">
				<view class="tit">
					<image src="https://lxnapi.ccttiot.com/bike/img/static/uByIrgaV23PDGZWReKHW" mode=""></image>
					请选择车辆故障部位
				</view>
				<!-- https://lxnapi.ccttiot.com/bike/img/static/uZQYJi6D7tPy4CszHtau -->
				<view class="txt">
					车头故障
				</view>
				<view class="checkbox">
					<view v-for="(item, index) in cbgz" :key="index" class="check_li" :class="item.checked === true ? 'act1' : ''" @click="toggleCheckbox(index)">
					  {{ item.dictLabel }}
					  <image src="https://lxnapi.ccttiot.com/bike/img/static/ufYwbVclwhX64u4eGu6u" mode="" v-if="item.checked === true "></image>
					</view>
				</view>
				<view class="txt">
					车身故障
				</view>
				<view class="checkbox">
					<view v-for="(item, index) in csgz" :key="index" class="check_li" :class="item.checked === true ? 'act1' : ''" @click="csCheckbox(index)">
					  {{ item.dictLabel }}
					  <image src="https://lxnapi.ccttiot.com/bike/img/static/ufYwbVclwhX64u4eGu6u" mode="" v-if="item.checked === true "></image>
					</view>
				
				</view>
				<view class="txt">
					特殊故障
				</view>
				<view class="checkbox">
					<view v-for="(item, index) in tsgz" :key="index" class="check_li" :class="item.checked === true ? 'act1' : ''" @click="tsCheckbox(index)">
					  {{ item.dictLabel }}
					  <image src="https://lxnapi.ccttiot.com/bike/img/static/ufYwbVclwhX64u4eGu6u" mode="" v-if="item.checked === true "></image>
					</view>
				</view>
				<view class="input-container">
					<view class="placeholder" v-if="!textValue">如选项未涵盖，请输入故障问题</view>
					<textarea class="custom-textarea" v-model="textValue" @focus="hidePlaceholder" style="border: none;"
						@input="updateWordCount" @blur="showPlaceholder"></textarea>
					<text class="word-count">{{ currentCount }}/500</text>
				</view>
			</view>
			<view class="cont_box">
				<view class="tit">
					<image src="https://lxnapi.ccttiot.com/bike/img/static/uByIrgaV23PDGZWReKHW" mode=""></image>
					请对故障部位拍照并环绕车身进行录像
				</view>
			
				<view class="icon">
				
					<view class="imgbox" v-for="(item,index) in imglist " :key="index">
						<image :src="item" mode=""></image>
					</view>
					<view class="imgbox" @click="btn">
						<image src="https://api.ccttiot.com/smartmeter/img/static/uY8CPw9YE6JxPzcHUaqf" mode=""></image>
					</view>
				
				</view>
				<!-- https://lxnapi.ccttiot.com/bike/img/static/uZQYJi6D7tPy4CszHtau -->
				
			</view>
			<view class="tits">
				点击扫码或输入车辆编号
			</view>
			<view class="iptbox">
				<view class="qrcode" @click="qrcode()">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uy7BNwAMIKwvstqFnRhs" mode=""></image>
				</view>
				<input type="text" class="ips" v-model="sn" placeholder="请扫描设备上的二维码" style="margin-left: 32rpx;"
					placeholder-class="my-placeholder" />
			
			</view>
			
			<view class="conts_box">
				<view class="left">
					<view class="km">
						可继续行驶{{OrderdeviceInfos.remainingMileage}}公里
					</view>
					<view class="speed">
						<view class="speeds" :style="{ width: OrderdeviceInfos.remainingPower + '%' }">
			
						</view>
					</view>
					<view class="NO">
						NO.{{OrderdeviceInfos.sn}}
					</view>
				</view>
				<view class="right">
					<image src="https://lxnapi.ccttiot.com/bike/img/static/uqKmFMF9YHTX8lAQARSd" mode=""></image>
				</view>
			</view>
			<view class="conts_box">
				<view class="left">
					已骑行
				</view>
				<view class="right">
					{{timeString}}
				</view>
			</view>
			<view class="conts_box">
				<view class="left">
					预估金额
				</view>
				<view class="right">
					{{money}}元
				</view>
			</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bgc: {
					backgroundColor: "#fff",
				},
				cbgz: [
				],
				csgz: [
				],
				tsgz: [
					
				],
				textValue: '',
				currentCount: 0,
				imglist: [],
				token: '',
				sn:'',
				upurl:''
				
			}
		},
		onLoad(e) {

		this.getlist()
		},
		onShow() {
		
		},
		methods: {
			toggleCheckbox(index) {
				this.cbgz[index].checked = !this.cbgz[index].checked;
				this.$forceUpdate()
			},
			csCheckbox(index){
				this.csgz[index].checked = !this.csgz[index].checked;
			},
			tsCheckbox(index){
				this.tsgz[index].checked = !this.tsgz[index].checked;
			},
			hidePlaceholder() {
				this.placeholderVisible = false;
			},
			showPlaceholder() {
				if (!this.textValue) {
					this.placeholderVisible = true;
				}
			},
			getlist(){
				// checked
				this.$u.get("/appVerify/fault/allList?dictType=et_fault_type").then((res) => {
				
					if (res.code == 200) {
						 this.cbgz = res.data.headstock.map(item => ({...item, checked: false}));
					    this.csgz = res.data.body.map(item => ({...item, checked: false}));
					    this.tsgz = res.data.special.map(item => ({...item, checked: false}));
					} else {
						uni.showToast({
							title: '未登录，请登录后尝试',
							icon: 'none',
							duration: 2000
						});
					}
				});
			},
		}
	}
</script>
<style lang="scss">
	page {
		background-color: #F7FAFE;
	}

	.page {
		padding-bottom: 100rpx;
		// width: 750rpx;
		width: 750rpx;
		// height: 530rpx;
		// background: linear-gradient( 180deg, #64B6A7 0%, rgba(255,255,255,0) 100%), #FFFFFF;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		.iptbox {
			display: flex;
			align-items: center;
			flex-wrap: nowrap;
			padding: 22rpx;
			margin: 28rpx auto 0;
			width: 680rpx;
			height: 88rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0, 0, 0, 0.15);
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			.qrcode{
				padding-right: 20rpx;
				border-right: 2rpx solid #D8D8D8;
				image{
					width: 54rpx;
					height: 54rpx;
				}
			}
			.ips {
				width: 630rpx;
		
			}
		
			image {
				width: 18rpx;
				height: 32rpx;
			}
		
			.my-placeholder {
				font-weight: 400;
				font-size: 32rpx;
				color: #808080;
			}
		}
		.conts_box {
			width: 680rpx;
			margin-top: 36rpx;
			margin: 0 auto;
			display: flex;
			flex-wrap: nowrap;
			align-items: center;
			justify-content: space-between;
		
			.left {
				display: flex;
				flex-wrap: wrap;
				font-weight: 600;
				font-size: 36rpx;
				color: #3D3D3D;
		
				.km {
					font-weight: 400;
					font-size: 28rpx;
					color: #3D3D3D;
				}
		
				.speed {
					margin-top: 18rpx;
					width: 226rpx;
					height: 22rpx;
					background: #ccc;
					border-radius: 16rpx 16rpx 16rpx 16rpx;
		
					.speeds {
						// width: 90%;
						height: 100%;
						background: #64B6A7;
						border-radius: 16rpx 16rpx 16rpx 16rpx;
					}
				}
		
				.NO {
					font-weight: 400;
					font-size: 24rpx;
					color: #3D3D3D;
				}
			}
		
			.right {
				font-weight: 600;
				font-size: 36rpx;
				color: #3D3D3D;
		
				image {
					width: 244rpx;
					height: 196rpx;
				}
			}
		}
		
		.tits{
			width: 680rpx;
			margin: 0 auto;
			font-weight: 400;
			margin-top: 38rpx;
			font-size: 36rpx;
			color: #3D3D3D;
		}
		.cont_box{
			
			margin: 0 auto;
			padding: 24rpx 32rpx;
			width: 680rpx;
			margin-top: 38rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 10rpx 64rpx 0rpx rgba(0,0,0,0.08);
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			.tit{
				width: 100%;
				display: flex;
				flex-wrap: nowrap;	
				align-items: center;
				image{
					margin-right: 12rpx;
					width: 24rpx;
					height: 24rpx;
				}
			
			}
			.choose_li{
				margin-top: 34rpx;
				width: 100%;
				display: flex;
				flex-wrap: nowrap;
				align-items: center;
				// justify-content: space-between;
				.li_cont{
					width: 50%;
					display: flex;
					flex-wrap: nowrap;
					
					.img_box{
						margin-right: 30rpx;
						width: 38rpx;
						height: 38rpx;
						border-radius: 50%;
						border: 2rpx solid #3D3D3D;
					}
				}
			}
			.tip {
				display: flex;
				flex-wrap: nowrap;
				// align-items: center;
				font-weight: 700;
				font-size: 32rpx;
				color: #3D3D3D;
				line-height: 44rpx;
			
				.ipnt {
					margin-top: 10rpx;
					margin-right: 12rpx;
					color: #FF4444;
					font-size: 48rpx;
			
				}
			}
			
			.iptbox {
				display: flex;
				align-items: center;
				margin-top: 30rpx;
				width: 592rpx;
				height: 80rpx;
				border-radius: 20rpx 20rpx 20rpx 20rpx;
				border: 2rpx solid #979797;
				
				.ips {
					margin-left: 30rpx;
					width: 80%;
				}
			
				.iptbtn {
					display: flex;
					align-items: center;
					justify-content: center;
					width: 112rpx;
					height: 80rpx;
					background: #64B6A7;
					border-radius: 20rpx 20rpx 20rpx 20rpx;
			
					image {
						width: 37rpx;
						height: 37rpx;
					}
				}
			}
			
			.txt {
				margin-top: 18rpx;
				font-weight: 400;
				font-size: 28rpx;
				color: #3D3D3D;
			}
			.icon {
				display: flex;
				flex-wrap: wrap;
				align-items: center;
				margin-top: 40rpx;
			
				.imgbox {
					width: 33%;
			
					image {
						width: 142rpx;
						height: 142rpx;
					}
				}
			
			}
			.checkbox {
				display: flex;
				flex-wrap: wrap;
			
				.check_li {
					position: relative;
					 margin-right: 10rpx;
					margin-top: 18rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					width: 142rpx;
					height: 65rpx;
					border-radius: 20rpx 20rpx 20rpx 20rpx;
					border: 2rpx solid #C7C7C7;
					image{
						position: absolute;
						right: 0;
						bottom: 0;
						width: 40rpx;
						height: 20rpx;
					}
				}
				.check_li:nth-child(4n) {
				  margin-right: 0;
				}
				.act1 {
					// background-image: url(https://api.ccttiot.com/smartmeter/img/static/uaqN5qdoGNCs7Dumzr3F);
					width: 142rpx;
					height: 65rpx;
					 // background-size: cover;
					 border: 2rpx solid #1E807A;
					// background: #4C97E7;
				}
			}
			.input-container {
				position: relative;
				width: 612rpx;
				height: 248rpx;
				background: #FFFFFF;
				box-shadow: 0rpx 16rpx 40rpx 0rpx rgba(42, 130, 228, 0.1);
				border-radius: 20rpx;
				margin-top: 40rpx;
				overflow: hidden;
				padding-right: 38rpx;
				box-sizing: border-box;
				border: 2rpx solid #C7C7C7;
			}
			
			.placeholder {
				position: absolute;
				top: 18rpx;
				left: 38rpx;
				color: #999;
				/* placeholder颜色 */
				pointer-events: none;
				/* 确保点击事件可以穿透到textarea上 */
			}
			.custom-textarea {
				width: 100%;
				height: 100%;
				/* 设置一个合适高度 */
				padding-top: 18rpx;
				/* 为placeholder留出空间 */
				padding-left: 38rpx;
				box-sizing: border-box;
				border: 1px solid #ccc;
			}
			
			.word-count {
				position: absolute;
				right: 10px;
				bottom: 10px;
				font-size: 12px;
				color: #999;
			}
		}
	
	}
</style>