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