<template>
	<view class="home">
		<view class="list-area" v-for="item in dataList" :key="item.id" @click="toDetail(item.id,item.assetBarCode,item.isreturn)">
			<u-cell :isLink="true">
				<view slot="title" class="u-slot-title">
					<i class="iconfont icon-shijian"></i>
					<text>{{item.isreturn=="0"?"借用时间："+item.borrowDate:"归还时间："+item.actualReturnDate}}</text>
				</view>
				<view slot="label" class="u-slot-label">
					<text class="list-name">设备：{{item.assetBarCode}}</text>
					<text class="list-status">{{isReturn(item.isreturn)}}</text>
				</view>
			</u-cell>
		</view>
	</view>
</template>

<script>
	import { getBorrowList } from '@/api/asset.js'
	export default {
		data() {
			return {
				dataList:[]
			};
		},
		methods:{
			scroll(){
				console.log(111)
			},
			init(){
				getBorrowList({
					pageNum:1,
					pageSize:10
				}).then(res=>{
					console.log(res)
					this.dataList = res.data.rows
				})
			},
			isReturn(val){
				if(val=="0"){
					return "未归还"
				}else if(val=="1"){
					return "已归还"
				}
			},
			toDetail(id,bar,isreturn){
				// 0 未还 1 已还
				if(isreturn=="0"){
					uni.navigateTo({
						url:'/pages/borrow/borrow?number='+bar,
					})
				}else{
					uni.navigateTo({
						url:'/pages/return/return?id='+id
					})
				}
			}
		},
		onLoad() {
			this.init()
		}
	}
</script>

<style lang="scss">
page{
	background-color: #eae9e9;
}
.home{
	width: 100%;
	height: 100%;
	padding:20rpx 30rpx;
	background-color: #eae9e9;
	box-sizing: border-box;
	.ul-area{
		padding: 20rpx 30rpx 0;
		box-sizing: border-box;
	}
}
.list-area{
	background-color: $uni-bg-color;
	margin: 0 0 20rpx 0;
	line-height: 150%;
	.u-slot-title{
		display: flex;
		align-items: center;
		.iconfont{
			margin-right: 20rpx;
			font-size: 38rpx;
			font-weight: bold;
		}
	}
	.u-slot-label{
		position: relative;
		.list-status{
			position: absolute;
			right: 140rpx;
		}
	}
}

</style>
