You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
906 B
TypeScript
28 lines
906 B
TypeScript
|
8 months ago
|
import { t } from './i18n'
|
||
|
|
|
||
|
|
export const handleNoPermission = (res: any): void => {
|
||
|
|
if (
|
||
|
|
uni.getSystemInfoSync().platform == 'android' ||
|
||
|
|
uni.getSystemInfoSync().platform == 'ios'
|
||
|
|
) {
|
||
|
|
const appAuthorizeSetting = uni.getAppAuthorizeSetting()
|
||
|
|
//点击取消时不出现弹窗
|
||
|
|
const isCameraDenied = appAuthorizeSetting.cameraAuthorized === 'denied'
|
||
|
|
const isUserCancelled =
|
||
|
|
res.errMsg === 'chooseImage:fail User cancelled' ||
|
||
|
|
res.errMsg === 'chooseImage:fail cancel' ||
|
||
|
|
res.errMsg === 'chooseVideo:fail cancel' ||
|
||
|
|
res.errMsg === 'chooseVideo:fail User cancelled'
|
||
|
|
if (
|
||
|
|
(res.code === 11 && isCameraDenied && !isUserCancelled) ||
|
||
|
|
(res.code === 12 && isCameraDenied && !isUserCancelled) ||
|
||
|
|
(res.code === 2 && !isUserCancelled)
|
||
|
|
) {
|
||
|
|
uni.showToast({
|
||
|
|
icon: 'none',
|
||
|
|
title: t('addPermissionText'),
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|