| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <template>
- <view :class="$isEmpty(deviceList) ? 'bg-white':''">
- <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption"
- :up="upOption">
- <device-card :list="deviceList"></device-card>
- </mescroll-body>
- <view class="footer-fixed">
- <view class="margin">
- <u-button type="primary" shape="circle" @click="subscribeMessage">订阅设备告警通知</u-button>
- </view>
- </view>
- </view>
- </template>
- <script>
- var app = getApp();
- import MescrollMixin from "@/comps/mescroll-body/mescroll-mixins.js";
- import DeviceCard from "@/comps/device-card.vue";
- import DtEmpty from '@/comps/dt_empty.vue';
- export default {
- mixins: [MescrollMixin], // 使用mixin
- components: {
- DeviceCard, DtEmpty
- },
- data() {
- return {
- deviceList: [],
- }
- },
- onLoad() {
- },
- methods: {
- //订阅消息通知
- subscribeMessage() {
- this.$util.subscribe(["nSBYQTAe7wtQFPyHLXkacYF3IxwkYKjzWxsiVMzx-xM"]);
- },
- downCallback(mescroll) {
- setTimeout(() => {
- this.mescroll.resetUpScroll()
- }, 1500)
- },
- upCallback(mescroll) {
- let that = this;
- let params = {
- memberId: app.globalData.member.id,
- residentialId: uni.getStorageSync("residentialId")
- };
- let operation = 'device/list';
- try {
- app.globalData.postRequest(params, operation, function (res) {
- if (res.data.code == 500) {
- mescroll.endErr()
- return
- }
- let data = res.data.smartDevices;
- // let total = res.data.carPage.total;
- // mescroll.endBySize(data.length, total);
- mescroll.endSuccess(data.length);
- if (mescroll.num == 1) {
- that.deviceList = []; //如果是第一页需手动制空列表
- }
- that.deviceList = that.deviceList.concat(data); //追加新数据
- });
- } catch (e) {
- mescroll.endErr()
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- </style>
|