联调设备存储

This commit is contained in:
xuli3099
2025-08-15 10:13:39 +08:00
parent aede40ff2a
commit b88c64af7e
8 changed files with 150 additions and 176 deletions

View File

@@ -57,42 +57,22 @@ onLoad(async(opt) => {
if(!versionVisible.value){
try {
// 授权设备存储
// let result = {granted:false}
// if(systemInfo.osVersion<13){
// let permissions = ['android.permission.READ_EXTERNAL_STORAGE', 'android.permission.WRITE_EXTERNAL_STORAGE'];
// result = await requestAndroidPermissionAsync(systemInfo,permissions);
// }else if(systemInfo.osVersion==13){
// let permissions = ['android.permission.READ_MEDIA_IMAGES', 'android.permission.READ_MEDIA_VIDEO', 'android.permission.READ_MEDIA_AUDIO'];
// result = await requestAndroidPermissionAsync(systemInfo,permissions);
// }else{
// let permissions = ['android.permission.READ_MEDIA_VISUAL_USER_SELECTED'];
// result = await requestAndroidPermissionAsync(systemInfo,permissions);
// }
// if (result.granted) {
// showAlert("11授权成功")
// setTimeout(()=>{
// selectDeviceId();
// },500)
// } else {
let granted = requestAndroidPermission(systemInfo);
if(granted){
showAlert("22授权成功")
setTimeout(()=>{
selectDeviceId();
},500)
}
// showAlert("您还没对设备授权,请授权!")
// }
let granted = requestAndroidPermission(systemInfo);
if(granted){
// showAlert("22授权成功")
setTimeout(()=>{
selectDeviceId();
},500)
}
} catch (error) {
console.error('权限请求出错:', error);
showAlert(JSON.stringify(error))
// showAlert(JSON.stringify(error))
}
}
// #endif
// #ifdef H5
setTimeout(()=>{
// setTimeout(()=>{
if(userStore.isLogin){
uni.reLaunch({
url: '/pages/home/home',
@@ -102,7 +82,7 @@ onLoad(async(opt) => {
url: '/pages/login/login',
});
}
},2000)
// },1000)
// #endif
});
@@ -153,16 +133,14 @@ const selectDeviceId = async()=>{
// 查询本地缓存的设备状态是否绑定过
// let deviceId = uni.getStorageSync('app_device_id');// 本地设备ID
try {
// showAlert("safeSave=>"+safeSave)
safeSave.getSafeFile({ "key": "app_device_id" }, res2 => {
// showAlert("读取成功=>"+JSON.stringify(res2));
if (res2.code == 1) {
let deviceId = res2.data;
console.log("读取成功=>",deviceId)
showAlert("读取成功=>"+deviceId);
// showAlert("读取成功=>"+deviceId);
getBindStatus({uniqCode:deviceId}).then(res=>{
let bindStatus = res.bindStatus
setTimeout(()=>{
// setTimeout(()=>{
// 绑定状态1=已提交、2=等待审核、3=审核通过、4=绑定成功、5=审核拒绝)
if(bindStatus == 4){
// 检查是否已登录 并 获取用户信息
@@ -181,19 +159,20 @@ const selectDeviceId = async()=>{
url: '/pages/deviceAuth/deviceAuth',
});
}
},2000)
// },1000)
});
} else {
showAlert('读取失败:'+res2.msg)
setTimeout(()=>{
// showAlert('读取失败:'+res2.msg)
// setTimeout(()=>{
uni.reLaunch({
url: '/pages/deviceAuth/deviceAuth',
});
},2000)
// },1000)
}
})
} catch (error) {
showAlert("catch=>"+error)
console.log("getSafeFile=>",error)
// showAlert("catch=>"+error)
}
}
// 下载最新版本