wx-starlock/App.vue

63 lines
1.9 KiB
Vue
Raw Normal View History

2024-08-06 09:40:20 +08:00
<script>
import { useBluetoothStore } from '@/stores/bluetooth'
import { useUserStore } from '@/stores/user'
import { useBasicStore } from '@/stores/basic'
import { mapState, mapActions } from 'pinia'
import { getUserInfoRequest } from '@/api/user'
let vm
2024-08-06 09:40:20 +08:00
export default {
globalData: {
// 更新登录状态
updateIsLogin(isLogin) {
useUserStore().updateLoginStatus(isLogin)
}
},
computed: {
...mapState(useBluetoothStore, ['bluetoothStatus']),
},
2024-08-06 09:40:20 +08:00
onLaunch: function() {
// 检查强制升级
2024-08-06 11:07:48 +08:00
this.updateMiniProgram()
// // 初始化蓝牙
// this.initBluetooth()
// // 监听蓝牙开关状态
// this.onBluetoothState()
// // 监听蓝牙连接状态
// this.onBluetoothConnectStatus()
// // 监听设备特征值变化
// this.onBluetoothCharacteristicValueChange()
this.getDeviceInfo()
this.getButtonInfo()
2024-08-06 09:40:20 +08:00
},
onShow: function() {
this.checkSetting()
2024-08-06 11:07:48 +08:00
},
methods: {
...mapActions(useBluetoothStore, ['initBluetooth', 'onBluetoothState', 'updateBluetoothStatus', 'checkSetting',
'onBluetoothConnectStatus', 'onBluetoothCharacteristicValueChange']),
...mapActions(useBasicStore, ['getDeviceInfo', 'getButtonInfo']),
...mapActions(useUserStore, ['updateLoginStatus']),
2024-08-06 11:07:48 +08:00
// 强制升级
updateMiniProgram() {
const updateManager = uni.getUpdateManager()
updateManager.onUpdateReady(function () {
uni.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
showCancel: false,
success: function () {
updateManager.applyUpdate()
}
})
})
}
}
2024-08-06 09:40:20 +08:00
}
</script>
2024-08-06 10:57:56 +08:00
<style lang="scss">
@import "uview-plus/index.scss";
</style>