<template>
	<view>
		<view class="box">
			<view class="top">
				<text class="title">用户管理</text>
				<text class="add" @click="addUser">+添加
				</text>
			</view>
		</view>
		<view>
			<u-cell-group>
				<u-cell :isLink="true" arrow-direction="right" @click="toUserFn(item)"
				:value="item.roleName"
				 v-for="(item,index) in userList">
					<u-icon name="account" slot="icon" size="30"></u-icon>
					<text slot="title" style="font-size: 40rpx;">{{item.name}}</text>
				</u-cell>
			</u-cell-group>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				customerId: '',
				userList:[]
			}
		},
		onShow() {
			let info = uni.getStorageSync('userInfo');
			this.customerId = info.customerId;
			this.getUserList();
		},
		onBackPress() {
			this.$common.to('/');
			return true;
		},
		methods: {
			getUserList() {
				this.$api.getUserList({customerId:this.customerId}).then(resp=>{
					this.userList=resp.data;
				})
			},
			toUserFn(data){
				this.$common.to('/pages/user/addUser?id='+data.id+'&name='+data.name+'&roleId='+data.roleId+'&status='+data.status)
			},
			addUser() {
				this.$common.to('/pages/user/addUser')
			}
		}
	}
</script>
<style lang="scss">
	.add {
		position: absolute;
		right: 40rpx;
		top: -60rpx;
		z-index: 999;
		font-size: 40rpx;
		color: white;
	}

	@import '@/common/common.scss'
</style>
