<template>
	<view class="page">
		<view class="toptit" @click="shows()">
			{{areaInfo.areaName}}
		</view>
		<!-- <u-navbar  :is-back='false' title="工作台" :border-bottom="false" :background="bgc" title-color='#2E4975' title-size='36'
			height='45'></u-navbar> -->
			
		<view class="cont_box">
			<view class="top">
				<image src="https://lxnapi.ccttiot.com/bike/img/static/uMlgu6j9jnDqP1ZFL7xj" mode=""></image>
				应用入口
			</view>
			<view class="app_box">
				<view class="cont" @click="topage(0)">
					<image src="https://lxnapi.ccttiot.com/bike/img/static/unnmUkUif2eWNKFq9fdg" mode=""></image>
					<view class="text">
						运营数据
					</view>
				</view>
				<view class="cont"  @click="topage(1)">
					<image src="https://lxnapi.ccttiot.com/bike/img/static/upJFJIIZ4hbSEuchNQi3" mode=""></image>
					<view class="text">
						收入对账
					</view>
				</view>
				<view class="cont"  @click="topage(2)">
					<image src="https://lxnapi.ccttiot.com/bike/img/static/uNfRjhtxYmMPKaX4DqTS" mode=""></image>
					<view class="text">
						设备管理
					</view>
				</view>
				<!-- <view class="cont"  @click="topage(3)">
					<image src="https://lxnapi.ccttiot.com/bike/img/static/ugC3s7fvhckzJN9vqsHa" mode=""></image>
					<view class="text">
						用户管理
					</view>
				</view> -->
				<view class="cont" @click="topage(4)">
					<image src="https://lxnapi.ccttiot.com/bike/img/static/uM4rBBaXc7b3TmsqQTvz" mode=""></image>
					<view class="text">
						用户页面
					</view>
				</view>
				<view class="cont" @click="topage(5)">
					<image src="https://lxnapi.ccttiot.com/bike/img/static/uM4rBBaXc7b3TmsqQTvz" mode=""></image>
					<view class="text">
						车辆绑定
					</view>
				</view>
				<view class="cont" @click="topage(6)" >
					<image src="https://lxnapi.ccttiot.com/bike/img/static/u47okd0YdEQBsyhLlQIt" mode="" style="width: 50rpx;height: 50rpx;"></image>
					<view class="text">
						账户明细
					</view>
				</view>
				<view class="cont" @click="topage(7)" >
					<image src="https://lxnapi.ccttiot.com/bike/img/static/u47okd0YdEQBsyhLlQIt" mode="" style="width: 50rpx;height: 50rpx;"></image>
					<view class="text">
						故障审核
					</view>
				</view>
			</view>
		</view>
			<u-select v-model="show" :list="list" title='选择运营区' @confirm="confirm"></u-select>
		<tab-bar :indexs='0' style=""></tab-bar>
	</view>
</template>

<script>
	export default {
		data() { 
			return {
				bgc: {
					backgroundColor: "#FFFFFF",
				},
				sn:'',
				areaId:0,
				areaInfo:{},
				list: [],
				show: false,
				info:{}
			
			}
		},
		onShow() {
			this.$store.dispatch('userInfo', this.$u).then(() => {

				// 执行其他操作...
			});
			if(uni.getStorageSync('adminAreaid')){
				this.areaId = uni.getStorageSync('adminAreaid')
				this.getArea()
				this.getareaList()
				this.getareaInfo()
			}
		
		},
		computed: {
			userId() {
				return this.$store.getters.userId;
			},
		},
		methods: {
			getareaInfo() {
				this.$u.get('/appVerify/getDept').then((res) => {
					if (res.code == 200) {
						this.info=res.data
						console.log(this.userId,'userIduserIduserId');
					}
				}).catch(error => {
					console.error("Error fetching area data:", error);
				});
			},
			shows(){
				
				if(this.list.length<2){
					
				}else{
					this.show =true
				}
			},
			getareaList(){
			
			
				this.$u.get('/appVerify/getAreaList').then((res) => {
					if(res.code==200){
					  this.list = res.data.map(item => ({
					            value: item.areaId,
					            label: item.areaName
					        }));
					}
				}).catch(error => {
					console.error("Error fetching area data:", error);
				});
			},
			confirm(e){
				// console.log(e);
				uni.setStorageSync('adminAreaid', e[0].value);
				this.areaId= e[0].value
				this.getArea()
				
			},
			getArea() {
				
				let id = this.areaId
				this.$u.get("/app/area/" + id).then((res) => {
				
					if (res.code == 200) {
						this.areaInfo=res.data
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						});
					}
				});
			},
			topage(num){
				if(num==0){
					uni.navigateTo({
						url:'/pages_admin/worke/worke_Operation'
					})
				}else if(num==1){
					uni.navigateTo({
						url:'/pages_admin/worke/worke_income'
					})
				}else if(num==2){
					uni.navigateTo({
						url:'/pages_admin/worke/woke_deviceMgmt'
					})
				}else if(num==3){
					uni.navigateTo({
						url:'/pages_admin/worke/worke_user'
					})
				}else if(num==4){
					uni.navigateTo({
						url:'/pages/index/index'
					})
				}else if(num==5){
					uni.navigateTo({
						url:'/pages_admin/worke/bind_sn'
					})
					// uni.scanCode({
					// 	onlyFromCamera: true,
					// 	scanType: ['qrCode'],
					// 	success: res => {
					
					// 		let sn = null;
					// 		let queryParams = res.result.split('?')[1];
					// 		if (queryParams) {
					// 			let params = queryParams.split('&');
					// 			params.forEach(param => {
					// 				let [key, value] = param.split('=');
					// 				if (key === 'sn') {
					// 					sn = value;
					// 				}
					// 			});
					// 		}
							
					// 		this.sn = sn
					// 		console.log(res.result);
					// 		if (this.sn != '') {
								
					// 		}
					
					// 	},
					// 	fail: err => {
					// 		console.error('扫描失败:', err);
					// 		uni.showToast({
					// 			title: '扫描失败',
					// 			icon: 'none'
					// 		});
					// 	}
					// });
				}else if(num==6){
					uni.navigateTo({
						url:'/pages_admin/worke/AccountDetails'
					})
				}else if(num==7){
					uni.navigateTo({
						url:'/pages_adminSet/shgl'
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #FFFFFF;
	}

	.page {
		width: 750rpx;
		.toptit{
			margin-top: 100rpx;
			margin-left: 100rpx;
			font-size: 38rpx;
		}
		.cont_box{
			padding: 46rpx 50rpx;
			margin: 68rpx auto;
			width: 680rpx;
			height: 498rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 4rpx 22rpx 0rpx rgba(0,0,0,0.07);
			border-radius: 24rpx 24rpx 24rpx 24rpx;
			.top{
				width: 100%;
				display: flex;
				flex-wrap: nowrap;
				align-items: center;
				image{
					margin-right: 16rpx;
					width: 32rpx;
					height: 32rpx;
				}
				font-weight: 500;
				font-size: 32rpx;
				color: #3D3D3D;
				
			}
			.app_box{
				display: flex;
				flex-wrap: wrap;
				.cont:nth-child(4n) {
				    margin-right: 0;
				}
				.cont{
					margin-right: 60rpx;
					margin-top: 70rpx;
					width: 96rpx;
					display: flex;
					flex-wrap: wrap;
					justify-content: center;
					image{
						width: 54rpx;
						height: 52rpx;
					}
					.text{
						margin-top: 14rpx;
						font-weight: 400;
						font-size: 24rpx;
						color: #3D3D3D;
					}
				}
			}
		}
	}
</style>