<template>
	<view class="contianer">
		<view class="">

		</view>
		<view class="list" v-if="false">
			<view @click="clickItem(item,index)" v-for="(item,index) in list" :key="index" class="list-item">
				<view class="list-item-img">
					<!-- 	<image v-if="item." style="width:72rpx;height: 72rpx;margin-right: 20rpx;" src="@/static/image/male.png" mode=""></image> -->
					<image style="width:72rpx;height: 72rpx;margin-right: 20rpx;" src="@/static/image/female.png"
						mode=""></image>
					<view class="list-item-name">
						我是 {{item.school.school_name}} {{item.role.title}}
					</view>
				</view>
				<view class="list-item-active">
					<uni-icons v-if="active == item.id" style="color:rgba(5,204,161, 1) ;" type="checkmarkempty"
						size="24"></uni-icons>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				active: 0,
				list: []
			}
		},
		methods: {
			clickItem(item, index) {
				this.$api.sendRequest({
					url: '/mobile/selectRole',
					data: {
						role_id: item.role_id,
						school_id: item.school.id,
					},
					success: res => {
						console.log(res);
						this.active = item.id
						this.$store.commit('setInfo', item)
						this.$store.commit('setRoleInfo', res.data)
						
						let url = item.role.title == '维修人员' ?
							'/pages/fixedAssetsProcessed/fixedAssetsProcessed' :
							'/pages/homePage/homePage'
						uni.navigateTo({
							url: url
						})
					},
				})
			},
			getUserList() {
				this.$api.sendRequest({
					url: '/mobile/getRole',
					success: res => {
						this.list = res.data
						let info = res.data[0]
						this.$store.commit('setInfo', info)
						this.active = info.id
					}
				})
			}
		},
		mounted() {
			this.getUserList()
		}

	}
</script>

<style lang="scss" scoped>
	.contianer {
		padding: 48rpx;

		.list {
			width: 100%;

		}

		.list-item {
			height: 94rpx;
			width: 100%;
			border-radius: 10rpx;
			background-color: #fff;
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-bottom: 32rpx;
			box-shadow: -0.67px 0px 5px 0.67px rgba(46, 46, 46, 0.28);

			.list-item-img {
				margin-left: 32rpx;
				border-radius: 50%;
				display: flex;
				align-items: center;

			}

			.list-item-active {
				margin-right: 32rpx;

			}

		}
	}
</style>