SD-20230427NBFT\Administrator 9 months ago
parent 97c3cb6532
commit bb43554a4f
  1. 3
      pages.json
  2. 124
      pagesA/photo/face.vue
  3. 111
      pagesA/photo/photo_1.vue
  4. 19
      pagesA/photo/photo_2.vue

@ -70,7 +70,8 @@
"path": "photo/photo_1", "path": "photo/photo_1",
"style": { "style": {
"navigationBarTitleText": "AI写真", "navigationBarTitleText": "AI写真",
"navigationStyle": "custom" "navigationStyle": "custom",
"enablePullDownRefresh":false
} }
}, },
{ {

@ -34,13 +34,8 @@
--> -->
<u-upload <u-upload :fileList="photoList" @afterRead="afterRead" @delete="deletePic" name="1" multiple
:fileList="photoList" :maxCount="10">
@afterRead="afterRead"
@delete="deletePic"
name="1"
multiple
:maxCount="10">
<view class="photo_main_face_4 photo_full_blue_btn" style="margin-left: 24rpx;"> <view class="photo_main_face_4 photo_full_blue_btn" style="margin-left: 24rpx;">
上传照片 上传照片
</view> </view>
@ -171,6 +166,9 @@
show_2: false, show_2: false,
show_3: false, show_3: false,
photoList: [], photoList: [],
uploadFiles:[],
successFiles:[],
errorFiles:[]
} }
}, },
@ -227,52 +225,78 @@
}, },
async afterRead(event) { async afterRead(event) {
var _this = this; var _this = this;
let lists = [].concat(event.file); let lists = [].concat(event.file);
console.log(lists);
uni.showLoading({
title: '图片上传中',
});
_this.uploadFiles = [];
for (let i = 0; i < lists.length; i++) { for (let i = 0; i < lists.length; i++) {
var edetail =lists[i].url; var edetail = lists[i].url;
let filePath = edetail; let filePath = edetail;
let _date = new Date(); let _date = new Date();
let ext_name = filePath.substr(filePath.lastIndexOf('.')); let ext_name = filePath.substr(filePath.lastIndexOf('.'));
let address = _date.getFullYear() + '' + (_date.getMonth() + 1) + '' + _date.getDate(); let address = _date.getFullYear() + '' + (_date.getMonth() + 1) + '' + _date.getDate();
let fileName = address + _date.getTime() + ext_name; let fileName = address + _date.getTime() + ext_name;
const img_info = await unit.getImgInfo(filePath); const img_info = await unit.getImgInfo(filePath);
let { width, height } = img_info; let {
let maxWidth = 2480; width,
if (width > maxWidth) { height
let scale = Math.ceil(width / maxWidth); } = img_info;
height = Math.ceil(height / scale); let maxWidth = 2480;
width = Math.ceil(maxWidth); if (width > maxWidth) {
} let scale = Math.ceil(width / maxWidth);
let compress_path = ''; height = Math.ceil(height / scale);
compress_path = await unit.compressImg(filePath, { compressedWidth: width }).catch((res) => { width = Math.ceil(maxWidth);
console.log('上传压缩失败', err); }
}); let compress_path = '';
compress_path = compress_path ? compress_path : filePath; compress_path = await unit.compressImg(filePath, {
console.log('&&&&&&&&&&',compress_path,fileName) ; compressedWidth: width
_this.upload_img(compress_path, fileName); }).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) { uploadFilePromise(url) {
}, },
async upload_img(filePath, fileName) { async upload_img(filePath, fileName) {
var _this =this; var _this = this;
try { try {
uni.showLoading({ uni.showLoading({
title: '图片上传中', title: '图片上传中',
}); });
const { file_url = '' } = await photoUploadFile(filePath, fileName,'user_avatar') const {
file_url = ''
} = await photoUploadFile(filePath, fileName, 'user_avatar')
.finally(() => { .finally(() => {
uni.hideLoading(); uni.hideLoading();
}) })
@ -280,7 +304,7 @@
console.log('ossUploadFile==', res); console.log('ossUploadFile==', res);
uni.$u.toast('图片上传失败!!'); uni.$u.toast('图片上传失败!!');
}); });
if (!file_url) { if (!file_url) {
uni.$u.toast('图片上传失败!!!!!'); uni.$u.toast('图片上传失败!!!!!');
return; return;
@ -288,24 +312,24 @@
console.log('success upload') console.log('success upload')
console.log(file_url); console.log(file_url);
_this.info.avatar = 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 => { updateUserInfo(_this.info).then(res => {
if (res.code != 200) { if (res.code != 200) {
uni.$u.toast(res.msg); uni.$u.toast(res.msg);
} } else {
else
{
store.commit('userInfo/set_user_info', _this.info); store.commit('userInfo/set_user_info', _this.info);
} }
}); });
} catch (err) { } catch (err) {
console.log('图片上传失败', err); console.log('图片上传失败', err);
uni.$u.toast('上传照片失败~~'); uni.$u.toast('上传照片失败~~');
} }
}, },
loadData() { loadData() {
}, },

