device.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <view :class="$isEmpty(deviceList) ? 'bg-white':''">
  3. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  4. <device-card :list="deviceList" ></device-card>
  5. </mescroll-body>
  6. <view class="footer-fixed">
  7. <view class="margin">
  8. <u-button type="primary" shape="circle" @click="subscribeMessage">订阅设备告警通知</u-button>
  9. </view>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. var app = getApp();
  15. import MescrollMixin from "@/comps/mescroll-body/mescroll-mixins.js";
  16. import DeviceCard from "@/comps/device-card.vue";
  17. import DtEmpty from '@/comps/dt_empty.vue';
  18. export default {
  19. mixins: [MescrollMixin], // 使用mixin
  20. components:{
  21. DeviceCard,DtEmpty
  22. },
  23. data() {
  24. return {
  25. deviceList:[],
  26. }
  27. },
  28. onLoad() {
  29. },
  30. methods: {
  31. //订阅消息通知
  32. subscribeMessage() {
  33. this.$util.subscribe(["nSBYQTAe7wtQFPyHLXkacYF3IxwkYKjzWxsiVMzx-xM"]);
  34. },
  35. downCallback(mescroll) {
  36. setTimeout(() => {
  37. this.mescroll.resetUpScroll()
  38. },1500)
  39. },
  40. upCallback(mescroll) {
  41. let that = this;
  42. let params = {
  43. memberId: app.globalData.member.id,
  44. residentialId: uni.getStorageSync("residentialId")
  45. };
  46. // let operation = 'device/list';
  47. try {
  48. that.$http.iotDeviceList(params).then(res=>{
  49. let data = res.data.iotDevices;
  50. // let total = res.data.carPage.total;
  51. // mescroll.endBySize(data.length, total);
  52. mescroll.endSuccess(data.length);
  53. if (mescroll.num == 1) {
  54. that.deviceList = []; //如果是第一页需手动制空列表
  55. }
  56. that.deviceList = that.deviceList.concat(data); //追加新数据
  57. });
  58. } catch(e) {
  59. this.mescroll.endErr()
  60. }
  61. }
  62. }
  63. }
  64. </script>
  65. <style lang="scss" scoped>
  66. </style>