<template>
	<view class="page">
		<u-navbar :is-back="false"  title="商户中心" :border-bottom="false" back-icon-color="#fff" :background="bgc" title-color='#fff' 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.nickName == null ? '' : userinfo.nickName}}
						</view>
						<view class="num">
							共{{userinfo.storeCount == null ? 0 : userinfo.storeCount}}间店铺
						</view>
					</view>
					<view class="" v-if="userinfo.deviceAdmin == true">
						<view class="botcard" @click="btnsblr">
							<view class="txt">设备录入</view>
						</view>
					</view>
					<view class="" v-if="userinfo.type == 3">
						<view class="botcard" @click="btndaili">
							<view class="txt">代理入口</view>
						</view>
					</view>
				</view>
				<!-- <view class="tit">
					我的钱包
				</view> -->
				<view class="cont_box">
					<view class="cont" @click="topage(8)">
						<view class="top" >
							<view class="txt" style="font-size: 24rpx;">
								￥
							</view>
							{{userinfo.balance == undefined ? '' : Number(userinfo.balance) + Number(userinfo.waitBonusAmount)}}
						</view>
						<view class="bot">
							钱包余额
						</view>
					</view>
					<view class="cont" @click="topage(6)">
						<view class="top"  >
							<image src="https://api.ccttiot.com/smartmeter/img/static/u9VRzUjhkZHj4ExkXC10" mode="aspectFit" style="width: 61.83rpx;height: 46.35rpx;"></image>
						</view>
						<view class="bot">
							收款账户
						</view>
					</view>
					<view class="cont"  @click="topage(7)">
						<view class="top" >
							<image src="https://api.ccttiot.com/smartmeter/img/static/utQedWhwW39J2qbeWvn8" mode="aspectFit" style="width: 45rpx;height: 55rpx;"></image>
						</view>
						<view class="bot">
							收支明细
						</view>
					</view>
				</view>
			</view>
			<view class="bot_box" style="max-height: 1000rpx;
    overflow: scroll;">
				<view class="botcard" @click="topage(0)">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uATEvHAKIB0tdXk0embn" mode="aspectFit"></image>
					<view class="txt">我的店铺</view>
				</view>
				
				<view class="botcard" @click="btnguanli">
					<image src="https://api.ccttiot.com/smartmeter/img/static/umjPUc8nDKf1JwVqRAeb" mode="aspectFit"></image>
					<view class="txt">套餐模版</view>
				</view>
				<view class="botcard" @click="topage(1)">
					<image src="https://api.ccttiot.com/smartmeter/img/static/ujXfMLJmerXRSRGZfGFV" mode="aspectFit"></image>
					<view class="txt">订单管理</view>
				</view>
				<view class="botcard" @click="topage(10)">
					<image src="https://api.ccttiot.com/smartmeter/img/static/ui06lcaul58Y3ianRZAZ" mode="aspectFit"></image>
					<view class="txt">订单统计</view>
				</view>
				<view class="botcard" @click="topage(4)" v-if="false">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uKewAY8xvJN04yFpGEjl" mode="aspectFit"></image>
					<view class="txt">安全中心</view>
				</view>
				<!-- <view class="botcard" @click="topage(9)">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uYOquvGtfb1sm5F60NgJ" mode="aspectFit"></image>
					<view class="txt">商家合作</view>
				</view> -->
				<!-- <view class="botcard" @click="topage(2)">
					<image src="https://api.ccttiot.com/smartmeter/img/static/u6qVTFXdkQKEqE1y0J4o" mode="aspectFit"></image>
					<view class="txt">帮助中心</view>
				</view> -->
				<!-- <view class="botcard" @click="topage(3)">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uGlrjkSOTDXMFuuRb03l" mode="aspectFit"></image>
					<view class="txt">意见反馈</view>
				</view> -->
				<!-- <view class="botcard" @click="btnhhr">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uspdprPKiYdcIdwhtdPM"></image>
					<view class="txt">合伙人</view>
				</view> -->
				<view class="botcard" @click="btnjiefeng">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uGlrjkSOTDXMFuuRb03l" mode="aspectFit"></image>
					<view class="txt">解封记录</view>
				</view>
				<view class="botcard" @click="topage(3)">
					<image src="https://api.ccttiot.com/smartmeter/img/static/ufkTrhk4AurNtIHXwe35" mode="aspectFit"></image>
					<view class="txt">咨询客服</view>
				</view>
				<view class="botcard" @click="btntuichu">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uHB7v39URI7EL8s9bSIC" mode="aspectFit"></image>
					<view class="txt">退出登录</view>
				</view>
			
				<!-- <view class="botcard" @click="topage(5)">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uYWpW30vIQ6M4svb7Vnb"></image>
					<view class="txt">设置</view>
				</view> -->
				
				<!-- <view class="botcard" style="padding-left: 220rpx;font-size: 40rpx;font-weight: 600;" @click="btntc">
					切换用户端
				</view> -->
			</view>
		</view>
		
		<!-- #ifdef MP-WEIXIN -->
		       <tab-bar :indexs='2' style=""></tab-bar>
		<!-- #endif -->
	
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bgc: {
					backgroundColor: " #8883F0",
				},
				userType:'',
				userinfo:''
			}
		},
		onLoad() {
		
		},
		onShow() {
				this.logins()
		},
		// 分享到好友（会话）
		  onShareAppMessage: function () {  
		    return {  
		      title: '创想物联',  
		      path: '/pages/shouye/index'  
		    }  
		  },  
		  
		  // 分享到朋友圈  
		  onShareTimeline: function () {  
		    return {  
		      title: '创想物联',  
		      query: '',  
		      path: '/pages/shouye/index'  
		    }  
		  },
		methods: {
			// 点击进行商家实名
			// btnsm(){
			// 	uni.navigateTo({
			// 		url:'/pages/sjshiming'
			// 	})
			// },
			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/jiefeng/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_fenbao/statulist/myorder/index'
					// })
					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'
					})
				}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') {
						// this.getDeviceList()
					} else if (this.userType == '00') {
						// this.getdevice()
					}
				} else {
					
				}
				this.getuserinfo()
			},
			getuserinfo() {
				this.$u.get("/app/user/userInfo").then((res) => {
					// this.$forceUpdate()
					if (res.code == 200) {
					this.userinfo=res.data
						// uni.setStorageSync('userType', res.data.userType)
						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: #F7FAFE;
}
.page{
	width: 750rpx;
	height: 100vh;
	.userpage{
		.top_box{
			padding-top: 40rpx;
			width: 750rpx;
			height: 352rpx;
			background-color: #8883F0;
		}
		.bot_box{
			position: relative;
		
			padding: 40rpx 50rpx ;
			margin-top: -50rpx;
			width: 750rpx;
			background: #F7FAFE;
			border-radius: 50rpx 50rpx 0 0;
			.userinfo{
				display: flex;
				justify-content: center;
				position: absolute;
				top: -100rpx;
				width: 650rpx;
				height: 184rpx;
				background: #FFFFFF;
				box-shadow: 0rpx 16rpx 40rpx 0rpx rgba(53,140,255,0.1);
				border-radius: 32rpx 32rpx 32rpx 32rpx;
				.userimg_box{
					display: flex;
					align-items: center;
					justify-content: center;
					position: absolute;
					top: -36rpx;
					width: 140rpx;
					height: 140rpx;
					background: #FFFFFF;
					border-radius: 50%;
					image{
						width: 120rpx;
						height: 120rpx;
						border-radius: 50%;
						
					}
				}
				.nickname{
					width: 100%;
					text-align: center;
					margin-top: 110rpx;
					
					font-weight: 400;
					font-size: 36rpx;
					color: #262B37;
				}
			}
			.botcard{
				margin-bottom: 32rpx;
				display: flex;
				align-items: center;
				padding-left: 38rpx;
				width: 650rpx;
				height: 118rpx;
				background: #FFFFFF;
				border-radius: 30rpx;
				box-shadow: 0rpx 16rpx 40rpx 0rpx rgba(42,130,228,0.1);
				image{
					width: 52rpx;
					height: 52rpx;
					margin-right: 32rpx
					;
				}
				.txt{
					font-size: 30rpx;
					font-family: Source Han Sans, Source Han Sans;
					font-weight: 400;
					color: #383838;
				}
			}
		}
			
	}
	.botcard{
		// margin-bottom: 32rpx;
		// display: flex;
		// align-items: center;
		// padding-left: 12rpx;
		line-height: 66rpx;
		text-align: center;
		width: 190rpx;
		height: 66rpx;
		background: #FFFFFF;
		border-radius: 30rpx;
		box-shadow: 0rpx 16rpx 40rpx 0rpx rgba(42,130,228,0.1);
		image{
			width: 52rpx;
			height: 52rpx;
			margin-right: 32rpx;
		}
		.txt{
			font-size: 30rpx;
			font-family: Source Han Sans, Source Han Sans;
			font-weight: 400;
			color: #383838;
		}
	}
	.fdpage{
		.top_box{
			padding-top: 40rpx;
			width: 750rpx;
			height: 360rpx;
			background-color: #8883F0;
			.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: 32rpx;
						font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
						font-weight: 400;
						color: #FFFFFF;
					}
					.num{
						margin-top: 20rpx;
						font-size: 30rpx;
						font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
						font-weight: 400;
						color: #ABA8F4;
					}
				}
			}
			.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;
				.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{
			padding: 40rpx 50rpx ;
			margin-top: -50rpx;
			width: 750rpx;
			background: #F7FAFE;
			border-radius: 50rpx 50rpx 0 0;
			.botcard{
				margin-bottom: 32rpx;
				display: flex;
				align-items: center;
				padding-left: 38rpx;
				width: 650rpx;
				height: 100rpx;
				background: #FFFFFF;
				border-radius: 30rpx;
				box-shadow: 0rpx 16rpx 40rpx 0rpx rgba(42,130,228,0.1);
				image{
					width: 46rpx;
					height: 46rpx;
					margin-right: 32rpx
					;
				}
				.txt{
					font-size: 30rpx;
					font-family: Source Han Sans, Source Han Sans;
					font-weight: 400;
					color: #383838;
				}
			}
		}
	}
}

</style>
