|
|
@@ -7,7 +7,7 @@
|
|
|
</div>
|
|
|
<div class="top-bar">
|
|
|
<div class="back-and-company">
|
|
|
- <div class="back" @click="router.back">
|
|
|
+ <div class="back" @click="handelClickBack">
|
|
|
<img src="@/assets/rollback.png" />
|
|
|
<span>返回</span>
|
|
|
</div>
|
|
|
@@ -111,7 +111,12 @@
|
|
|
import usePageConfig from './usePageConfig';
|
|
|
import MapContainer from './component/mapContainer/MapContainer.vue';
|
|
|
import useMapEditor, { LabelPositionEnum } from './stores/useMapEditor';
|
|
|
- import { uploadCompanyLayout, updateCompanyLayout, getCompanyLayoutApi } from '@/api/scene/scene';
|
|
|
+ import {
|
|
|
+ uploadCompanyLayout,
|
|
|
+ updateCompanyLayout,
|
|
|
+ getCompanyLayoutApi,
|
|
|
+ getMobileCompanyLayoutApi,
|
|
|
+ } from '@/api/scene/scene';
|
|
|
import safeParse from '@/utils/safeParse';
|
|
|
import { useRouter } from 'vue-router';
|
|
|
import urlJoin from 'url-join';
|
|
|
@@ -119,6 +124,7 @@
|
|
|
import { getHeaders } from '@/utils/http/axios';
|
|
|
import { ShopType } from '@/types/page-config/type';
|
|
|
import ShopTagEditArea from './component/ShopTagEditArea.vue';
|
|
|
+ import { ViewType } from '@/types/page-config/type';
|
|
|
|
|
|
const mapEditor = useMapEditor();
|
|
|
const { bgImg, addedShops, activeShopId, showShops, mapHeight, mapWidth } =
|
|
|
@@ -156,6 +162,8 @@
|
|
|
),
|
|
|
);
|
|
|
|
|
|
+ const defaultLayoutString = ref(''); // 默认布局的string,用于点击返回时判断是否未保存布局就离开
|
|
|
+
|
|
|
const handleBeforeUpload = (rawFile) => {
|
|
|
if (
|
|
|
rawFile.type !== 'image/jpg' &&
|
|
|
@@ -204,11 +212,15 @@
|
|
|
};
|
|
|
|
|
|
const getShopContent = () => {
|
|
|
+ const companyLayoutApiMap = {
|
|
|
+ [ViewType.companyHomepage_PC]: getCompanyLayoutApi,
|
|
|
+ [ViewType.companyHomepage_phone]: getMobileCompanyLayoutApi,
|
|
|
+ };
|
|
|
getWorkshopListApi({ companyId: companyId.value! }).then((res) => {
|
|
|
shopList.value = res;
|
|
|
});
|
|
|
|
|
|
- getCompanyLayoutApi({
|
|
|
+ companyLayoutApiMap[viewType.value!]({
|
|
|
companyId: companyId.value!,
|
|
|
}).then((res) => {
|
|
|
if (!res) {
|
|
|
@@ -223,6 +235,7 @@
|
|
|
}
|
|
|
hasBg.value = true;
|
|
|
createMap(layoutJSON);
|
|
|
+ defaultLayoutString.value = res.layout;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
@@ -303,8 +316,23 @@
|
|
|
},
|
|
|
);
|
|
|
}
|
|
|
+ defaultLayoutString.value = layout;
|
|
|
};
|
|
|
|
|
|
+ function handelClickBack() {
|
|
|
+ const json = calcLayout(mapContainerRef.value?.getLayout().json);
|
|
|
+
|
|
|
+ if (json !== defaultLayoutString.value) {
|
|
|
+ ElMessageBox.confirm('未保存当前设置,是否离开?', '提示', {
|
|
|
+ confirmButtonText: '确认',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ }).then(() => {
|
|
|
+ router.back();
|
|
|
+ });
|
|
|
+ } else router.back();
|
|
|
+ }
|
|
|
+
|
|
|
watch(
|
|
|
() => mapHeight.value,
|
|
|
() => {
|