2023-02-01 16:59:32 +08:00
|
|
|
<template>
|
2023-02-07 17:59:54 +08:00
|
|
|
<view class='new'>
|
|
|
|
|
<template v-if="type == 1">
|
|
|
|
|
<view style="display:flex">
|
|
|
|
|
<uni-easyinput type="number" v-model="code" placeholder="请输入设备DID" />
|
|
|
|
|
|
|
|
|
|
<uni-icons type="camera" color="#007aff" size="30" class="ml20" @click="scanCode"></uni-icons>
|
2023-02-01 16:59:32 +08:00
|
|
|
</view>
|
2023-02-07 17:59:54 +08:00
|
|
|
<view class="new-btn" @click="register"> 发起注册 </view>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else>
|
|
|
|
|
<view style="display:flex;">
|
|
|
|
|
<uni-easyinput :clearable="false" type="text" v-model="address" placeholder="请输入地址" />
|
|
|
|
|
<uni-icons type="location" color="#007aff" size="30" class="ml20" @click="chooseLocation"></uni-icons>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="new-btn" @click="submit"> 提交 </view>
|
|
|
|
|
</template>
|
|
|
|
|
</view>
|
2023-02-01 16:59:32 +08:00
|
|
|
</template>
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
2023-02-07 17:59:54 +08:00
|
|
|
loading: false,
|
|
|
|
|
code: '',
|
|
|
|
|
type: 1,
|
|
|
|
|
formData: {
|
|
|
|
|
address: '',
|
|
|
|
|
},
|
2023-02-01 16:59:32 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
2023-02-07 17:59:54 +08:00
|
|
|
scanCode () {
|
|
|
|
|
uni.scanCode({
|
|
|
|
|
success: function (res) {
|
|
|
|
|
console.log('条码类型:' + res.scanType);
|
|
|
|
|
console.log('条码内容:' + res.result);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
register () {
|
|
|
|
|
this.type = 2
|
|
|
|
|
},
|
|
|
|
|
chooseLocation () {
|
|
|
|
|
uni.chooseLocation({
|
|
|
|
|
success: function (res) {
|
|
|
|
|
this.address = res.name
|
|
|
|
|
console.log('位置名称:' + res.name);
|
|
|
|
|
console.log('详细地址:' + res.address);
|
|
|
|
|
console.log('纬度:' + res.latitude);
|
|
|
|
|
console.log('经度:' + res.longitude);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
submit(){
|
|
|
|
|
this.$util.toast('提交成功')
|
|
|
|
|
uni.navigateBack({ delta: 1 })
|
|
|
|
|
},
|
2023-02-01 16:59:32 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
<style lang='scss'>
|
2023-02-07 17:59:54 +08:00
|
|
|
.new {
|
|
|
|
|
padding: 100rpx 100rpx 0;
|
|
|
|
|
|
|
|
|
|
.new-btn {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
margin: 80rpx auto 0;
|
|
|
|
|
width: 320rpx;
|
|
|
|
|
background: $uni-theme-blue;
|
|
|
|
|
color: #fff;
|
|
|
|
|
height: 80rpx;
|
|
|
|
|
border-radius: 12rpx;
|
|
|
|
|
}
|
2023-02-01 16:59:32 +08:00
|
|
|
}
|
|
|
|
|
</style>
|