<template>
	<view :style="{ minHeight: sys.windowHeight + 'px' }"
		:class="[$tm.vx.state().tmVuetify.black ? 'black' : ' ']">
		<tm-menubars title="用户新增/切换" :shadow="0" :showback="true"></tm-menubars>
		<div class="zhuti">
			<!-- <tm-sheet class="kuang">
				<view class="mt-2 flex-between flex-center dingwei pt-20 pb-20">
					<view class="touxiang">
						<image class="ml-20" style="vertical-align: middle;" src="/static/img/53.png" mode="widthFix"></image>
						<text style="vertical-align: middle;" class="text-size-g text-white">Hahhhnxsm_</text>
					</view>
					<view >
						<text class="text-size-g you" style="vertical-align: middle;">（当前用户）</text>
						<tm-checkbox class="you" v-model="checked1" label=""></tm-checkbox>
					</view>
				</view>
			</tm-sheet> -->
			<tm-sheet class="kuang" v-for="(item,index) in userList">
				<view class="mt-2 flex-between flex-center dingwei pt-20 pb-20">
					<view class="touxiang">
						<image v-if="index==0" class="ml-20" style="vertical-align: middle;" src="/static/img/53.png" mode="widthFix"></image>
						<image v-else class="ml-20" style="vertical-align: middle;" src="/static/img/61.png" mode="widthFix"></image>
						<text style="vertical-align: middle;" class="text-size-g text-white">{{item.username}}</text>
					</view>
					<view @click="qiehuanFun(item,index)">
						<!-- <text class="text-size-g you" style="vertical-align: middle;">（家庭成员）</text> -->
						<tm-checkbox class="you" v-model="item.checked" label=""></tm-checkbox>
					</view>
				</view>
			</tm-sheet>
			<tm-sheet class="kuang">
				<view class="mt-2 flex-between flex-center dingwei pt-20 pb-20">
					<view class="touxiang">
						<image class="ml-20" style="vertical-align: middle;" src="/static/img/54.png" mode="widthFix"></image>
						<text style="vertical-align: middle;" class="text-size-g text-white">新增家庭成员</text>
					</view>
				</view>
			</tm-sheet>
		</div>
		
	</view>
</template>	
<script>
import{myRequest} from '@/api/request.js'
export default {
	data() {
		return {
			indexsoyin:0,
			userList:[]
		};
	},
	onLoad() {
		
	},
	created() {
		this.sys = uni.getSystemInfoSync();
		if(uni.getStorageSync("itemuser")){
			
			console.log(uni.getStorageSync("itemuser"))
		}
		this.getDate()
	},
	methods: {
		qiehuanFun(item){
			var that=this;
			myRequest({
				url: "/api/MemberInfo/switchRole",
				method:'post',
				data:{family_id:uni.getStorageSync("family_id"),id:item.id}
			}).then(res => {
				if (res.data.code == 200) {
					uni.navigateTo({
						url: "/pages/index/index?index=1",
					})
				}else{
					
				}
			})
		},
		getDate(){
			var that=this;
			myRequest({
				url: "/api/MemberInfo/getFamilyMember",
				method:'post',
				data:{family_id:uni.getStorageSync("family_id")}
			}).then(res => {
				if (res.data.code == 200) {
					var data=res.data.data,panduan=0;
					for(let i=0;i<data.length;i++){
						if(data[i].checked!=0){
							panduan=1
						}
						data[i].checked=data[i].checked==0?false:true;
					}
					if(panduan==0){
						data[0].checked=true;
					}
					that.userList=res.data.data;
					console.log(that.userList)
				}else{
					that.userList=[];
				}
			})
		}
	},
}
</script>

<style lang="scss">
	/deep/ .tm-menubars .body{
		background-color: #1b1b1b !important;
	}
	.dingwei{width: 100%;margin: 0 auto;margin-top: 10px;}
	.dingwei image{width: 55px;margin-right: 10px;	}
	/deep/ .border-primary-a-1{border-color: #303440;background: #303440;}
	/deep/ .shuru .grey-darken-5{
		background-color: #0d0d0d!important;
		padding: 0px !important;
	}
	.you{text-align: right;}
</style>
