From 3070dc87c0a848a03f36941fcefcf117a000ad34 Mon Sep 17 00:00:00 2001
From: "SD-20230427NBFT\\Administrator" <609306725@qq.com>
Date: Thu, 1 Aug 2024 10:26:46 +0800
Subject: [PATCH] 11111
---
config/unit.js | 31 +++++------
pagesA/merge/face_1.vue | 115 ++++++++++++++++++++++++----------------
pagesA/merge/idcard.vue | 20 +++++--
pagesA/merge/this.scss | 2 +-
4 files changed, 100 insertions(+), 68 deletions(-)
diff --git a/config/unit.js b/config/unit.js
index 3f4e7cf..28d54f2 100644
--- a/config/unit.js
+++ b/config/unit.js
@@ -1,28 +1,25 @@
var unit ={
-
-
getImgInfo:function(filePath){
function getInfo(resolve, reject) {
+ uni.getImageInfo({
+ src: filePath,
+ success: function (image) {
+
+ resolve(image);
+ },
+ fail: (res) => {
+
+ reject(res);
+ },
+ });
- try {
- uni.getImageInfo({
- src: filePath,
- success: function (image) {
- resolve(image);
- },
- fail: (res) => {
- reject(res);
- },
- });
- return new Promise(getInfo);
- } catch (error) {
- console.log(error)
- }
}
-
+ return new Promise(getInfo);
},
+
+
compressImg:function(filePath, config = {}){
const { width = '', quality = 80 } = config;
return new Promise((resolve, reject) => {
diff --git a/pagesA/merge/face_1.vue b/pagesA/merge/face_1.vue
index 04d9761..a9f1fa8 100644
--- a/pagesA/merge/face_1.vue
+++ b/pagesA/merge/face_1.vue
@@ -52,8 +52,8 @@
以下照片不合格,请重新上传
-
-
+
+
@@ -72,9 +72,9 @@
服务说明
- 1.AI生成写真实际效果与您上传的照片有关,请认真上传。
+ 1.面部档案实际效果与您上传的照片有关,请认真上传。
2.生成高峰期,可能会有排队情况,请耐心等候。
- 3.如需更换写真人物, 请前往【我的】增加人物的面部档案。
+ 3.稍后请前往【我的】增加人物的面部档案。
确认
@@ -134,7 +134,7 @@
setSuccessFiles() {
this.uploadFiles = uni.getStorageSync('ai_face_success');
- console.log('&&&&&&&&&&&&&&&&&&&&&&&&&&', this.uploadFiles);
+ // console.log('&&&&&&&&&&&&&&&&&&&&&&&&&&', this.uploadFiles);
if (!this.uploadFiles) {
this.uploadFiles = [];
}
@@ -142,7 +142,7 @@
this.uploadFiles.forEach((item, index) => {
this.successFiles.push(item);
})
- console.log('&&&&&&&&&&&&&&&&&&&&&&&&&&', this.successFiles);
+ // console.log('&&&&&&&&&&&&&&&&&&&&&&&&&&', this.successFiles);
let slen = this.successFiles.length;
for (let n = slen; n < 10; n++) {
@@ -171,35 +171,39 @@
},
subPhoto(){
- let data = {};
- data.tmp_id = '';
- let imgs = uni.getStorageSync('ai_face_success');
- if(imgs.length < 5){
- this.$com.showError('请上传至少5张照片!')
- return false;
- }
-
- data.imgs = imgs;
//提交申请
uni.redirectTo({
- url:'/pagesA/photo/cartoon_4?from=photo'
+ url:'/pagesA/photo/cartoon_4?from=idcard'
})
},
subFace(){
let data = {};
- data.tmp_id = '';
+ data.images = [];
let imgs = uni.getStorageSync('ai_face_success');
if(imgs.length < 5){
this.$com.showError('请上传至少5张照片!')
return false;
}
+ let root = this.$api.getOssurl();
+ if(typeof(root) == 'undefined' || !root){
+ this.$com.showError('数据获取错误!');
+ return false;
+ }
- data.imgs = imgs;
-
- this.show_1 = true;
+ imgs.forEach((item,key)=>{
+ data.images.push(item.replace(root,''))
+ })
+
+ let _this = this;
+ this.$api.post('/api/portrait/append',data,function(rs){
+ uni.redirectTo({
+ url:'/pagesA/photo/cartoon_4?from=idcard'
+ })
+
+ })
},
@@ -233,16 +237,18 @@
let lists = [].concat(event.file);
- uni.showLoading({
+ uni.showLoading({
title: '图片上传中',
+ mask:true
});
-
+
for (let i = 0; i < lists.length; i++) {
var edetail = lists[i].url;
let filePath = edetail;
let _date = new Date();
let ext_name = filePath.substr(filePath.lastIndexOf('.'));
- if (ext_name !== 'png' && ext_name !== 'jpg' && ext_name !== 'jpeg') {
+ console.log(ext_name);
+ if (ext_name !== '.png' && ext_name !== '.jpg' && ext_name !== '.jpeg') {
_this.$com.showError('请上传 png / jpg / jpeg 格式的图片');
return false;
}
@@ -250,6 +256,7 @@
let address = _date.getFullYear() + '' + (_date.getMonth() + 1) + '' + _date.getDate();
let fileName = address + _date.getTime() + ext_name;
const img_info = await unit.getImgInfo(filePath);
+
if(typeof(img_info) == 'undefined' || !img_info){
this.$com.showError('图片格式错误!请重试!');
return false;
@@ -280,38 +287,56 @@
fileType: 'image',
scene: 'user_max'
};
+
_this.$api.ossUpload(upData, function(res) {
if (res.code == 200) {
let url = res.data.file_url;
+
url = _this.$api.ossurl(url);
//开始验证图片
- let checkData = {
- 'url': url
- }
-
-
-
- // _this.$api.post('',checkData,function(rs){
-
- // },function(err){
- // console.log(err);
- // });
-
- //验证成功
- _this.uploadFiles = uni.getStorageSync('ai_face_success');
- if (!_this.uploadFiles) {
- _this.uploadFiles = [];
+ let check_image = {
+ 'check_image': res.data.file_url
}
- if (_this.uploadFiles.length < 10) {
- _this.uploadFiles.push(url);
+
+ uni.showLoading({
+ mask: true,
+ title: '图片验证中',
+ });
+ _this.$api.post('/api/portrait/check',check_image,function(rs){
+ uni.hideLoading();
+ console.log('-------------',rs);
+ if(rs.status == 0){
+ //验证成功
+ _this.uploadFiles = uni.getStorageSync('ai_face_success');
+ if (!_this.uploadFiles) {
+ _this.uploadFiles = [];
+ }
+ if (_this.uploadFiles.length < 10) {
+
+ _this.uploadFiles.push(url);
+
+ uni.setStorageSync('ai_face_success', _this.uploadFiles);
+ _this.setSuccessFiles();
+ }
+ }else{
+ //验证失败
+ _this.errorFiles.push(url);
+ console.log(_this.errorFiles);
+
+ }
+
+
+ },function(err){
+ uni.hideLoading();
+ this.$com.showError('图片验证失败!');
+ return false;
+
+ });
- uni.setStorageSync('ai_face_success', _this.uploadFiles);
- _this.setSuccessFiles();
- }
+
- // _this.uploadFiles.push(url);
//验证失败
diff --git a/pagesA/merge/idcard.vue b/pagesA/merge/idcard.vue
index 222d3eb..9157f1f 100644
--- a/pagesA/merge/idcard.vue
+++ b/pagesA/merge/idcard.vue
@@ -47,8 +47,9 @@
保存
- 剩余生成次数
- 0 / 30 张
+ 剩余生成次数
+
+ {{photo_has}} / 30 张
@@ -116,7 +117,8 @@
name: '男装'
},
],
- tem_list: []
+ tem_list: [],
+ photo_has :0
}
},
@@ -127,7 +129,7 @@
onLoad() {
this.changeTab();
this.root_path = this.$api.getOssurl();
-
+ this.getUserInfo();
},
onShow() {
@@ -136,7 +138,15 @@
methods: {
-
+ ///api/userInfo
+ getUserInfo(){
+
+ let _this = this;
+ this.$api.get('/api/userInfo',{},function(res){
+ _this.photo_has = res.attach.photo.specs_number;
+
+ });
+ },
getNavHeight(e) {
this.margin_top += e;
},
diff --git a/pagesA/merge/this.scss b/pagesA/merge/this.scss
index 57ea413..a651c7a 100644
--- a/pagesA/merge/this.scss
+++ b/pagesA/merge/this.scss
@@ -263,7 +263,7 @@ image{
.idcard_2_2{
width: 725rpx;
height: 120rpx;
- margin-left: 24rpx;
+ margin-left: 38rpx;
.idcard_2_2_1{
width: 100%;