<template>
	<view class="page">
		<u-navbar title="设置" :border-bottom="false" :background="bgc" back-icon-color="#fff" title-color='#fff' title-size='36'
			height='50'></u-navbar>
		<view class="card">
			<view class="li">
				<view class="tit">
					绑定手机号
				</view>
				<view class="info">
					<view class="txt">
						{{userinfo.phonenumber}}
					</view>
					<!-- <view class="iconfont icon-xiangyou1"></view> -->
				</view>
			</view>
	
			<view class="li" style="border-bottom: #fff solid 2rpx;" v-if='false'>
				<view class="tit">
					修改密码
				</view>
				<view class="info">
					<!-- <view class="txt">
						ESP2001
					</view> -->
					<view class="iconfont icon-xiangyou1"></view>
				</view>
			</view>
		</view>
		<view class="card" style="margin-top: 26rpx;">
			<view class="li" @click="btnwz(1)">
				<view class="tit">
					用户协议
				</view>
				<view class="info">
					
					<view class="iconfont icon-xiangyou1"></view>
				</view>
			</view>
			<view class="li" @click="btnwz(2)">
				<view class="tit">
					隐私政策
				</view>
				<view class="info">
					
					<view class="iconfont icon-xiangyou1"></view>
				</view>
			</view>
			
			<view class="li" style="border-bottom: #ccc solid 2rpx;" @click="btnwz(3)">
				<view class="tit">
					个人信息收集清单
				</view>
				<view class="info">
					
					<view class="iconfont icon-xiangyou1"></view>
				</view>
			</view>
			
			<view class="li" style="border-bottom: #fff solid 2rpx;" @click="btnwz(4)">
				<view class="tit">
					秘钥管理
				</view>
				<view class="info">
					
					<view class="iconfont icon-xiangyou1"></view>
				</view>
			</view>
			
			
		</view>
		<view class="card" style="margin-top: 26rpx;" v-if='false'>
			<view class="li">
				<view class="tit">
					常见问题
				</view>
				<view class="info">
					
					<view class="iconfont icon-xiangyou1"></view>
				</view>
			</view>
			
			<view class="li" style="border-bottom: #fff solid 2rpx;">
				<view class="tit">
					意见反馈
				</view>
				<view class="info">
					
					<view class="iconfont icon-xiangyou1"></view>
				</view>
			</view>
			
		</view>
		<u-mask :show="showloading"></u-mask>
		<view class="fz" v-show="showfz">
			<view class="fz_top">
				<view class="iconfont icon-shanchu">

				</view>
				<view class="tit">
					设备分组
				</view>
				<view class="txt">
					管理
				</view>
			</view>
			<view class="card_cont">
				<view class="cards" v-for="item in 10" :key="item">
					<view class="txt">
						全部
					</view>
					<view class="num">
						1
					</view>
				</view>
				<view class="zhanwei" style="width: 100%;height: 100rpx;">

				</view>
			</view>
		</view>
		<view class="dd">
			<u-select v-model="show" :list="list" title='角色切换' @confirm="confirm"></u-select>
		</view>
	
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bgc: {
					backgroundColor: "#8883f0",
				},
				showloading: false,
				showfz: false,
				show: false,
				list: [{
						value: '1',
						label: '房东模式'
					},
					{
						value: '2',
						label: '用户模式'
					}
				],
				mode:'房东模式',
				userinfo:{},
				type:''
			}
		},
		onLoad() {
			this.getuserinfo()
		},
		// 分享到好友（会话）
		  onShareAppMessage: function () {  
		    return {  
		      title: '创想物联',  
		      path: '/pages/shouye/index'  
		    }  
		  },  
		  
		  // 分享到朋友圈  
		  onShareTimeline: function () {  
		    return {  
		      title: '创想物联',  
		      query: '',  
		      path: '/pages/shouye/index'  
		    }  
		  },
		methods: {
			
			
			btnwz(num){
				if(num == 1){
					this.type = 'user'
					uni.navigateTo({
						url:'/page_components/wentdetail?type=' + this.type
					})
				}else if(num == 2){
					this.type = 'privacy'
					uni.navigateTo({
						url:'/page_components/wentdetail?type=' + this.type
					})
				}else if(num == 3){
					this.type = 'collection'
					uni.navigateTo({
						url:'/page_components/wentdetail?type=' + this.type
					})
				}else if(num == 4){
					uni.navigateTo({
						url:'/page_components/miyao'
					})
				}
			},
			
			
			// 点击更换用户模式
            confirm(e){
				// console.log(e);
				this.mode = e[0].label
				this.gettype()
			},
			// 请求修改用户类型
			gettype() {
				let type = ''
				if(this.mode == '房东模式'){
					type = '01'
				}else if(this.mode == '用户模式'){
					type = '00'
				}
				this.$u.put('/app/user/changeType?userType=' + type).then((res) => {
					if (res.code == 200) {
						console.log(res)
						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') {
							this.mode='房东模式'
						} else if (this.userType == '00') {
							this.mode='用户模式'
						}
			
					}
				});
			},
		}
	}
