<template>
    <view class="container-view-contril">
		<scroll-view class="scroll-view flex-row" scroll-x="true">
			<view @tap="tapOpen" v-for="(item,index) of contrilList" :key="index" :data-item="item" class="contril-item flex-row">
				<img class="contril-item-img"  :src="item.iconUrl" alt="">
				<text>{{item.name}}</text>
			</view>
			<view class="contril-item flex-row" @tap="toMoreFunctionSet">
				<img class="contril-item-img" src="https://qiniu.bms16.com/Ft3pNyStT22LP8Ds1Mru2LoTHadx" alt="">
				<text>{{$t("更多功能")}}</text>
			</view>
		</scroll-view>
		<view v-if="popupShow" class="show-modal">
			<view class="modal-info">
				<view class="popup-title">{{$t(popText)}}</view>
				<view class="popup-content">{{$t("您确认")+$t(popText)}}</view>
				<view class="flex-row modal-footer">
					<view class="show-btn cencel-btn-pop" @tap="closePopup">{{$t("取消")}}</view>
					<view class="show-btn ok-btn-pop" @tap="tapBlueToothCmd">{{$t("确定")}}</view>
				</view>
			</view>
		</view>
		<!-- <u-popup v-model="popupShow" mode="center" border-radius="30" height="30%" length="60%">
			<view class="popup-title">开启车辆</view>
			<view class="popup-content">确定打开</view>
			<view class="flex-row">
				<view class="sure-btn cencel-btn" @tap="closePopup">取消</view>
				<view class="sure-btn ok-btn" >确定</view>
			</view>
		</u-popup> -->
		<!-- <view v-if="isShowMore" class="show-more">
			<view class="more-info">
				<view class="flex-row flex-between model-title">
					<view>{{$t("更多功能")}}</view>
					<view>
						<image style="width: 32rpx;height: 32rpx;" @tap="isShowMore = false"
							src="https://qiniu.bms16.com/FtoTEHOJiUf_gjPCJGGHMsAtHI5M" />
					</view>
				</view>
				<view style="height: 300rpx;">
					<view data-url="test" @tap="navUrl" class="more-item flex-row">
						<img class="more-img" src="https://qiniu.bms16.com/FgxiD-W96FGvgyLI_kXUfWVDYLQ9" alt="">
						<text>{{$t("胎压")}}</text>
					</view>
					<view class="more-item flex-row">
						<img class="more-img" src="https://qiniu.bms16.com/FgxiD-W96FGvgyLI_kXUfWVDYLQ9" alt="">
						<text>{{$t("电池信息")}}</text>
					</view>
					<view @tap="navCarLocation" class="more-item flex-row">
						<img class="more-img" src="https://qiniu.bms16.com/FgxiD-W96FGvgyLI_kXUfWVDYLQ9" alt="">
						<text>{{$t("导航")}}</text>
					</view>
				</view>
				<view class="lift-btn-view">
					<view class="lift-btn">{{$t("解除绑定")}}</view>
				</view>
			</view>
		</view>
   -->
   
	</view>
</template>

<script>
	var app = getApp();
	var bluetooth = require('@/common/bluetooth.js');
export default {
	props:{
		contrilList: {
			type: Array,
			default: () => []
		},
	},
	
    data() {
        return {
			popText:'',
			popupShow:false,
			controlType:null,//选择的车辆控制
			isShowMore:false
		};
    },
	mounted() {
		// this.contrilList = getFunctionTag().activeTag
	},
 
    /**
     * 组件的方法列表
     */
    methods: {
		tapOpen(e){
			const {name} = e.currentTarget.dataset.item;
			this.setData({
				popText:name,
				popupShow:true
			})
		},
		tapBlueToothCmd(){
			// const isLock=this.contrilList.map(i=>i.isLock||false)
			if(this.popText=='开机'){
				bluetooth.turnOnCar('900000997',()=>{
					console.log('发送开机指令结束');
				})
			}else if(this.popText=='闪灯鸣笛'){
				bluetooth.findCarCmd('900000997',()=>{
					console.log('发送闪灯鸣笛指令结束');
				})
			}else if(this.popText=='打开座桶'){
				bluetooth.openCarSeat('900000997',()=>{
					console.log('发送打开座桶指令结束');
				})
			}else if(this.popText=='打开尾箱'){
				bluetooth.openCarTrunk('900000997',()=>{
					console.log('发送打开尾箱指令结束');
				})
			}else if(this.popText=='关机'){
				bluetooth.turnOffCar('900000997',()=>{
					console.log('发送关机指令结束');
				})
			}else if(this.popText=='胎压'){
				bluetooth.getCarPressure('900000997',()=>{
					console.log('发送胎压指令结束');
				})
			}
		},
		closePopup(){
			this.popupShow=false
		},
		tapOpenMore(){
			// this.isShowMore=true
		},
		closeMore(){
			this.isShowMore=false
		},
		navUrl(url){
			// ifconsole.log(url,'sj');
		},
		navCarLocation(){
			//前往配置更多功能
			uni.navigateTo({
				url:'/pages/carLocation/carLocation'
			})
		},
		toMoreFunctionSet() {
			uni.navigateTo({
				url: '/pages/carFunctionSet/more'
			})
		}
	}
};
</script>
<style>
@import './control.css';
</style>
