xy 1 year ago
parent
commit
1991acf27c
2 changed files with 39 additions and 15 deletions
  1. 35 15
      xs-app/components/read/chapterCatalog.vue
  2. 4 0
      xs-app/pages/readbook/read.vue

+ 35 - 15
xs-app/components/read/chapterCatalog.vue

@@ -67,6 +67,7 @@
 					</view>
 				</scroll-view>
 			</view>
+			<!-- <button @click="onTest()"> 跳转第100章</button> -->
 		</view>
 	</uni-popup>
 	
@@ -76,9 +77,9 @@
 <script setup lang="ts">
 	import { ref,onMounted,computed, nextTick} from 'vue';
 	import { ReadSetting } from '../../stores/readSetting';
-import { tools } from '../../framework/tools';
-import { book_item_data } from '../../data/data';
-import { UserStatus } from '../../stores/userStatusManager';
+	import { tools } from '../../framework/tools';
+	import { book_item_data } from '../../data/data';
+	import { UserStatus } from '../../stores/userStatusManager';
 	// const {items,remain,size,active,scrollHeight} = defineProps(['items','remain','size','active','scrollHeight'])
 	const {items,remain,size,scrollHeight} =defineProps({
 		  items: {
@@ -118,6 +119,8 @@ import { UserStatus } from '../../stores/userStatusManager';
 	let mode = ref(ReadSetting().getReadSetting().readMode)
 	let sortItems = ref(items)
 	const catalog = ref(null)
+	let first_join = ref(true)
+	let first_chapter_num = ref(100)
 	onMounted(()=>{
 		const type = 'bottom'
 		// open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
@@ -135,6 +138,12 @@ import { UserStatus } from '../../stores/userStatusManager';
 	let visibleData = computed(()=>{
 		const t_start = start.value - preCount.value;
 		const t_end = end.value + nextCount.value;
+		// console.log("visibleData",t_start,t_end)
+		// if(first_join.value==true){
+		// 	first_join.value = false
+		// 	return sortItems.value.slice(t_start+first_chapter_num.value, t_end+first_chapter_num.value);
+		// }
+		// return sortItems.value.slice(t_start, t_end);
 		return sortItems.value.slice(t_start, t_end);
 	})
 	
@@ -147,17 +156,20 @@ import { UserStatus } from '../../stores/userStatusManager';
 	}
 	
 	function change(e){
-		if (e.detail.source !== 'touch') {
-			return;
-		}
-		let y = e.detail.y;
-		let scroll = (y / (scrollHeight - 40)) * (localHeight.value - scrollHeight);
-		scroll = scroll < 0 ? 0 : scroll;
-		scrollTop.value = scroll;
+		// if (e.detail.source !== 'touch') {
+		// 	return;
+		// }
+		// let y = e.detail.y;
+		// let scroll = (y / (scrollHeight - 40)) * (localHeight.value - scrollHeight);
+		// scroll = scroll < 0 ? 0 : scroll;
+		// scrollTop.value = scroll;
 	}
 	
+	let default_scroll = ref(0)
+	
 	function handleScroll(ev){
-		const scrollTop = ev.detail.scrollTop;
+		const scrollTop = default_scroll.value+ev.detail.scrollTop;
+		
 		y.value = (scrollTop / (localHeight.value - scrollHeight)) * (scrollHeight - 40);
 		// 开始位置
 		const t_start = Math.floor(scrollTop / size);
@@ -167,12 +179,14 @@ import { UserStatus } from '../../stores/userStatusManager';
 		// 计算偏移
 		const t_offset = scrollTop - (scrollTop % size) - preCount.value * size;
 		offset.value = t_offset < 0 ? 0 : t_offset;
+		
+		// console.log('scrollTop',scrollTop,start.value,end.value,offset.value,y.value)
 	}
 	//
 	function onChange(e){
-		// if(e.show==false){
-		// 	emits('Close')
-		// }
+		if(e.show==false){
+			emits('Close')
+		}
 	}
 	
 	let font_color = ref(tools.getFontColorByMode(ReadSetting().getReadSetting().readMode))
@@ -205,8 +219,14 @@ import { UserStatus } from '../../stores/userStatusManager';
 				})
 			}
 		})
+	}
 	
-	
+	function onTest(){
+		let scroll = (first_chapter_num.value*size)-size
+		console.log("scroll",scroll)
+		// handleScroll({detail:{scrollTop:scroll}})
+		// default_scroll.value = scroll
+		// handleScroll({detail:{scrollTop:500}})
 	}
 	
 </script>

+ 4 - 0
xs-app/pages/readbook/read.vue

@@ -326,6 +326,10 @@
 			})
 			hideChapterList()
 		}else{
+			uni.showToast({
+				title:'没有此章节哦!',
+				icon:'none'
+			})
 			log.Error('goToChapter error!',cur_read_chapter_index.value)
 		}