记uniapp uview图片上传组件处理--关于华为应用市场上架,申请权限未告知目的被驳回问题

566 阅读1分钟

最近有发布华为应用市场的需求,但是隐私审核通不过,于是借鉴了插件市场和社区的文章解决了,如果是单个操作提示,不用这么麻烦。1.这里涉及到“相机”和“从相册选择”两个方法,直接引用uview的u-upload好像没有监听是选择哪一个的方法,从而触发隐私弹窗,2.根据这个插件市场作者的回复,直接copy一个了u-upload,然后在里面改造,u-action-sheet操作菜单上通过点击的选项来实现触发相相机还是相册

image.png

提示框使用的社区里的plus.nativeObj.View,隐私提示才不会被权限弹窗遮挡

authpup.vue
.....其他内容参考插件.......

 //提示框  
 
    nativeObjView({  
        state  
    }, permissionID) {  
        const systemInfo = uni.getSystemInfoSync();  
        const statusBarHeight = systemInfo.statusBarHeight;  
        const navigationBarHeight = systemInfo.platform === 'android' ? 48 :  
            44; // Set the navigation bar height based on the platform  
        const totalHeight = statusBarHeight + navigationBarHeight;  
        let view = new plus.nativeObj.View('per-modal', {  
            top: '0px',  
            left: '0px',  
            width: '100%',  
             backgroundColor: 'rgba(0,0,0,0.2)', 
         })  
  })

u-upload改造

u-upload.vue
        <template>
            	<u-action-sheet :list="sheetList" v-model="sheetShow" @click="onSheetSelect"></u-action-sheet>
		<authpup ref="authpup" type="top" @changeAuth="changeAuth" :permissionID="permissionID"></authpup>
        </template>

        data() {
                return {
                        sheetList: [
                                        {
                                                text: '拍摄',
                                                permissionID:'CAMERA',
                                        }, {
                                                text: '从相册选择' ,
                                                permissionID:'WRITE_EXTERNAL_STORAGE'
                                        }],
                                        sheetShow: false,
                                        permissionID:''
                };
        },
    	methods: {
		onSheetSelect(index){
                    this.permissionID = this.sheetList[index].permissionID
                    setTimeout(()=>{
                            this.$refs['authpup'].open();
                    },500)
				
		},
		//用户授权权限后的回调
		changeAuth(){
			//这里是权限通过后执行自己的代码逻辑
			this.selectFile()
		},
                
          selectFile(){
              uni.chooseImage({
                    sourceType:[this.permissionID=='CAMERA'?'camera':'album'],
               });
          }
        }

参考链接: