feat: 在多个组件中添加小程序环境下的账号信息获取和蓝牙设置逻辑

This commit is contained in:
范鹏 2025-05-16 14:23:41 +08:00
parent 24b6fb61b5
commit 06ebc96086
5 changed files with 26 additions and 4 deletions

View File

@ -39,11 +39,12 @@
// #ifdef MP-WEIXIN
//
this.updateMiniProgram()
// #endif
//
this.onBluetoothState()
// voip
this.setVoipConfig()
// #endif
//
this.onBluetoothState()
//
const checkResult = await this.checkSetting()
console.log(checkResult)

View File

@ -38,9 +38,11 @@
const time = ref(0)
onMounted(async () => {
// #ifdef MP-WEIXIN
const accountInfo = uni.getAccountInfoSync()
getApp().globalData.appid = accountInfo.miniProgram.appId
getApp().globalData.envVersion = accountInfo.miniProgram.envVersion
// #endif
const result = await passthrough({
request_method: 'POST',

View File

@ -218,9 +218,11 @@
title: '加载中',
mask: true
})
// #ifdef MP-WEIXIN
const accountInfo = uni.getAccountInfoSync()
getApp().globalData.appid = accountInfo.miniProgram.appId
getApp().globalData.envVersion = accountInfo.miniProgram.envVersion
// #endif
this.deviceInfo = await this.getDeviceInfo()
const token = getStorage('token')
if (token) {
@ -243,9 +245,12 @@
await this.homeLogin()
this.pending = false
uni.hideLoading()
console.log('登录成功')
}
// #ifdef MP-WEIXIN
const _data = JSON.parse(JSON.stringify(data))
this.shareJump(_data)
// #endif
},
methods: {
timeFormat,
@ -403,6 +408,7 @@
homeLogin() {
const that = this
return new Promise(resolve => {
// #ifdef MP-WEIXIN
uni.login({
provider: 'weixin',
async success(loginRes) {
@ -437,6 +443,8 @@
resolve(false)
}
})
// #endif
resolve(false)
})
},
changeRadio() {

View File

@ -172,7 +172,11 @@
></image>
<view>掌静脉</view>
</view>
<view class="menu-main-view" @click="$basic.routeJump({ name: 'p2pPlayer' })">
<view
v-if="$bluetooth.currentLockInfo.transportType === transportType.TRANSPORT_TENCENT_YUN"
class="menu-main-view"
@click="$basic.routeJump({ name: 'p2pPlayer' })"
>
<image
class="menu-main-image transform-scale-140"
src="https://oss-lock.xhjcn.ltd/mp/icon_control.png"
@ -191,6 +195,7 @@
<view>授权管理员</view>
</view>
<view
v-if="$bluetooth.currentLockInfo.transportType !== transportType.TRANSPORT_TENCENT_YUN"
class="menu-main-view transform-scale-105"
@click="$basic.routeJump({ name: 'recordList' })"
>
@ -201,6 +206,7 @@
<view>操作记录</view>
</view>
<view
v-if="$bluetooth.currentLockInfo.transportType === transportType.TRANSPORT_TENCENT_YUN"
class="menu-main-view transform-scale-105"
@click="$basic.routeJump({ name: 'videoLog' })"
>
@ -223,6 +229,7 @@
</view>
<view
class="menu-main-view transform-scale-105"
v-if="$bluetooth.currentLockInfo.transportType === transportType.TRANSPORT_TENCENT_YUN"
@click="$basic.routeJump({ name: 'authorizeWechat' })"
>
<image
@ -279,6 +286,7 @@
import { useUserStore } from '@/stores/user'
import { getLockDetailRequest, getLockNetTokenRequest } from '@/api/lock'
import { deleteKeyRequest } from '@/api/key'
import { transportType } from '@/constant/transportType'
const $bluetooth = useBluetoothStore()
const $basic = useBasicStore()

View File

@ -898,6 +898,7 @@ export const useBluetoothStore = defineStore('ble', {
checkSetting() {
const that = this
return new Promise(resolve => {
// #ifdef MP-WEIXIN
uni.getSetting({
async success(res) {
const bluetooth = res.authSetting['scope.bluetooth']
@ -924,6 +925,8 @@ export const useBluetoothStore = defineStore('ble', {
resolve(false)
}
})
// #endif
resolve(false)
})
},
// 连接蓝牙设备+获取设备服务+获取设备特征值