uni.getSystemInfo({
success: function(res) {
console.log(res)
if(platform == 'android') {
// 加判断 deviceId 是否存在逗号
if(res.deviceId.indexOf(",") != -1 ){
// console.log("有逗号")
res.deviceId = res.deviceId.split(",")[0]
}
// console.log(res.deviceId)
This.globalData.sn = "VNA" + res.deviceId;
uni.setStorageSync("sn",This.globalData.sn);
uni.setStorageSync("isIOS",false);
} else if(platform == 'ios') {
res.deviceId = This.md5(res.deviceId,16);
console.log(res.deviceId);
This.globalData.sn = "VNI" + res.deviceId;
uni.setStorageSync("sn",This.globalData.sn);
uni.setStorageSync("isIOS",true);
} else {
console.log(platform)
This.globalData.isH5 = true,
console.log(This.globalData.isH5)
console.log(res)
This.globalData.sn = "VNP" + res.deviceId;
uni.setStorageSync("sn",This.globalData.sn);
uni.setStorageSync("isIOS",false);
}
uni.setStorageSync("ver",This.globalData.ver);
}
});
- 发布:2023-04-14 14:10
- 更新:2023-04-14 14:10
- 阅读:432
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: win10
HBuilderX类型: 正式
HBuilderX版本号: 3.4.7
手机系统: Android
手机系统版本号: Android 12
手机厂商: 小米
手机机型: 小米10
页面类型: vue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
操作步骤:
1.获取deviceId
2.打包app上架
3.再次打包查看deviceId是否变化
1.获取deviceId
2.打包app上架
3.再次打包查看deviceId是否变化
预期结果:
同一设备获取的deviceId不变或者至少为16位数的deviceId
同一设备获取的deviceId不变或者至少为16位数的deviceId
实际结果:
同一设备获取的deviceId有时为16位数,有时为32位数
同一设备获取的deviceId有时为16位数,有时为32位数
bug描述:
我在使用hbuilderx 3.4.7版本打包我的app。其中使用到了uni.getSystemInfo获取设备的deviceId。在app的某个版本中设备的deviceId为16位数的deviceId,例如334cfda4b5dabfce这样,但在之后的打包后的版本中,deviceId变成了32位数的58DBA22F65CDD2C4079CB36A9E878373。(源代码未发生改变,且为同一设备)。我想知道 为什么会出现这种情况,以及这种情况是否跟hbuilder的版本有关系。我该怎么解决这个问题,使uni.getSystemInfo获取到的deviceId始终为16位数。(另外我试过将hbuilderx版本升到3.4.18和最新版本都有这个问题)