</script>

<style lang="scss">
	/deep/ .u-title{
		padding-bottom: 22rpx;
	}
	/deep/ .u-icon__icon{
		padding-bottom: 22rpx;
	}
	page {
		background-color: #F7FAFE;
	}

	.page {
		width: 750rpx;

		.card {
			padding: 16rpx 38rpx;
			margin: 60rpx auto 0;
			width: 654rpx;
			// height: 734rpx;
			background: #FFFFFF;
			border-radius: 30rpx;
			box-shadow: 0rpx 16rpx 40rpx 0rpx rgba(42, 130, 228, 0.1);
			opacity: 1;

			.li {
				display: flex;
				flex-wrap: nowrap;
				align-items: center;
				justify-content: space-between;
				height: 94rpx;
				border-bottom: #E5E5E5 solid 2rpx;

				.tit {
					font-size: 32rpx;
					font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
					font-weight: 400;
					color: #000000;
				}

				.info {
					display: flex;
					flex-wrap: nowrap;
					align-items: center;

					.txt {
						font-size: 32rpx;
						font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
						font-weight: 400;
						color: #95989D;
					}

					.icon-xiangyou1 {
						margin-left: 6rpx;
						color: #95989D;
					}
				}
			}
		}

		

		.fz {

			position: fixed;
			bottom: 0;
			width: 750rpx;
			height: 1152rpx;
			background: #F7FAFE;
			border-radius: 30rpx 30rpx 0 0;
			z-index: 10071;

			.fz_top {
				margin: 18rpx 0 auto;
				display: flex;
				flex-wrap: nowrap;
				justify-content: space-between;

				.icon-shanchu {
					margin-left: 40rpx;
					font-size: 50rpx;
				}

				.tit {
					font-size: 36rpx;
					font-family: Source Han Sans, Source Han Sans;
					font-weight: 400;
					color: #000000;
				}

				.txt {
					margin-right: 40rpx;
					font-size: 36rpx;
					font-family: Source Han Sans, Source Han Sans;
					font-weight: 400;
					color: #2A82E4;

				}
			}

			.card_cont {
				width: 750rpx;
				display: flex;
				flex-wrap: wrap;
				align-items: baseline;
				justify-content: center;
				height: 1030rpx;
				overflow-y: auto;
				overflow-x: hidden;

				.cards {
					margin-top: 32rpx;
					display: flex;
					flex-wrap: nowrap;
					align-items: center;
					justify-content: space-between;
					padding: 0 40rpx;
					width: 682rpx;
					border-radius: 30rpx;
					height: 114rpx;
					background: #FFFFFF;
					box-shadow: 0rpx 16rpx 40rpx 0rpx rgba(42, 130, 228, 0.1);

					.txt {
						font-size: 36rpx;
						font-family: Source Han Sans, Source Han Sans;
						font-weight: 400;
						color: #000000;
					}

					.num {
						font-size: 36rpx;
						font-family: Source Han Sans, Source Han Sans;
						font-weight: 400;
						color: #000000;
					}
				}
			}
		}
	}
</style>