|
|
@@ -130,13 +130,15 @@ export default {
|
|
|
const currentY = e.touches[0].clientY
|
|
|
const deltaY = currentY - this.startY
|
|
|
|
|
|
+ const systemInfo = uni.getSystemInfoSync()
|
|
|
+ const pixelRatio = 750 / systemInfo.windowWidth
|
|
|
// 根据设备像素比例转换为upx单位
|
|
|
- const deltaYupx = deltaY * (750 / uni.getSystemInfoSync().windowWidth)
|
|
|
+ const deltaYupx = deltaY * pixelRatio
|
|
|
|
|
|
this.dragOffsetY = deltaYupx
|
|
|
|
|
|
// 计算目标位置
|
|
|
- const itemHeightUpx = this.itemHeight * (750 / uni.getSystemInfoSync().windowWidth)
|
|
|
+ const itemHeightUpx = this.itemHeight * pixelRatio
|
|
|
|
|
|
// 使用更精确的计算方法确定移动的项目数
|
|
|
const moveDistance = Math.abs(deltaYupx)
|
|
|
@@ -180,6 +182,7 @@ export default {
|
|
|
const sortData = this.list.data.map((item, index) => ({
|
|
|
id: item.id,
|
|
|
inTurn: this.list.data.length - index // 反向索引,使第一个项目有最大值
|
|
|
+ // 如果是分页加载的,请用 data.total 替换掉 this.list.data.length
|
|
|
}))
|
|
|
|
|
|
// 调用API更新排序
|