fix: 联调白模

This commit is contained in:
wam
2022-12-24 15:21:40 +08:00
parent f835ab8e4b
commit 7a5288e4a6
12 changed files with 208 additions and 57 deletions

View File

@@ -44,9 +44,14 @@ const constantRoutes = [
}, },
{ {
path: '/edit-creative', path: '/edit-creative-scene',
name: 'editCreative', name: 'editCreativeScene',
component: () => import(/* webpackChunkName: 'creative' */ '@views/Creative/Creation.vue') component: () => import(/* webpackChunkName: 'creative' */ '@views/Creative/CreationScene.vue')
},
{
path: '/edit-creative-model',
name: 'editCreativeModel',
component: () => import(/* webpackChunkName: 'creative' */ '@views/Creative/CreationModel.vue')
}, },
{ {
path: '/ring360-preview', path: '/ring360-preview',

View File

@@ -12,7 +12,7 @@
<TabListCommodity @clickThumb="clickThumbCommodity" @add="addCommodity" @remove="removeCommodity" /> <TabListCommodity @clickThumb="clickThumbCommodity" @add="addCommodity" @remove="removeCommodity" />
</div> </div>
<div class="yo-main"> <div class="yo-main">
<SceneSeparateTexturePreviewer :selCommodity="selCommodity" :selTexture="selTexture" /> <SceneSeparateTexturePreviewer ref="ss" :selCommodity="selCommodity" :selTexture="selTexture" />
</div> </div>
<div class="right"> <div class="right">
<TabListCommodityRelTexture :relCommodity="selCommodity" @clickThumb="clickThumbTexture" <TabListCommodityRelTexture :relCommodity="selCommodity" @clickThumb="clickThumbTexture"
@@ -46,7 +46,16 @@ import SceneSeparateTexturePreviewer from '../../shelves-vue/components/SceneSep
<script> <script>
import { updateMaterialCenter } from "../../../../api.js"
import common from "@/api/common.js";
export default { export default {
props: {
currentModelData: {
type: Object,
default: () => (null)
}
},
data() { data() {
return { return {
isOpenCommodityUploader: false, isOpenCommodityUploader: false,
@@ -60,19 +69,46 @@ export default {
back() { back() {
this.$router.push("/") this.$router.push("/")
}, },
save() { async save() {
// create new ware // create new ware
if (this.selCommodity && this.selTexture) { if (this.selCommodity && this.selTexture) {
this.$store.dispatch('wares/add', { var clone = {
type: 1, type: 1,
commodity: this.selCommodity, commodity: this.selCommodity,
texture: this.selTexture, texture: this.selTexture,
urlThumb: this.selCommodity.urlThumb, urlThumb: this.selCommodity.urlThumb,
}).then(data2 => { }
}) console.log(clone)
try{
const blob = await this.$refs.ss.previewer_.snapshot();
const res = await common.cosUpload3DCompress(blob);
await updateMaterialCenter({
id: this.$route.query.id,
data: clone,
version: new Date().getTime(),
cover: res.url
});
this.$router.go(-1);
}
catch(e){
console.log(e)
}
// this.$store.dispatch('wares/add', {
// type: 1,
// commodity: this.selCommodity,
// texture: this.selTexture,
// urlThumb: this.selCommodity.urlThumb,
// }).then(data2 => {
// })
} }

View File

@@ -26,6 +26,8 @@ import SearchSvg from '../../asset/icon2/search.svg'
<script> <script>
import { getMaterialLibrary } from "../../../../../api.js"
export default { export default {
data() { data() {
return { return {
@@ -33,10 +35,21 @@ export default {
list: [] list: []
} }
}, },
mounted() { async mounted() {
this.$store.dispatch('commodities/list').then(list => {
this.list = list var res = await getMaterialLibrary({
type: 7,
title: ""
}) })
this.list = res.data.map((x, index) => ({
...x.material_json,
urlThumb: x.material_json.urlThumb || x.cover,
}));
// this.$store.dispatch('commodities/list').then(list => {
// this.list = list
// })
}, },
methods: { methods: {
clickThumb(itm) { clickThumb(itm) {

View File

@@ -23,6 +23,8 @@ import ImageSvg from '../../asset/icon2/image.svg'
<script> <script>
import { getMaterialLibrary } from "../../../../../api.js"
export default { export default {
props: ['relCommodity'], props: ['relCommodity'],
data() { data() {
@@ -34,16 +36,27 @@ export default {
// mounted() { // mounted() {
// }, // },
watch: { watch: {
relCommodity(newV, oldV) { async relCommodity(newV, oldV) {
if (newV) { if (newV) {
// api.listTexturesByRelCommodityId(newV.id).then(list => { // api.listTexturesByRelCommodityId(newV.id).then(list => {
// console.log('xx list', list) // console.log('xx list', list)
// this.list = list // this.list = list
// }) // })
this.$store.dispatch('textures/listByRelCommodityId', { relCommodityId: newV.id }).then(list => { // this.$store.dispatch('textures/listByRelCommodityId', { relCommodityId: newV.id }).then(list => {
this.list = list // this.list = list
// console.log('COMMODITY fetch list', newV.id, list) // // console.log('COMMODITY fetch list', newV.id, list)
// })
var res = await getMaterialLibrary({
type: 8,
title: ""
}) })
this.list = res.data.map((x, index) => ({
...x.material_json,
urlThumb: x.material_json.urlThumb || x.cover,
}));
} else { } else {
this.list = [] this.list = []

View File

@@ -13,10 +13,7 @@
</a-button> </a-button>
<a-button class="yo-btn-right yo-btn-blue" type="primary" @click="$emit('save')"> <a-button class="yo-btn-right yo-btn-blue" type="primary" @click="$emit('save')">
<template #icon> 保存
<img :src="SendSvg" />
</template>
发送
</a-button> </a-button>
</div> </div>

View File

@@ -0,0 +1,39 @@
<template>
<div style="height: 100%;">
<AddWareWithSeparateTextureDemo v-if="modelData" :currentModelData="modelData" />
</div>
</template>
<script setup>
import { reactive, ref } from "@vue/reactivity";
import { onMounted } from "@vue/runtime-core";
import AddWareWithSeparateTextureDemo from "./3d/crossyo/shelves-vue-demo/view/AddWareWithSeparateTextureDemo.vue";
import { getMaterialsById } from "./api";
import { useRoute } from "vue-router";
const modelData = ref(null);
const route = useRoute();
onMounted(async () => {
const res = await getMaterialsById(route.query.id);
try{
modelData.value = res.data.materials[0].space_json;
}
catch(e){
console.error(`解析数据出错:` + e)
}
})
</script>
<style lang="scss" scoped>
@import url("./utils.default.scss");
:deep(img){
width: 100%;
}
</style>

View File

@@ -47,7 +47,7 @@
<a-menu-item> <a-menu-item>
<a href="javascript:;" @click="previewerCreationRef.show(row)">预览</a> <a href="javascript:;" @click="previewerCreationRef.show(row)">预览</a>
</a-menu-item> </a-menu-item>
<a-menu-item v-if="row.type==CREATIVE_TYPE.THREE_D"> <a-menu-item>
<a href="javascript:;" @click="edit(row)">编辑</a> <a href="javascript:;" @click="edit(row)">编辑</a>
</a-menu-item> </a-menu-item>
<a-menu-item> <a-menu-item>
@@ -156,12 +156,22 @@ const query = async () => {
} }
const edit = (row) => { const edit = (row) => {
router.push({ if(row.type == CREATIVE_TYPE.THREE_D) {
path: '/edit-creative', router.push({
query: { path: '/edit-creative-scene',
id: row.id query: {
} id: row.id
}) }
})
}
if(row.type == CREATIVE_TYPE.MODEL_3D) {
router.push({
path: '/edit-creative-model',
query: {
id: row.id
}
})
}
} }
const del = (row) => { const del = (row) => {

View File

@@ -83,7 +83,7 @@ const factorys = [
"urlThumb": "https://test-cxp-public-web-1302259445.cos.ap-beijing.myqcloud.com/uat-yls/3D/shelves/shelves-v3-store/v3.4/ware/milkpowder-can1.png" "urlThumb": "https://test-cxp-public-web-1302259445.cos.ap-beijing.myqcloud.com/uat-yls/3D/shelves/shelves-v3-store/v3.4/ware/milkpowder-can1.png"
}, },
"surveyLogo": "", "surveyLogo": "",
"surveyPrice": 190 "surveyPrice": 19
})) }))
} }
] ]
@@ -110,8 +110,22 @@ const factorys = [
}, },
{ {
type: CREATIVE_TYPE.MODEL_3D, type: CREATIVE_TYPE.MODEL_3D,
build: (data) => { build: (origin) => {
const data = origin.data;
var key = new Date().getTime();
origin.data = {
"id": `ware-${key}`,
"type": 1,
"commodity": {
"url": data.wares[0].material_json.url
},
"texture": null,
"urlThumb": ""
};
return origin;
} }
}, },
]; ];

View File

@@ -28,7 +28,7 @@
</div> </div>
<div v-if="formData.type==CREATIVE_TYPE.MODEL_3D" style="margin: 20px 0;"> <div v-if="formData.type==CREATIVE_TYPE.MODEL_3D" style="margin: 20px 0;">
<div v-if="step==1"> <div v-if="step==1">
<ChooseMarerial :type="THREE_D_TYPE.CHARTLET" @change="val => formData.data.panorama = val"/> <ChooseMarerial :type="THREE_D_TYPE.EMPTY_3D" @change="val => formData.data.wares = val"/>
</div> </div>
</div> </div>
<div v-if="formData.type==CREATIVE_TYPE.RING_360" style="margin: 20px 0;"> <div v-if="formData.type==CREATIVE_TYPE.RING_360" style="margin: 20px 0;">
@@ -171,6 +171,26 @@ const ok = async () => {
emit("complete"); emit("complete");
} }
} }
if(formData.value.type == CREATIVE_TYPE.MODEL_3D) {
if(step.value == 1) {
if(formData.value.data.wares.length <= 0) {
message.warning("请请选择一个模型")
return;
}
if(formData.value.data.wares.length > 1) {
message.warning("请请选择一个模型")
return;
}
}
if(step.value >= 1) {
const data = JSON.parse(JSON.stringify(formData.value));
await createMaterialCenter(buildData(data));
visible.value = false;
emit("complete");
}
}
step.value++; step.value++;
} }

View File

@@ -193,29 +193,38 @@ const factorys = [
{ {
type: THREE_D_TYPE.EMPTY_3D, type: THREE_D_TYPE.EMPTY_3D,
build(data){ build(data){
var url = data.fileList[0].response.url;
var key = new Date().getTime();
return { return {
...data, ...data,
"planetid": "ware1-1", data: {
"name": "伊利", "id": `model-${key}`,
"surveyWare": { "name": `${data.title}`,
"id": "ware1-1", "url":url,
"type": 1, "urlThumb": "",
"commodity": { "uvGroup": "uv0001"
"url": ""
},
"texture": null,
"urlThumb": ""
}, },
"surveyLogo": "",
"surveyPrice": 190
}; };
} }
}, },
{ {
type: THREE_D_TYPE.CHARTLET, type: THREE_D_TYPE.CHARTLET,
build(data){ build(data){
var url = data.fileList[0].response.url;
var key = new Date().getTime();
return { return {
...data ...data,
data: {
"id": `texture-${key}`,
"name": `${data.title}`,
"relUvGroup": "uv0001",
"url": url,
"urlSmall": url,
"relCommodityId": "vB8DxY"
}
}; };
} }
}, },

View File

@@ -10,7 +10,7 @@
</a-form-item> </a-form-item>
</a-form> </a-form>
<a-form v-if="step==1" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }" style="margin: 20px 0;"> <a-form v-if="step==1" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }" style="margin: 20px 0;">
<a-form-item v-if="[THREE_D_TYPE.PANORAMA].includes(formData.type)" label="上传图片" style="padding-right: 10%;"> <a-form-item v-if="[THREE_D_TYPE.PANORAMA, THREE_D_TYPE.CHARTLET].includes(formData.type)" label="上传图片" style="padding-right: 10%;">
<a-upload :customRequest="onCustomRequest" v-model:file-list="formData.fileList"> <a-upload :customRequest="onCustomRequest" v-model:file-list="formData.fileList">
<a-button> <a-button>
<upload-outlined></upload-outlined> <upload-outlined></upload-outlined>
@@ -21,7 +21,7 @@
全景图文件格式大小JPEG格式全景图比例21建议单张分辨率大小在2K及以上单张全景图最大支持上传120M建议上传小于10M的全景图效果更佳 全景图文件格式大小JPEG格式全景图比例21建议单张分辨率大小在2K及以上单张全景图最大支持上传120M建议上传小于10M的全景图效果更佳
</p> </p>
</a-form-item> </a-form-item>
<a-form-item v-if="[THREE_D_TYPE.ENV_3D, THREE_D_TYPE.SHELF, THREE_D_TYPE.EXHIBITION_BOOTH, THREE_D_TYPE.WARE].includes(formData.type)" label="" style="margin-left: 20%;"> <a-form-item v-if="[THREE_D_TYPE.ENV_3D, THREE_D_TYPE.SHELF, THREE_D_TYPE.EXHIBITION_BOOTH, THREE_D_TYPE.WARE, THREE_D_TYPE.EMPTY_3D].includes(formData.type)" label="" style="margin-left: 20%;">
<a-upload-dragger <a-upload-dragger
v-model:fileList="formData.fileList" v-model:fileList="formData.fileList"
name="file" name="file"
@@ -84,11 +84,6 @@ const formData = ref({
const show = (type) => { const show = (type) => {
if(type == THREE_D_TYPE.CHARTLET) {
message.info("素材库不支持上传贴图");
return;
}
const obj = THREE_D_TYPE_S.find(x => x.type == type); const obj = THREE_D_TYPE_S.find(x => x.type == type);
if(!obj) return; if(!obj) return;
@@ -124,7 +119,7 @@ const onCustomRequest = async (upload) => {
} }
// 缩略图预览 // 缩略图预览
if([THREE_D_TYPE.ENV_3D, THREE_D_TYPE.SHELF, THREE_D_TYPE.EXHIBITION_BOOTH, THREE_D_TYPE.WARE].includes(formData.value.type)){ if([THREE_D_TYPE.ENV_3D, THREE_D_TYPE.SHELF, THREE_D_TYPE.EXHIBITION_BOOTH, THREE_D_TYPE.WARE, THREE_D_TYPE.EMPTY_3D].includes(formData.value.type)){
let reader = new FileReader(); let reader = new FileReader();
reader.addEventListener( reader.addEventListener(
@@ -141,8 +136,8 @@ const onCustomRequest = async (upload) => {
reader.readAsArrayBuffer(upload.file); reader.readAsArrayBuffer(upload.file);
} }
// 全景图直接上传缩略图 // 全景图、贴图的缩略图直接上传
if(THREE_D_TYPE.PANORAMA == formData.value.type) { if([THREE_D_TYPE.PANORAMA, THREE_D_TYPE.CHARTLET].includes(formData.value.type)) {
const data = await common.cosUpload3DCompress(upload.file); const data = await common.cosUpload3DCompress(upload.file);
formData.value.cover = data.url; formData.value.cover = data.url;
} }
@@ -169,7 +164,7 @@ const ok = async () => {
if(step.value >= 1) { if(step.value >= 1) {
if([THREE_D_TYPE.ENV_3D, THREE_D_TYPE.SHELF, THREE_D_TYPE.EXHIBITION_BOOTH, THREE_D_TYPE.WARE].includes(formData.value.type)){ if([THREE_D_TYPE.ENV_3D, THREE_D_TYPE.SHELF, THREE_D_TYPE.EXHIBITION_BOOTH, THREE_D_TYPE.WARE, THREE_D_TYPE.EMPTY_3D].includes(formData.value.type)){
var blob = await viewerRef.value.snapshot(); var blob = await viewerRef.value.snapshot();
const data = await common.cosUpload3DCompress(blob); const data = await common.cosUpload3DCompress(blob);
formData.value.cover = data.url; formData.value.cover = data.url;