.
This commit is contained in:
parent
2cb9fbbe34
commit
e58cc90113
29
App.vue
29
App.vue
@ -6,9 +6,9 @@
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
indexData: new indexUtil(this.deviceChange), //全局地块列表管理
|
||||
indexData: new indexUtil(this.indexDataHandler), //全局地块列表管理
|
||||
dc: new dc(),
|
||||
mqtt: null,
|
||||
mqtt: new mqttUtil(),
|
||||
mqttObj: {
|
||||
topics: []
|
||||
},
|
||||
@ -29,7 +29,6 @@
|
||||
uni.$on("mqtt-subscribes", topics => {
|
||||
this.mqttSubscribes();
|
||||
});
|
||||
|
||||
},
|
||||
onShow: function() {
|
||||
console.log('App Show')
|
||||
@ -38,21 +37,29 @@
|
||||
console.log('App Hide')
|
||||
},
|
||||
methods: {
|
||||
deviceChange(e) {
|
||||
console.error("deviceChange:", e);
|
||||
//监听indexData的回调
|
||||
indexDataHandler(e, data) {
|
||||
// console.error("indexDataHandler_1:", {
|
||||
// e: e,
|
||||
// data: data
|
||||
// });
|
||||
if (e == this.indexData.eventType.land) {
|
||||
console.error("地块更新通知")
|
||||
// this.indexData.getNewDeviceList();
|
||||
// console.error("地块更新通知:", this.indexData.selectItem)
|
||||
|
||||
this.dc.setLandItem(this.indexData.selectItem, null);
|
||||
}
|
||||
if (e == this.indexData.eventType.device) {
|
||||
console.error("设备更新通知")
|
||||
console.error("dexice:", this.indexData.device)
|
||||
// console.error("设备更新通知:", this.indexData.device)
|
||||
|
||||
this.dc.setStations(this.indexData.device.stations);
|
||||
this.dc.setFlapValves(this.indexData.device.flapValves);
|
||||
this.dc.setValves(this.indexData.selectItem.id, this.indexData.device.waterOutlets);
|
||||
|
||||
console.error("this.dc:",this.dc)
|
||||
}
|
||||
uni.hideLoading();
|
||||
// console.error("indexDataHandler_2:", {
|
||||
// indexData: this.indexData,
|
||||
// dc: this.dc,
|
||||
// })
|
||||
},
|
||||
setTime: function() {
|
||||
console.error(this.globalData.num);
|
||||
|
@ -87,9 +87,15 @@
|
||||
this.indexData.selectItem = item;
|
||||
this.indexData.showIndex = index;
|
||||
if (item.id != oldItem.id) {
|
||||
/*
|
||||
1.设置缓存
|
||||
2.回调的方式通知改变
|
||||
3.全局订阅的方式通知改变
|
||||
4.组件回调的方式通知改变
|
||||
*/
|
||||
this.indexData.setStorage(2, item);
|
||||
this.indexData.onEventHandler(this.indexData.eventType.land);
|
||||
uni.$emit("notify-update-land");
|
||||
this.indexData.onEventHandler(this.indexData.eventType.land, item);
|
||||
uni.$emit("notify-update-land", item);
|
||||
this.$emit("select", item);
|
||||
}
|
||||
this.close();
|
||||
|
@ -157,8 +157,8 @@
|
||||
<view class="iconfont icon-diefa icon"></view>
|
||||
<view class="text">{{ item.rowKey }}</view>
|
||||
<view style="margin:0 10px;">出水口数量</view>
|
||||
<u-badge numberType="overflow" type="info" max="999"
|
||||
:value="item.children.length || 0" />
|
||||
<u-badge numberType="overflow" type="info" showZero max="999"
|
||||
:value="item.children.length" />
|
||||
</view>
|
||||
</template>
|
||||
<view class="u-collapse-content">
|
||||
@ -178,7 +178,7 @@
|
||||
</view>
|
||||
</u-col>
|
||||
<u-col span="3" style="align-items: flex-end;">
|
||||
<u-switch v-model="value" @change="change" size="20"
|
||||
<u-switch v-model="value" @change="flapValveChange" size="20"
|
||||
activeColor="#39ac4f"></u-switch>
|
||||
</u-col>
|
||||
</u-row>
|
||||
@ -408,7 +408,7 @@
|
||||
<!-- 弹窗 -->
|
||||
<view>
|
||||
<!-- 地块选择 -->
|
||||
<custom-select-land ref="refLand"></custom-select-land>
|
||||
<custom-select-land ref="refLand" @select="landChange"></custom-select-land>
|
||||
<!-- 角度 -->
|
||||
<custom-angle-slider ref="refAngleSlider" mode="bottom" @close="" @confirm="angleSliderConfirm" />
|
||||
</view>
|
||||
@ -425,6 +425,7 @@
|
||||
indexData: getApp().indexData,
|
||||
dc: getApp().dc,
|
||||
// show: false,
|
||||
isLandChange: false,
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
@ -432,10 +433,9 @@
|
||||
// uni.$emit("mqtt-link");
|
||||
|
||||
uni.$off("notify-update-land");
|
||||
uni.$on("notify-update-land", () => {
|
||||
console.error("index监听地块更新")
|
||||
// this.landDataChange = true;
|
||||
getApp().indexData.getNewDeviceList();
|
||||
uni.$on("notify-update-land", (data) => {
|
||||
console.error("index监听地块更新:", data)
|
||||
this.isLandChange = true;
|
||||
});
|
||||
},
|
||||
onShow() {
|
||||
@ -443,9 +443,9 @@
|
||||
plus.screen.lockOrientation("portrait-primary");
|
||||
plus.navigator.setFullscreen(false);
|
||||
// #endif
|
||||
this.getDevice();
|
||||
},
|
||||
onPageScroll(e) {
|
||||
// 页面滚动触发事件的处理函数
|
||||
onPageScroll(e) { // 页面滚动触发事件的处理函数
|
||||
// console.log(e.scrollTop); // 输出滚动位置的垂直距离
|
||||
if (e.scrollTop >= 100) {
|
||||
this.isSticky = true;
|
||||
@ -454,24 +454,44 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
//打开地块
|
||||
openLand() {
|
||||
this.$refs.refLand.open();
|
||||
},
|
||||
change(e) {
|
||||
console.log('change', e);
|
||||
//地块选择回调
|
||||
landChange(e) {
|
||||
this.isLandChange = true;
|
||||
this.getDevice();
|
||||
},
|
||||
//更新设备列表
|
||||
getDevice() {
|
||||
if (this.isLandChange) {
|
||||
console.error('getDevice_index_开始更新地块');
|
||||
uni.showLoading();
|
||||
getApp().indexData.getNewDeviceList();
|
||||
this.isLandChange = false;
|
||||
}
|
||||
},
|
||||
//蝶阀按钮切换
|
||||
flapValveChange(e) {
|
||||
console.error('flapValveChange', e);
|
||||
},
|
||||
//去列表
|
||||
toList() {
|
||||
uni.navigateTo({
|
||||
url: `/pages/index-list`
|
||||
})
|
||||
},
|
||||
//去扫码
|
||||
toQRCode() {},
|
||||
//显示角度弹框
|
||||
angleSliderShow() {
|
||||
this.$refs.refAngleSlider.show("1-1", "①开", 10, {
|
||||
// item: e.row,
|
||||
// index: e.index,
|
||||
});
|
||||
},
|
||||
//显示角度弹框确认
|
||||
angleSliderConfirm(e) {
|
||||
console.error("angleSliderConfirm:", e);
|
||||
},
|
||||
|
@ -58,7 +58,7 @@ class indexUtil {
|
||||
if (this.isFirst) {
|
||||
this.isFirst = false;
|
||||
this.getNewLandList(userId);
|
||||
this.getNewDeviceList(userId);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,6 +99,7 @@ class indexUtil {
|
||||
this.setStorage(1, null);
|
||||
}
|
||||
this.setStorage(2, this.selectItem);
|
||||
this.getNewDeviceList();
|
||||
}
|
||||
|
||||
// 组织地块数据
|
||||
@ -197,9 +198,9 @@ class indexUtil {
|
||||
} else {
|
||||
device = null;
|
||||
}
|
||||
console.error("device:", device)
|
||||
// console.error("device:", device)
|
||||
this.device = device;
|
||||
this.onEventHandler(this.eventType.device);
|
||||
this.onEventHandler(this.eventType.device, device);
|
||||
}).catch(error => {
|
||||
commonUtils.toast(error);
|
||||
})
|
||||
@ -211,6 +212,8 @@ class indexUtil {
|
||||
uni.setStorageSync(constant.lands, data);
|
||||
} else if (type == 2) {
|
||||
uni.setStorageSync(constant.landItem, data);
|
||||
} else if (type == 3) {
|
||||
uni.setStorageSync(constant.device, data);
|
||||
} else {
|
||||
commonUtils.toast("数据持久化异常");
|
||||
}
|
||||
@ -221,8 +224,8 @@ class indexUtil {
|
||||
land: "land",
|
||||
device: "device",
|
||||
}
|
||||
onEventHandler(type) {
|
||||
this.eventHandler(type);
|
||||
onEventHandler(type, data) {
|
||||
this.eventHandler(type, data);
|
||||
}
|
||||
}
|
||||
export default indexUtil
|
Loading…
Reference in New Issue
Block a user