You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
2.4 KiB
112 lines
2.4 KiB
<template>
|
|
<view class="container">
|
|
<!-- 头部标题 -->
|
|
<!-- <view class="title">STM32智能AI家居系统</view> -->
|
|
<u-navbar class="navbar" title="阈值设定" fixed @leftClick="handleBack">
|
|
</u-navbar>
|
|
<view class="view-data" :style="{ marginTop: systemBarHeight + 45 + 'px' }">
|
|
<u--input
|
|
type="number"
|
|
placeholder="请输入内容"
|
|
border="surround"
|
|
v-model="value"
|
|
></u--input>
|
|
<view class="but-box">
|
|
<u-button
|
|
@click="handleSubmit"
|
|
type="primary"
|
|
:plain="true"
|
|
text="确 认"
|
|
></u-button>
|
|
</view>
|
|
</view>
|
|
<u-toast ref="uToast"></u-toast>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import { sendAttribute } from "@/common/api.js";
|
|
export default {
|
|
data() {
|
|
return {
|
|
value: 30,
|
|
name: "",
|
|
deviceId: "",
|
|
systemBarHeight: 0, // 状态栏高度
|
|
};
|
|
},
|
|
methods: {
|
|
getSysteminfo() {
|
|
uni.getSystemInfo({
|
|
success: (res) => {
|
|
this.systemBarHeight = res.statusBarHeight;
|
|
console.log("systemBarHeight", this.systemBarHeight);
|
|
},
|
|
});
|
|
},
|
|
handleBack() {
|
|
console.log("返回");
|
|
uni.navigateBack({
|
|
delta: 1,
|
|
});
|
|
},
|
|
/** 下发属性 */
|
|
async handleSubmit() {
|
|
const res = await sendAttribute({
|
|
deviceId: this.deviceId, // 设备id
|
|
// 阈值JSON字符串
|
|
attributeAndValues: [
|
|
{
|
|
attributeIdentifier: this.name,
|
|
attributeValue: this.value,
|
|
},
|
|
],
|
|
});
|
|
const { data, code } = res;
|
|
if (code == 200) {
|
|
// this.$modal.msgSuccess("操作成功");
|
|
this.$refs.uToast.show({
|
|
type: "success",
|
|
message: "操作成功",
|
|
});
|
|
}
|
|
},
|
|
},
|
|
created() {},
|
|
onShow() {},
|
|
onLoad(options) {
|
|
console.log("options", options);
|
|
this.name = options.name; // 参数名称
|
|
this.value = options.value; // 阈值
|
|
this.deviceId = options.deviceId; // 设备id
|
|
this.getSysteminfo();
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.but-box {
|
|
width: 50%;
|
|
margin: 0 auto;
|
|
margin-top: 50px;
|
|
}
|
|
.view-data {
|
|
padding: 14px;
|
|
margin-top: 44px;
|
|
border-radius: 10px;
|
|
background: #fff;
|
|
}
|
|
.container {
|
|
padding: 16px;
|
|
box-sizing: border-box;
|
|
min-height: 100vh;
|
|
background: #fcfcfc;
|
|
}
|
|
.title {
|
|
line-height: 40px;
|
|
font-size: 18px;
|
|
text-align: center;
|
|
background: #fff;
|
|
}
|
|
</style>
|
|
<style></style>
|
|
|