From 6078950093802a9a1e426d63ddba3704bbc85bb6 Mon Sep 17 00:00:00 2001 From: xjs Date: Thu, 20 Mar 2025 18:02:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=88=91=E7=9A=84=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=AD=A3=E5=9C=A8=E7=BC=96=E5=86=99=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/dragSort/DragSort.vue | 235 ++++-------------- .../home/major/components/MajorUniversity.vue | 2 +- .../home/wishesList/components/DataTable.vue | 1 + .../wishesList/components/SortCollege.vue | 1 + src/pages-sub/home/wishesList/wishesList.vue | 15 +- .../static/images/ucenter/vip-crown.png | Bin 0 -> 1934 bytes .../ucenter/appointment/appointment.vue | 76 ++++++ .../ucenter/evaluate/evaluateList.vue | 62 +++++ src/pages-sub/ucenter/openVip.vue | 11 - src/pages-sub/ucenter/star/myStar.vue | 159 ++++++++++++ .../ucenter/vip/components/VipTable.vue | 166 +++++++++++++ src/pages-sub/ucenter/vip/openVip.vue | 148 +++++++++++ src/pages-sub/ucenter/wishList/wishList.vue | 119 +++++++++ src/pages.json | 42 +++- src/pages/ucenter/index/index.vue | 41 ++- src/service/index/api.ts | 17 ++ src/types/uni-pages.d.ts | 6 +- src/typings.ts | 6 - 18 files changed, 883 insertions(+), 224 deletions(-) create mode 100644 src/pages-sub/static/images/ucenter/vip-crown.png create mode 100644 src/pages-sub/ucenter/appointment/appointment.vue create mode 100644 src/pages-sub/ucenter/evaluate/evaluateList.vue delete mode 100644 src/pages-sub/ucenter/openVip.vue create mode 100644 src/pages-sub/ucenter/star/myStar.vue create mode 100644 src/pages-sub/ucenter/vip/components/VipTable.vue create mode 100644 src/pages-sub/ucenter/vip/openVip.vue create mode 100644 src/pages-sub/ucenter/wishList/wishList.vue delete mode 100644 src/typings.ts diff --git a/src/pages-sub/components/dragSort/DragSort.vue b/src/pages-sub/components/dragSort/DragSort.vue index c583995..4d6e1b3 100644 --- a/src/pages-sub/components/dragSort/DragSort.vue +++ b/src/pages-sub/components/dragSort/DragSort.vue @@ -24,8 +24,8 @@ :style="[ { 'z-index': activeIndex === index ? 9 : 1 }, { top: activeIndex === index ? scrollInfo.y + 'px' : 0 }, + isList ? { height: item.height + 'px' } : getItemStyle, - { position: 'absolute' }, ]" class="base-drag-wrapper" > @@ -58,7 +58,6 @@ { 'z-index': activeIndex === index ? 9 : 1 }, { top: activeIndex === index ? scrollInfo.y + 'px' : 0 }, isList ? { height: item.height + 'px' } : getItemStyle, - { position: 'absolute' }, ]" class="base-drag-wrapper" > @@ -261,13 +260,10 @@ const getAreaStyle = computed(() => { const w = getRealWidth(width.value) let h: string | number = props.height if (h === 'auto') { - if (isList.value) { - // 列表模式下,计算所有元素的总高度 - h = showList.value.reduce((total, item) => total + (item.height || defaultHeight), 0) - } else { - // 网格模式下,根据列数和每行高度计算 - h = Math.ceil(showList.value.length / props.column) * getItemHeight.value - } + // 长度/横排的数量 * 高度 = 总高度; 不能使用viewMaxHeight的高度,因为这是根据每个item的高度分别增加的,而不是根据 最高的item增加的。 + h = isList.value + ? viewMaxHeight.value + : Math.ceil(showList.value.length / props.column) * getItemHeight.value } let style = { width: w + 'px', @@ -333,174 +329,56 @@ const getPosition = (index: number, list = cloneList.value): [number, number] => return [x, y] } -// 添加任务调度系统 -interface Task { - index: number - priority: number - timestamp: number -} - -const taskQueue = ref([]) -const isProcessing = ref(false) -const lastFrameTime = ref(0) -const FRAME_DURATION = 16 // 16ms 每帧 -const IDLE_TIMEOUT = 50 // 空闲超时时间 -const defaultHeight = 400 // 默认高度 400rpx -const viewportTop = ref(0) -const viewportHeight = ref(0) -const viewportBottom = computed(() => viewportTop.value + viewportHeight.value) - -// 计算元素优先级 -const calculatePriority = (index: number, y: number, height: number): number => { - let priority = 0 - // 在视口中的元素优先级最高 - if (y <= viewportBottom.value && y + height >= viewportTop.value) { - priority = 3 - } - // 即将进入视口的元素次之 - else if (y < viewportBottom.value + 200) { - priority = 2 - } - // 其他元素优先级最低 - else { - priority = 1 - } - return priority -} - -// 任务处理函数 -const processTask = (task: Task) => { - return new Promise((resolve) => { - const item = showList.value[task.index] - if (!item) { - resolve() - return +// 初始化 +const initList = (list: ItemType[] = [], changeheight: boolean = false) => { + const newList = deepCopy(list) + showList.value = newList.map((item, index) => { + const [x, y] = getPosition(index) + let data = { + ...item, + x, + y, + dropId: index + 1, } - - // 获取元素实际高度 + let key = 'slot' + Math.random() + index + // 如果x轴和y轴没变,那么不用更新key来刷新状态 + if (x === item?.x && y === item?.y) { + if (activeIndex.value !== index) { + // 非当前点击的下标和目标下标的下标不需要生成新的key + key = item.key + } + } + data.key = key + return data + }) + cloneList.value = deepCopy(showList.value) + nextTick(() => { + showArea.value = true + }) + if (changeheight && props.itemHeight === 'auto') { const query = uni.createSelectorQuery().in(instance.proxy) query .selectAll('.slotContent') .boundingClientRect((data) => { - if (data && Array.isArray(data) && data[task.index]) { - // 更新高度 - item.height = data[task.index].height - - // 计算y值:累加之前所有元素的高度 - let y = 0 - for (let i = 0; i < task.index; i++) { - y += data[i].height || defaultHeight + let domList = JSON.parse(JSON.stringify(data)) + let max = 0 + let _viewMaxHeight = 0 + for (let i = 0; i < domList.length; i++) { + let height = domList[i].height + if (isList.value) { + cloneList.value[i].height = height + } + _viewMaxHeight += height + if (height > max) { + max = height } - - // 计算x值 - const x = (task.index % props.column) * Number(getItemWidth.value) - - // 更新位置 - item.x = x - item.y = y - - // 更新列表 - showList.value[task.index] = { ...item } - console.log('更新高度和位置:', task.index, item.height, item.x, item.y) } - resolve() + viewMaxHeight.value = _viewMaxHeight // 内容区域总高度 + itemMaxHeight.value = max + 'px' + initList(cloneList.value) }) .exec() - }) -} - -// 任务调度器 -const scheduleTask = async () => { - if (isProcessing.value || taskQueue.value.length === 0) return - - isProcessing.value = true - const currentTime = Date.now() - const timeSinceLastFrame = currentTime - lastFrameTime.value - - // 如果距离上一帧时间太短,等待下一帧 - if (timeSinceLastFrame < FRAME_DURATION) { - await new Promise((resolve) => setTimeout(resolve, FRAME_DURATION - timeSinceLastFrame)) } - - // 获取优先级最高的任务 - const task = taskQueue.value.reduce((prev, curr) => (prev.priority > curr.priority ? prev : curr)) - - // 从队列中移除 - taskQueue.value = taskQueue.value.filter((t) => t.index !== task.index) - - // 处理任务 - await processTask(task) - - lastFrameTime.value = Date.now() - isProcessing.value = false - - // 如果还有任务,继续调度 - if (taskQueue.value.length > 0) { - setTimeout(() => { - scheduleTask() - }, 0) - } -} - -// 修改初始化列表方法 -const initList = (list: ItemType[] = [], changeheight: boolean = false): Promise => { - return new Promise((resolve) => { - const newList = deepCopy(list) - - // 初始化显示列表,使用默认高度 - showList.value = newList.map((item, index) => { - let y = 0 - // 计算当前元素之前所有元素的高度总和 - for (let i = 0; i < index; i++) { - y += newList[i]?.height || defaultHeight - } - - const x = (index % props.column) * Number(getItemWidth.value) - return { - ...item, - x, - y, - height: item.height || defaultHeight, - dropId: index + 1, - key: 'slot' + Math.random() + index, - } - }) - - cloneList.value = deepCopy(showList.value) - - if (changeheight && props.itemHeight === 'auto') { - // 初始化任务队列 - taskQueue.value = showList.value.map((_, index) => ({ - index, - priority: 0, - timestamp: Date.now(), - })) - - // 开始任务调度 - nextTick(() => { - console.log('开始处理任务队列:', taskQueue.value.length) - scheduleTask() - }) - } else { - resolve() - } - }) -} - -// 修改滚动处理函数 -const handleScroll = (e: any) => { - const scrollTop = e.detail.scrollTop - viewportTop.value = scrollTop - - // 更新任务队列优先级 - taskQueue.value = taskQueue.value.map((task) => ({ - ...task, - priority: calculatePriority( - task.index, - showList.value[task.index].y, - showList.value[task.index].height, - ), - })) } // 方法 @@ -509,6 +387,10 @@ const showPlaceholder = (i: number): boolean => { // 位于底部或者指定位置等于活动位置时,都不会显示占位 let isShow = false if (moveToIndex.value > activeIndex.value) { + // 指定下标位置大于活动下标,i-1; 目的是为了用指定位置的下一级判断占位 + if (moveToIndex.value === i - 1) { + isShow = true + } } else if (moveToIndex.value === activeIndex.value) { return false // 位置不变时 } else if (moveToIndex.value < activeIndex.value) { @@ -734,10 +616,8 @@ const getViewCallback = (data: any, size: number) => { return } width.value = data.width - showArea.value = true // 确保显示区域 nextTick(() => { - console.log('初始化列表,数据长度:', showList.value.length) - initList(showList.value, true) + initList(showList.value, true) // 初始化 dom }) } @@ -766,9 +646,7 @@ showList.value = deepCopy(props.list) || [] // 组件挂载后初始化 onMounted(() => { - nextTick(() => { - setLeoDrag() - }) + setLeoDrag() }) // 暴露方法给父组件调用 @@ -787,21 +665,12 @@ defineExpose({ display: flex; align-items: center; transition: top 0.4s; - position: absolute; - left: 0; - top: 0; + flex-wrap: wrap; /* #ifndef APP-NVUE */ width: 100%; /* #endif */ } - -.movable-area { - position: relative; - width: 100%; - overflow: hidden; -} - .slotContent { display: flex; /* #ifndef APP-NVUE */ diff --git a/src/pages-sub/home/major/components/MajorUniversity.vue b/src/pages-sub/home/major/components/MajorUniversity.vue index 6828ed9..1eebaab 100644 --- a/src/pages-sub/home/major/components/MajorUniversity.vue +++ b/src/pages-sub/home/major/components/MajorUniversity.vue @@ -42,7 +42,7 @@ [{{ item.yxdm }}]{{ item.yxmc }} {{ item.cityname }}·{{ item.ulevel }} - {{ item.featuretag?.split('/').slice(0, 4).join('/') }}/ 排名68 + {{ item.featuretag?.split('/').slice(0, 4).join('/') }}/ 排名{{ item.zytjRank }} diff --git a/src/pages-sub/home/wishesList/components/DataTable.vue b/src/pages-sub/home/wishesList/components/DataTable.vue index e55b788..8bfb076 100644 --- a/src/pages-sub/home/wishesList/components/DataTable.vue +++ b/src/pages-sub/home/wishesList/components/DataTable.vue @@ -88,6 +88,7 @@ const rankDiff = (index: number, item) => { } const recompileData = computed(() => { + if (!props.data) return [] let _data = props.data.map((item, index) => { item['rankDiff'] = rankDiff(index, item) item['lineDiff'] = item['score'] - props.score diff --git a/src/pages-sub/home/wishesList/components/SortCollege.vue b/src/pages-sub/home/wishesList/components/SortCollege.vue index 9cda6e9..44605e3 100644 --- a/src/pages-sub/home/wishesList/components/SortCollege.vue +++ b/src/pages-sub/home/wishesList/components/SortCollege.vue @@ -65,6 +65,7 @@