congming_huose-apk/subpackage/device/deviceaddroom.vue

368 lines
7.0 KiB
Vue
Raw 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="device-detail">
<view class="bj">
</view>
<!-- 顶部导航 -->
<view class="tabback">
<view class="rtjt" @click="btnback"></view>
<view class="name">{{ $i18n.t('addDevice') }}</view>
<view style="width: 36rpx;"></view>
</view>
<view class="content-container">
<!-- 设备ID 灰条 -->
<view class="id-strip">
<view class="id-text">{{ $i18n.t('deviceIdLabel') }}{{deviceId}}</view>
<!-- <view class="id-text" style="margin-top: 20rpx;">{{ sbobj.productName }}</view> -->
</view>
<!-- 白色信息卡设备ID 名称输入 -->
<view class="card">
<view class="field">
<text class="field-label">{{ $i18n.t('deviceName') }}</text>
<!-- <input class="field-input" type="text" v-model="deviceName" :placeholder="$i18n.t('deviceNamePlaceholder')"
placeholder-style="color:#BFBFBF" maxlength="20" /> -->
<input class="field-input" type="text" :disabled="true" v-model="deviceName" :placeholder="$i18n.t('deviceNamePlaceholder')"
placeholder-style="color:#BFBFBF" maxlength="20" />
</view>
</view>
<!-- 提示说明 -->
<view class="tip-box">
<text class="tip-text">{{ $i18n.t('deviceNameTip') }}</text>
</view>
<!-- 列表:添加房间 -->
<view class="list">
<view :class="activeindex == index ? 'active' : ''" @click="onAddRoom(item,index)" v-for="(item,index) in roomlist" :key="index">
<text class="cell-title">{{ item.name }}</text>
<text v-if="activeindex == index">✔</text>
</view>
</view>
</view>
<!-- 底部添加设备按钮 -->
<view class="button-section">
<button class="continue-btn" @click="handleContinue">{{ $i18n.t('addDevice') }}</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
deviceId: '', // 设备ID输入值
deviceName: '',
kjid:'',
roomlist:[],
activeindex:-1,
roomid:'',
fangdouflag:true,
sbobj:{}
}
},
onLoad(option) {
this.kjid = uni.getStorageSync('kjid');
this.deviceId = option.deviceId
this.getlist()
this.getsb()
},
methods: {
// 查询设备详情
getsb(){
this.$http.get(`/bst/device/detail?sn=${this.deviceId}`).then(res =>{
if(res.code == 200){
this.sbobj = res.data
this.deviceName = res.data.productName
}
})
},
// 点击添加成功
handleContinue(){
let data = {
sn:this.deviceId,
spaceId:this.kjid,
roomId:this.roomid,
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.reLaunch({
url:'/pages/index/index'
})
},1500)
}else{
uni.showToast({
title: res.msg,
icon: 'none',
duration:3000
})
this.fangdouflag = true
}
})
}
},
// 请求房间列表
getlist(){
this.$http.get(`/bst/room/list?spaceId=${this.kjid}&pageNum=1&pageSize=999`).then(res =>{
if(res.code == 200){
this.roomlist = res.rows
}
})
},
// 返回上一页
btnback() {
uni.navigateBack({
delta: 1
});
},
// 点击选择房间
onAddRoom(item,index) {
this.activeindex = index
this.roomid = item.id
}
}
}
</script>
<style scoped lang="less">
.active{
background-color: #d8d9da;
color: #000 !important;
.cell-title{
font-weight: 600 !important;
}
}
// 底部按钮区域
.button-section {
flex: 1;
display: flex;
align-items: flex-end;
padding: 0 40rpx 80rpx;
background-color: #F3F5F6;
.continue-btn {
width: 100%;
height: 100rpx;
background-color: #000;
color: #fff;
border: none;
border-radius: 50rpx;
font-size: 36rpx;
font-weight: 500;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
}
}
.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;
border: 1rpx solid #D8D8D8;
margin-top: 102rpx;
border-radius: 30rpx 30rpx 0 0;
.rtjt {
font-size: 36rpx;
color: #333;
}
.name {
font-size: 36rpx;
font-weight: bold;
color: #333;
}
}
.device-detail {
height: 93vh;
}
// 顶部导航样式贴近系统样式
.tabback {
display: flex;
align-items: center;
justify-content: space-between;
height: 98rpx;
padding: 0 24rpx;
background: #fff;
border-bottom: 2rpx solid #ECECEC;
.name {
font-size: 32rpx;
color: #333;
}
.rtjt {
font-size: 36rpx;
color: #333;
}
}
// 页面容器
.content-container {
height: 74vh;
background: #F3F5F6;
padding-bottom: 40rpx;
}
// 顶部设备ID灰条
.id-strip {
height: 142rpx;
// line-height: 142rpx;
background: #F3F5F6;
text-align: center;
padding: 0 24rpx;
padding-top: 30rpx;
box-sizing: border-box;
border-bottom: 2rpx solid #ECECEC;
}
// 卡片
.card {
background: #fff;
margin-top: 0;
padding: 0 24rpx;
}
.id-text {
color: #9EA3A8;
font-size: 26rpx;
}
.field {
padding: 24rpx 0 32rpx;
}
.field-label {
color: #9EA3A8;
font-size: 26rpx;
}
.field-input {
margin-top: 16rpx;
height: 72rpx;
border: 0;
border-bottom: 2rpx solid #E6E6E6;
font-size: 28rpx;
}
// 提示
.tip-box {
padding: 20rpx 24rpx;
background: #F3F5F6;
border-top: 2rpx solid #ECECEC;
}
.tip-text {
color: #9EA3A8;
font-size: 24rpx;
line-height: 40rpx;
}
// 列表
.list {
background: #fff;
margin-top: 12rpx;
max-height: 44vh;
overflow: scroll;
view {
height: 96rpx;
padding: 0 24rpx;
display: flex;
align-items: center;
justify-content: space-between;
border-top: 2rpx solid #ECECEC;
}
}
.cell-title {
color: #333;
font-size: 30rpx;
font-weight: 500;
}
.arrow {
color: #C0C0C0;
font-size: 44rpx;
line-height: 1;
}
.scan-tip {
text-align: center;
padding: 40rpx 20rpx;
color: #666;
font-size: 28rpx;
}
.scan-container {
display: flex;
justify-content: center;
padding: 40rpx 20rpx;
}
@keyframes scan {
0% {
top: 20rpx;
}
100% {
top: 580rpx;
}
}
.flashlight-btn {
display: flex;
justify-content: center;
margin: 40rpx 0;
.flashlight-icon {
width: 120rpx;
height: 60rpx;
background-color: #333;
border-radius: 30rpx;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-size: 32rpx;
transition: all 0.3s ease;
&.active {
background-color: #007aff;
transform: scale(1.1);
}
.icon {
font-size: 28rpx;
}
}
}
</style>