From bb43554a4fd5b20e1f2659a450ff1662251968f7 Mon Sep 17 00:00:00 2001 From: "SD-20230427NBFT\\Administrator" <609306725@qq.com> Date: Fri, 26 Jul 2024 19:16:18 +0800 Subject: [PATCH] 111 --- pages.json | 3 +- pagesA/photo/face.vue | 124 +++++++++++++++++++++++---------------- pagesA/photo/photo_1.vue | 111 ++++++++++++++++++++++++++++------- pagesA/photo/photo_2.vue | 19 +++++- 4 files changed, 183 insertions(+), 74 deletions(-) diff --git a/pages.json b/pages.json index 4cd3dbd..e8a551f 100644 --- a/pages.json +++ b/pages.json @@ -70,7 +70,8 @@ "path": "photo/photo_1", "style": { "navigationBarTitleText": "AI写真", - "navigationStyle": "custom" + "navigationStyle": "custom", + "enablePullDownRefresh":false } }, { diff --git a/pagesA/photo/face.vue b/pagesA/photo/face.vue index 3eaedb3..bb02dd7 100644 --- a/pagesA/photo/face.vue +++ b/pagesA/photo/face.vue @@ -34,13 +34,8 @@ --> - + 上传照片 @@ -171,6 +166,9 @@ show_2: false, show_3: false, photoList: [], + uploadFiles:[], + successFiles:[], + errorFiles:[] } }, @@ -227,52 +225,78 @@ }, async afterRead(event) { - var _this = this; - let lists = [].concat(event.file); - console.log(lists); - + 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; - let _date = new Date(); - let ext_name = filePath.substr(filePath.lastIndexOf('.')); - let address = _date.getFullYear() + '' + (_date.getMonth() + 1) + '' + _date.getDate(); - let fileName = address + _date.getTime() + ext_name; - const img_info = await unit.getImgInfo(filePath); - - let { width, height } = img_info; - let maxWidth = 2480; - if (width > maxWidth) { - let scale = Math.ceil(width / maxWidth); - height = Math.ceil(height / scale); - width = Math.ceil(maxWidth); - } - let compress_path = ''; - compress_path = await unit.compressImg(filePath, { compressedWidth: width }).catch((res) => { - console.log('上传压缩失败', err); - }); - compress_path = compress_path ? compress_path : filePath; - console.log('&&&&&&&&&&',compress_path,fileName) ; - _this.upload_img(compress_path, fileName); + var edetail = lists[i].url; + let filePath = edetail; + let _date = new Date(); + let ext_name = filePath.substr(filePath.lastIndexOf('.')); + let address = _date.getFullYear() + '' + (_date.getMonth() + 1) + '' + _date.getDate(); + let fileName = address + _date.getTime() + ext_name; + const img_info = await unit.getImgInfo(filePath); + + let { + width, + height + } = img_info; + let maxWidth = 2480; + if (width > maxWidth) { + let scale = Math.ceil(width / maxWidth); + height = Math.ceil(height / scale); + width = Math.ceil(maxWidth); + } + let compress_path = ''; + compress_path = await unit.compressImg(filePath, { + compressedWidth: width + }).catch((res) => { + console.log('上传压缩失败', err); + }); + 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); + // }); + + + } + uni.hideLoading(); + console.log('***************',_this.uploadFiles) }, uploadFilePromise(url) { }, - - + + async upload_img(filePath, fileName) { - var _this =this; + var _this = this; try { uni.showLoading({ title: '图片上传中', }); - - const { file_url = '' } = await photoUploadFile(filePath, fileName,'user_avatar') + + const { + file_url = '' + } = await photoUploadFile(filePath, fileName, 'user_avatar') .finally(() => { uni.hideLoading(); }) @@ -280,7 +304,7 @@ console.log('ossUploadFile==', res); uni.$u.toast('图片上传失败!!'); }); - + if (!file_url) { uni.$u.toast('图片上传失败!!!!!'); return; @@ -288,24 +312,24 @@ console.log('success upload') console.log(file_url); _this.info.avatar = file_url; - _this.wxAvatar = [{url:ossurl(file_url, 'user_face')}]; + _this.wxAvatar = [{ + url: ossurl(file_url, 'user_face') + }]; updateUserInfo(_this.info).then(res => { - if (res.code != 200) { + if (res.code != 200) { uni.$u.toast(res.msg); - } - else - { + } else { store.commit('userInfo/set_user_info', _this.info); } - + }); } catch (err) { console.log('图片上传失败', err); uni.$u.toast('上传照片失败~~'); - + } }, - + loadData() { }, diff --git a/pagesA/photo/photo_1.vue b/pagesA/photo/photo_1.vue index 13f87c9..4fea045 100644 --- a/pagesA/photo/photo_1.vue +++ b/pagesA/photo/photo_1.vue @@ -4,7 +4,7 @@ - + @@ -16,7 +16,7 @@ - + - + - 港风复古-{{n}} + {{item.title}} @@ -65,15 +71,20 @@ navbar_title: 'AI写真', theme: "white", search_text: '', - margin_top: 10, + margin_top: 0, lineBg: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAOCAYAAABDwm71AAAAAXNSR0IArs4c6QAAAm5JREFUSEu1lD1oFEEUx39vZhOCpghikUIwkMKAjYWFEEELQdQTRfwqLGyMgsFcNDEWEbYQNB+Sw7ugdilSBDQ2tikSsFCwsBFiIVikSBEwQoRLuMzT3ds9z8vtXcjHwOzCzs57v/ef/xshGmdeaLsVUgZQYeZ9t3yN13bz/bpf2wVSYQ7DTNdQMa8Ej1RO76JkRPBQ8JS8OAbfpeX5bkLlHumAcTyxihcIAuSBvlsjMi7nc3pY4TPQFJIq2GiKY3TpF49nfQk27NjwffX25RkzSreJckVggS4FhQ5JZbVHhEwpaxlYsMk4PjYYbk6m5dtOkGUG9ZBzTFjHsUCASrAgh0I6BKMMrFyxeJN15A28susMTTyUxa0A+v3auqeRHqP0GcWLTyURLDL9fOivCHfDpljFAFCZ8oS3P38z98aXlVqQvq/N4jjhKddNcYZApYKrK5ZXw9HQ/OfG9YEoo5UeK1VTcbwhuKPwN9m8VeYNLHqO5cAnxtFs4YBxdFilw4BnXdG3teLFHgO6Q/PHFZ/N6QUDU6I0JSpWL3iVAsrsUA8sr3Cja0SmS9dF6S7LameDMmmgrW6FtSCKTVNUiVDdeootoFy+PSqfYpaSYvGHi2PaIoaXhtAT/wXcFqyrfpQCE2ur9PZmZLncrxvA4sVLWe206+SscqSqWberGHwRSN97KnPVGigRLP75akZPNzjSxnHKgrdlFYuKFQzMWMez+wlAiUeZ1P5XhrV1r+GacZy0cNwo+2s2yT+PLXmOD1aZlTWmB4ZlYTP3YF3FkoLc8bVNGjkYNUqLB82R0VeMY9kTfqw6vg/7mwOpzPMHTiZrgwPNrpsAAAAASUVORK5CYII=', - + list1: [{ name: '女生' }, { name: '男生', }], + this_tab:0, + + curPage: 0, + total: 0, + temList:[] } }, @@ -85,33 +96,89 @@ methods: { lower(){ console.log('this is lower') + this.loadMore(); }, + + + loadMore() { + + let isLoad = Math.ceil(this.total / 10) > this.curPage; + if (isLoad) { + this.getList(); + } + }, + getNavHeight(e) { this.margin_top += e; }, goSearch() { - console.log(this.search_text); + this.total =0; + this.temList=[]; + this.curPage = 0; + this.getList(); }, changeTab(e) { - console.log(e) + this.this_tab = e.index; + this.total =0; + this.temList = []; + this.curPage = 0; + let that = this; + setTimeout(function(){ + that.getList(); + },1000) }, - initListHeight(){ + onLoad(){ + this.getList(); + }, + + getListData(){ + let list = []; + let n= 0; + for(n=0;n<10;n++){ + let t = {}; + t.url = 'https://img30.360buyimg.com/sku/jfs/t1/221254/4/39390/74349/661e039aF46114279/48532008a0001dd0.jpg' + t.id = '123'; + t.title = '哈哈哈哈哈哈哈哈哈哈或或或哈哈哈哈哈哈哈哈哈哈或或或'; + list.push(t); + } + return {total:32,list:list}; }, - getScreenSize() { - uni.getSystemInfo({ - success: (res) => { - const screenWidth = res.windowWidth; // 屏幕宽度,单位为px - const screenHeight = res.windowHeight; // 屏幕高度,单位为px - console.log('屏幕宽度:', screenWidth); - console.log('屏幕高度:', screenHeight); - }, - }); + getList(){ + + let params = { + page: this.curPage + 1, + limit: 10, + sex: this.this_tab, + text:this.search_text + }; + + let res = this.getListData(); + + + this.curPage = params.page; + this.total = res.total; + + let datas = [...this.temList]; + + if (params.page > 1) { + datas.push(...res.list) + } else { + datas = res.list; + } + + this.temList = datas; + }, - - + goThis(id){ + uni.navigateTo({ + url:'/pagesA/photo/photo_2?id='+id + }) + } + } + } diff --git a/pagesA/photo/photo_2.vue b/pagesA/photo/photo_2.vue index 45a29f3..951cd63 100644 --- a/pagesA/photo/photo_2.vue +++ b/pagesA/photo/photo_2.vue @@ -61,6 +61,10 @@ 'https://img30.360buyimg.com/sku/jfs/t1/221254/4/39390/74349/661e039aF46114279/48532008a0001dd0.jpg', 'https://img30.360buyimg.com/sku/jfs/t1/221254/4/39390/74349/661e039aF46114279/48532008a0001dd0.jpg', ], + has_face : 0 ,//是否已有模板 及数量 + + + } }, @@ -68,12 +72,25 @@ mounted() { }, + onLoad() { + getFace() + }, + onShow() { + + }, + methods: { getNavHeight(e) { this.margin_top += e; } - + , + getFace(){ + + if(this.has_face == 0){ + this.show_1 + } + } } }