<template>
	<view class="page">
		<u-navbar :is-back="false"  title="商户中心" :border-bottom="false" back-icon-color="#000" :background="bgc" title-color='#000' title-size='36'
			height='36'	id="navbar">
		</u-navbar>

		<view class="fdpage">
			<view class="top_box">
				<view class="userinfo">
					<view class="info" @click="topage(5)">
						<view class="username">
							{{userinfo.userName == null ? '' : userinfo.userName}}
						</view>
						<view class="num" style="color: #8883F0;">
							共{{userinfo.deviceCount == null ? 0 : userinfo.deviceCount}}台设备
						</view>
					</view>
				</view>
				<!-- <view class="tit">
					我的钱包
				</view> -->
				<view class="cont_box">
					<view class="cont" @click="topage(8)">
						<view class="top">
							<image src="https://api.ccttiot.com/smartmeter/img/static/uHOo30kXB3YW8ZtXfHhf" mode="aspectFit" style="width: 64rpx;height: 64rpx;"></image>
						</view>
						<view class="bot">
							钱包余额
						</view>	
						<view class="top" style="font-size: 24rpx;color: #FFFFFF;margin-top: 16rpx;">
							<view class="txt" style="font-size: 24rpx;">
								￥
							</view>
							{{userinfo.balance == undefined ? '' : Number(userinfo.balance) + Number(userinfo.waitBonusAmount)}}
						</view>
						
					</view>
					<view class="cont" @click="topage(6)">
						<view class="top">
							<image src="https://api.ccttiot.com/smartmeter/img/static/uOOWx12k9HwJC1H2VboU" mode="aspectFit" style="width: 64rpx;height: 64rpx;"></image>
						</view>
						<view class="bot">
							收款账户
						</view>
						<view class="" style="font-size: 24rpx;color: #FFFFFF;margin-top: 16rpx;">
							微信收款
						</view>
					</view>
					<view class="cont"  @click="topage(7)">
						<view class="top" >
							<image src="https://api.ccttiot.com/smartmeter/img/static/uNHen7RecrdS4wCByzTg" mode="aspectFit" style="width: 64rpx;height: 64rpx;"></image>
						</view>
						<view class="bot">
							收支明细
						</view>
						<view class="" style="font-size: 24rpx;color: #FFFFFF;margin-top: 16rpx;">
							近30天
						</view>
					</view>
				</view>
			</view>
			<view class="bot_box">
				<view class="botcard" @click="topage(0)">
					<image src="https://api.ccttiot.com/smartmeter/img/static/ueChEPTc9fqVEhESWbiL" mode="aspectFit"></image>
					<view class="txt">我的店铺</view>
				</view>
				<view class="botcard" @click="btnguanli">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uR42KHhw7robZ6SgCo3s" mode="aspectFit"></image>
					<view class="txt">套餐模版</view>
				</view>
				<view class="botcard" @click="topage(1)">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uu4fzNHGnupEtlZhEIPF" mode="aspectFit"></image>
					<view class="txt">订单管理</view>
				</view>
				<view class="botcard" @click="topage(10)">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uUb0uN0maidsuLqPayKm" mode="aspectFit"></image>
					<view class="txt">订单统计</view>
				</view>
				<view style="margin-top:40rpx" class="botcard" @click="topage(4)">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uTZBKfNX9FO1iwFosYI8" mode="aspectFit"></image>
					<view class="txt">安全中心</view>
				</view>
				<view style="margin-top:40rpx" class="botcard" @click="btnbangzhu">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uyRB5Kph6fn7DBMqmaYI" mode="aspectFit"></image>
					<view class="txt">帮助中心</view>
				</view>
				<view style="margin-top:40rpx" class="botcard" @click="topage(3)">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uUcPNyoPuISC6uS5GBpi" mode="aspectFit"></image>
					<view class="txt">咨询客服</view>
				</view>
				<view style="margin-top:40rpx" class="botcard" v-if="userinfo.deviceAdmin == true" @click="btnsblr">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uez0K9n1SgNjYBPbQgDW" mode="aspectFit"></image>
					<view class="txt">设备录入</view>
				</view>
				<view style="margin-top:40rpx" class="botcard" v-if="userinfo.type == 3" @click="btndaili">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uAjP0V10qIEJn4ruztGa" mode="aspectFit"></image>
					<view class="txt">代理入口</view>
				</view>
				<view style="margin-top:40rpx" class="botcard" @click="btnshipin">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uFGWU1QHchbCKedNWK74" mode="aspectFit"></image>
					<view class="txt">视频教程</view>
				</view>
				<view style="margin-top:40rpx" class="botcard" @click="btntuichu">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uSBN3RkeyeJLJev5Sk2F" mode="aspectFit"></image>
					<view class="txt">退出登录</view>
				</view>
			</view>
		</view>
		<!-- #ifdef MP-WEIXIN -->
		       <tab-bar :indexs='2' style=""></tab-bar>
		<!-- #endif -->
	
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bgc: {
					backgroundColor: " #F0EFFF",
				},
				userType:'',
				userinfo:''
			}
		},
		onLoad() {
		
		},
		onShow() {
				this.logins()
		},
		// 分享到好友（会话）
		  onShareAppMessage: function () {  
		    return {  
		      title: '创想物联',  
		      path: '/pages/shouye/index'  
		    }  
		  },  
		  
		  // 分享到朋友圈  
		  onShareTimeline: function () {  
		    return {  
		      title: '创想物联',  
		      query: '',  
		      path: '/pages/shouye/index'  
		    }  
		  },
		methods: {
			// 点击跳转到视频教程
			btnshipin(){
				uni.navigateTo({
					url:'/page_geren/shipin/index'
				})
			},
			// 点击进行商家实名
			// btnsm(){
			// 	uni.navigateTo({
			// 		url:'/pages/sjshiming'
			// 	})
			// },
			// 点击跳转到帮助中心
			// 点击跳转到会员
			btnhuiyuan(){
				uni.navigateTo({
					url:'/page_geren/buyCard'
				})
			},
			btnbangzhu(){
				uni.navigateTo({
					url:'/pages/daili/bangzhu'
				})
			},
			btnhhr(){
				uni.navigateTo({
					url:'/page_fenbao/hehuoren/index'
				})
			},
			// 退出登录
			btntuichu(){
				uni.showModal({
					title: '提示',
					content: '您确定要退出登录吗？',
					success: function(res) {
						if (res.confirm) {
							try {
							  const storageInfo = uni.getStorageInfoSync() 
							  const keys = storageInfo.keys // 获取所有键  
							  keys.forEach(key => {  
							    uni.removeStorageSync(key) // 遍历并删除每个键  
							  });  
							  console.log('所有本地存储已删除')
							   uni.reLaunch({
							   	url:'/pages/login/login'
							   })
							} catch (e) {  
							  console.error('删除本地存储时发生错误：', e)
							}  
						} 
					}
				})
			},
			// 点击跳转到帮助中心
			btnjiefeng(){
				uni.navigateTo({
					url:'/page_fenbao/statulist/question/index'
				})
			},
			
			btnguanli(){
				uni.navigateTo({
					url:'/page_components/newtaocan'
				})
			},
			btnmy(){
				uni.navigateTo({
					url:'/page_components/miyao'
				})
			},
			btntc(){
				uni.reLaunch({
					url:'/pages/shouye/index'
				})
			},
			topage(num){
				if(num==0){
					uni.navigateTo({
						url:'/page_fenbao/statulist/myshop/index'
					})
				}else if(num==1){
					uni.navigateTo({
						url:'/page_user/switchs'
					})
				}else if(num==2){
					uni.navigateTo({
						url:'/page_fenbao/statulist/question/index?id=' + 1
					})
				}else if(num==3){
					uni.navigateTo({
						url:'/page_user/Feedback'
					})
				}else if(num==4){
					// uni.navigateTo({
					// 	url:'/page_fenbao/statulist/fault/index'
					// })
					uni.showToast({
						title:'该功能暂未开放',
						icon: 'none',
						duration: 2000
					})
				}else if(num==5){
					uni.navigateTo({
						url:'/page_user/userSet'
					})
				}else if(num==6){
					uni.navigateTo({
						url:'/page_user/skzh'
					})
				}else if(num==7){
					uni.navigateTo({
						url:'/page_user/shouzhi'
					})
				}else if(num==8){
					uni.navigateTo({
						url:'/page_user/yetx'
					})
				}else if(num == 9){
					uni.navigateTo({
						url:'/page_fenbao/statulist/merchant/index'
					})
				}else if(num == 10){
					uni.navigateTo({
						url:'/pages/tongji'
					})
				}
			},
			topages(num){
				if(num==0){
					uni.navigateTo({
						url:'/page_user/usercz'
					})
				}else if(num==1){
					uni.navigateTo({
						url:'/page_user/cbRecord'
					})
				}else if(num==2){
					uni.navigateTo({
						url:'/page_user/aske'
					})
				}else if(num==3){
					uni.navigateTo({
						url:'/page_user/Feedback'
					})
				}else if(num==4){
					uni.navigateTo({
						url:'/page_user/userSet'
					})
				}
			},
			logins(){
				if (uni.getStorageSync('userType')) {
					this.userType = uni.getStorageSync('userType')
					this.userType='01'
					if (this.userType == '01') {
					} else if (this.userType == '00') {
					}
				} else {
					
				}
				this.getuserinfo()
			},
			getuserinfo() {
				this.$u.get("/app/user/userInfo").then((res) => {
					if (res.code == 200) {
					this.userinfo=res.data
						this.userType = res.data.userType
						if (this.userType == '01') {
							
						} else if (this.userType == '00') {
							
						}
			
					}
				})
			},
			
			// 跳转设备录入
			btnsblr(){
				uni.reLaunch({
					url:'/page_fenbao/zhuce'
				})
			},
			// 代理入口
			btndaili(){
				uni.navigateTo({
					url:'/pages/daili/index'
				})
			}
		}
	}
