<template>
	<view class="u-p-30">
		<view>
			<up-button type="warning" @click="popupShow">初始化</up-button>
		</view>
		<view class="u-m-t-30">
			<up-button type="primary" @click="toCreate">去下单</up-button>
		</view>
		
		<up-popup :show="show" mode="bottom" close-on-click-overlay @close="resetForm">
			<view class="u-p-30">
				<up-form label-width="80" ref="refForm">
					<up-form-item label="台桌码">
							<up-input v-model="form.tableCode" placeholder="请输入台桌码"></up-input>
					</up-form-item>
				</up-form>
				<view class="u-flex gap-20 u-m-t-30">
					<up-button @click="show=false">取消</up-button>
					<up-button type="primary" @click="scanCodehandle">确定</up-button>
				</view>
			</view>
			
		</up-popup>
	</view>
</template>

<script setup>
	import {onLoad} from '@dcloudio/uni-app'
	import { reactive,ref} from 'vue'
	import {
		productStore
	} from '@/stores/user.js';
	const store = productStore();
	const scanCodehandle = async (i) => {
		await store.scanCodeactions(form)
	}
	const show=ref(false);
	const options=ref({})
	function popupShow(){
		show.value=true;
	}
	const refForm=ref(null);
	const form=reactive({
		tableCode:"40963902920"
	})
	function resetForm(){
		form.tableCode=""
	}
	onLoad((opt)=>{
		console.log(opt);
		options.value=opt
	})
	function toCreate(){
		uni.navigateTo({
			url:'/pages/index/index'
		})
	}
</script>

<style lang="scss" scoped>
	.gap-20{
		gap: 20rpx;
	}

</style>
