Files
lanecarford_front/src/views/Workshop/customize.vue

269 lines
6.0 KiB
Vue
Raw Normal View History

2025-10-09 16:25:20 +08:00
<script setup lang="ts">
2025-10-16 11:01:54 +08:00
import HeaderTitle from '@/components/HeaderTitle.vue'
import FooterNavigation from '@/components/FooterNavigation.vue'
2025-10-21 13:41:54 +08:00
import GenerateLoading from '@/views/asistant/components/GenerateLoading.vue'
2025-10-23 15:11:24 +08:00
import { ref, onMounted } from 'vue'
2025-10-23 17:01:13 +08:00
import {
generateTryOnEffect,
setTryOnEffectFavorite,
cancelTryOnEffectFavorite
} from '@/api/workshop'
2025-10-16 14:49:01 +08:00
const emit = defineEmits(['viewType'])
2025-10-16 15:53:47 +08:00
import { useRouter } from 'vue-router'
2025-10-23 16:37:59 +08:00
import { useGenerateStore } from '@/stores'
const store = useGenerateStore()
2025-10-16 14:49:01 +08:00
2025-10-23 16:37:59 +08:00
const router = useRouter()
2025-10-16 15:53:47 +08:00
const inputText = ref('')
2025-10-23 17:01:13 +08:00
const isFavorite = ref(false)
const tryOnUrl = ref('')
2025-10-23 16:37:59 +08:00
const loading = ref(false)
2025-10-16 14:49:01 +08:00
const onSend = () => {
if (inputText.value === '') return
2025-10-23 17:01:13 +08:00
generate()
2025-10-16 14:49:01 +08:00
const text = inputText.value
inputText.value = ''
2025-10-23 17:01:13 +08:00
// console.log('发送消息:', text)
2025-10-16 14:49:01 +08:00
}
2025-10-23 16:37:59 +08:00
const onReload = () => {
inputText.value = ''
2025-10-23 17:01:13 +08:00
generate(true)
2025-10-23 16:37:59 +08:00
}
// 生成结果
const generate = (isRegenerated = false) => {
const data = {
customerId: store.customerId,
visitRecordId: store.visitRecordId,
styleId: store.styleId,
modelPhotoId: store.modelPhotoId,
2025-10-23 16:41:38 +08:00
customerPhotoId: store.customerPhotoId,
2025-10-23 16:37:59 +08:00
originalTryOnId: store.originalTryOnId,
isRegenerated: isRegenerated ? 1 : 0,
2025-10-23 17:01:13 +08:00
prompt: inputText.value
}
2025-10-23 16:37:59 +08:00
loading.value = true
generateTryOnEffect(data)
2025-10-23 17:01:13 +08:00
.then((res) => {
tryOnUrl.value = res.tryOnUrl
isFavorite.value = !!res.isFavorite
2025-10-23 16:37:59 +08:00
loading.value = false
})
2025-10-23 17:01:13 +08:00
.catch((err) => {
2025-10-23 16:37:59 +08:00
console.error(err)
loading.value = false
})
}
2025-10-23 17:01:13 +08:00
generate()
2025-10-23 16:37:59 +08:00
// 喜欢
const isLoveLoading = ref(false)
2025-10-16 14:49:01 +08:00
const onLove = () => {
2025-10-23 16:37:59 +08:00
if (isLoveLoading.value) return
2025-10-23 17:01:13 +08:00
const http = isFavorite.value ? cancelTryOnEffectFavorite : setTryOnEffectFavorite
2025-10-23 16:37:59 +08:00
isLoveLoading.value = true
2025-10-23 17:01:13 +08:00
isFavorite.value = !isFavorite.value
http('tryOnId')
2025-10-23 16:37:59 +08:00
.then(() => {
isLoveLoading.value = false
})
.catch((err) => {
console.error(err)
isLoveLoading.value = false
})
2025-10-16 14:49:01 +08:00
}
const onDownload = () => {
2025-10-16 15:53:47 +08:00
console.log('download')
}
2025-10-16 17:05:40 +08:00
const onRetry = () => {
router.back()
}
2025-10-20 15:45:42 +08:00
const onFinish = () => {
2025-10-16 15:53:47 +08:00
router.push({ name: 'creation' })
2025-10-16 14:49:01 +08:00
}
2025-10-09 16:25:20 +08:00
</script>
<template>
2025-10-16 11:01:54 +08:00
<header-title style-type="2" />
2025-10-21 13:41:54 +08:00
<div class="loading" v-if="loading"><generate-loading /></div>
<template v-else>
<div class="customize">
<div class="title">Customize your Look!</div>
<p class="tip">Refine your Look</p>
<div class="input-box">
<div class="help">?</div>
<input
type="text"
v-model="inputText"
@keyup.enter="onSend"
placeholder="Try: “Change background to Tokyo City”"
/>
<div class="send" @click="onSend"><SvgIcon name="send" size="48" /></div>
</div>
<div class="card">
2025-10-23 17:01:13 +08:00
<img :src="tryOnUrl" />
2025-10-21 13:41:54 +08:00
<!-- <div class="select-box">
2025-10-10 17:01:13 +08:00
<div class="icon"><SvgIcon name="history" size="35" /></div>
<div class="label">History</div>
<div class="icon"><SvgIcon name="xialajiantou" size="29" /></div>
2025-10-20 15:45:42 +08:00
</div> -->
2025-10-21 13:41:54 +08:00
<div class="icons">
2025-10-23 17:01:13 +08:00
<div @click="onLove"><SvgIcon :name="`love_${isFavorite ? 1 : 0}`" size="35" /></div>
2025-10-21 13:41:54 +08:00
<div @click="onReload"><SvgIcon name="reload" size="35" /></div>
<!-- <div @click="onDownload"><SvgIcon name="download" size="35" /></div> -->
</div>
</div>
<div class="btns">
<button @click="onFinish">Finish</button>
2025-10-10 17:01:13 +08:00
</div>
</div>
2025-10-21 13:41:54 +08:00
<footer-navigation />
</template>
2025-10-09 16:25:20 +08:00
</template>
<style scoped lang="less">
2025-10-23 15:11:24 +08:00
.loading {
2025-10-21 13:41:54 +08:00
width: 100%;
margin-top: 36.6rem;
display: flex;
align-items: center;
justify-content: center;
}
2025-10-16 11:01:54 +08:00
.customize {
2025-10-09 16:25:20 +08:00
width: 100%;
position: relative;
color: #000;
display: flex;
flex-direction: column;
align-items: center;
> .title {
font-family: satoshiBold;
font-size: 8.4rem;
text-align: center;
line-height: 124%;
2025-10-16 11:01:54 +08:00
margin-top: 3.6rem;
2025-10-09 16:25:20 +08:00
}
> .tip {
margin-top: 0.56rem;
font-family: satoshiRegular;
font-size: 3.74rem;
line-height: 124%;
2025-10-20 15:45:42 +08:00
color: rgba(0, 0, 0, 0.6);
2025-10-09 16:25:20 +08:00
}
2025-10-10 17:01:13 +08:00
> .input-box {
2025-10-20 15:45:42 +08:00
margin-top: 6rem;
2025-10-10 17:01:13 +08:00
width: 87.5rem;
height: 8.3rem;
border-radius: 0.5rem;
2025-10-20 15:45:42 +08:00
border: 0.3rem solid #000000;
2025-10-10 17:01:13 +08:00
box-sizing: content-box;
display: flex;
align-items: center;
> .help {
margin: 0 2.5rem;
width: 4.2rem;
height: 4.2rem;
border-radius: 50%;
border: 0.3rem solid #000;
display: flex;
align-items: center;
justify-content: center;
font-size: 3rem;
}
> input {
width: 0;
flex: 1;
height: 100%;
font-family: satoshiRegular;
font-size: 3.4rem;
color: #000;
border: none;
&::placeholder {
color: #777;
}
}
> .send {
margin: 0 2.5rem;
--svg-icon-color: #000;
}
}
> .card {
2025-10-20 15:45:42 +08:00
margin-top: 6.4rem;
width: 72.9rem;
height: 102.3rem;
2025-10-10 17:01:13 +08:00
border-radius: 2rem;
2025-10-16 11:01:54 +08:00
// box-shadow: 1.3rem 1.4rem 2rem 0.2rem #0000004d;
2025-10-16 14:49:01 +08:00
border: 0.2rem solid #d9d9d9;
2025-10-10 17:01:13 +08:00
overflow: hidden;
> * {
position: absolute;
}
> img {
width: 100%;
height: 100%;
object-fit: contain;
}
> .select-box {
top: 1.8rem;
left: 1.8rem;
width: 30.2rem;
height: 6.52rem;
border-radius: 0.91rem;
border: 0.24rem solid #000;
display: flex;
align-items: center;
2025-10-16 11:01:54 +08:00
> .icon {
2025-10-10 17:01:13 +08:00
margin: 0 1.8rem;
}
2025-10-16 11:01:54 +08:00
> .label {
2025-10-10 17:01:13 +08:00
flex: 1;
font-family: satoshiRegular;
font-size: 2.97rem;
color: #000;
}
}
> .icons {
bottom: 0.27rem;
right: 0;
height: 10rem;
display: flex;
align-items: center;
justify-content: center;
> div {
margin-right: 1.5rem;
width: 6.2rem;
height: 6.2rem;
border-radius: 1rem;
border: 0.2rem solid #000;
display: flex;
align-items: center;
justify-content: center;
}
}
}
2025-10-16 17:05:40 +08:00
> .btns {
2025-10-20 15:45:42 +08:00
margin-top: 5.6rem;
2025-10-16 17:05:40 +08:00
width: 100%;
display: flex;
justify-content: center;
> button {
box-sizing: content-box;
font-family: satoshiRegular;
2025-10-20 15:45:42 +08:00
// margin: 0 1.8rem;
2025-10-21 13:41:54 +08:00
border: none;
2025-10-20 15:45:42 +08:00
margin: 0 5.2rem 0 auto;
width: 23.8rem;
height: 6.9rem;
2025-10-16 17:05:40 +08:00
border-radius: 1.3rem;
background: #000;
font-weight: 400;
2025-10-20 15:45:42 +08:00
font-size: 3.89rem;
2025-10-16 17:05:40 +08:00
color: #fff;
&:active {
opacity: 0.7;
}
2025-10-16 15:53:47 +08:00
}
}
2025-10-09 16:25:20 +08:00
}
</style>