limingtao 11 months ago
parent 5f03690545
commit 8a4c86fe31
  1. 104
      pages/knowledge/index.vue

@ -1,6 +1,6 @@
<template> <template>
<view class="detail"> <view class="detail">
<scroll-view scroll-y="true" :scroll-top="scrollTop" :style="{ <scroll-view @scroll="handleScroll" scroll-y="true" :scroll-top="scrollTop" :style="{
height: isExpanded ? 'calc(100% - 1rpx)' : 'calc(100% - 1rpx)', height: isExpanded ? 'calc(100% - 1rpx)' : 'calc(100% - 1rpx)',
}" class="chatlist" :class="{ 'chatlist-wrapper-expanded': isExpanded }" id="scrollView" ref="scrollView" }" class="chatlist" :class="{ 'chatlist-wrapper-expanded': isExpanded }" id="scrollView" ref="scrollView"
@click="clickContent"> @click="clickContent">
@ -64,6 +64,9 @@
</view> </view>
</view> </view>
<!-- <view class="downward" v-if="isToBottom" @click="toBottom">
<u-icon name="arrow-downward"></u-icon>
</view> -->
</view> </view>
</template> </template>
@ -114,7 +117,14 @@
text: "请给我一个典型的视距不良路口案例。", text: "请给我一个典型的视距不良路口案例。",
}, },
], ],
timer: null timer: null,
isHandleScroll: true,
startX: 0, // X
startY: 0, // Y
isScrolling: false, //
isToBottom: false,
lastScrollTop: 0, //
temp: 0,
}; };
}, },
onLoad() { onLoad() {
@ -142,6 +152,65 @@
} }
}, },
methods: { methods: {
handleTouchStart(e) {
//
this.startX = e.touches[0].clientX;
this.startY = e.touches[0].clientY;
// this.isScrolling = false; //
},
handleTouchMove(e) {
//
let moveX = e.touches[0].clientX;
let moveY = e.touches[0].clientY;
//
let deltaX = moveX - this.startX;
let deltaY = moveY - this.startY;
// 5px
if (Math.abs(deltaX) > 5 || Math.abs(deltaY) > 5) {
// this.isScrolling = true; //
this.isHandleScroll = false
// deltaY
if (deltaY > 0) {
console.log('用户正在向下滑动');
} else if (deltaY < 0) {
console.log('用户正在向上滑动');
}
// startXstartYmoveXmoveY
//
}
// startXstartY
},
handleTouchEnd(e) {
//
// startXstartY
//
},
handleScroll(event) {
// event.detail
const scrollTop = event.detail.scrollTop;
if (scrollTop > this.lastScrollTop) {
console.log('向下滑动');
} else {
this.temp++
if (this.temp == 2) {
this.isHandleScroll = false
}
console.log('向上滑动');
}
this.lastScrollTop = scrollTop;
},
toBottom() {
this.isToBottom = false
this.scrollTop = Number(this.scrollTop) + 100;
this.isHandleScroll = true
},
async queryChat(voiceText) { async queryChat(voiceText) {
// console.log(voiceText,"voiceText"); // console.log(voiceText,"voiceText");
clearInterval(this.timer) clearInterval(this.timer)
@ -214,6 +283,8 @@
duration: 2000, duration: 2000,
}); });
} }
this.temp = 0
this.isHandleScroll = true
this.changeMsgList("0", this.inputValue || text); this.changeMsgList("0", this.inputValue || text);
this.queryChat(this.inputValue || text); this.queryChat(this.inputValue || text);
this.inputValue = ""; this.inputValue = "";
@ -252,7 +323,10 @@
// this.$refs.scrollView.$refs.content // this.$refs.scrollView.$refs.content
// ? this.$refs.scrollView.$refs.content.scrollHeight // ? this.$refs.scrollView.$refs.content.scrollHeight
// : 0; // : 0;
this.scrollTop = this.scrollTop + 100; if (this.isHandleScroll) {
this.scrollTop = Number(this.scrollTop) + 100;
}
}); });
if (newdata == data) { if (newdata == data) {
clearInterval(this.timer); clearInterval(this.timer);
@ -274,7 +348,9 @@
// this.$refs.scrollView.$refs.content // this.$refs.scrollView.$refs.content
// ? this.$refs.scrollView.$refs.content.scrollHeight // ? this.$refs.scrollView.$refs.content.scrollHeight
// : 0; // : 0;
this.scrollTop = this.scrollTop + 100; if (this.isHandleScroll) {
this.scrollTop = Number(this.scrollTop) + 100;
}
}); });
} }
@ -943,4 +1019,24 @@
transform: scale(1); transform: scale(1);
} }
} }
.downward {
position: fixed;
z-index: 100rpx;
right: 20rpx;
bottom: 150rpx;
background: #ffffff;
border: #cccccc solid 1px;
width: 60rpx;
height: 60rpx;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
/deep/ .u-icon__icon {
font-size: 30rpx !important;
color: #999999 !important;
}
}
</style> </style>
Loading…
Cancel
Save