2025-04-03 11:12:42 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<page-meta :page-font-size="fontValue+'px'" :root-font-size="fontValue+'px'"></page-meta>
|
2025-01-16 11:09:35 +08:00
|
|
|
|
<view class="container">
|
|
|
|
|
|
<!-- 顶部导航栏 -->
|
|
|
|
|
|
<!-- <view class="header">-->
|
|
|
|
|
|
<!-- <view class="back-icon" @click="goBack">-->
|
|
|
|
|
|
<!-- <image class="icon" :src="require('@/static/images/icons/back.png')" mode="aspectFit"></image>-->
|
|
|
|
|
|
<!-- </view>-->
|
|
|
|
|
|
<!-- <text class="title">人脸上传</text>-->
|
|
|
|
|
|
<!-- </view>-->
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
<!-- 主要内容区域 -->
|
|
|
|
|
|
<view class="content">
|
|
|
|
|
|
<!-- 上传区域 -->
|
|
|
|
|
|
<view class="upload-area" @click="handleChooseImage">
|
2025-02-19 09:34:34 +08:00
|
|
|
|
<view class="upload-box" :class="{ 'has-image': facePhotoUrl }">
|
|
|
|
|
|
<image v-if="facePhotoUrl" :src="facePhotoUrl" mode="aspectFill" class="preview-image" />
|
2025-01-16 11:09:35 +08:00
|
|
|
|
<view v-else class="upload-placeholder">
|
|
|
|
|
|
<image class="camera-icon" :src="require('@/static/images/my/camera.png')" mode="aspectFill"></image>
|
|
|
|
|
|
<text class="upload-text">点击上传照片</text>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
<!-- 提示信息 -->
|
|
|
|
|
|
<view class="tips">
|
|
|
|
|
|
<text class="tip-item">·五官端正,面部无遮挡(请使用人脸照片)</text>
|
2025-08-13 15:49:15 +08:00
|
|
|
|
<text class="tip-item">·不要带饰品(如墨镜等)</text>
|
2025-01-16 11:09:35 +08:00
|
|
|
|
<text class="tip-item">·请在光线明亮的纯色背景下拍照(建议背景颜色为白色)</text>
|
|
|
|
|
|
<text class="tip-item">·上传照片后需保存,保存失败照片将被清除</text>
|
|
|
|
|
|
</view>
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
<!-- 隐私协议 -->
|
|
|
|
|
|
<!-- <view class="privacy-agreement">-->
|
|
|
|
|
|
<!-- <checkbox-->
|
|
|
|
|
|
<!-- :checked="agreed"-->
|
|
|
|
|
|
<!-- @click="agreed = !agreed"-->
|
|
|
|
|
|
<!-- color="#FF8126"-->
|
|
|
|
|
|
<!-- />-->
|
|
|
|
|
|
<!-- <text class="agreement-text">我已阅读并同意</text>-->
|
|
|
|
|
|
<!-- <text class="agreement-link" @click="showAgreement">《东华管理生物特征采集私隐声明》</text>-->
|
|
|
|
|
|
<!-- </view>-->
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
<!-- 按钮组 -->
|
|
|
|
|
|
<view class="button-group">
|
|
|
|
|
|
<button class="submit-btn" :disabled="!agreed || !imageUrl" @click="handleUpload">确定上传</button>
|
|
|
|
|
|
<button class="cancel-btn" @click="goBack">取消</button>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
2025-01-03 18:28:23 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2025-04-27 15:58:51 +08:00
|
|
|
|
|
2025-02-19 09:34:34 +08:00
|
|
|
|
import { queryFacePhotoApi,uploadPhotoGenCodeForAppApi } from '@/api/mine/index'
|
|
|
|
|
|
import { uploadBase64 } from "@/api/upload"
|
|
|
|
|
|
import { pathToBase64, base64ToPath } from 'image-tools';
|
2025-08-13 15:49:15 +08:00
|
|
|
|
import Compressor from 'compressorjs';
|
|
|
|
|
|
import ImageCompressor from 'image-compressor.js';
|
2025-04-22 13:05:32 +08:00
|
|
|
|
import config from '@/config'
|
2025-02-19 09:34:34 +08:00
|
|
|
|
import { showConfirm } from '@/utils/common'
|
2025-01-16 11:09:35 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
2025-04-27 15:58:51 +08:00
|
|
|
|
fontValue:uni.getStorageSync('fontSize') || 8,
|
2025-02-19 09:34:34 +08:00
|
|
|
|
facePhotoUrl:"",
|
2025-01-16 11:09:35 +08:00
|
|
|
|
imageUrl: '',
|
|
|
|
|
|
agreed: true,
|
2025-02-19 09:34:34 +08:00
|
|
|
|
userInfo: {},
|
|
|
|
|
|
faceData:{}
|
2025-01-16 11:09:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
onLoad() {
|
2025-02-19 09:34:34 +08:00
|
|
|
|
this.getFacePhoto()
|
2025-01-16 11:09:35 +08:00
|
|
|
|
},
|
2025-02-19 09:34:34 +08:00
|
|
|
|
methods: {
|
|
|
|
|
|
getFacePhoto(){
|
2025-04-27 15:58:51 +08:00
|
|
|
|
queryFacePhotoApi({"custId":uni.getStorageSync('custId')}).then(res => {
|
2025-02-19 09:34:34 +08:00
|
|
|
|
console.log(res)
|
|
|
|
|
|
this.facePhotoUrl = res.facePhotoUrl
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2025-01-16 11:09:35 +08:00
|
|
|
|
goBack() {
|
|
|
|
|
|
uni.navigateBack()
|
|
|
|
|
|
},
|
2025-02-19 09:34:34 +08:00
|
|
|
|
imgToBase64(data) {
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
|
pathToBase64(data)
|
|
|
|
|
|
.then(base64 => {
|
|
|
|
|
|
resolve(base64)
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch(error => {
|
|
|
|
|
|
console.error(error)
|
|
|
|
|
|
reject(error)
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
uploadFaceImg(){
|
|
|
|
|
|
let param = {
|
2025-02-21 10:03:35 +08:00
|
|
|
|
"MERCHANT-ID":"378915229716713472",
|
2025-02-19 09:34:34 +08:00
|
|
|
|
"uploadKey":'face',
|
|
|
|
|
|
"base64File":this.base64
|
|
|
|
|
|
}
|
|
|
|
|
|
uploadBase64(param).then(res => {
|
|
|
|
|
|
console.log(res)
|
|
|
|
|
|
if(res.code==200){
|
|
|
|
|
|
this.faceData = res.data
|
|
|
|
|
|
}else{
|
|
|
|
|
|
this.faceData = {}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2025-01-16 11:09:35 +08:00
|
|
|
|
handleChooseImage() {
|
|
|
|
|
|
uni.chooseImage({
|
2025-08-13 15:49:15 +08:00
|
|
|
|
count: 1,
|
|
|
|
|
|
sizeType:["compressed"],
|
2025-02-19 09:34:34 +08:00
|
|
|
|
success: resImage => {
|
|
|
|
|
|
console.log(resImage)
|
|
|
|
|
|
this.facePhotoUrl = resImage.tempFilePaths[0]
|
|
|
|
|
|
this.imageUrl = resImage.tempFilePaths[0]
|
2025-08-13 15:49:15 +08:00
|
|
|
|
const tempFile = resImage.tempFiles[0];
|
|
|
|
|
|
console.log(tempFile)
|
|
|
|
|
|
this.compressFile(tempFile).then(res => {
|
|
|
|
|
|
console.log(res)
|
|
|
|
|
|
const url = URL.createObjectURL(res)
|
|
|
|
|
|
this.imgToBase64(url).then(base64 => {
|
|
|
|
|
|
console.log(base64)
|
|
|
|
|
|
this.base64=base64;
|
|
|
|
|
|
this.uploadFaceImg()
|
|
|
|
|
|
})
|
2025-02-19 09:34:34 +08:00
|
|
|
|
})
|
2025-01-16 11:09:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
2025-08-13 15:49:15 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
handleUpload() {
|
2025-02-19 09:34:34 +08:00
|
|
|
|
console.log(this.imageUrl)
|
|
|
|
|
|
if (!this.agreed || !this.imageUrl) return
|
2025-01-16 11:09:35 +08:00
|
|
|
|
uni.showLoading({
|
|
|
|
|
|
title: '上传中...'
|
|
|
|
|
|
})
|
2025-02-19 09:34:34 +08:00
|
|
|
|
let param = {
|
2025-04-27 15:58:51 +08:00
|
|
|
|
"custId": uni.getStorageSync('custId'),
|
|
|
|
|
|
"openid": uni.getStorageSync('openId'),
|
2025-02-19 09:34:34 +08:00
|
|
|
|
"sourceType": "7",
|
|
|
|
|
|
"photoUrl": this.faceData.fileNameUrl
|
|
|
|
|
|
}
|
|
|
|
|
|
uploadPhotoGenCodeForAppApi(param).then(res => {
|
|
|
|
|
|
console.log(res)
|
2025-02-21 10:03:35 +08:00
|
|
|
|
if(res.code==200){
|
|
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: '保存成功',
|
|
|
|
|
|
icon: 'success'
|
|
|
|
|
|
});
|
|
|
|
|
|
}else{
|
|
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: res.msg,
|
|
|
|
|
|
icon: 'success'
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2025-02-19 09:34:34 +08:00
|
|
|
|
// if(res)
|
2025-08-13 15:49:15 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
compressFile(file) {
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
|
const options = {
|
|
|
|
|
|
success(result) {
|
|
|
|
|
|
// 将压缩后的 Blob 转换为 File 对象(如果组件支持Blob则不用这一步)
|
|
|
|
|
|
const compressedFile = new File([result], file.name, {
|
|
|
|
|
|
type: file.type,
|
|
|
|
|
|
lastModified: Date.now(),
|
|
|
|
|
|
});
|
|
|
|
|
|
return resolve(compressedFile);
|
|
|
|
|
|
},
|
|
|
|
|
|
error(e) {
|
|
|
|
|
|
return reject(e);
|
|
|
|
|
|
},
|
|
|
|
|
|
};
|
|
|
|
|
|
// 1-3MB
|
|
|
|
|
|
if (file.size > 0.5 * 1024 * 1024 && file.size <= 3 * 1024 * 1024) {
|
|
|
|
|
|
options.quality = 0.3; // 压缩质量
|
|
|
|
|
|
options.convertSize = false;//不进行图像尺寸的调整
|
|
|
|
|
|
options.checkOrientation = false; // 图片翻转,默认为false
|
|
|
|
|
|
}
|
|
|
|
|
|
// 3-4MB
|
|
|
|
|
|
if (file.size > 3 * 1024 * 1024 && file.size <= 4 * 1024 * 1024) {
|
|
|
|
|
|
options.quality = 0.25; // 压缩质量
|
|
|
|
|
|
options.convertSize = false;//不进行图像尺寸的调整
|
|
|
|
|
|
options.checkOrientation = false; // 图片翻转,默认为false
|
|
|
|
|
|
}
|
|
|
|
|
|
// 5-6MB
|
|
|
|
|
|
if (file.size > 5 * 1024 * 1024 && file.size <= 6 * 1024 * 1024) {
|
|
|
|
|
|
options.quality = 0.2; // 压缩质量
|
|
|
|
|
|
options.convertSize = false;//不进行图像尺寸的调整
|
|
|
|
|
|
options.checkOrientation = false; // 图片翻转,默认为false
|
|
|
|
|
|
}
|
|
|
|
|
|
// 6-7MB
|
|
|
|
|
|
if (file.size > 6 * 1024 * 1024 && file.size <= 7 * 1024 * 1024) {
|
|
|
|
|
|
options.quality = 0.15; // 压缩质量
|
|
|
|
|
|
options.convertSize = false;//不进行图像尺寸的调整
|
|
|
|
|
|
options.checkOrientation = false; // 图片翻转,默认为false
|
|
|
|
|
|
}
|
|
|
|
|
|
// 7-9MB
|
|
|
|
|
|
if (file.size > 7 * 1024 * 1024 && file.size <= 9 * 1024 * 1024) {
|
|
|
|
|
|
options.quality = 0.1; // 压缩质量
|
|
|
|
|
|
options.convertSize = false;//不进行图像尺寸的调整
|
|
|
|
|
|
options.checkOrientation = false; // 图片翻转,默认为false
|
|
|
|
|
|
}
|
|
|
|
|
|
new ImageCompressor(file, options);
|
|
|
|
|
|
});
|
2025-01-16 11:09:35 +08:00
|
|
|
|
},
|
|
|
|
|
|
showAgreement() {
|
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
|
url: '/pages/privacy-agreement/index'
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-01-03 18:28:23 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
2025-01-16 11:09:35 +08:00
|
|
|
|
.container {
|
|
|
|
|
|
min-height: 100vh;
|
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
|
}
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
.header {
|
|
|
|
|
|
padding: 44px 32rpx 0;
|
|
|
|
|
|
height: 88rpx;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
.back-icon {
|
|
|
|
|
|
padding: 20rpx;
|
|
|
|
|
|
margin-left: -20rpx;
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
.icon {
|
|
|
|
|
|
width: 40rpx;
|
|
|
|
|
|
height: 40rpx;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
.title {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
font-size: 34rpx;
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
color: #333;
|
|
|
|
|
|
margin-right: 60rpx;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
.content {
|
|
|
|
|
|
padding: 32rpx;
|
|
|
|
|
|
}
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
.upload-area {
|
|
|
|
|
|
margin-bottom: 48rpx;
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
.upload-box {
|
|
|
|
|
|
width: 75%;
|
|
|
|
|
|
height: 400rpx;
|
|
|
|
|
|
border: 2rpx dashed #CCCCCC;
|
|
|
|
|
|
border-radius: 16rpx;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
|
}
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
&.has-image {
|
|
|
|
|
|
border-style: solid;
|
|
|
|
|
|
}
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
.preview-image {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
object-fit: cover;
|
|
|
|
|
|
}
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
.upload-placeholder {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
align-items: center;
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
.camera-icon {
|
|
|
|
|
|
width: 80rpx;
|
|
|
|
|
|
height: 80rpx;
|
|
|
|
|
|
margin-bottom: 16rpx;
|
|
|
|
|
|
}
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
.upload-text {
|
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
|
color: #999;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
|
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
.tips {
|
|
|
|
|
|
margin-bottom: 48rpx;
|
|
|
|
|
|
width: 75%;
|
|
|
|
|
|
margin-left: auto;
|
|
|
|
|
|
margin-right: auto;
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
.tip-item {
|
|
|
|
|
|
display: block;
|
|
|
|
|
|
font-size: 24rpx;
|
|
|
|
|
|
color: #999;
|
|
|
|
|
|
line-height: 1.6;
|
|
|
|
|
|
text-align: left;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
.privacy-agreement {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
margin-bottom: 48rpx;
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
/deep/ .uni-checkbox-input {
|
|
|
|
|
|
border-radius: 50% !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
.button-group {
|
|
|
|
|
|
margin-top: 32rpx;
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
.submit-btn {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 88rpx;
|
|
|
|
|
|
background: #FF8126;
|
|
|
|
|
|
color: #fff;
|
|
|
|
|
|
font-size: 32rpx;
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
border-radius: 44rpx;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
border: none;
|
|
|
|
|
|
margin-bottom: 24rpx;
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
&:disabled {
|
|
|
|
|
|
opacity: 0.5;
|
|
|
|
|
|
}
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
&:active {
|
|
|
|
|
|
opacity: 0.9;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-01-03 18:28:23 +08:00
|
|
|
|
|
2025-01-16 11:09:35 +08:00
|
|
|
|
.cancel-btn {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 88rpx;
|
|
|
|
|
|
background: #fff;
|
|
|
|
|
|
color: #333;
|
|
|
|
|
|
font-size: 32rpx;
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
border-radius: 44rpx;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
border: 2rpx solid #CCCCCC;
|
|
|
|
|
|
|
|
|
|
|
|
&:active {
|
|
|
|
|
|
background: #f5f5f5;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|