May丶泡泡
May丶泡泡
  • 发布:2022-11-02 17:44
  • 更新:2023-02-08 16:05
  • 阅读:433

【报Bug】应用安装成功第一次获取的uuid不正确,第二次以后进入APP获取的uuid是正确的。

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: 10

HBuilderX类型: Alpha

HBuilderX版本号: 3.6.8

手机系统: Android

手机系统版本号: Android 11

手机厂商: 华为

手机机型: HONOR Pad View7

页面类型: vue

vue版本: vue2

打包方式: 离线

项目创建方式: HBuilderX

示例代码:
<template>  
	<view class="content">  
		<image class="logo" @click="getUuid" src="/static/logo.png"></image>  
		<view class="text-area">  
			<text class="title">{{title}}</text>  
		</view>  
	</view>  
</template>  
  
<script>  
	export default {  
		data() {  
			return {  
				title: 'Hello'  
			}  
		},  
		onLoad() {  
			  
  
		},  
		methods: {  
			getUuid(){  
				plus.device.getInfo({  
				  success: function (e) {  
							uni.showModal({  
								title: '提示',  
								content: JSON.stringify(e),  
								success: function (res) {  
									if (res.confirm) {  
										console.log('用户点击确定');  
									} else if (res.cancel) {  
										console.log('用户点击取消');  
									}  
								}  
							});  
				    // console.log('getDeviceInfo success: ' + JSON.stringify(e));  
				    uni.setStorageSync('uuid', e.uuid)  
				    resolve(e.uuid)  
				  },  
				  fail: function (e) {  
				    console.log('getDeviceInfo failed: ' + JSON.stringify(e));  
				  }  
				});  
			}  
		}  
	}  
</script>  
  
<style>  
	.content {  
		display: flex;  
		flex-direction: column;  
		align-items: center;  
		justify-content: center;  
	}  
  
	.logo {  
		height: 200rpx;  
		width: 200rpx;  
		margin-top: 200rpx;  
		margin-left: auto;  
		margin-right: auto;  
		margin-bottom: 50rpx;  
	}  
  
	.text-area {  
		display: flex;  
		justify-content: center;  
	}  
  
	.title {  
		font-size: 36rpx;  
		color: #8f8f94;  
	}  
</style>  

操作步骤:

创建一个uni-app项目,把pages\index\index.vue改成下面这个代码,运行到安卓手机上,第一次进入点击Logo获得的是32位的,退出应用再次进入再点击Logo是正确的。

<template>  
	<view class="content">  
		<image class="logo" @click="getUuid" src="/static/logo.png"></image>  
		<view class="text-area">  
			<text class="title">{{title}}</text>  
		</view>  
	</view>  
</template>  
  
<script>  
	export default {  
		data() {  
			return {  
				title: 'Hello'  
			}  
		},  
		onLoad() {  
			  
  
		},  
		methods: {  
			getUuid(){  
				plus.device.getInfo({  
				  success: function (e) {  
							uni.showModal({  
								title: '提示',  
								content: JSON.stringify(e),  
								success: function (res) {  
									if (res.confirm) {  
										console.log('用户点击确定');  
									} else if (res.cancel) {  
										console.log('用户点击取消');  
									}  
								}  
							});  
				    // console.log('getDeviceInfo success: ' + JSON.stringify(e));  
				    uni.setStorageSync('uuid', e.uuid)  
				    resolve(e.uuid)  
				  },  
				  fail: function (e) {  
				    console.log('getDeviceInfo failed: ' + JSON.stringify(e));  
				  }  
				});  
			}  
		}  
	}  
</script>  
  
<style>  
	.content {  
		display: flex;  
		flex-direction: column;  
		align-items: center;  
		justify-content: center;  
	}  
  
	.logo {  
		height: 200rpx;  
		width: 200rpx;  
		margin-top: 200rpx;  
		margin-left: auto;  
		margin-right: auto;  
		margin-bottom: 50rpx;  
	}  
  
	.text-area {  
		display: flex;  
		justify-content: center;  
	}  
  
	.title {  
		font-size: 36rpx;  
		color: #8f8f94;  
	}  
</style>  

预期结果:

2147f2006035cc0c

实际结果:

ba2aa798fc614f65a7bd42b4b865726e

bug描述:

应用安装完成后第一次获取设备uuid得到的是32位的字符串,当应用关闭第二次以后进入的才是正确的uuid。
HBuilderX3.6.4也是一样的问题,3.6.3在线运行没问题但是离线打包就有问题。

2022-11-02 17:44 负责人:无 分享
已邀请:
9***@qq.com

9***@qq.com

我也遇到了相同的问题,我估计是第一次打开APP时,没有检测到授权,所以返回了一个随机的字符串。

diyiying

diyiying

我也是遇到这个问题,请问您解决了么?

diyiying

diyiying

我也是遇到这个问题,请问您解决了么?

兔兔Z

兔兔Z

我也遇到了这个问题,请问您最后解决了吗

要回复问题请先登录注册