<template>
	<view>
		<view class="input-box">
			<view class="icon search"></view>
			<input placeholder="输入二维码序列号" v-model="scanNo" placeholder-style="color:#c0c0c0;" @input="toSearch()" />
		</view>

		<view v-if="serviceList == ''" class="mart60 fotct font14 fcor666">
			<image mode="widthFix" style="width: 70vw;" src="../../../static/img/noorder.png"></image>
		</view>
		<view class="width94 backcorfff mart20" v-for="(item,index) in serviceList" :key="index" @click="lookimgage(item.qrCodeUrl)">
			<view class="font20 font306adb paddtop10 fontwig6 padleft15">{{item.serialNumber}}</view>
			<view class="mart10 fcor666  padleft15 font14 paddbotm10">绑定时间:
				{{item.storeBindTime | timeFormat('yyyy-mm-dd')}}
				{{item.storeBindTime | timeFormat('hh:mm')}}
			</view>
		</view>
		
		<wybPopup ref="popup" type="center" height="650" width="600" bgColor="" radius="6" :showCloseIcon="false">
			<image class="popImg" :src="images"></image>
		</wybPopup>
	</view>
</template>

<script>
	import {
		getStoreQrCodeList
	} from '../../../Utils/Api.js';
	import wybPopup from '../../../components/wyb-popup/wyb-popup.vue'
	let app = getApp();
	export default {
		components: {
			wybPopup
		},
		data() {
			return {
				serviceList: [],
				pageNum: 1,
				pageSize: 15,
				isLoadMore: false, //是否加载中
				userInfo: app.globalData.userInfo, //用户信息
				scanNo: '' ,// 二维码编号
				images:'' //二维码图片
			}
		},
		onReachBottom() { //上拉触底函数
			// if (!this.isLoadMore) { //此处判断，上锁，防止重复请求
			// 	this.isLoadMore = true
			// 	this.pageNum += 1
			// 	this.getStoreQrCodeList();
			// }
			this.getStoreQrCodeList();
		},
		onLoad(options) {
			this.getStoreQrCodeList();
		},
		methods: {
			toSearch() {
				this.pageNum = 1;
				this.isLoadMore = false;
				this.serviceList = [];
				this.getStoreQrCodeList();
			},
			//门店查询设备列表
			getStoreQrCodeList() {
				uni.showLoading({
					title: '加载中...'
				})
				let params = {
					pageNum: this.pageNum,
					pageSize: this.pageSize,
					serialNumber: this.scanNo,
					storeId: this.userInfo.store.id
				}
				getStoreQrCodeList(params).then(res => {
					uni.hideLoading();
					if (res.return_code == '000000' && res.return_data.list) {
						this.serviceList = this.serviceList.concat(res.return_data.list);
						if (res.return_data.pages == this.pageNum) {
							this.isLoadMore = true;
						} else {
							this.isLoadMore = false
						}
						this.pageNum = this.pageNum+1;
					} else {
						uni.showToast({
							title: res.return_msg,
							icon: 'none',
							duration: 2000
						})
					}
				});
			},
			lookimgage(item){
				this.images = item;
				this.$refs.popup.show();
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f8f9f9;
	}

	.input-box {
		width: 90%;
		margin-left: 5%;
		margin-top: 15px;
		height: 70rpx;
		background-color: #f5f5f5;
		border-radius: 10rpx;
		position: relative;
		display: flex;
		align-items: center;

		.icon {
			display: flex;
			align-items: center;
			position: absolute;
			top: 2px;
			left: 5px;
			width: 60upx;
			height: 60upx;
			font-size: 34upx;
			color: #c0c0c0;
		}

		input {
			padding-left: 50upx;
			height: 28upx;
			font-size: 28upx;
			width: 100%;
		}
	}

	.font306adb {
		color: #306adb;
	}

	.xfimg {
		width: 100rpx;
		bottom: 60rpx;
		position: fixed;
		right: 40rpx;
	}

	.btns {
		width: 25%;
		margin-left: 68%;
		height: 35px;
		line-height: 35px;
		background-color: #0083f5;
		color: #FFFFFF;
		font-weight: bold;
		font-size: 14px;
		padding: 0px;
	}
	.popImg {
		width: 300px;
		height: 300px;
	}
</style>
