From 3f9032e92fdd383bfefc87a0bec9b242e1223851 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期二, 09 六月 2026 17:08:44 +0800
Subject: [PATCH] 改bug

---
 app/utils/utils.js |   46 ++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/app/utils/utils.js b/app/utils/utils.js
index eefaa45..962a9b5 100644
--- a/app/utils/utils.js
+++ b/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') {

--
Gitblit v1.9.3