123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <template>
- <view class="container" v-show="show">
- <prodnum-06 v-if="detail.miniapppath == 'prodnum-06'" :control="control" />
- <prodnum-MT01 v-else-if="detail.miniapppath == 'prodnum-MT01'" :control="control" />
- <prodnum-MT02 v-else-if="detail.miniapppath == 'prodnum-MT02'" :control="control" />
- <prodnum-MT03 v-else-if="detail.miniapppath == 'prodnum-MT03'" :control="control" />
- <prodnum-YK01 v-else-if="detail.miniapppath == 'prodnum-YK01'" :control="control" />
- <prodnum-FW01 v-else-if="detail.miniapppath == 'prodnum-FW01'" :control="control" />
- <block v-else>
- <view style="height: 50px;" />
- <u-empty mode="data" />
- </block>
- </view>
- </template>
- <script>
- let monitoring = null;
- export default {
- name: "control",
- props: {
- detail: Object,
- onUpdate: Function
- },
- 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.$emit("onUpdate", true);
- this.$Http.updateFacilityList && this.$Http.updateFacilityList();
- }
- })
- }, 5000);
- }
- },
- beforeDestroy() {
- clearInterval(monitoring)
- },
- }
- </script>
- <style lang="scss" scoped>
- .container {
- width: 355px;
- margin: 0 auto;
- }
- </style>
|