|
|
|
@ -37,11 +37,41 @@ Component({ |
|
|
|
type: 1, |
|
|
|
type: 1, |
|
|
|
// 拍摄位置名称映射
|
|
|
|
// 拍摄位置名称映射
|
|
|
|
typeNameMap: { |
|
|
|
typeNameMap: { |
|
|
|
1: { name: '正面睁眼', group: '正面', index: 1, total: 3, tip: '平视,目光看向镜头方向,自然睁眼,不眯眼、不瞪眼。' }, |
|
|
|
1: { |
|
|
|
2: { name: '正面闭眼', group: '正面', index: 2, total: 3, tip: '正对镜头,面部居中,自然放松,双眼轻轻闭合,不皱眉、不挤眼。' }, |
|
|
|
name: '正面睁眼', |
|
|
|
3: { name: '正面仰头', group: '正面', index: 3, total: 3, tip: '拍摄时,正对镜头,面部居中,头部自然向上仰至约45°,双眼同步平视,保持自然睁眼、不眯眼。' }, |
|
|
|
group: '正面', |
|
|
|
4: { name: '左侧-90°', group: '侧面', index: 1, total: 4, tip: '身体与头部完全转向右侧,呈标准90°侧面,仅可见左侧眼睛。' }, |
|
|
|
index: 1, |
|
|
|
5: { name: '右侧-90°', group: '侧面', index: 2, total: 4, tip: '身体与头部完全转向左侧,呈标准90°侧面,仅可见右侧眼睛。' }, |
|
|
|
total: 3, |
|
|
|
|
|
|
|
tip: '平视,目光看向镜头方向,自然睁眼,不眯眼、不瞪眼。', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
2: { |
|
|
|
|
|
|
|
name: '正面闭眼', |
|
|
|
|
|
|
|
group: '正面', |
|
|
|
|
|
|
|
index: 2, |
|
|
|
|
|
|
|
total: 3, |
|
|
|
|
|
|
|
tip: '正对镜头,面部居中,自然放松,双眼轻轻闭合,不皱眉、不挤眼。', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
3: { |
|
|
|
|
|
|
|
name: '正面仰头', |
|
|
|
|
|
|
|
group: '正面', |
|
|
|
|
|
|
|
index: 3, |
|
|
|
|
|
|
|
total: 3, |
|
|
|
|
|
|
|
tip: '拍摄时,正对镜头,面部居中,头部自然向上仰至约45°,双眼同步平视,保持自然睁眼、不眯眼。', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
4: { |
|
|
|
|
|
|
|
name: '左侧-90°', |
|
|
|
|
|
|
|
group: '侧面', |
|
|
|
|
|
|
|
index: 1, |
|
|
|
|
|
|
|
total: 4, |
|
|
|
|
|
|
|
tip: '身体与头部完全转向右侧,呈标准90°侧面,仅可见左侧眼睛。', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
5: { |
|
|
|
|
|
|
|
name: '右侧-90°', |
|
|
|
|
|
|
|
group: '侧面', |
|
|
|
|
|
|
|
index: 2, |
|
|
|
|
|
|
|
total: 4, |
|
|
|
|
|
|
|
tip: '身体与头部完全转向左侧,呈标准90°侧面,仅可见右侧眼睛。', |
|
|
|
|
|
|
|
}, |
|
|
|
6: { name: '左侧-45°', group: '侧面', index: 3, total: 4, tip: '身体与头部转向右前方45°。' }, |
|
|
|
6: { name: '左侧-45°', group: '侧面', index: 3, total: 4, tip: '身体与头部转向右前方45°。' }, |
|
|
|
7: { name: '右侧-45°', group: '侧面', index: 4, total: 4, tip: '身体与头部转向左前方45°' }, |
|
|
|
7: { name: '右侧-45°', group: '侧面', index: 4, total: 4, tip: '身体与头部转向左前方45°' }, |
|
|
|
8: { name: '左上', group: '眼球运动', index: 1, total: 8, tip: '正对镜头,双眼向左上方看。' }, |
|
|
|
8: { name: '左上', group: '眼球运动', index: 1, total: 8, tip: '正对镜头,双眼向左上方看。' }, |
|
|
|
@ -133,11 +163,12 @@ Component({ |
|
|
|
}) |
|
|
|
}) |
|
|
|
// 如果设置了只使用相机,直接打开相机
|
|
|
|
// 如果设置了只使用相机,直接打开相机
|
|
|
|
if (this.properties.onlyCamera) { |
|
|
|
if (this.properties.onlyCamera) { |
|
|
|
|
|
|
|
this.checkCameraPermission(() => { |
|
|
|
this.setData({ |
|
|
|
this.setData({ |
|
|
|
visible: true, |
|
|
|
visible: true, |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
else { |
|
|
|
} else { |
|
|
|
this.setData({ |
|
|
|
this.setData({ |
|
|
|
selectShow: true, |
|
|
|
selectShow: true, |
|
|
|
}) |
|
|
|
}) |
|
|
|
@ -149,10 +180,47 @@ Component({ |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
handleCamera() { |
|
|
|
handleCamera() { |
|
|
|
|
|
|
|
// 先检查相机权限
|
|
|
|
|
|
|
|
this.checkCameraPermission(() => { |
|
|
|
this.setData({ |
|
|
|
this.setData({ |
|
|
|
selectShow: false, |
|
|
|
selectShow: false, |
|
|
|
visible: true, |
|
|
|
visible: true, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 检查相机权限
|
|
|
|
|
|
|
|
checkCameraPermission(callback: () => void) { |
|
|
|
|
|
|
|
wx.getSetting({ |
|
|
|
|
|
|
|
success: (res) => { |
|
|
|
|
|
|
|
if (res.authSetting['scope.camera'] != undefined && res.authSetting['scope.camera'] == true) { |
|
|
|
|
|
|
|
callback() |
|
|
|
|
|
|
|
} else if (res.authSetting['scope.camera'] == undefined) { |
|
|
|
|
|
|
|
callback() |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
wx.showModal({ |
|
|
|
|
|
|
|
title: '请求授权相机权限', |
|
|
|
|
|
|
|
content: '需要使用相机进行拍摄,请确认授权', |
|
|
|
|
|
|
|
confirmColor: '#8c75d0', |
|
|
|
|
|
|
|
success: (res) => { |
|
|
|
|
|
|
|
if (res.cancel) { |
|
|
|
|
|
|
|
wx.showToast({ title: '拒绝授权', icon: 'none' }) |
|
|
|
|
|
|
|
} else if (res.confirm) { |
|
|
|
|
|
|
|
wx.openSetting({ |
|
|
|
|
|
|
|
success: (res) => { |
|
|
|
|
|
|
|
if (res.authSetting['scope.camera'] == true) { |
|
|
|
|
|
|
|
callback() |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
wx.showToast({ title: '授权失败', icon: 'none' }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
handleHideCamera() { |
|
|
|
handleHideCamera() { |
|
|
|
this.triggerEvent('close') |
|
|
|
this.triggerEvent('close') |
|
|
|
@ -160,8 +228,7 @@ Component({ |
|
|
|
this.setData({ |
|
|
|
this.setData({ |
|
|
|
visible: false, |
|
|
|
visible: false, |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
else { |
|
|
|
|
|
|
|
this.setData({ |
|
|
|
this.setData({ |
|
|
|
visible: false, |
|
|
|
visible: false, |
|
|
|
selectShow: true, |
|
|
|
selectShow: true, |
|
|
|
@ -170,6 +237,8 @@ Component({ |
|
|
|
}, |
|
|
|
}, |
|
|
|
handlePicture() { |
|
|
|
handlePicture() { |
|
|
|
this.handleCancel() |
|
|
|
this.handleCancel() |
|
|
|
|
|
|
|
// 检查相册权限
|
|
|
|
|
|
|
|
this.checkAlbumPermission(() => { |
|
|
|
wx.chooseMedia({ |
|
|
|
wx.chooseMedia({ |
|
|
|
count: 1, |
|
|
|
count: 1, |
|
|
|
mediaType: ['image'], |
|
|
|
mediaType: ['image'], |
|
|
|
@ -180,7 +249,7 @@ Component({ |
|
|
|
const maxSize = 10 * 1024 * 1024 |
|
|
|
const maxSize = 10 * 1024 * 1024 |
|
|
|
if (tempFile.size > maxSize) { |
|
|
|
if (tempFile.size > maxSize) { |
|
|
|
wx.showToast({ |
|
|
|
wx.showToast({ |
|
|
|
title: '图片大小不能超过10M', |
|
|
|
title: '图片大小不能超过10MB', |
|
|
|
icon: 'none', |
|
|
|
icon: 'none', |
|
|
|
}) |
|
|
|
}) |
|
|
|
this.triggerEvent('uploaderror', { reason: 'file_too_large', size: tempFile.size, maxSize }) |
|
|
|
this.triggerEvent('uploaderror', { reason: 'file_too_large', size: tempFile.size, maxSize }) |
|
|
|
@ -196,6 +265,44 @@ Component({ |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 检查相册权限
|
|
|
|
|
|
|
|
checkAlbumPermission(callback: () => void) { |
|
|
|
|
|
|
|
wx.getSetting({ |
|
|
|
|
|
|
|
success: (res) => { |
|
|
|
|
|
|
|
if ( |
|
|
|
|
|
|
|
res.authSetting['scope.writePhotosAlbum'] != undefined && |
|
|
|
|
|
|
|
res.authSetting['scope.writePhotosAlbum'] == true |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
callback() |
|
|
|
|
|
|
|
} else if (res.authSetting['scope.writePhotosAlbum'] == undefined) { |
|
|
|
|
|
|
|
callback() |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
wx.showModal({ |
|
|
|
|
|
|
|
title: '请求授权相册权限', |
|
|
|
|
|
|
|
content: '需要访问相册选择照片,请确认授权', |
|
|
|
|
|
|
|
confirmColor: '#8c75d0', |
|
|
|
|
|
|
|
success: (res) => { |
|
|
|
|
|
|
|
if (res.cancel) { |
|
|
|
|
|
|
|
wx.showToast({ title: '拒绝授权', icon: 'none' }) |
|
|
|
|
|
|
|
} else if (res.confirm) { |
|
|
|
|
|
|
|
wx.openSetting({ |
|
|
|
|
|
|
|
success: (res) => { |
|
|
|
|
|
|
|
if (res.authSetting['scope.writePhotosAlbum'] == true) { |
|
|
|
|
|
|
|
callback() |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
wx.showToast({ title: '授权失败', icon: 'none' }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
openCamera() { |
|
|
|
openCamera() { |
|
|
|
this.setData({ |
|
|
|
this.setData({ |
|
|
|
@ -258,9 +365,27 @@ Component({ |
|
|
|
|
|
|
|
|
|
|
|
onCameraError(e: WechatMiniprogram.CustomEvent) { |
|
|
|
onCameraError(e: WechatMiniprogram.CustomEvent) { |
|
|
|
console.error('相机错误:', e.detail) |
|
|
|
console.error('相机错误:', e.detail) |
|
|
|
wx.showToast({ |
|
|
|
// 相机出错时引导用户去设置页开启权限
|
|
|
|
title: '相机权限未开启', |
|
|
|
wx.showModal({ |
|
|
|
icon: 'none', |
|
|
|
title: '请求授权相机权限', |
|
|
|
|
|
|
|
content: '需要使用相机进行拍摄,请确认授权', |
|
|
|
|
|
|
|
confirmColor: '#8c75d0', |
|
|
|
|
|
|
|
success: (res) => { |
|
|
|
|
|
|
|
if (res.cancel) { |
|
|
|
|
|
|
|
this.setData({ visible: false, selectShow: true }) |
|
|
|
|
|
|
|
} else if (res.confirm) { |
|
|
|
|
|
|
|
wx.openSetting({ |
|
|
|
|
|
|
|
success: (res) => { |
|
|
|
|
|
|
|
if (res.authSetting['scope.camera'] == true) { |
|
|
|
|
|
|
|
wx.showToast({ title: '授权成功', icon: 'success' }) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.setData({ visible: false, selectShow: true }) |
|
|
|
|
|
|
|
wx.showToast({ title: '授权失败', icon: 'none' }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
}) |
|
|
|
}) |
|
|
|
this.triggerEvent('error', { reason: 'permission_denied' }) |
|
|
|
this.triggerEvent('error', { reason: 'permission_denied' }) |
|
|
|
}, |
|
|
|
}, |
|
|
|
@ -275,13 +400,12 @@ Component({ |
|
|
|
const fileSize = (stats as WechatMiniprogram.Stats).size |
|
|
|
const fileSize = (stats as WechatMiniprogram.Stats).size |
|
|
|
if (fileSize > maxSize) { |
|
|
|
if (fileSize > maxSize) { |
|
|
|
wx.showToast({ |
|
|
|
wx.showToast({ |
|
|
|
title: '图片大小不能超过10M', |
|
|
|
title: '图片大小不能超过10MB', |
|
|
|
icon: 'none', |
|
|
|
icon: 'none', |
|
|
|
}) |
|
|
|
}) |
|
|
|
this.triggerEvent('uploaderror', { reason: 'file_too_large', size: fileSize, maxSize }) |
|
|
|
this.triggerEvent('uploaderror', { reason: 'file_too_large', size: fileSize, maxSize }) |
|
|
|
resolve(false) |
|
|
|
resolve(false) |
|
|
|
} |
|
|
|
} else { |
|
|
|
else { |
|
|
|
|
|
|
|
resolve(true) |
|
|
|
resolve(true) |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
@ -294,8 +418,7 @@ Component({ |
|
|
|
|
|
|
|
|
|
|
|
uploadImage(tempFilePath: string) { |
|
|
|
uploadImage(tempFilePath: string) { |
|
|
|
this.checkImageSize(tempFilePath).then((isValid) => { |
|
|
|
this.checkImageSize(tempFilePath).then((isValid) => { |
|
|
|
if (!isValid) |
|
|
|
if (!isValid) return |
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wx.showLoading({ |
|
|
|
wx.showLoading({ |
|
|
|
title: '正在上传', |
|
|
|
title: '正在上传', |
|
|
|
@ -313,8 +436,7 @@ Component({ |
|
|
|
const photoUrl = data.data.Url |
|
|
|
const photoUrl = data.data.Url |
|
|
|
// 第二步:调用 photo-upload 接口保存照片信息
|
|
|
|
// 第二步:调用 photo-upload 接口保存照片信息
|
|
|
|
this.savePhotoInfo(photoUrl) |
|
|
|
this.savePhotoInfo(photoUrl) |
|
|
|
} |
|
|
|
} else { |
|
|
|
else { |
|
|
|
|
|
|
|
wx.hideLoading() |
|
|
|
wx.hideLoading() |
|
|
|
wx.showToast({ |
|
|
|
wx.showToast({ |
|
|
|
title: '上传失败', |
|
|
|
title: '上传失败', |
|
|
|
@ -322,8 +444,7 @@ Component({ |
|
|
|
}) |
|
|
|
}) |
|
|
|
this.triggerEvent('uploaderror', { reason: 'upload_failed', data }) |
|
|
|
this.triggerEvent('uploaderror', { reason: 'upload_failed', data }) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
catch (e) { |
|
|
|
|
|
|
|
wx.hideLoading() |
|
|
|
wx.hideLoading() |
|
|
|
wx.showToast({ |
|
|
|
wx.showToast({ |
|
|
|
title: '解析响应失败', |
|
|
|
title: '解析响应失败', |
|
|
|
@ -355,15 +476,16 @@ Component({ |
|
|
|
method: 'GET', |
|
|
|
method: 'GET', |
|
|
|
url: '?r=xd/proptosis/get-session-id', |
|
|
|
url: '?r=xd/proptosis/get-session-id', |
|
|
|
data: {}, |
|
|
|
data: {}, |
|
|
|
}).then((res: any) => { |
|
|
|
}) |
|
|
|
|
|
|
|
.then((res: any) => { |
|
|
|
if (res.sessionId) { |
|
|
|
if (res.sessionId) { |
|
|
|
this.setData({ sessionIdCache: res.sessionId }) |
|
|
|
this.setData({ sessionIdCache: res.sessionId }) |
|
|
|
resolve(res.sessionId) |
|
|
|
resolve(res.sessionId) |
|
|
|
} |
|
|
|
} else { |
|
|
|
else { |
|
|
|
|
|
|
|
reject(new Error('sessionId not found')) |
|
|
|
reject(new Error('sessionId not found')) |
|
|
|
} |
|
|
|
} |
|
|
|
}).catch((err) => { |
|
|
|
}) |
|
|
|
|
|
|
|
.catch((err) => { |
|
|
|
reject(err) |
|
|
|
reject(err) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
@ -383,7 +505,8 @@ Component({ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 先获取 sessionId,再上传照片
|
|
|
|
// 先获取 sessionId,再上传照片
|
|
|
|
this.getSessionId().then((sessionId) => { |
|
|
|
this.getSessionId() |
|
|
|
|
|
|
|
.then((sessionId) => { |
|
|
|
const recordId = this.properties.recordId |
|
|
|
const recordId = this.properties.recordId |
|
|
|
wx.ajax({ |
|
|
|
wx.ajax({ |
|
|
|
method: 'POST', |
|
|
|
method: 'POST', |
|
|
|
@ -394,7 +517,8 @@ Component({ |
|
|
|
photoAngle, |
|
|
|
photoAngle, |
|
|
|
photoUrl, |
|
|
|
photoUrl, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}).then((res: any) => { |
|
|
|
}) |
|
|
|
|
|
|
|
.then((res: any) => { |
|
|
|
wx.hideLoading() |
|
|
|
wx.hideLoading() |
|
|
|
const { photoId, checkStatus, isContinue, message } = res |
|
|
|
const { photoId, checkStatus, isContinue, message } = res |
|
|
|
|
|
|
|
|
|
|
|
@ -423,15 +547,15 @@ Component({ |
|
|
|
confirmColor: '#8c75d0', |
|
|
|
confirmColor: '#8c75d0', |
|
|
|
cancelColor: '#141515', |
|
|
|
cancelColor: '#141515', |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} else if (checkStatus === 2 && isContinue) { |
|
|
|
else if (checkStatus === 2 && isContinue) { |
|
|
|
|
|
|
|
// 机审不通过但允许继续,提示用户
|
|
|
|
// 机审不通过但允许继续,提示用户
|
|
|
|
wx.showToast({ |
|
|
|
wx.showToast({ |
|
|
|
title: message || '图片可能不合规', |
|
|
|
title: message || '图片可能不合规', |
|
|
|
icon: 'none', |
|
|
|
icon: 'none', |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}).catch((err) => { |
|
|
|
}) |
|
|
|
|
|
|
|
.catch((err) => { |
|
|
|
wx.hideLoading() |
|
|
|
wx.hideLoading() |
|
|
|
wx.showToast({ |
|
|
|
wx.showToast({ |
|
|
|
title: '保存照片信息失败', |
|
|
|
title: '保存照片信息失败', |
|
|
|
@ -439,7 +563,8 @@ Component({ |
|
|
|
}) |
|
|
|
}) |
|
|
|
this.triggerEvent('uploaderror', { reason: 'save_photo_failed', error: err }) |
|
|
|
this.triggerEvent('uploaderror', { reason: 'save_photo_failed', error: err }) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}).catch((err) => { |
|
|
|
}) |
|
|
|
|
|
|
|
.catch((err) => { |
|
|
|
wx.hideLoading() |
|
|
|
wx.hideLoading() |
|
|
|
wx.showToast({ |
|
|
|
wx.showToast({ |
|
|
|
title: '获取会话ID失败', |
|
|
|
title: '获取会话ID失败', |
|
|
|
|