|
@@ -178,28 +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, 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();
|
|
|
|
|
@@ -259,6 +297,10 @@ 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 = [];
|
|
@@ -332,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 },
|
|
|
}
|
|
|
);
|
|
|
|
|
@@ -340,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;
|
|
@@ -483,6 +528,16 @@ const open = async (item: any) => {
|
|
|
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: {
|
|
@@ -490,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[]) => {
|
|
@@ -825,6 +880,32 @@ const drop = (obj: any) => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+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);
|