diff --git a/pagesA/photo/face.vue b/pagesA/photo/face.vue index bb02dd7..37bb502 100644 --- a/pagesA/photo/face.vue +++ b/pagesA/photo/face.vue @@ -5,7 +5,8 @@ - + + 上传5-10张,有效照片越多,生成效果越好 @@ -15,40 +16,43 @@ - - - + + - + + + + + - + + 上传照片 - + - 以下照片不合格,请重新上传 - - + 以下照片不合格,请重新上传 + + @@ -72,7 +76,7 @@ 2.生成高峰期,可能会有排队情况,请耐心等候。 3.如需更换写真人物, 请前往【我的】增加人物的面部档案。 - + 确认 @@ -166,9 +170,9 @@ show_2: false, show_3: false, photoList: [], - uploadFiles:[], - successFiles:[], - errorFiles:[] + uploadFiles: [], + successFiles: [], + errorFiles: [] } }, @@ -186,19 +190,84 @@ } }, - onShow() { var _this = this; _this.checkAuth(); + this.setSuccessFiles(); }, methods: { + setSuccessFiles() { + this.uploadFiles = uni.getStorageSync('ai_face_success'); + console.log('&&&&&&&&&&&&&&&&&&&&&&&&&&', this.uploadFiles); + if (!this.uploadFiles) { + this.uploadFiles = []; + } + this.successFiles = []; + this.uploadFiles.forEach((item, index) => { + this.successFiles.push(item); + }) + console.log('&&&&&&&&&&&&&&&&&&&&&&&&&&', this.successFiles); + let slen = this.successFiles.length; + + for (let n = slen; n < 10; n++) { + this.successFiles.push(''); + } + + }, + + delPhoto(url) { + let tmp = uni.getStorageSync('ai_face_success'); + if (tmp) { + const index = tmp.indexOf(url); + if (index !== -1) { + tmp.splice(index, 1); + } + + uni.setStorageSync('ai_face_success', tmp); + this.setSuccessFiles(); + } + + + }, + getNavHeight(e) { this.margin_top += e; }, - upPhoto() { - + + 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' + }) + + }, + subFace(){ + 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; + + this.show_1 = true; + + }, + //判断 checkAuth() { var _this = this; @@ -227,11 +296,12 @@ async afterRead(event) { var _this = this; let lists = [].concat(event.file); - + + uni.showLoading({ title: '图片上传中', }); - _this.uploadFiles = []; + for (let i = 0; i < lists.length; i++) { var edetail = lists[i].url; let filePath = edetail; @@ -256,125 +326,70 @@ compressedWidth: width }).catch((res) => { console.log('上传压缩失败', err); + return false; }); compress_path = compress_path ? compress_path : filePath; - + //_this.upload_img(compress_path, fileName); //上传 - var upData = {filePath:compress_path,fileType:'image',scene:'user_max'}; - // _this.$api.ossUpload(upData, function(res) { - // console.log('ossUpload success', res); - // if(res.code == 200){ - // //_this.uploadFiles.push(res.data.file_url); - // } - // // var d = res.data; - // // _this.info.avatar = d.file_url; - // // _this.uploadImg = [{ - // // url: _this.$api.ossurl(d.file_url) - // // }];; - // }, function(err) { - // console.log('ossUpload fail', err); - // }); + var upData = { + filePath: compress_path, + 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){ - } - uni.hideLoading(); - console.log('***************',_this.uploadFiles) - }, - uploadFilePromise(url) { + // },function(err){ + // console.log(err); + // }); - }, + //验证成功 + _this.uploadFiles = uni.getStorageSync('ai_face_success'); + if (!_this.uploadFiles) { + _this.uploadFiles = []; + } + if (_this.uploadFiles.length < 10) { + _this.uploadFiles.push(url); - async upload_img(filePath, fileName) { - var _this = this; - try { - uni.showLoading({ - title: '图片上传中', - }); + uni.setStorageSync('ai_face_success', _this.uploadFiles); + _this.setSuccessFiles(); + } - const { - file_url = '' - } = await photoUploadFile(filePath, fileName, 'user_avatar') - .finally(() => { - uni.hideLoading(); - }) - .catch((res) => { - console.log('ossUploadFile==', res); - uni.$u.toast('图片上传失败!!'); - }); - - if (!file_url) { - uni.$u.toast('图片上传失败!!!!!'); - return; - } - console.log('success upload') - console.log(file_url); - _this.info.avatar = file_url; - _this.wxAvatar = [{ - url: ossurl(file_url, 'user_face') - }]; - updateUserInfo(_this.info).then(res => { - if (res.code != 200) { - uni.$u.toast(res.msg); - } else { - store.commit('userInfo/set_user_info', _this.info); - } + // _this.uploadFiles.push(url); - }); - } catch (err) { - console.log('图片上传失败', err); - uni.$u.toast('上传照片失败~~'); - } - }, + //验证失败 + //_this.errorFiles.push(url); - loadData() { - - }, - async upload_img(filePath, fileName) { - var _this = this; - try { - uni.showLoading({ - title: '图片上传中', - }); - const { - file_url = '' - } = await photoUploadFile(filePath, fileName, 'user_avatar') - .finally(() => { - uni.hideLoading(); - }) - .catch((res) => { - console.log('ossUploadFile==', res); - uni.$u.toast('图片上传失败!!'); - }); - - if (!file_url) { - uni.$u.toast('图片上传失败!!!!!'); - return; - } - console.log('success upload') - console.log(file_url); - _this.info.avatar = file_url; - _this.wxAvatar = [{ - url: ossurl(file_url, 'user_face') - }]; - updateUserInfo(_this.info).then(res => { - if (res.code != 200) { - uni.$u.toast(res.msg); - } else { - store.commit('userInfo/set_user_info', _this.info); } + }, function(err) { + console.log('ossUpload fail', err); + _this.$com.showError('上传图片错误!!') + }); - } catch (err) { - console.log('图片上传失败', err); - uni.$u.toast('上传照片失败~~'); + + } - }, + uni.hideLoading(); + + } + } }