<template>
	<view class="content">
		<view class="my-header">
			<view class="my-icons" @click="goback">
				<uni-icons type="arrow-left" color="#fff" size="22px"></uni-icons>
			</view>
			<view class="top_whit">
				<input type="text" @input="getTerminalList()" v-model="merchantNameOrSn" placeholder="请输入商户名称或SN查询"
					placeholder-style="text-align: center; color:#fff;font-size:12px">
			</view>
			<view class="my-icons"></view>
		</view>
		<view class="container">
			<view class="list-box" @click="goDetails(item.sn)" v-for="item in terminalList">
				<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-two" v-if="item.remarks">备注:{{item.remarks||""}}</view>
				</view>
				<u-icon name="arrow-right" size="18"></u-icon>
			</view>
		</view>
	</view>
</template>

<script>
	import request from '../../utils/request.js'
	export default {
		data() {
			return {
				show: false,
				terminalList: [],
				merId: null,
				merchantNameOrSn: null,
				addSnNo: null
			}
		},
		onLoad(option) {
			this.merId = option.merId
		},
		onShow() {
			this.getTerminalList()
		},
		onPullDownRefresh() {
			console.log("刷新");
			this.getTerminalList()
			uni.stopPullDownRefresh()
		},
		components: {

		},
		methods: {
			bindTr() {

				request({
					url: 'app/uaSalesman/bindTerminal',
					method: 'post',
					data: {
						merchantId: this.merId,
						sn: this.addSnNo
					},
				}).then(res => {
					this.getTerminalList()
					uni.showToast({
						title: "添加成功"
					})
				}).finally(rrr => {
					this.show = false
					this.addSnNo = null
				})

			},
			closeBind() {
				this.addSnNo = null
				this.show = false
			},
			getTerminalList() {
				request({
					url: 'app/uaMer/terminalList',
					method: 'post',
					data: {
						merchantId: this.merId,
						limit: 10000,
						page: 1,
						merchantNameOrSn: this.merchantNameOrSn
					},
				}).then(res => {
					this.terminalList = res.data
				})
			},
			close() {
				this.show = false
			},
			open() {

			},
			goDetails(sn) {
				uni.navigateTo({
					url: '/homePages/Manage/DeviceDetails?sn=' + sn
				})
			},
			goback() {
				uni.navigateBack()
			}
		}
	}
</script>

<style scoped lang="scss">
	.content {
		background: #f4f5f6;
		height: 100vh;
	}

	.container {
		width: 100%;
		background: #f4f5f6;
		box-sizing: border-box;
		padding: 190rpx 30rpx 30rpx 30rpx;
	}

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

		.top_whit {
			width: 55%;
			border-radius: 50px;
			border: 1px solid #fff;
			box-sizing: border-box;
			padding: 5px;
		}

		.my-icons {

			height: 20px;
			width: 15%;

		}

		.my-text {
			width: 25%;
			font-weight: bold;
		}

	}

	.c-text {
		font-size: 14px;
		color: #fff;
	}

	.popup-bs {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;

	}

	.bottom-left {
		width: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
		height: 30px;

	}

	.bottom-right {
		width: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
		height: 30px;
		color: #E4612E;
	}

	.p-input-box {
		width: 100%;
		border: 1px solid #e7e7e8;
		border-radius: 4px;
		box-sizing: border-box;
		padding: 10px 15px;
		margin-bottom: 20px;
	}

	.box-pop {
		width: 300px;
		background: #fff;
		box-sizing: border-box;
		padding: 15px;
	}

	.pop-title {
		width: 100%;
		text-align: center;
		margin-bottom: 15px;
	}

	.list-box {
		width: 100%;
		box-sizing: border-box;
		padding: 15rpx;
		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;
	}
</style>
