This commit is contained in:
杨鹏
2025-10-21 18:22:21 +08:00
parent 0b31cfc8dd
commit 3420a2894e
3 changed files with 168 additions and 4 deletions
+12
View File
@@ -97,6 +97,18 @@
"group": "基础信息收集页-更多选项" "group": "基础信息收集页-更多选项"
} }
}, },
{
"path": "pages/takePhoto/index",
"style": {
"navigationBarTitleText": "上传照片",
"navigationStyle": "custom"
},
"meta": {
"sync": true,
"title": "上传照片",
"group": "上传照片"
}
},
{ {
"path": "pages/uploadClothes/index", "path": "pages/uploadClothes/index",
"style": { "style": {
+8 -4
View File
@@ -36,7 +36,9 @@
> >
<view <view
class="checkmark" class="checkmark"
v-show="item.multiply ? form[item.key].includes(v.label) : form[item.key] === v.label" v-show="
item.multiply ? form[item.key].includes(v.label) : form[item.key] === v.label
"
> >
<image <image
src="https://oss.yz.zglvling.com/user/image/2025-07-23/1753234211808517.png" src="https://oss.yz.zglvling.com/user/image/2025-07-23/1753234211808517.png"
@@ -52,7 +54,7 @@
<view class="btn-bottom"> <view class="btn-bottom">
<button class="next-btn" @tap="nextStep"> 下一步 </button> <button class="next-btn" @tap="nextStep"> 下一步 </button>
<uni-file-picker <!-- <uni-file-picker
v-if="isHideUploadBtn" v-if="isHideUploadBtn"
:auto-upload="false" :auto-upload="false"
:del-icon="false" :del-icon="false"
@@ -63,7 +65,7 @@
limit="1" limit="1"
mode="grid" mode="grid"
@select="selectPic" @select="selectPic"
/> /> -->
</view> </view>
<div class="dialog" v-if="false"> <div class="dialog" v-if="false">
@@ -90,6 +92,7 @@
import { ref, computed } from 'vue'; import { ref, computed } from 'vue';
import { getAccessToken } from '@/sheep/request'; import { getAccessToken } from '@/sheep/request';
import { getUserInfo, saveUserInfo } from '@/sheep/api/user'; import { getUserInfo, saveUserInfo } from '@/sheep/api/user';
import sheep from '@/sheep';
// const token = getAccessToken(); // const token = getAccessToken();
@@ -478,7 +481,6 @@
purpose: form.value.purpose.toString(), purpose: form.value.purpose.toString(),
occasion_dressing: form.value.occasion_dressing.toString(), occasion_dressing: form.value.occasion_dressing.toString(),
}).then(() => { }).then(() => {
uni.showLoading({ uni.showLoading({
icon: 'loading', icon: 'loading',
title: '', title: '',
@@ -577,6 +579,8 @@
return; return;
} }
uni.setStorageSync('formData', form.value);
sheep.$router.go(`/pages/takePhoto/index?token=${getAccessToken()}`);
}; };
</script> </script>
+148
View File
@@ -0,0 +1,148 @@
<template>
<view class="take-photo-page">
<image
src="https://puton.huimeimeta.com/imgs/close.png"
class="close-icon"
@tap="
() => {
sheep.$router.back();
}
"
/>
<view class="btn-box">
<view class="bottom-btn upload-photo-btn" @tap="takePhoto">上传照片</view>
<view class="bottom-btn" @tap="chooseImage">拍摄</view>
</view>
</view>
</template>
<script setup>
import { ref, computed } from 'vue';
import { getAccessToken } from '@/sheep/request';
import { getUserInfo, saveUserInfo } from '@/sheep/api/user';
import sheep from '@/sheep';
const selectPic = async (imgPath) => {
console.log('selectPic: ', imgPath);
uni.showLoading({
icon: 'loading',
title: '',
});
const userInfo = await getUserInfo();
console.log('userInfo: -----------', userInfo);
const formData = uni.getStorageSync('formData');
console.log('formData: ', formData);
await saveUserInfo({
...JSON.parse(userInfo.data.dataJson),
...formData,
question: formData.question.toString(),
purpose: formData.purpose.toString(),
occasion_dressing: formData.occasion_dressing.toString(),
}).then(() => {
uni.showLoading({
icon: 'loading',
title: '',
});
uni.uploadFile({
url: 'https://puton.huimeimeta.com/app-api/cloth/uploadFace',
filePath: imgPath,
name: 'file',
formData: {},
header: {
Authorization: getAccessToken(),
},
success: (res) => {
console.log('上传成功', typeof res.data);
console.log('res.data.code: ', JSON.parse(res.data));
if (JSON.parse(res.data).code === 200) {
window.location.href = `https://face-canvas.huimeimeta.com/?img=${
JSON.parse(res.data).result.fileUrl
}&token=${getAccessToken()}`;
}
uni.hideLoading();
},
complete: () => {
uni.hideLoading();
},
});
});
};
const takePhoto = () => {
uni.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['camera'],
success: (res) => {
selectPic(res.tempFilePaths[0]);
},
fail: (err) => {
console.log('取消拍照或失败:', err);
},
});
};
const chooseImage = () => {
uni.chooseImage({
count: 1,
sourceType: ['album'],
success: (res) => {
selectPic(res.tempFilePaths[0]);
},
fail: (err) => {
console.log('取消选择或失败:', err);
},
});
};
</script>
<style lang="scss" scoped>
.take-photo-page {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 10;
background-image: url('https://puton.huimeimeta.com/imgs/upload-face-bg.jpg');
background-size: cover;
.close-icon {
width: 48rpx;
height: 48rpx;
position: absolute;
left: 40rpx;
top: 120rpx;
}
.btn-box {
width: 100%;
height: 292rpx;
background: rgba(0, 0, 0, 0.5);
position: fixed;
left: 0;
bottom: 0;
display: flex;
justify-content: center;
.bottom-btn {
width: 314rpx;
height: 80rpx;
color: #fff;
font-size: 28rpx;
text-align: center;
line-height: 80rpx;
background: #031c24;
margin-top: 90rpx;
}
.upload-photo-btn {
margin-right: 26rpx;
}
}
}
</style>