"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