smart-home/smart-home-app/pages/room/settings.vue
2026-02-26 09:16:34 +08:00

219 lines
4.6 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="container">
<!-- 设置项列表 -->
<view class="settings-group">
<view class="setting-item" @click="editName">
<text class="setting-label">名称</text>
<view class="setting-value">
<text class="value-text">{{roomName}}</text>
<text class="arrow"></text>
</view>
</view>
<view class="setting-item" @click="editGroup">
<text class="setting-label">分组</text>
<view class="setting-value">
<text class="value-text placeholder">未分组房间</text>
<text class="arrow"></text>
</view>
</view>
<view class="setting-item" @click="manageDevices">
<text class="setting-label">设备</text>
<view class="setting-value">
<text class="arrow"></text>
</view>
</view>
<view class="setting-item" @click="automationSettings">
<text class="setting-label">手动执行</text>
<view class="setting-value">
<text class="arrow"></text>
</view>
</view>
</view>
<!-- 显示视频组件开关 -->
<view class="settings-group">
<view class="setting-item">
<text class="setting-label">展示视频组件</text>
<switch :checked="showVideo" @change="e => showVideo = e.detail.value" color="#3498DB" />
</view>
<view class="setting-item" @click="videoDevices">
<text class="setting-label">视频关联设备</text>
<view class="setting-value">
<text class="arrow"></text>
</view>
</view>
<view class="setting-item" @click="displayMode">
<text class="setting-label">设备列表样式</text>
<view class="setting-value">
<text class="value-text">宫格</text>
<text class="arrow"></text>
</view>
</view>
<view class="setting-hint">
<text class="hint-text">所有房间统一切换</text>
</view>
</view>
<!-- 删除房间按钮 -->
<view class="delete-btn" @click="deleteRoom">
<text class="delete-text">删除房间</text>
</view>
</view>
</template>
<script>
export default {
data() {
return {
roomId: '',
roomName: '',
showVideo: true
}
},
onLoad(options) {
if (options.roomId) {
this.roomId = options.roomId
}
if (options.roomName) {
this.roomName = decodeURIComponent(options.roomName)
}
uni.setNavigationBarTitle({
title: '房间设置'
})
},
methods: {
editName() {
uni.showModal({
title: '修改房间名称',
editable: true,
placeholderText: '请输入房间名称',
content: this.roomName,
success: (res) => {
if (res.confirm && res.content) {
this.roomName = res.content
uni.showToast({ title: '修改成功', icon: 'success' })
}
}
})
},
editGroup() {
uni.showToast({ title: '分组功能开发中', icon: 'none' })
},
manageDevices() {
uni.navigateTo({
url: `/pages/device/room?roomId=${this.roomId}`
})
},
automationSettings() {
uni.showToast({ title: '自动化功能开发中', icon: 'none' })
},
videoDevices() {
uni.showToast({ title: '视频设备功能开发中', icon: 'none' })
},
displayMode() {
uni.showActionSheet({
itemList: ['宫格', '列表'],
success: (res) => {
const mode = res.tapIndex === 0 ? '宫格' : '列表'
uni.showToast({ title: `已切换为${mode}模式`, icon: 'success' })
}
})
},
deleteRoom() {
uni.showModal({
title: '删除房间',
content: `确定要删除"${this.roomName}"吗?删除后房间内的设备将不会被删除`,
confirmColor: '#E74C3C',
success: (res) => {
if (res.confirm) {
uni.showToast({ title: '删除成功', icon: 'success' })
setTimeout(() => {
uni.navigateBack()
}, 1500)
}
}
})
}
}
}
</script>
<style>
.container {
min-height: 100vh;
background: #f5f5f5;
padding-bottom: 40rpx;
}
.settings-group {
background: #fff;
margin-bottom: 20rpx;
}
.setting-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 32rpx 30rpx;
border-bottom: 1rpx solid #f0f0f0;
}
.setting-item:last-child {
border-bottom: none;
}
.setting-label {
font-size: 30rpx;
color: #333;
}
.setting-value {
display: flex;
align-items: center;
}
.value-text {
font-size: 28rpx;
color: #666;
margin-right: 8rpx;
}
.value-text.placeholder {
color: #ccc;
}
.arrow {
font-size: 32rpx;
color: #ccc;
}
.setting-hint {
padding: 16rpx 30rpx;
background: #f8f9fa;
}
.hint-text {
font-size: 24rpx;
color: #999;
}
.delete-btn {
background: #fff;
margin: 20rpx;
padding: 32rpx;
border-radius: 12rpx;
text-align: center;
}
.delete-text {
font-size: 30rpx;
color: #E74C3C;
}
</style>