Novecane
2025-02-15 a12e5f63a90446525b2f322fb2bbd21d5285cd6d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
"use strict";
const common_vendor = require("../../../common/vendor.js");
const common_assets = require("../../../common/assets.js");
const api_index = require("../../../api/index.js");
const _sfc_main = {
  __name: "index",
  setup(__props) {
    const state = common_vendor.ref({});
    const controlValue = common_vendor.ref(100);
    const logEntry = common_vendor.ref([]);
    const temp = common_vendor.ref({});
    const controInfo = common_vendor.ref({});
    common_vendor.onMounted(async () => {
      const option = getCurrentPages()[getCurrentPages().length - 1].options;
      const deviceInfo = JSON.parse(decodeURIComponent(option.device));
      state.value = deviceInfo;
      getOpeHistory();
      getControlData();
      try {
        const res = await api_index.getDeviceInfoByDeviceId(deviceInfo.facilityCode);
        state.value = {
          ...res.data,
          ...deviceInfo
        };
      } catch (error) {
        common_vendor.index.__f__("error", "at pages/router/deviceInfo/index.vue:88", "Failed to fetch device info:", error);
      }
    });
    const removeSharedDevice = async () => {
      temp.value = {
        facilityCode: state.value.facilityCode
      };
      try {
        const res = await api_index.deleteDevice(temp.value);
        if (res.code === 200) {
          common_vendor.index.redirectTo({
            url: "/pages/layout/index"
          });
        } else {
          common_vendor.index.showToast({
            title: "设备删除失败",
            icon: "fail"
          });
        }
      } catch (error) {
        common_vendor.index.__f__("error", "at pages/router/deviceInfo/index.vue:112", "Failed to delete device:", error);
      }
    };
    const handleControlChange = (e) => {
      controInfo.value = {
        sn: state.value.facilityCode,
        destinationPosition: e.detail.value
      };
      api_index.deviceControlInfo(controInfo.value).then((res) => {
      }).catch((error) => {
        common_vendor.index.__f__("error", "at pages/router/deviceInfo/index.vue:124", "Failed to control device:", error);
      });
    };
    const getOpeHistory = () => {
      api_index.getOpeInfo(state.value.facilityCode).then((res) => {
        if (res.code === 200) {
          logEntry.value = res.data;
        }
      }).catch((e) => {
        common_vendor.index.__f__("log", "at pages/router/deviceInfo/index.vue:135", "fail info", e);
      });
    };
    const getControlData = () => {
      api_index.getControlInfo(state.value.facilityCode).then((res) => {
        controlValue.value = res.data.position;
      });
    };
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_assets._imports_0$1,
        b: common_vendor.t(state.value.facilityName),
        c: common_vendor.t(state.value.facilityCode),
        d: state.value.isOnLine == 1
      }, state.value.isOnLine == 1 ? {} : {}, {
        e: common_vendor.t(state.value.dcInputVolt),
        f: common_vendor.t(state.value.rssi),
        g: common_vendor.o(handleControlChange),
        h: controlValue.value,
        i: common_vendor.f(logEntry.value, (item, index, i0) => {
          return {
            a: common_vendor.t(item.operateName),
            b: common_vendor.t(item.operateStatus),
            c: common_vendor.t(item.createTimeView),
            d: index
          };
        }),
        j: common_vendor.o(removeSharedDevice)
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-68c572bb"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/pages/router/deviceInfo/index.js.map