2024-08-06 09:40:20 +08:00
|
|
|
<script>
|
2024-08-14 15:04:01 +08:00
|
|
|
import { useBluetoothStore } from '@/stores/bluetooth'
|
2024-08-21 16:20:11 +08:00
|
|
|
import { useUserStore } from '@/stores/user'
|
2024-08-20 19:54:37 +08:00
|
|
|
import { useBasicStore } from '@/stores/basic'
|
2024-08-14 15:04:01 +08:00
|
|
|
import { mapState, mapActions } from 'pinia'
|
2024-08-21 16:20:11 +08:00
|
|
|
import { getUserInfoRequest } from '@/api/user'
|
|
|
|
|
let vm
|
2024-08-14 15:04:01 +08:00
|
|
|
|
2024-08-06 09:40:20 +08:00
|
|
|
export default {
|
2024-08-21 16:20:11 +08:00
|
|
|
globalData: {
|
|
|
|
|
// 更新登录状态
|
|
|
|
|
updateIsLogin(isLogin) {
|
|
|
|
|
useUserStore().updateLoginStatus(isLogin)
|
|
|
|
|
}
|
|
|
|
|
},
|
2024-08-14 15:04:01 +08:00
|
|
|
computed: {
|
2024-08-21 16:20:11 +08:00
|
|
|
...mapState(useBluetoothStore, ['bluetoothStatus']),
|
2024-08-14 15:04:01 +08:00
|
|
|
},
|
2024-08-06 09:40:20 +08:00
|
|
|
onLaunch: function() {
|
2024-08-14 18:33:23 +08:00
|
|
|
// 检查强制升级
|
2024-08-06 11:07:48 +08:00
|
|
|
this.updateMiniProgram()
|
2024-08-20 19:54:37 +08:00
|
|
|
// // 初始化蓝牙
|
|
|
|
|
// this.initBluetooth()
|
|
|
|
|
// // 监听蓝牙开关状态
|
|
|
|
|
// this.onBluetoothState()
|
|
|
|
|
// // 监听蓝牙连接状态
|
|
|
|
|
// this.onBluetoothConnectStatus()
|
|
|
|
|
// // 监听设备特征值变化
|
|
|
|
|
// this.onBluetoothCharacteristicValueChange()
|
|
|
|
|
|
|
|
|
|
this.getDeviceInfo()
|
|
|
|
|
this.getButtonInfo()
|
2024-08-06 09:40:20 +08:00
|
|
|
},
|
|
|
|
|
onShow: function() {
|
2024-08-14 15:04:01 +08:00
|
|
|
this.checkSetting()
|
2024-08-06 11:07:48 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
2024-08-14 18:33:23 +08:00
|
|
|
...mapActions(useBluetoothStore, ['initBluetooth', 'onBluetoothState', 'updateBluetoothStatus', 'checkSetting',
|
|
|
|
|
'onBluetoothConnectStatus', 'onBluetoothCharacteristicValueChange']),
|
2024-08-20 19:54:37 +08:00
|
|
|
...mapActions(useBasicStore, ['getDeviceInfo', 'getButtonInfo']),
|
2024-08-21 16:20:11 +08:00
|
|
|
...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>
|