<template>
	<view class="content">
		<view class="container">
			<view class="haers">
				<view style="width: 20%; text-align: left;" @click="goback()">
					<u-icon name="arrow-left" color="#fff" size="18"></u-icon>
				</view>
				<view style="width: 60%; text-align: center; font-size: 18px;  ">
					(员工)设备列表
				</view>
				<view style="width: 20%;text-align: right;" @click="goallocation()">
					分配
				</view>
			</view>
			<view class="qs-y" v-if="dataList.length == 0">
				暂无数据
			</view>
      <view class="list_">
        <view class="list-box" v-for="item in dataList" @click="goDevice(item.sn)">
          <view class="">
            <view class="t-one">设备SN:{{item.sn}}</view>
            <view class="t-two">商户名称:{{item.merchantName||""}}</view>
            <view class="t-three">状态: <text style="color: #E4612E;margin-left: 10px;">绑定</text> </view>
            <view class="t-three">备注：{{item.remarks}}</view>
          </view>
          <u-icon name="arrow-right" size="18"></u-icon>
        </view>
      </view>

			<u-loadmore :status="status" v-if="show == true" />
		</view>

	</view>
</template>

<script>
	import headers from '../../components/header/headers.vue'
	import request from '../../utils/request.js'
	export default {
		data() {
			return {
				dataList: [],
				page: 1,
				limit: 10,
				totalPage: 0,
				staffId: null

			}
		},
		onLoad(option) {
			this.staffId = option.staffId
		},
		onShow() {
			this.dataList = []
			this.page = 1
			this.getDataList()
		},
		onPullDownRefresh() {
			this.page = 1,
				this.limit = 10,
				this.totalPage = 0,
				this.dataList = [],
				this.getDataList();

			uni.stopPullDownRefresh()
		},
		onReachBottom() {
			// 触底加载
			if (this.page < this.totalPage) {
				this.page++
				this.getDataList()

			} else {
				uni.showToast({
					title: '没有下一页数据',
					icon: 'none'
				})
			}
		},
		components: {
			headers

		},
		methods: {
			getDataList() {
				uni.showLoading({
					title: '加载中'
				});
				request({
					url: 'app/uaMer/staffTerminal/' + this.staffId,
					method: 'post',
					data: {
						limit: this.limit,
						page: this.page
					},
				}).then(res => {
					if (res.data) {
						if (this.page != 1) {
							this.dataList = this.dataList.concat(res.data)
						} else {
							this.dataList = res.data
						}
						this.totalPage = res.pages

					}

				}).finally(rrr => {
					uni.hideLoading()
				})
			},
			goDevice(snNo) {
				uni.navigateTo({
					url: '/homePages/Manage/DeviceDetails?sn=' + snNo + "&type=1" + "&staffId=" + this.staffId
				})
			},

			goallocation() {
				uni.navigateTo({
					url: '/homePages/StaffManagement/allocation?staffId=' + this.staffId
				})
			},
			goback() {
				uni.navigateBack()
			}
		}
	}
</script>

<style scoped lang="scss">
	input {
		&::-webkit-input-placeholder,
		/* WebKit browsers*/
		&:-moz-input-placeholder,
		/* Mozilla Firefox 4 to 18*/
		&::-moz-input-placeholder,
		/* Mozilla Firefox 19+*/
		&:-ms-input-placeholder

		/* Internet Explorer 10+*/
			{
			color: #fff !important;
		}
	}

	.content {
		background: #f4f4f4;
		height: 100vh;
	}

	.container {
		width: 100%;
		background: #f4f4f4;
		box-sizing: border-box;
		padding-top: 98px;
	}

	.haers {
		width: 100%;
		background: #E4612E;
		height: 88px;
		box-sizing: border-box;
		padding: 0px 15px;
		padding-top: 40px;
		color: white;
		z-index: 99999;
		background: #E4612E;
		position: fixed;
		top: 0px;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.input-box {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		width: 65%;
		height: 25px;
		border-radius: 50px;
		border: 1px solid #fff;
		color: white;

		input {
			width: 80%;
		}


	}

	.box_ {
		width: 95%;
		margin: 0 auto;
		margin-bottom: 15px;
		background: #fff;
		// border-bottom: 1px solid #efefef;

	}

	.list-box {
		width: 100%;
		box-sizing: border-box;
		padding: 10px 20px;
		background: #fff;
		display: flex;
		align-items: center;
		justify-content: space-between;
    margin-bottom: 20rpx;
    border-radius: 20rpx;
	}

	.t-one {
		font-size: 14px;
		margin-bottom: 10px;
	}

	.t-two {
		margin-bottom: 10px;
	}

	.t-three {
		font-size: 12px;
	}

	.title_ {
		font-size: 18px;
		margin: 10px 0px;
	}

	.box-top {
		width: 100%;
		border-bottom: 1px solid #efefef;
		box-sizing: border-box;
		padding: 10px;
	}

	.box-bottom {
		width: 100%;
		box-sizing: border-box;
		padding: 10px;
		border-bottom: 1px solid #efefef;
	}

	.box-bs {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		font-size: 14px;
		color: #979797;
		margin: 2px 0px;
	}

	.bottom-bs {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		font-size: 14px;
		color: #000000;
		margin-bottom: 5px;
	}

	.box-end {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: flex-end;
	}

	.aaniu {
		width: 120px;
		height: 35px;
		border-radius: 50px;
		background: #E4612E;
		color: white;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.box_ {
		width: 100%;
		background: #fff;
		box-sizing: border-box;
		padding: 15px;
		display: flex;
		align-items: center;
		justify-content: space-between;

	}

	.qs-y {
		width: 100%;
		height: 80vh;
		display: flex;
		align-items: center;
		justify-content: center;
	}
  .list_{
    padding: 20rpx;
  }
</style>
