<template>
	<view>

		<view class="username">
			<view class="namecont">绑定门店</view>
			<view class="font14 fcor333 text2 width75 fotrt">{{storeName}}</view>
		</view>

		<view class="username">
			<view class="namecont">绑定编号</view>
			<view class="font14 fcor333 text2 width75 fotrt">{{scanNo}}</view>
		</view>

		<view class="btn" @tap="bindStore">提交绑定</view>
	</view>
</template>

<script>
	import {
		bindStore
	} from '../../../Utils/Api.js';
	export default {
		data() {
			return {
				scanNo: '', //扫码编号,
				storeName: '', //门店名称
				storeId: '' //订单编号
			}
		},
		onLoad(options) {
			this.scanNo = options.scanno;
			this.storeName = options.storename;
			this.storeId = options.storeId;
		},
		methods: {
			//分配设备
			bindStore() {
				uni.showModal({
					title: '温馨提示',
					content: '是否分配当前设备',
					success: (res) => {
						if (res.confirm) {
							uni.showLoading({
								title: '加载中'
							})
							let datas = {
								"serialNumber": this.scanNo,
								"storeId": this.storeId
							}
							bindStore(datas).then(res => {
								uni.hideLoading();
								if (res.return_code == '000000') {
									uni.showToast({
										title: '分配成功',
										duration: 2000,
										icon: 'none'
									})
									uni.navigateBack({})
								} else {
									uni.showToast({
										title: res.return_msg,
										duration: 2000,
										icon: 'none'
									})
								}
							})
						} else if (res.cancel) {}
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	.username {
		width: calc(100% - 90upx);
		height: 100upx;
		display: flex;
		align-items: center;
		background-color: rgba($color: #ffffff, $alpha: 0.1);
		border-bottom: 1px solid #f6f6f6;
		padding: 8upx 45upx;

		.namecont {
			color: #666666;
			width: 28%;
		}
	}

	.btn {
		color: #FFFFFF;
		background-color: #0083f5;
		width: 90%;
		margin-left: 5%;
		margin-top: 80rpx;
		margin-bottom: 50rpx;
		height: 90rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		border-radius: 10rpx;
		font-size: 40rpx;
	}
</style>