congming_huose-apk/pages/device/addhubtwo.vue

393 lines
7.2 KiB
Vue
Raw Normal View History

2025-11-08 11:30:06 +08:00
<template>
<view class="device-detail">
<view class="bj"></view>
<!-- 头部保持原样 -->
<view class="tabback">
<view style="font-size: 36rpx;font-weight: 600;" class="" @click="onCancel">
</view>
<view class="name">{{$i18n.t('addHubTitle')}}</view>
<view class="add-btn" style="width: 50rpx;"></view>
</view>
<view class="content-container" style="background-color: #F3F5F6;">
<!-- <view class="" style="width: 100%;text-align: center;font-size: 30rpx;color: #727272;padding: 0 58rpx;box-sizing: border-box;margin-top: 50rpx;">
一个清晰的名称有助于将此设备与设备列表中的其他 设备区分开来并且通知源也使用该名称
</view>
<view class="names">
<view class="tit">
设备名称
</view>
<input type="text" placeholder="例如,家庭"/>
</view> -->
<view class="centxt">
{{$i18n.t('manualAddInstruction')}}
</view>
<view class="names">
<view class="tit">
{{$i18n.t('deviceIdLabel')}}
</view>
<input type="text" v-model="deviceid" :placeholder="$i18n.t('deviceIdPlaceholder')"/>
</view>
<view class="saoma" @click="scanQRCode">
<view class="lt">
<image src="https://api.ccttiot.com/smartmeter/img/static/umxJ6NYLhcJix13BgBrG" mode=""></image>
<view style="width:500rpx;">{{$i18n.t('scanIdentifyDeviceId')}}</view>
</view>
<view class="rt">
<image src="https://api.ccttiot.com/smartmeter/img/static/u4FuRu2C3Oblp9JWvvwj" mode=""></image>
</view>
</view>
</view>
<view class="anniu">
<view class="btnan" @click="btnjx">
{{$i18n.t('continueText')}}
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
deviceid:'',
fangdouflag:true,
kjid:''
}
},
computed: {
},
onLoad() {
this.kjid = uni.getStorageSync('kjid');
},
methods: {
// 点击扫码
scanQRCode() {
uni.scanCode({
onlyFromCamera: true,
scanType: ['qrCode'],
success: res => {
console.log(res);
this.deviceid = res.result
},
fail: err => {
console.error('扫描失败:', err)
uni.showToast({
title: this.$i18n.t('scanFailed'),
icon: 'none'
})
}
})
},
// 点击返回上一级
onCancel() {
uni.navigateBack({
delta: 1
})
},
// 点击继续下一步
btnjx(){
let data = {
sn:this.deviceid,
spaceId:this.kjid,
// name:this.deviceName
}
if(this.fangdouflag == true){
this.fangdouflag = false
this.$http.put(`/bst/device/bind`,data).then(res =>{
if(res.code == 200){
uni.showToast({
title: res.msg,
icon: 'success',
duration:3000
})
setTimeout(()=>{
this.fangdouflag = true
uni.navigateTo({
url:'/pages/device/addthr?sn=' + this.deviceid
})
},1500)
}else{
uni.showToast({
title: res.msg,
icon: 'none',
duration:3000
})
this.fangdouflag = true
}
})
}
}
}
}
</script>
<style scoped lang="less">
.saoma{
width: 750rpx;
height: 128rpx;
background: #FFFFFF;
margin-top: 26rpx;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 32rpx;
box-sizing: border-box;
.lt{
display: flex;
align-items: center;
font-size: 30rpx;
color: #3D3D3D;
image{
width: 80rpx;
height: 80rpx;
margin-right: 46rpx;
}
}
.rt{
width: 56rpx;
height: 56rpx;
image{
width: 56rpx;
height: 56rpx;
}
}
}
.centxt{
font-size: 28rpx;
color: #727272;
margin-top: 90rpx;
width: 100%;
text-align: center;
}
.names{
width: 750rpx;
height: 200rpx;
background: #FFFFFF;
border-radius: 0rpx 0rpx 0rpx 0rpx;
margin-top: 54rpx;
padding: 34rpx 48rpx;
box-sizing: border-box;
.tit{
font-size: 28rpx;
color: #7F7F7F;
}
input{
font-size: 32rpx;
color: #000;
margin-top: 22rpx;
border-bottom: 1px solid #9E9E9E;
padding-bottom: 26rpx;
}
}
.anniu{
width: 750rpx;
height: 126rpx;
padding-top: 24rpx;
box-sizing: border-box;
background: #FFFFFF;
border-radius: 0rpx 0rpx 0rpx 0rpx;
position: fixed;
left: 0;
bottom: 0;
.btnan{
width: 674rpx;
height: 80rpx;
background: #0F0F0F;
font-size: 32rpx;
color: #FFFFFF;
text-align: center;
line-height: 80rpx;
border-radius: 50rpx;
margin: auto;
}
}
.crop-container {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
background-color: #000;
}
.bj {
width: 100%;
height: 50vh;
position: fixed;
top: 0;
z-index: -1;
background-color: #0F0F0F;
}
.tabback {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
height: 126rpx;
padding: 0 20rpx;
box-sizing: border-box;
background-color: #fff;
margin-top: 102rpx;
border-radius: 30rpx 30rpx 0 0;
.rtjt {
font-size: 36rpx;
color: #333;
}
.name {
font-size: 36rpx;
font-weight: bold;
color: #333;
margin: 0 auto;
}
.add-btn {
font-size: 32rpx;
color: #ccc;
transition: color 0.3s;
&.active {
color: #333;
}
}
}
.device-detail {
// min-height: 100vh;
}
.content-container {
display: flex;
flex-direction: column;
min-height: calc(100vh - 228rpx);
padding-bottom: 200rpx;
}
.instruction-section {
background: #f3f5f6;
text-align: center;
width: 100%;
height: 448rpx;
view {
position: relative;
left: 50%;
transform: translateX(-50%);
width: 272rpx;
margin-top: 88rpx;
}
.da {
width: 272rpx;
height: 272rpx;
border-radius: 50%;
}
.xiao {
width: 116rpx;
height: 72rpx;
position: absolute;
right: 0;
bottom: 0;
}
.instruction-text {
font-size: 28rpx;
color: #666;
line-height: 1.6;
margin-top: 30rpx;
}
}
.input-section {
background: #fff;
padding: 40rpx 32rpx;
margin-top: 40rpx;
.input-group {
margin-bottom: 40rpx;
}
.input-label {
display: block;
font-size: 28rpx;
color: #666;
margin-bottom: 20rpx;
}
.code-input {
width: 100%;
height: 80rpx;
border: none;
border-bottom: 2rpx solid #e5e5e5;
font-size: 32rpx;
color: #333;
background: transparent;
padding: 0;
&::placeholder {
color: #bbb;
letter-spacing: 8rpx;
}
&:focus {
border-bottom-color: #000;
outline: none;
}
}
}
.help-section {
background: #f3f5f6;
padding: 40rpx 0;
padding-top: 20rpx;
padding-left: 48rpx;
}
.help-text {
font-size: 28rpx;
color: #727272;
}
.button-section {
margin-top: auto;
padding-top: 42rpx;
display: flex;
flex-direction: column;
align-items: center;
width: 750rpx;
height: 220rpx;
background: #FFFFFF;
border-radius: 0rpx 0rpx 0rpx 0rpx;
position: fixed;
left: 50%;
transform: translateX(-50%);
bottom: 0;
.continue-btn {
width: 674rpx;
height: 80rpx;
line-height: 80rpx;
background: #BBBBBB;
color: #fff;
border: none;
border-radius: 50rpx;
font-size: 32rpx;
font-weight: 600;
}
.continue-btn.active {
background: #000;
}
.cancel-btn {
margin-top: 34rpx;
font-size: 28rpx;
color: #000;
}
}
</style>