钟铮锁App web部分 需要打包放进对应的安卓项目 生成apk 才能正常使用功能
he wei
2025-01-19 ba2cfa9907623c094e6e2d52d12dc3055ddd587a
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
import { ref, reactive, onMounted } from "vue";
import axios from "@/assets/js/axios";
 
/**
 * 查询所有在用电池信息
 */
function getBatts() {
  return axios({
    method: "GET",
    url: "binf/getAllSinfBinf1",
  });
}
 
/**
 * 查询所有在用电源信息
 */
function getPowers() {
  return axios({
    method: "GET",
    url: "binf/getAllSinfBinf2",
  });
}
 
/**
 * type: 0 电池   ; 1 电源
 */
export default (type = 0) => {
  const batts = reactive([]);
  const powers = reactive([]);
 
  async function getBattList() {
    let res = await getBatts();
    batts.length = 0;
    let { code, data, data2 } = res.data;
    if (code && data) {
      batts.push(...data2);
    }
  }
 
  async function getPowerList() {
    let res = await getPowers();
    powers.length = 0;
    let { code, data, data2 } = res.data;
    if (code && data) {
      powers.push(...data2);
    }
  }
 
 onMounted(() => {
    switch (type) {
      case 0:
        getBattList();
        break;
      case 1:
        getPowerList();
        break;
      default:
        console.error("type参数不正确 ", type);
        break;
    }
  });
 
  return { batts, powers, getBattList, getPowerList };
};