<template>
	<view class="">
		<uni-collapse :accordion="true">
			<uni-list>
				<view  v-for="user in userList" :key="user.id">
					<uni-list-item :title="getMerchantTitle(user)" @click="doing(user)"/>
				</view>
			</uni-list>
		</uni-collapse>	
	</view>
</template>

<script>
	import {mapState,mapActions,mapMutations} from 'vuex'
	import uniCollapse from '@/components/uni-collapse/uni-collapse.vue'
	import uniCollapseItem from '@/components/uni-collapse-item/uni-collapse-item.vue'
	import uniList from '@/components/uni-list/uni-list.vue'
	import uniListItem from '@/components/uni-list-item/uni-list-item.vue'
	export default {
		components: {
			uniCollapse,
			uniCollapseItem,
			uniList,
			uniListItem
		},
		data() {
			return {
				userList:[],
				globalUser:{},
				merchantList:[{equipmentList:[]}],
			}
		},
		onPullDownRefresh() {
				setTimeout(function() {
					uni.stopPullDownRefresh();
				}, 800);
			},
			onShow() {
				var token = uni.getStorageSync("token");
				if (token.length>1) {
					var name = uni.getStorageSync("name");
					this.name = name;
					var listName = uni.getStorageSync("listName");
					this.listName = listName;
					var level = uni.getStorageSync("level");
					this.level = level;
					this.getList();
				} else {
					uni.reLaunch({
						url: '../Login/Login',
					});
				}
			},
			onLoad() {
			},
			methods: {
				getList(){
					var user  = uni.getStorageSync("globalUser");
					this.$store.dispatch('list',user)
						.then(_ => {
							this.userList =_.data;
						});
				},
				doing(user){
					uni.setStorageSync("flagUser",user);
					uni.navigateTo({
						url: './userInfo'
					});
				},
				getMerchantTitle(user){
					return user.name?user.name:user.username;
				},
				updataPassword() {
					uni.navigateTo({
						url: 'updataPassword',
					});
				},
			}
		}
</script>

<style>
	
</style>
