|
@@ -77,9 +77,7 @@
|
|
|
v-for="elem in item.list"
|
|
|
:draggable="true"
|
|
|
@dragstart="dragStart($event, elem)"
|
|
|
- @drag="drag($event, elem)"
|
|
|
- @dragend="dragEnd()"
|
|
|
- @click.stop="dragStart($event, elem)"
|
|
|
+ @click.prevent="dragStart($event, elem)"
|
|
|
@dblclick.stop="open(elem)"
|
|
|
@contextmenu="onContextMenu($event, item, elem)"
|
|
|
>
|
|
@@ -114,8 +112,6 @@
|
|
|
v-for="elem in subGroups"
|
|
|
:draggable="true"
|
|
|
@dragstart="dragStart($event, elem)"
|
|
|
- @drag="drag($event, elem)"
|
|
|
- @dragend="dragEnd()"
|
|
|
@click.stop="dragStart($event, elem)"
|
|
|
@dblclick.stop="open(elem)"
|
|
|
>
|
|
@@ -149,13 +145,14 @@
|
|
|
v-if="contextmenu.visible"
|
|
|
tabindex="0"
|
|
|
:style="contextmenu.style"
|
|
|
- @blu1r="contextmenu.visible = false"
|
|
|
+ @blur="contextmenu.visible = false"
|
|
|
>
|
|
|
<t-menu class="context-menu" @change="onMenu" expandType="popup">
|
|
|
<t-submenu
|
|
|
value="move"
|
|
|
title="移动到"
|
|
|
v-if="contextmenu.subMenus.length"
|
|
|
+ :disabled="!contextmenu.component.component"
|
|
|
>
|
|
|
<t-menu-item
|
|
|
v-for="subMenu in contextmenu.subMenus"
|
|
@@ -165,7 +162,9 @@
|
|
|
</t-menu-item>
|
|
|
</t-submenu>
|
|
|
<t-menu-item value="edit"> 编辑 </t-menu-item>
|
|
|
- <t-menu-item value="del"> 删除 </t-menu-item>
|
|
|
+ <t-menu-item value="del" :disabled="!contextmenu.component.component">
|
|
|
+ 删除
|
|
|
+ </t-menu-item>
|
|
|
</t-menu>
|
|
|
</div>
|
|
|
|
|
@@ -179,27 +178,66 @@
|
|
|
>
|
|
|
确定删除该数据吗?删除后不可恢复!
|
|
|
</t-dialog>
|
|
|
+ <t-dialog
|
|
|
+ v-if="chargeDialog.show"
|
|
|
+ :header="chargeDialog.data.name"
|
|
|
+ :visible="true"
|
|
|
+ @close="chargeDialog.show = false"
|
|
|
+ width="70%"
|
|
|
+ :top="8"
|
|
|
+ >
|
|
|
+ <t-image :src="chargeDialog.data.image" />
|
|
|
+ <template #footer>
|
|
|
+ <div class="flex between" style="margin-top: -7px">
|
|
|
+ <p>付费项目,购买后查看并使用</p>
|
|
|
+ <div>
|
|
|
+ <label>金额:</label>
|
|
|
+ <label class="bland">¥{{ chargeDialog.data.price }}</label>
|
|
|
+ <t-button class="primary ml-12" @click="onSubmitOrder"
|
|
|
+ >购买</t-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </t-dialog>
|
|
|
+
|
|
|
+ <t-dialog
|
|
|
+ v-if="wechatPayDialog.show"
|
|
|
+ v-model:visible="wechatPayDialog.show"
|
|
|
+ class="pay-dialog"
|
|
|
+ header="乐吾乐收银台"
|
|
|
+ :close-on-overlay-click="false"
|
|
|
+ :top="95"
|
|
|
+ :width="700"
|
|
|
+ confirm-btn="支付完成"
|
|
|
+ :cancel-btn="null"
|
|
|
+ @close="getPayResult"
|
|
|
+ >
|
|
|
+ <WechatPay
|
|
|
+ :order="wechatPayDialog.order"
|
|
|
+ :code-url="wechatPayDialog.order.codeUrl"
|
|
|
+ @success="onChargeSuccess"
|
|
|
+ />
|
|
|
+ </t-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
import { onMounted, onUnmounted, reactive, ref } from 'vue';
|
|
|
import { useRouter } from 'vue-router';
|
|
|
+import { MessagePlugin } from 'tdesign-vue-next';
|
|
|
import axios from 'axios';
|
|
|
|
|
|
-import { cases, shapes, charts, formComponents } from '@/services/defaults';
|
|
|
+import { cases, shapes, formComponents } from '@/services/defaults';
|
|
|
+import { charts } from '@/services/echarts';
|
|
|
import { getFolders, getFiles, getIcons } from '@/services/png';
|
|
|
-import {
|
|
|
- getComponents,
|
|
|
- getComponentsList,
|
|
|
- getLe5leV,
|
|
|
- updateCollection,
|
|
|
-} from '@/services/api';
|
|
|
+import { getComponentsList, getLe5leV, updateCollection } from '@/services/api';
|
|
|
import { convertPen } from '@/services/upgrade';
|
|
|
import { deepClone } from '@meta2d/core';
|
|
|
import { isGif } from '@/services/utils';
|
|
|
import { autoSave, delAttrs } from '@/services/common';
|
|
|
-import { MessagePlugin } from 'tdesign-vue-next';
|
|
|
+
|
|
|
+import WechatPay from './WechatPay.vue';
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
@@ -258,6 +296,12 @@ const materials = ref([]);
|
|
|
const pngs = ref([]);
|
|
|
const icons = ref([]);
|
|
|
|
|
|
+let dropped = false;
|
|
|
+const chargeDialog = reactive<any>({});
|
|
|
+const wechatPayDialog = reactive<any>({
|
|
|
+ show: false,
|
|
|
+});
|
|
|
+
|
|
|
const groupChange = async (name: string) => {
|
|
|
activedPanel.value = [];
|
|
|
activedGroup.value = name;
|
|
@@ -330,7 +374,7 @@ const getCaseProjects = async (name: string, group?: string) => {
|
|
|
{
|
|
|
query,
|
|
|
shared: 'true',
|
|
|
- projection: { _id: 1, name: 1, image: 1, price: 1 },
|
|
|
+ projection: { id: 1, _id: 1, name: 1, image: 1, price: 1 },
|
|
|
}
|
|
|
);
|
|
|
|
|
@@ -338,6 +382,9 @@ const getCaseProjects = async (name: string, group?: string) => {
|
|
|
return [];
|
|
|
}
|
|
|
for (const item of ret.list) {
|
|
|
+ if (!item.id) {
|
|
|
+ item.id = item._id;
|
|
|
+ }
|
|
|
item.draggable = false;
|
|
|
}
|
|
|
return ret.list;
|
|
@@ -391,74 +438,83 @@ const getPrivateGroups = async () => {
|
|
|
|
|
|
const dragStart = async (event: DragEvent | MouseEvent, item: any) => {
|
|
|
event.stopPropagation();
|
|
|
-
|
|
|
- let data = null;
|
|
|
-
|
|
|
- if (!item || (event instanceof DragEvent && !event.dataTransfer)) {
|
|
|
+ if (!item) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (!item.draggable) {
|
|
|
- data = item.data;
|
|
|
+ meta2d.canvas.addCaches = [];
|
|
|
+ dropped = false;
|
|
|
+
|
|
|
+ let data = null;
|
|
|
+ const id = item._id || item.id;
|
|
|
+ let isAsync: boolean;
|
|
|
+ if (item.draggable === false) {
|
|
|
+ // 场景
|
|
|
+ data = item.data || item;
|
|
|
} else if (item['3d']) {
|
|
|
+ // 3D
|
|
|
data = {
|
|
|
name: 'iframe',
|
|
|
width: 400,
|
|
|
height: 300,
|
|
|
externElement: true,
|
|
|
- iframe: 'https://view3d.le5le.com/?id=' + (item._id || item.id),
|
|
|
+ iframe: 'https://view3d.le5le.com/?id=' + id,
|
|
|
};
|
|
|
- } else {
|
|
|
- if (item._id && !item.componentDatas) {
|
|
|
- let res: any = await getComponents(item._id);
|
|
|
- item.component = true;
|
|
|
- item.componentDatas = res.componentDatas;
|
|
|
- item.componentData = res.componentData;
|
|
|
+ } else if (item.component) {
|
|
|
+ // 我的组件
|
|
|
+ if (!item.componentDatas && !item.componentData) {
|
|
|
+ isAsync = true;
|
|
|
+ const ret: any = await axios.post(`/api/data/le5leV-components/get`, {
|
|
|
+ id,
|
|
|
+ });
|
|
|
+ item.componentDatas = ret.componentDatas;
|
|
|
+ item.componentData = ret.componentData;
|
|
|
}
|
|
|
- if (!item.data && !item.component && item.image) {
|
|
|
- let target: any = event.target;
|
|
|
- target.children[0] && (target = target.children[0].children[0]);
|
|
|
- // firefox naturalWidth svg 图片 可能是 0
|
|
|
- const normalWidth = target.naturalWidth || target.width;
|
|
|
- const normalHeight = target.naturalHeight || target.height;
|
|
|
- const [name, lockedOnCombine] = isGif(item.image)
|
|
|
- ? ['gif', 0]
|
|
|
- : ['image', undefined];
|
|
|
-
|
|
|
- data = {
|
|
|
- name,
|
|
|
- width: 100,
|
|
|
- height: 100 * (normalHeight / normalWidth),
|
|
|
- image: item.image,
|
|
|
- imageRatio: true,
|
|
|
- lockedOnCombine,
|
|
|
- };
|
|
|
- } else if (item.component) {
|
|
|
- if (item.componentData) {
|
|
|
- const pens = convertPen([item.componentData]);
|
|
|
- data = deepClone(pens);
|
|
|
- } else if (item.componentDatas) {
|
|
|
- data = deepClone(item.componentDatas);
|
|
|
- }
|
|
|
- } else {
|
|
|
- data = item.componentDatas || item.data;
|
|
|
+ if (item.componentData) {
|
|
|
+ const pens = convertPen([item.componentData]);
|
|
|
+ data = deepClone(pens);
|
|
|
+ } else if (item.componentDatas) {
|
|
|
+ data = deepClone(item.componentDatas);
|
|
|
}
|
|
|
- }
|
|
|
+ } else if (item.data) {
|
|
|
+ // 普通图元
|
|
|
+ data = item.data;
|
|
|
+ } else if (item.image) {
|
|
|
+ // 拖拽图片
|
|
|
+ let target: any = event.target;
|
|
|
+ target.children[0] && (target = target.children[0].children[0]);
|
|
|
+ // firefox naturalWidth svg 图片 可能是 0
|
|
|
+ const normalWidth = target.naturalWidth || target.width;
|
|
|
+ const normalHeight = target.naturalHeight || target.height;
|
|
|
+ const [name, lockedOnCombine] = isGif(item.image)
|
|
|
+ ? ['gif', 0]
|
|
|
+ : ['image', undefined];
|
|
|
|
|
|
- if (event instanceof DragEvent) {
|
|
|
- meta2d.canvas.addCaches = [];
|
|
|
- event.dataTransfer?.setData('Meta2d', JSON.stringify(data));
|
|
|
+ data = {
|
|
|
+ name,
|
|
|
+ width: 100,
|
|
|
+ height: 100 * (normalHeight / normalWidth),
|
|
|
+ image: item.image,
|
|
|
+ imageRatio: true,
|
|
|
+ lockedOnCombine,
|
|
|
+ };
|
|
|
} else {
|
|
|
- if (!Array.isArray(data)) {
|
|
|
- data = deepClone([data]);
|
|
|
- }
|
|
|
- meta2d.canvas.addCaches = data;
|
|
|
+ return;
|
|
|
}
|
|
|
-};
|
|
|
|
|
|
-const drag = (event: DragEvent, item: any) => {};
|
|
|
+ if (!Array.isArray(data)) {
|
|
|
+ data = deepClone([data]);
|
|
|
+ }
|
|
|
+
|
|
|
+ !dropped && (meta2d.canvas.addCaches = data);
|
|
|
|
|
|
-const dragEnd = () => {};
|
|
|
+ if (event instanceof DragEvent) {
|
|
|
+ event.dataTransfer.setData(
|
|
|
+ 'Meta2d',
|
|
|
+ isAsync ? undefined : JSON.stringify(data)
|
|
|
+ );
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
const dragstart = (event: any) => {
|
|
|
event.target.style.opacity = 0.5;
|
|
@@ -469,9 +525,19 @@ const dragend = (event: any) => {
|
|
|
};
|
|
|
|
|
|
const open = async (item: any) => {
|
|
|
- if (item.draggable !== false) {
|
|
|
+ if (!item || item.draggable !== false) {
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
+ const ret: any = await getLe5leV(item._id || item.id);
|
|
|
+ if (!ret) {
|
|
|
+ if (item.price > 0) {
|
|
|
+ chargeDialog.data = item;
|
|
|
+ chargeDialog.show = true;
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
router.push({
|
|
|
path: '/',
|
|
|
query: {
|
|
@@ -479,12 +545,12 @@ const open = async (item: any) => {
|
|
|
},
|
|
|
});
|
|
|
|
|
|
- const ret: any = await getLe5leV(item._id || item.id);
|
|
|
for (const k of delAttrs) {
|
|
|
- delete (ret as any)[k];
|
|
|
+ delete ret[k];
|
|
|
}
|
|
|
+
|
|
|
+ autoSave();
|
|
|
meta2d.open(ret);
|
|
|
- autoSave(true);
|
|
|
};
|
|
|
|
|
|
const onChangeGroupPanel = async (val: string[]) => {
|
|
@@ -666,7 +732,7 @@ const onContextMenu = async (e: MouseEvent, group: string, item: any) => {
|
|
|
e.preventDefault();
|
|
|
e.stopPropagation();
|
|
|
|
|
|
- if (activedGroup.value !== '我的' || !item.component) {
|
|
|
+ if (activedGroup.value !== '我的') {
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -707,15 +773,23 @@ const onMenu = async (val: string) => {
|
|
|
|
|
|
switch (val) {
|
|
|
case 'edit':
|
|
|
- autoSave();
|
|
|
- router.push({
|
|
|
- path: '/',
|
|
|
- query: {
|
|
|
- id,
|
|
|
- c: 1,
|
|
|
- r: Date.now() + '',
|
|
|
- },
|
|
|
- });
|
|
|
+ if (contextmenu.component.component) {
|
|
|
+ autoSave();
|
|
|
+ router.push({
|
|
|
+ path: '/',
|
|
|
+ query: {
|
|
|
+ id,
|
|
|
+ c: 1,
|
|
|
+ r: Date.now() + '',
|
|
|
+ },
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ let url = 'https://3d.le5le.com/?id=';
|
|
|
+ if (import.meta.env.VITE_TRIAL == 0 && (window as any).url3D) {
|
|
|
+ url = (window as any).url3D;
|
|
|
+ }
|
|
|
+ window.open(url + id, '_blank');
|
|
|
+ }
|
|
|
|
|
|
break;
|
|
|
case 'del':
|
|
@@ -796,13 +870,49 @@ const delComponet = async () => {
|
|
|
delDialog.show = false;
|
|
|
};
|
|
|
|
|
|
+const drop = (obj: any) => {
|
|
|
+ dropped = true;
|
|
|
+
|
|
|
+ if (obj) {
|
|
|
+ Array.isArray(obj) && open(obj[0]);
|
|
|
+ } else {
|
|
|
+ MessagePlugin.warning('正在请求网络数据中,请稍后重试');
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const onSubmitOrder = async () => {
|
|
|
+ const result: any = await axios.post('/api/order/datas/submit', {
|
|
|
+ collection: 'le5leV',
|
|
|
+ id: chargeDialog.data._id,
|
|
|
+ });
|
|
|
+ if (result) {
|
|
|
+ wechatPayDialog.order = result;
|
|
|
+ wechatPayDialog.show = true;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const getPayResult = async () => {
|
|
|
+ const result: { state: number } = await axios.post('/api/order/pay/state', {
|
|
|
+ id: wechatPayDialog.order.id || wechatPayDialog.order._id,
|
|
|
+ });
|
|
|
+ if (result && result.state) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const onChargeSuccess = () => {
|
|
|
+ MessagePlugin.success('支付成功!');
|
|
|
+ wechatPayDialog.show = false;
|
|
|
+ chargeDialog.show = false;
|
|
|
+};
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
groupChange('场景');
|
|
|
document.addEventListener('dragstart', dragstart, false);
|
|
|
document.addEventListener('dragend', dragend, false);
|
|
|
|
|
|
setTimeout(() => {
|
|
|
- meta2d.on('drop', open);
|
|
|
+ meta2d.on('drop', drop);
|
|
|
}, 2000);
|
|
|
});
|
|
|
|
|
@@ -810,7 +920,7 @@ onUnmounted(() => {
|
|
|
document.removeEventListener('dragstart', dragstart);
|
|
|
document.removeEventListener('dragend', dragend);
|
|
|
|
|
|
- meta2d.off('drop', open);
|
|
|
+ meta2d.off('drop', drop);
|
|
|
});
|
|
|
</script>
|
|
|
<style lang="postcss" scoped>
|
|
@@ -830,7 +940,7 @@ onUnmounted(() => {
|
|
|
flex-grow: 1;
|
|
|
overflow-y: auto;
|
|
|
font-size: 12px;
|
|
|
- z-index: 100;
|
|
|
+ z-index: 7;
|
|
|
|
|
|
.groups {
|
|
|
& > div {
|