Merge branch 'master' of https://gitee.com/lvYeJu/lane-crawford-3
This commit is contained in:
@@ -3,26 +3,30 @@
|
||||
import FooterNavigation from '@/components/FooterNavigation.vue'
|
||||
import GenerateLoading from '@/views/asistant/components/GenerateLoading.vue'
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { generateTryOnEffect, setTryOnEffectFavorite, cancelTryOnEffectFavorite } from '@/api/workshop'
|
||||
import {
|
||||
generateTryOnEffect,
|
||||
setTryOnEffectFavorite,
|
||||
cancelTryOnEffectFavorite
|
||||
} from '@/api/workshop'
|
||||
const emit = defineEmits(['viewType'])
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useGenerateStore } from '@/stores'
|
||||
const store = useGenerateStore()
|
||||
|
||||
const customizeInfo = store.customizeInfo
|
||||
const router = useRouter()
|
||||
const inputText = ref('')
|
||||
const isLoved = ref(false)
|
||||
const loading = ref(false)
|
||||
const onSend = () => {
|
||||
if (inputText.value === '') return
|
||||
generate();
|
||||
const text = inputText.value
|
||||
inputText.value = ''
|
||||
console.log('发送消息:', text)
|
||||
if (customizeInfo.inputText === '') return
|
||||
generate()
|
||||
customizeInfo.inputText = ''
|
||||
// const text = inputText.value
|
||||
// inputText.value = ''
|
||||
// console.log('发送消息:', text)
|
||||
}
|
||||
const onReload = () => {
|
||||
inputText.value = ''
|
||||
generate(true);
|
||||
customizeInfo.inputText = ''
|
||||
generate(true)
|
||||
}
|
||||
|
||||
// 生成结果
|
||||
@@ -32,33 +36,36 @@
|
||||
visitRecordId: store.visitRecordId,
|
||||
styleId: store.styleId,
|
||||
modelPhotoId: store.modelPhotoId,
|
||||
customerPhotoId: store.id,
|
||||
customerPhotoId: store.customerPhotoId,
|
||||
originalTryOnId: store.originalTryOnId,
|
||||
isRegenerated: isRegenerated ? 1 : 0,
|
||||
prompt: inputText.value,
|
||||
|
||||
};
|
||||
prompt: customizeInfo.inputText
|
||||
}
|
||||
loading.value = true
|
||||
generateTryOnEffect(data)
|
||||
.then(res => {
|
||||
console.log(res)
|
||||
.then((res) => {
|
||||
customizeInfo.tryOnId = res.tryOnId
|
||||
customizeInfo.tryOnUrl = res.tryOnUrl
|
||||
customizeInfo.styleUrl = res.styleUrl
|
||||
customizeInfo.isRegenerated = res.isRegenerated
|
||||
customizeInfo.isFavorite = !!res.isFavorite
|
||||
loading.value = false
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
console.error(err)
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
generate();
|
||||
if (customizeInfo.tryOnId === '') generate()
|
||||
|
||||
// 喜欢
|
||||
const isLoveLoading = ref(false)
|
||||
const onLove = () => {
|
||||
if (isLoveLoading.value) return
|
||||
const http = isLoved.value ? cancelTryOnEffectFavorite : setTryOnEffectFavorite
|
||||
const http = customizeInfo.isFavorite ? cancelTryOnEffectFavorite : setTryOnEffectFavorite
|
||||
customizeInfo.isFavorite = !customizeInfo.isFavorite
|
||||
isLoveLoading.value = true
|
||||
isLoved.value = !isLoved.value
|
||||
http("tryOnId")
|
||||
http('tryOnId')
|
||||
.then(() => {
|
||||
isLoveLoading.value = false
|
||||
})
|
||||
@@ -89,21 +96,23 @@
|
||||
<div class="help">?</div>
|
||||
<input
|
||||
type="text"
|
||||
v-model="inputText"
|
||||
v-model="customizeInfo.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">
|
||||
<img src="@/assets/images/workshop/posture/posture_1.png" />
|
||||
<img :src="customizeInfo.tryOnUrl" />
|
||||
<!-- <div class="select-box">
|
||||
<div class="icon"><SvgIcon name="history" size="35" /></div>
|
||||
<div class="label">History</div>
|
||||
<div class="icon"><SvgIcon name="xialajiantou" size="29" /></div>
|
||||
</div> -->
|
||||
<div class="icons">
|
||||
<div @click="onLove"><SvgIcon :name="`love_${isLoved ? 1 : 0}`" size="35" /></div>
|
||||
<div @click="onLove">
|
||||
<SvgIcon :name="`love_${customizeInfo.isFavorite ? 1 : 0}`" size="35" />
|
||||
</div>
|
||||
<div @click="onReload"><SvgIcon name="reload" size="35" /></div>
|
||||
<!-- <div @click="onDownload"><SvgIcon name="download" size="35" /></div> -->
|
||||
</div>
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
import FooterNavigation from '@/components/FooterNavigation.vue'
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useGenerateStore } from '@/stores'
|
||||
const generateStore = useGenerateStore()
|
||||
const emit = defineEmits(['view-type'])
|
||||
onMounted(() => {
|
||||
emit('view-type', 1)
|
||||
@@ -11,10 +13,13 @@
|
||||
const faceUrl = ref('')
|
||||
// 上传照片
|
||||
const handleUploadFace = () => {
|
||||
generateStore.updatePhotoInfo({})
|
||||
router.push({ name: 'uploadFace2' })
|
||||
}
|
||||
// 完成上传
|
||||
// 跳过上传
|
||||
const handleFinish = () => {
|
||||
generateStore.updatePhotoInfo({})
|
||||
generateStore.clearCustomizeInfo({})
|
||||
router.push({ name: 'customize' })
|
||||
}
|
||||
</script>
|
||||
@@ -71,7 +76,7 @@
|
||||
line-height: 132%;
|
||||
}
|
||||
}
|
||||
>.btns {
|
||||
> .btns {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
@@ -4,27 +4,27 @@
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { uploadCustomerPhoto } from '@/api/workshop'
|
||||
import { useGenerateStore } from '@/stores'
|
||||
const generateStore = useGenerateStore()
|
||||
|
||||
const emit = defineEmits(['view-type'])
|
||||
onMounted(() => {
|
||||
emit('view-type', 1)
|
||||
})
|
||||
const router = useRouter()
|
||||
const fileData = reactive({
|
||||
url:"",
|
||||
file: null,
|
||||
});
|
||||
console.log(fileData)
|
||||
const fileData = generateStore.photoInfo
|
||||
// 上传照片
|
||||
const handleUploadFace = () => {
|
||||
const input = document.createElement('input')
|
||||
input.type = 'file'
|
||||
input.accept = 'image/*'
|
||||
input.capture = 'camera'
|
||||
// input.capture = 'camera'
|
||||
input.click()
|
||||
input.onchange = (e: any) => {
|
||||
const file = e.target.files[0]
|
||||
if (!file) return
|
||||
const url = URL.createObjectURL(file)
|
||||
fileData.id = ''
|
||||
fileData.url = url
|
||||
fileData.file = file
|
||||
// const reader = new FileReader()
|
||||
@@ -36,14 +36,15 @@
|
||||
}
|
||||
// 生成照片
|
||||
const handleGenerate = () => {
|
||||
if (fileData.id) return router.push({ name: 'customize' })
|
||||
if (!fileData.file) return
|
||||
const formData = new FormData()
|
||||
formData.append('customerId', "1")
|
||||
formData.append('visitRecordId', "1")
|
||||
formData.append('customerId', '1')
|
||||
formData.append('visitRecordId', '1')
|
||||
formData.append('file', fileData.file)
|
||||
uploadCustomerPhoto(formData).then(res => {
|
||||
console.log(res, res.photoUrl)
|
||||
|
||||
uploadCustomerPhoto(formData).then((res) => {
|
||||
generateStore.updatePhotoInfo(res)
|
||||
generateStore.clearCustomizeInfo({})
|
||||
router.push({ name: 'customize' })
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user