</script>

<style lang="scss">
page{
	background-color: #F0EFFF;
}
.page{
	width: 750rpx;
	height: 100vh;
	.userpage{
		.top_box{
			padding-top: 40rpx;
			width: 750rpx;
			height: 352rpx;
			background-color: #8883F0;
		}	
	}
	.anniu{
		width: 300rpx;
		height: 120rpx;
		background-color: #8883F0;
		color: #fff;
		font-size: 32rpx;
		text-align: center; 
		line-height: 120rpx;
		border-radius: 30rpx;
		margin-top: 20rpx;
		margin-left: 40rpx;
	}
	.fdpage{
		.top_box{
			padding-top: 40rpx;
			width: 750rpx;
			height: 470rpx;
			background-color: #F0EFFF;
			.userinfo{
				margin-left: 56rpx;
				padding-right: 56rpx;
				box-sizing: border-box;
				display: flex;
				flex-wrap: nowrap;
				align-content: flex-start;
				justify-content: space-between;
				.img{
					width: 100rpx;
					height: 100rpx;
					image{
						width: 100rpx;
						height: 100rpx;
						border-radius: 50%;
					}
				}
				.info{
					margin-left: 28rpx;
					.username{
						font-size: 40rpx;
						color: #3D3D3D;
					}
					.num{
						font-size: 28rpx;
						color: #999;
						margin-top: 14rpx;
					}
				}
			}
			.tit{
				margin-top: 32rpx;
				margin-left: 56rpx;
				width: 100%;
				font-size: 28rpx;
				font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
				font-weight: 400;
				color: #FFFFFF;
			}
			.cont_box{
				margin-top: 30rpx;
				display: flex;
				flex-wrap: nowrap;
				align-items: center;
				justify-content: space-around;
			    width: 688rpx;
			    height: 246rpx;
				margin: auto;
				border-radius: 24rpx;
			    background: #8883F0;
				margin-top: 54rpx;
				.cont{
					width: 116rpx;
					display: flex;
					flex-wrap: wrap;
					justify-content: center;
					.top{
						display: flex;
						flex-wrap: nowrap;
						align-items: baseline;
						font-size: 36rpx;
						font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
						font-weight: 400;
						color: #FFFFFF;
					}
					.bot{
						margin-top: 20rpx;
						font-size: 26rpx;
						font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
						font-weight: 400;
						color: #FFFFFF;
					}
				}
			}
		}
		.bot_box{
			width: 688rpx;
			max-height: 810rpx;
			background: #FFFFFF;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			display: flex;
			// justify-content: space-between;
			align-items: center;
			flex-wrap: wrap;
			margin: auto;
			margin-top: 28rpx;	
			padding: 48rpx 20rpx;
			box-sizing: border-box;		
			.botcard{
				width: 25%;;
				height: 140rpx;
				text-align: center;
				image{
					width: 76rpx;
					height: 76rpx;
				}
				.txt{
					margin-top: 10rpx;
					font-size: 30rpx;
					color: #383838;
				}
			}
		}
	}
}

</style>
