MrShi
10 小时以前 3f9032e92fdd383bfefc87a0bec9b242e1223851
app/utils/utils.js
@@ -77,6 +77,7 @@
         content: options.content,
         confirmText: options.confirmText,
         showCancel: false,
         confirmColor: '#106efa',
         success: (res) => {
            if (res.confirm) {
               uni.setStorageSync(LOCATION_NOTICE_STORAGE_KEY, true)
@@ -92,6 +93,8 @@
   })
}
let hasEmittedLocationPermissionGranted = false
export function getLocationWithNotice(locationOptions = {}, modalOptions = {}) {
   return ensureLocationPermissionNotice(modalOptions).then((confirmed) => {
      if (!confirmed) {
@@ -101,7 +104,10 @@
      return new Promise((resolve, reject) => {
         uni.getLocation(Object.assign({}, locationOptions, {
            success: (res) => {
               uni.$emit('locationPermissionGranted', res)
               if (!hasEmittedLocationPermissionGranted) {
                  hasEmittedLocationPermissionGranted = true
                  uni.$emit('locationPermissionGranted', res)
               }
               if (typeof locationOptions.success === 'function') {
                  locationOptions.success(res)
               }
@@ -162,11 +168,43 @@
               resolve(res)
            },
            fail: (err) => {
               console.log('chooseImage fail', err)
               const errMsg = (err && err.errMsg) || ''
               if (errMsg && !/cancel/i.test(errMsg)) {
               const errCode = (err && err.errCode) || ''
               if (errMsg && errMsg.includes('chooseImage:fail No Permission')) {
                  // const sourceType = imageOptions.sourceType || ['album', 'camera']
                  let toastTitle = ''
                  // 拍照权限
                  // 拍照权限
                  if (errCode === 11) {
                     toastTitle = '相机权限已关闭,请前往手机【设置】中手动开启'
                  }
                  // 相册权限
                  if (errCode === 12) {
                     toastTitle = '相册权限已关闭,请前往手机【设置】中手动开启'
                  }
                  // if (sourceType.length === 1) {
                  //    if (sourceType[0] === 'album') {
                  //       toastTitle = '相册权限已关闭,请前往手机【设置】中手动开启'
                  //    } else if (sourceType[0] === 'camera') {
                  //       toastTitle = '相机权限已关闭,请前往手机【设置】中手动开启'
                  //    }
                  // } else {
                  //    if (errMsg.includes('camera') || errMsg.includes('Camera')) {
                  //       toastTitle = '相机权限已关闭,请前往手机【设置】中手动开启'
                  //    } else if (errMsg.includes('album') || errMsg.includes('Album') || errMsg.includes('photo') || errMsg.includes('Photo')) {
                  //       toastTitle = '相册权限已关闭,请前往手机【设置】中手动开启'
                  //    }
                  // }
                  uni.showToast({
                     title: '需要授权相机权限',
                     icon: 'none'
                     title: toastTitle,
                     icon: 'none',
                     duration: 3000
                  })
               }
               if (typeof imageOptions.fail === 'function') {