<template>
	<view class="page">
		<u-navbar title="上报异常" :border-bottom="false" :background="bgc" title-color='#000' back-icon-color="#000" title-size='36' height='50'></u-navbar>
		<view class="box">
			<view class="list">
				<view class="sbbh">
					<view class="onr">
						<image src="https://api.ccttiot.com/smartmeter/img/static/uTo0sMNT1u6dyEgpvraQ" mode=""></image> 设备编号：
					</view>
					<view class="inp">
						<input type="text" placeholder="请输入编号" v-model="result" style="color: #999;padding-left: 30rpx;"/>
					</view>
					<view class="sm" @click="scanQRCode">
						<image src="https://api.ccttiot.com/smartmeter/img/static/uwtCTFeo0LULdRKL6wHG" mode=""></image>
					</view>
				</view>
				<view class="gzyy">
					<view class="">
						故障原因：
					</view>
					<view class="tcsb" @click="btntc" style="color: #999;padding-left: 30rpx;">
						{{text}}
					</view>
				</view>
				<view class="bz">
					<view class="tit">
						<image src="https://api.ccttiot.com/smartmeter/img/static/uTo0sMNT1u6dyEgpvraQ" mode=""></image>备&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;注：
					</view>
					<view class="wb">
						<textarea name=""  placeholder="请输入备注" v-model="cont" id="" cols="30" rows="10"></textarea>
					</view>
				</view>
			</view>
			
			<view class="yc" @click="btnyc">上报异常</view>
		</view>
		
		
		<u-select v-model="listshow" :list="list" @confirm="confirm"></u-select>
	</view>
</template>

<script>
	export default {
		data() {
			return {
                listshow:false,
				list: [{
						value: '1',
						label: '弹出失败'
					},
					{
						value: '2',
						label: '卡槽损坏'
					},
					{
						value: '3',
						label: '设备破坏'
					},
					{
						value: '4',
						label: '仓位异常'
					}
				],
				text:'弹出失败',
				result:'',
				cont:'',
				type:1
			}
		},
		methods: {
            btntc(){
				this.listshow = true
			},
			confirm(e){
				this.text = e[0].label
				this.type = e[0].value
			},
			
			scanQRCode() {
				uni.scanCode({
					onlyFromCamera: true,
					scanType: ['qrCode'],
					success: res => {
						console.log('扫描结果：', res);
						this.result = res.result
					},
					fail: err => {
						console.error('扫描失败：', err);
						uni.showToast({
							title: '扫描失败',
							icon: 'none'
						});
					}
				});
			},
			btnyc(){
				let data = {
					cabinetSn:this.result,
					type:this.type,
					remark:this.cont
				}
				this.$u.post('/agent/abnormal',data).then(res =>{
					if(res.code == 200){
						uni.showToast({
							title: '上报成功',
							icon: 'none',
							duration: 1000
						})
						setTimeout(()=>{
							uni.navigateBack()
						},1000)
					}
				})
			}
			
		}
	}
</script>

<style lang="scss">
	/deep/ .u-title,
	/deep/ .uicon-nav-back{
		padding-bottom: 22rpx;
	}
	page {
		background: linear-gradient(180deg, #25CE88 0%, rgba(255, 255, 255, 0) 100%);
	}
	.yc{
		width: 660rpx;
		height: 108rpx;
		margin: auto;
		background: #1DBE7B;
		border-radius: 20rpx;
		color: #FFFFFF;
		line-height: 108rpx;
		text-align: center;
		margin-top: 150rpx;
		font-size: 36rpx;
	}

	.page {
		width: 750rpx;
		position: fixed;
		top: 0;
		left: 0;

		.box {
			width: 750rpx;
			height: 1440rpx;
			background: #F4F5F7;
			padding-top: 30rpx;

			.list {
				width: 100%;
				width: 680rpx;
				height: 388rpx;
				background: #FFFFFF;
				border-radius: 24rpx 24rpx 24rpx 24rpx;
				margin: auto;
                padding: 42rpx 44rpx;
				box-sizing: border-box;
				.sbbh {
					width: 100%;
					display: flex;
					justify-content: space-between;
                    font-size: 28rpx;
                    color: #3D3D3D;
					.onr {
						margin-top: 10rpx;
						image {
							width: 20rpx;
							height: 20rpx;
							display: inline-block;
							margin-right: 10rpx;
						}
					}

					.inp {
						input {
							width: 340rpx;
							height: 50rpx;
							border-radius: 12rpx 12rpx 12rpx 12rpx;
							border: 2rpx solid #C9CDD4;
						}
					}
					.sm{
						image{
							width: 52rpx;
							height: 52rpx;
							// background-color: #ccc;
						}
					}
				}
				.gzyy{
					margin-top: 20rpx;
					display: flex;
					justify-content: space-between;
					font-size: 28rpx;
					color: #3D3D3D;
					padding-left: 24rpx;
					.tcsb{
						width: 430rpx;
						height: 50rpx;
						line-height: 50rpx;
						border-radius: 12rpx 12rpx 12rpx 12rpx;
						border: 2rpx solid #C9CDD4;
						font-size: 28rpx;
						color: #3D3D3D;
						padding-left: 30rpx;
					}
				}
				.bz{
					margin-top: 20rpx;
					display: flex;
					justify-content: space-between;
					font-size: 28rpx;
					color: #3D3D3D;
					.tit{
						image{
							width: 20rpx;
							height: 20rpx;
							display: inline-block;
							margin-right: 10rpx;
						}
					}
					.wb{
						width: 430rpx;
						height: 150rpx;
						border-radius: 12rpx 12rpx 12rpx 12rpx;
						border: 2rpx solid #C9CDD4;
						padding: 10rpx 30rpx;
					}
				}
			}
		}
	}
</style>