<template>
	<!-- 维护人员 -->
	<view class="member">
		<view class="main" v-for="(item, index) in assetList" :key="index" >
				<!-- <view class="u-img">
					<img :src="item.photo" ></img>
				</view> -->
				<u--image :src="item.photo" radius="5" :lazy-load="true" width="80" height="80" @click="imgPreview(item.photo)"></u--image>
				<view class="content"  @click="toDetail(item)">
					<view class="c-name">
						<u-text :text="'名称：'+item.name"></u-text>  
					</view>
					<view class="c-addtime">
						<u-text :text="'编号：'+item.assetNumber"></u-text>  
					</view>
					<view class="c-addtime">
						<u-text :text="'部门：'+item.deptName"></u-text>  
					</view>
					<view class="c-status">
						<u-text :text="'人员：'+item.nickName"></u-text>  
					</view>
				</view>
				<u-icon name="arrow-right" @click="toCheck(item)"></u-icon>
				<!-- <u-icon name="phone" size="30" @click="freeTell(item.phonenumber)"></u-icon> -->
			</view>
		<!-- 	<view class="btn" v-if="userinfo.roleId == 1">
				<u-button type="primary" class="submit" @click="add" text="新 增"></u-button>
			</view> -->
		<u-divider text="没有更多数据了"></u-divider>
	</view>

</template>

<script>
	
	import avatar from '@/static/work.png'
	export default {
		data() {
			return {
				// 搜索内容
				search: '',
				type: true,
				color: 'hsl(200, 88%, 55%)',
				
				assetList: [],
				keyword:'',
				userinfo: null
			}
		},
		
		onShow: function(options) {
			this.getList()
			this.userinfo = uni.getStorageSync('userinfo');
		},
		
		onPullDownRefresh(){
			this.getList();
			// this.stopPullDownRefresh()
		},
		methods: {
			async getList() {
				const { data:res } = await this.$http('/queryAssetList',{'keyword':this.keyword})
				if(res.code) return
				this.assetList = res.data
				for (var i = 0; i < this.assetList.length; i++) {
					if(this.assetList[i].photo){
						this.assetList[i].photo = this.API_URL + this.assetList[i].photo;
					}else{
						this.assetList[i].photo=avatar
					}
				}
			},
			imgPreview(url){
				uni.previewImage({
					indicator:"number",
					loop:true,
					urls: [url]
				})
			},
			toDetail(item) {
				wx.navigateTo({
						url:'asset_detail?data='+JSON.stringify(item),    
				    })
			}
			
		}
	}
</script>

<style lang="scss">
	.member {
		background: #f6f6f6;
		// padding: 2.667vw 0;
		height: 100vh;
		
		.btn{
			padding: 2.667vw;
			.u-button{
				margin-bottom: 1vh;
			}
			.u-form{
				margin-bottom: 1vh;
			}
		}
		.head {
			background: #fff;
			padding: 2.667vw;
			
			display: flex;
			justify-content: space-evenly;
			align-items: center;
			input {
				padding: 1vw;
				border-radius: 1vw;
			}
		}
		// 展示信息
		.main {
			background: #ffffff;
			margin: 2.667vw 0;
			display: flex;
			justify-content: space-around;
			padding: 2vh 0;
			.u-image{
				float: left;
			}
			.content{
				flex-direction: column;
				align-items: flex-start;
				justify-content: space-around;
				display: flex;
				width: 55vw;
				.c-status{
					display: flex;
				}
			}
			
			.u-img{
				height: 80px;
				width: 80px;
				position: relative;
				img{
					border-radius: 5px;
					height: 60px;
					width: 60px;
					position: absolute;
					top: 0;
					bottom: 0;
					left: 0;
					right: 0;
					margin: auto;
				}
			}
		}
	}
</style>
