index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <oa-scroll
  3. customClass="bg-white scroll-height"
  4. :pageSize="pageSize"
  5. :total="total"
  6. :refresherLoad="true"
  7. :refresherLoadTitle="false"
  8. :refresherEnabled="true"
  9. :refresherDefaultStyle="'none'"
  10. :refresherThreshold="44"
  11. :refresherBackground="'#f5f6f7'"
  12. @load="load"
  13. @refresh="refresh"
  14. :data-theme="'theme-' + proxy.$settingStore.themeColor.type"
  15. >
  16. <template #default>
  17. <view class="deviceManage">
  18. <u-grid :border="true">
  19. <u-grid-item v-for="(base, index) in dataList" :key="index" @click="handleToDevice(base.id, base.productName)">
  20. <u-badge type="primary" max="9999" :value="base.deviceCount" :showZero="true" :absolute="true" :offset="[10, 10, 0, 0]"></u-badge>
  21. <image class="mb15" style="width: 40px; height: 40px; margin-top: 35px" :src="base.typeImg" mode="aspectFill"></image>
  22. <view class="mb15 text-ellipsis" style="width: 100%; text-align: center">{{ base.productName }}</view>
  23. </u-grid-item>
  24. </u-grid>
  25. </view>
  26. </template>
  27. </oa-scroll>
  28. </template>
  29. <script setup>
  30. import { onReady, onLoad, onShow, onNavigationBarButtonTap, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app";
  31. import { ref, onMounted, inject, shallowRef, reactive, getCurrentInstance } from "vue";
  32. import { useStores, publicStores } from "@/store/modules/index";
  33. import { dmpProductInfo } from "@/api/business/fireIot/deviceManage.js";
  34. const { proxy } = getCurrentInstance();
  35. const dataList = ref([]);
  36. const pageSize = ref(20);
  37. const current = ref(1);
  38. const total = ref(0);
  39. /**
  40. * @页面初始化
  41. */
  42. function init() {
  43. dmpProductInfo({ productName: "", current: current.value, size: pageSize.value }).then((requset) => {
  44. if (requset.status === "SUCCESS") {
  45. requset.data.records.forEach((el) => {
  46. if (!el.typeImg) {
  47. el.typeImg = "/static/images/404.png";
  48. }
  49. if (el.deviceCount == null) {
  50. el.deviceCount = 0;
  51. }
  52. });
  53. dataList.value = requset.data.records;
  54. total.value = requset.data.total;
  55. }
  56. });
  57. }
  58. function handleToDevice(id, productName) {
  59. proxy.$tab.navigateTo(`/pages/business/fireIot/deviceManage/components/deviceDetailsList?id=${id}&productName=${productName}`);
  60. }
  61. /**
  62. * @scrollView加载数据
  63. */
  64. function load() {
  65. pageSize.value += 10;
  66. init();
  67. }
  68. /**
  69. * @scrollView刷新数据
  70. */
  71. function refresh() {
  72. pageSize.value = 20;
  73. total.value = 0;
  74. init();
  75. }
  76. onShow(() => {
  77. //调用系统主题颜色
  78. proxy.$settingStore.systemThemeColor([1]);
  79. init();
  80. });
  81. </script>