123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <template>
- <view v-show="show">
- <prodnum-06 v-if="detail.prodnum == '06'" :control="control" />
- </view>
- </template>
- <script>
- let monitoring = null;
- export default {
- components: {},
- name: "control",
- props: {
- detail: Object
- },
- data() {
- return {
- show: false,
- uninitialized: true,
- control: {}
- }
- },
- methods: {
- initialize(init = false) {
- if (init) this.getControl(true);
- },
- getControl(init) {
- if (init) this.control = null;
- this.$Http.basic({
- "id": "20230628084901",
- "content": {
- "w_deviceid": this.detail.w_deviceid
- }
- }).then(res => {
- console.log("设备控制", res)
- if (this.cutoff(res.msg)) return;
- this.uninitialized = false;
- this.control = res.data;
- this.$Http.setControlItem = this.setControlItem.bind(this);
- this.setMonitoring()
- })
- },
- setControlItem(w_functionid, params, title = "已发送修改指令") {
- return this.$Http.basic({
- "id": "20230627163701",
- "content": {
- "w_deviceid": this.detail.w_deviceid,
- w_functionid,
- params
- }
- }).then(res => {
- if (this.cutoff(res.msg, title)) return;
- console.log("更新设备控制", res)
- this.getControl(true);
- return res.msg == '成功'
- })
- },
- setMonitoring() {
- clearInterval(monitoring)
- monitoring = setInterval(() => {
- this.$Http.devicevaluecheck({
- "w_deviceid": this.detail.w_deviceid,
- }).then(res => {
- if (res == true) {
- uni.showModal({
- title: "通知",
- content: '设备控制参数已更新',
- showCancel: false,
- })
- this.getControl(true);
- }
- })
- }, 5000);
- }
- },
- beforeDestroy() {
- clearInterval(monitoring)
- },
- }
- </script>
- <style lang="scss" scoped></style>
|