SmartStorage/pages/IOTBinding/IOTBinding.vue

109 lines
2.3 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="page">
<uni-forms ref="IOTForm" :modelValue="IOTFormData" :rules="IOTRules">
<uni-forms-item name="IOTCode" label="IOT编码">
<uni-easyinput v-model="IOTFormData.IOTCode"></uni-easyinput>
<h4 @click="scanIOT">扫一扫</h4>
</uni-forms-item>
<uni-forms-item name="deviceCode" label="机具编码">
<uni-easyinput v-model="IOTFormData.deviceCode"></uni-easyinput>
<h4 @click="scanDevice">扫一扫</h4>
</uni-forms-item>
<button class="submit-btn" @click="confirmBinding">确认绑定</button>
</uni-forms>
</view>
</template>
<script>
export default {
data() {
return {
IOTFormData: {
IOTCode: '',
deviceCode: ''
},
IOTRules: {
IOTCode: {
rules: [
{
required: true,
errorMessage: '请输入IOT设备编码'
}
]
},
deviceCode: {
rules: [
{
required: true,
errorMessage: '请输入机具装备编码!'
}
]
}
},
}
},
methods: {
scanIOT() {
uni.scanCode({
success: (res) => {
console.log(res.result, 'iot')
this.IOTFormData.IOTCode = res.result
}
})
},
scanDevice() {
uni.scanCode({
success: (res) => {
console.log(res.result, 'device')
this.IOTFormData.deviceCode = res.result
}
})
},
confirmBinding() {
this.$refs.IOTForm.validate().then(formData => {
console.log(formData)
})
}
}
}
</script>
<style lang="scss">
.page{
width: 100vw;
height: 100vh;
box-sizing: border-box;
padding: 10vw 5vw;
.uni-forms-item__content[data-v-61dfc0d0] {
display: flex;
align-items: center;
}
h4{
font-size: 14px;
font-weight: normal;
margin-left: 2vw;
color: #007CCA;
}
.submit-btn{
width: 60%;
box-sizing: border-box;
//padding: 5rpx 0;
display: flex;
justify-content: center;
align-items: center;
background-color: #169BD5;
color: #fff;
margin: 10vh auto;
}
}
</style>