Commit 35f11d3a authored by DESKTOP-K893UGN\A's avatar DESKTOP-K893UGN\A

feat:详情页左右切换页面功能

parent 9b21e962
<template> <template>
<view class="viewport-wrapper" :style="[styleObject]" @touchstart.stop="handleTouchstart" @touchend.stop="handleTouchend"> <view class="viewport-wrapper" :style="[styleObject]">
<u-icon class="left-button" name="arrow-left" @click="handleLeftAction()"></u-icon>
<u-icon class="right-button" name="arrow-right" @click="handleRightAction()"></u-icon>
<template v-for="(element, index) in reportInfo.list"> <template v-for="(element, index) in reportInfo.list">
<view <view
class="view-element" class="view-element"
...@@ -66,6 +68,7 @@ ...@@ -66,6 +68,7 @@
detailId: "", detailId: "",
idList: [], idList: [],
indexs: 0, indexs: 0,
pageSize: 0,
timename: null, timename: null,
pageScrollTop: 0, pageScrollTop: 0,
horizontalBarHeight: 0 horizontalBarHeight: 0
...@@ -99,6 +102,12 @@ ...@@ -99,6 +102,12 @@
this.detailId = option.id this.detailId = option.id
this.idList = option.idList.split(",") this.idList = option.idList.split(",")
this.indexs = this.idList.findIndex((item)=>item === this.detailId) this.indexs = this.idList.findIndex((item)=>item === this.detailId)
this.pageSize = option.pageSize
//如果是最后一个元素,需要提前加载后面列表数据
if (this.indexs == this.idList.length-1) {
console.log("xiayiye")
this.getReportIdList()
}
this.getReportCharts() this.getReportCharts()
}, },
onShow() { onShow() {
...@@ -227,40 +236,27 @@ ...@@ -227,40 +236,27 @@
}, },
/** /**
* 获取鼠标、手指初始位置 * 点击向左切换按钮
*/ */
handleTouchstart(e) { handleLeftAction() {
this.startTime = Date.now(); this.indexs--
this.startX = e.changedTouches[0].clientX; if (this.indexs<0) {
this.startY = e.changedTouches[0].clientY; this.indexs = 0
return
}
this.handlePage()
}, },
/** /**
* 计算鼠标、手指偏移方向 * 点击向右切换按钮
*/ */
handleTouchend(e) { handleRightAction() {
const endTime = Date.now(); this.indexs++
const length = this.lengths - 1; if (this.indexs>this.idList.length-1) {
const endX = e.changedTouches[0].clientX; this.indexs--
const endY = e.changedTouches[0].clientY;
const differ = Math.abs(endY - this.startY);
const dirvalX = endX - this.startX;
// 纵轴偏移量不得超过 30,否则默认页面进行滚动操作
if (differ <= 30) {
// 按下时长不得超过 2秒,X轴滑动距离必须大于 40
if (endTime - this.startTime > 2000 || Math.abs(dirvalX) <= 40) {
return return
};
// 判断滑动方向
if (dirvalX > 0) {
this.indexs--;
if (this.indexs <= 0) this.indexs = 0;
} else if (dirvalX < 0){
this.indexs++;
if (this.indexs >= length) this.indexs = length;
} }
this.handlePage() this.handlePage()
}
}, },
/** /**
...@@ -273,8 +269,33 @@ ...@@ -273,8 +269,33 @@
uni.redirectTo({ uni.redirectTo({
url: url url: url
}) })
},
/**
* 请求下一页的列表id
*/
async getReportIdList() {
var pageNumber = parseInt((this.idList.length-1) / this.pageSize)+2
var list = []
const that = this
var param = {"pageSize":that.pageSize, "pageNumber":pageNumber, "folderId":"621db7710668d7e647d5f4cc", "superAdmin":true}
let res = await that.$u.api.getReportList(param)
const { Status, Result } = res.data
if (Status === 'true') {
if (pageNumber === 1) {
list = Result.content
} else {
list = that.reportList.concat(Result.content)
} }
if (list.length>0) {
for (var i=0; i<list.length; i++){
var obj = list[i]
that.idList.push(obj.id)
}
}
}
}
}, },
onPullDownRefresh() { onPullDownRefresh() {
this.getReportCharts() this.getReportCharts()
...@@ -286,6 +307,7 @@ ...@@ -286,6 +307,7 @@
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.viewport-wrapper { .viewport-wrapper {
position: relative; position: relative;
height: 100%; height: 100%;
...@@ -295,9 +317,25 @@ ...@@ -295,9 +317,25 @@
background-size: cover; background-size: cover;
background-position: center; background-position: center;
} }
.view-element { .view-element {
position: absolute; position: absolute;
user-select: none; user-select: none;
cursor: move; cursor: move;
} }
.left-button {
position: fixed;
bottom: 50%;
left: 10px;
z-index: 99;
}
.right-button {
position: fixed;
bottom: 50%;
right: 10px;
z-index: 99;
}
</style> </style>
...@@ -72,8 +72,7 @@ ...@@ -72,8 +72,7 @@
var obj = this.reportList[i] var obj = this.reportList[i]
idList.push(obj.id) idList.push(obj.id)
} }
const url = "/pages/details/details?id=" + item.id + "&idList=" + idList const url = "/pages/details/details?id=" + item.id + "&idList=" + idList +"&pageSize=" + this.params.pageSize
console.log(url)
uni.navigateTo({ uni.navigateTo({
url: url url: url
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment