|
|
@@ -132,6 +132,12 @@
|
|
|
<view class="save" @tap='setChatSave(1)'>发送</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
+ <!-- 权限说明弹窗 -->
|
|
|
+ <u-popup mode="top" ref="permission">
|
|
|
+ <view class="popup-content">
|
|
|
+ <view class="popup-text-permission">选择/拍摄照片需要相机/相册权限,用于上传用户头像</view>
|
|
|
+ </view>
|
|
|
+ </u-popup>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
@@ -527,25 +533,18 @@
|
|
|
this.content = '';
|
|
|
},
|
|
|
//发送图片
|
|
|
- chooseImage(sourceType) {
|
|
|
+ async chooseImage(sourceType) {
|
|
|
+ // 1. 检查权限状态
|
|
|
+ const hasPermission = await this.$queue.checkPermission(
|
|
|
+ 'camera',
|
|
|
+ '选择/拍摄照片需要相机/相册权限,用于上传用户头像',
|
|
|
+ this
|
|
|
+ );
|
|
|
|
|
|
- // 1. 先判断系统类型,区分Android/iOS权限
|
|
|
- const systemInfo = uni.getSystemInfoSync();
|
|
|
- const isAndroid = systemInfo.system.includes('Android');
|
|
|
- const permissionType = isAndroid ? 'storage' : 'photos'; // Android=存储,iOS=相册
|
|
|
-
|
|
|
- // 2. 权限检查(复用之前封装的 checkPermission 函数)
|
|
|
- const hasPermission = this.$queue.checkPermission(
|
|
|
- permissionType,
|
|
|
- isAndroid
|
|
|
- ? '选择/拍摄照片需要相机/相册权限,用于上传消息沟通图片' // Android 专属提示
|
|
|
- : '选择/拍摄照片需要相机/相册权限,用于上传消息沟通图片'
|
|
|
- );
|
|
|
-
|
|
|
- if (!hasPermission) {
|
|
|
- uni.showToast({ title: '未获取权限,无法选择照片', icon: 'none' });
|
|
|
- return;
|
|
|
- }
|
|
|
+ // 2. 如果未授权或者用户拒绝,显示提示
|
|
|
+ if (!hasPermission) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
uni.chooseImage({
|
|
|
count: 1,
|