@ -4,7 +4,7 @@
<custom_navbar :title="navbar_title" @getNavHeight="getNavHeight" :theme="theme" /> <custom_navbar :title="navbar_title" @getNavHeight="getNavHeight" :theme="theme" />
<view class="photo_main" :style="'margin-top:'+margin_top+'px'"> <view class="photo_main" :style="'margin-top:'+margin_top+'px'">
<view class="search_div"> <view class="search_div" style="margin-top: 20rpx;">
<view class="search_div_1"> <view class="search_div_1">
<image src="/static/img/common/search_icon.png" /> <image src="/static/img/common/search_icon.png" />
</view> </view>
@ -16,7 +16,7 @@
<view class="tabs_div"> <view class="tabs_div">
<u-tabs @click="changeTab()" :list="list1" lineWidth="25" lineHeight="10" <u-tabs @click="changeTab()" :current="this_tab" :list="list1" lineWidth="25" lineHeight="10"
:lineColor="`url(${lineBg}) 100% 100%`" :activeStyle="{ :lineColor="`url(${lineBg}) 100% 100%`" :activeStyle="{
color: '#333333', color: '#333333',
fontWeight: 'bold', fontWeight: 'bold',
@ -29,17 +29,23 @@
</view> </view>
<scroll-view class="photo_list_div" enable-flex="true" scroll-y="true" @scrolltolower="lower" lower-threshold="2"> <scroll-view class="photo_list_div"
enable-flex="true"
scroll-y="true"
scroll-with-animation="true"
@scrolltolower="lower"
lower-threshold="50">
<view class="photo_list_div_one" v-for="n in 10"> <view class="photo_list_div_one" v-for="(item,key) in temList" :key="key" @tap="goThis(item.id)">
<view class="photo_list_div_one_img" > <view class="photo_list_div_one_img" >
<image <image
src="https://img30.360buyimg.com/sku/jfs/t1/221254/4/39390/74349/661e039aF46114279/48532008a0001dd0.jpg" :src="item.url"
mode="aspectFill" /> mode="aspectFill" />
</view> </view>
<view class="photo_list_div_one_text"> <view class="photo_list_div_one_text">
港风复古-{{n}} {{item.title}}
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
@ -65,15 +71,20 @@
navbar_title: 'AI写真', navbar_title: 'AI写真',
theme: "white", theme: "white",
search_text: '', search_text: '',
margin_top: 10, margin_top: 0,
lineBg: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAOCAYAAABDwm71AAAAAXNSR0IArs4c6QAAAm5JREFUSEu1lD1oFEEUx39vZhOCpghikUIwkMKAjYWFEEELQdQTRfwqLGyMgsFcNDEWEbYQNB+Sw7ugdilSBDQ2tikSsFCwsBFiIVikSBEwQoRLuMzT3ds9z8vtXcjHwOzCzs57v/ef/xshGmdeaLsVUgZQYeZ9t3yN13bz/bpf2wVSYQ7DTNdQMa8Ej1RO76JkRPBQ8JS8OAbfpeX5bkLlHumAcTyxihcIAuSBvlsjMi7nc3pY4TPQFJIq2GiKY3TpF49nfQk27NjwffX25RkzSreJckVggS4FhQ5JZbVHhEwpaxlYsMk4PjYYbk6m5dtOkGUG9ZBzTFjHsUCASrAgh0I6BKMMrFyxeJN15A28susMTTyUxa0A+v3auqeRHqP0GcWLTyURLDL9fOivCHfDpljFAFCZ8oS3P38z98aXlVqQvq/N4jjhKddNcYZApYKrK5ZXw9HQ/OfG9YEoo5UeK1VTcbwhuKPwN9m8VeYNLHqO5cAnxtFs4YBxdFilw4BnXdG3teLFHgO6Q/PHFZ/N6QUDU6I0JSpWL3iVAsrsUA8sr3Cja0SmS9dF6S7LameDMmmgrW6FtSCKTVNUiVDdeootoFy+PSqfYpaSYvGHi2PaIoaXhtAT/wXcFqy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lYTP3YF3FkoLc8bVNGjkYNUqLB82R0VeMY9kTfqw6vg/7mwOpzPMHTiZrgwPNrpsAAAAASUVORK5CYII=',
list1: [{ list1: [{
name: '女生' name: '女生'
}, { }, {
name: '男生', name: '男生',
}], }],
this_tab:0,
curPage: 0,
total: 0,
temList:[]
} }
}, },
@ -85,33 +96,89 @@
methods: { methods: {
lower(){ lower(){
console.log('this is lower') console.log('this is lower')
this.loadMore();
}, },
loadMore() {
let isLoad = Math.ceil(this.total / 10) > this.curPage;
if (isLoad) {
this.getList();
}
},
getNavHeight(e) { getNavHeight(e) {
this.margin_top += e; this.margin_top += e;
}, },
goSearch() { goSearch() {
console.log(this.search_text); this.total =0;
this.temList=[];
this.curPage = 0;
this.getList();
}, },
changeTab(e) { 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() { getList(){
uni.getSystemInfo({
success: (res) => { let params = {
const screenWidth = res.windowWidth; // px page: this.curPage + 1,
const screenHeight = res.windowHeight; // px limit: 10,
console.log('屏幕宽度:', screenWidth); sex: this.this_tab,
console.log('屏幕高度:', screenHeight); 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
})
}
} }
} }
</script> </script>

@ -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',
'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() { mounted() {
}, },
onLoad() {
getFace()
},
onShow() {
},
methods: { methods: {
getNavHeight(e) { getNavHeight(e) {
this.margin_top += e; this.margin_top += e;
} }
,
getFace(){
if(this.has_face == 0){
this.show_1
}
}
} }
} }

Loading…
Cancel
Save