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 // #ifdef MP-WEIXIN
// //
this.updateMiniProgram() this.updateMiniProgram()
// #endif
//
this.onBluetoothState()
// voip // voip
this.setVoipConfig() this.setVoipConfig()
// #endif
//
this.onBluetoothState()
// //
const checkResult = await this.checkSetting() const checkResult = await this.checkSetting()
console.log(checkResult) console.log(checkResult)

View File

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

View File

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

View File

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

View File

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