This commit is contained in:
全栈小学生 2024-09-28 09:42:12 +08:00
parent 392c23f9a1
commit f77419bb60
2 changed files with 16 additions and 18 deletions

View File

@ -1,4 +1,4 @@
.draggable-element { .ignore-draggable-element, .draggable-element {
&.decorate { &.decorate {
&:hover:before { &:hover:before {
content: ''; content: '';

View File

@ -1,4 +1,4 @@
import { ref, reactive, onMounted, nextTick, computed } from 'vue'; import { ref, onMounted, nextTick, computed } from 'vue';
import Sortable from 'sortablejs'; import Sortable from 'sortablejs';
import { range } from 'lodash-es'; import { range } from 'lodash-es';
import { onPageScroll, onHide, onShow } from '@dcloudio/uni-app'; import { onPageScroll, onHide, onShow } from '@dcloudio/uni-app';
@ -7,8 +7,8 @@ import { getLocation } from '@/utils/common';
export function useDiyGroup(params: any = {}) { export function useDiyGroup(params: any = {}) {
let scrollVal = ""; //组件滚动值集合 let scrollVal: any = ""; //组件滚动值集合
const componentsScrollBool = ref({}); //组件是否根据滚动进行相应改变 const componentsScrollBool: any = ref({}); //组件是否根据滚动进行相应改变
const diyStore = useDiyStore(); const diyStore = useDiyStore();
const positionFixed = ref(['fixed', 'top_fixed', 'right_fixed', 'bottom_fixed', 'left_fixed']); const positionFixed = ref(['fixed', 'top_fixed', 'right_fixed', 'bottom_fixed', 'left_fixed']);
@ -60,13 +60,12 @@ export function useDiyGroup(params: any = {}) {
return false; return false;
} }
// 监听页面加载完成 // 监听页面加载完成
const onMountedLifeCycle = () => { const onMountedLifeCycle = () => {
onMounted(() => { onMounted(() => {
// #ifdef H5 // #ifdef H5
if (diyStore.mode == 'decorate') { if (diyStore.mode == 'decorate') {
var el = document.getElementById('componentList'); var el: any = document.getElementById('componentList');
const sortable = Sortable.create(el, { const sortable = Sortable.create(el, {
draggable: '.draggable-element', draggable: '.draggable-element',
animation: 200, animation: 200,
@ -77,7 +76,7 @@ export function useDiyGroup(params: any = {}) {
diyStore.value.splice(event.newIndex!, 0, temp); diyStore.value.splice(event.newIndex!, 0, temp);
nextTick(() => { nextTick(() => {
sortable.sort(range(diyStore.value.length).map(value => { sortable.sort(range(diyStore.value.length).map((value: any) => {
return value.toString(); return value.toString();
})); }));
@ -94,7 +93,6 @@ export function useDiyGroup(params: any = {}) {
// 第一次获取经纬度 // 第一次获取经纬度
getLocation() getLocation()
} }
}, 500)
// 初始化组件滚动值 // 初始化组件滚动值
scrollVal = uni.getStorageSync('componentsScrollValGroup'); scrollVal = uni.getStorageSync('componentsScrollValGroup');
@ -103,8 +101,8 @@ export function useDiyGroup(params: any = {}) {
componentsScrollBool.value[key] = -1; componentsScrollBool.value[key] = -1;
} }
} }
}, 500)
}); });
}); });
} }
@ -120,7 +118,7 @@ export function useDiyGroup(params: any = {}) {
const placeholderEvent = () => { const placeholderEvent = () => {
} }
let isPagesHide = ref(false) const isPagesHide = ref(false)
onShow(() => { onShow(() => {
isPagesHide.value = false; isPagesHide.value = false;
}) })
@ -129,7 +127,7 @@ export function useDiyGroup(params: any = {}) {
}) })
// 监听滚动事件 // 监听滚动事件
let scrollValStr = ref() const scrollValStr = ref()
const onPageScrollLifeCycle = () => { const onPageScrollLifeCycle = () => {
onPageScroll((e) => { onPageScroll((e) => {
if (scrollVal && !isPagesHide.value) { if (scrollVal && !isPagesHide.value) {